The if() statements are executed when CMake runs, because you’re basically 
adding logic to the “meta-build” process that generates your build system; not 
the build system itself. Maybe you can use “add_custom_target” to create 
targets which do nothing but print the desired message, and then use 
“add_dependencies” to tie these targets back to your original ones? So 
something like:

add_custom_target(“test_print” …)
add_dependencies(test test_print)




Parag Chandra
Senior Software Engineer, Mobile Team
Mobile: +1.919.824.1410

 <https://ionic.com> 

Ionic Security Inc.
1170 Peachtree St. NE STE 400, Atlanta, GA 30309













On 11/24/15, 12:04 AM, "CMake on behalf of Christopher Sean Morrison" 
<[email protected] on behalf of [email protected]> wrote:

>
>Hi,
>
>I’m trying to print a message for a particular build target and am a bit 
>stuck.  I found that the IF statement has a TARGET keyword that should 
>truthfully match for a particular build target, but it doesn’t seem to be 
>working at least the way I’m trying to use it and would expect it to work.  
>Snippet in question in a top-level CMakeLists.txt file looks like this:
>
>if (TARGET check)
>  message(“special note about CHECK target…”)
>elseif (TARGET test)
>  message(“different note about TEST target…”)
>endif (TARGET check)
>
>Now what happens is that the CHECK message is printed … during cmake(!).  What 
>I’m trying to achieve is only have those messages printed during≈ “make check” 
>and “make test”, etc.  Ideally, I want to be able to inject a message before 
>any target actions are taken and possibly after.
>
>I see in the docs that I can set COMMENT during add_custom_target(check …) and 
>that should print my message before any target actions, but how can I get a 
>similar message printed during ‘test’ or ‘all’ or some other implicit target?  
>Is there a better or more general way?  Thanks for your assistance.
>
>Cheers!
>Sean
>
>-- 
>
>Powered by www.kitware.com
>
>Please keep messages on-topic and check the CMake FAQ at: 
>http://www.cmake.org/Wiki/CMake_FAQ
>
>Kitware offers various services to support the CMake community. For more 
>information on each offering, please visit:
>
>CMake Support: http://cmake.org/cmake/help/support.html
>CMake Consulting: http://cmake.org/cmake/help/consulting.html
>CMake Training Courses: http://cmake.org/cmake/help/training.html
>
>Visit other Kitware open-source projects at 
>http://www.kitware.com/opensource/opensource.html
>
>Follow this link to subscribe/unsubscribe:
>http://public.kitware.com/mailman/listinfo/cmake
-- 

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake

Reply via email to