[CMake] Append an option to CMAKE_C_FLAGS_DEBUG

Mathieu Dubois mathieu.dubois at limsi.fr
Tue Apr 20 05:12:21 EDT 2010


Hello Michael,
> The usual way is to do it just the other way around, and that's also how CMake does it. Instead of defining DEBUG for debug builds, it defines NDEBUG for release builds. So, in your code do:
>
> #ifndef NDEBUG
> printf("THIS IS DEBUG INFORMATION\n");
> #endif
>   
Thank you for the tip... I'll use the standard way.
> Of course, if you insist on DEBUG you can do the following in your top-level CMakeLists.txt file:
>
> set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_DEBUG DEBUG=1)
>   
Nevertheless this is an interesting CMake directive.
> HTH
>   
Yeah it really helped!

Thanks,
Mathieu



More information about the CMake mailing list