[CMake] Source List Compilation Depending on Configuration
Nils Gladitz
nilsgladitz at gmail.com
Mon Jul 21 08:43:45 EDT 2014
On 07/21/2014 02:29 PM, Jörg Kreuzberger wrote:
> Hm, following your suggestion i replace lines
> if( "${CMAKE_BUILD_TYPE}" STREQUAL "Release")
> add_definitions( -DNDEBUG )
> endif()
>
> with
> set_directory_properties( PROPERTIES COMPILE_DEFINITIONS_RELEASE "${COMPILE_DEFINITIONS_RELEASE};NDEBUG" )
${COMPILE_DEFINITIONS_RELEASE} does not expand the property but you
could use set_property() with the APPEND flag for that.
NDEBUG is set by default for MinSizeRel, Release and RelWithDebInfo so
you should have found it in the Release flags even without using the
property (unless you override the default flags).
With
set_directory_properties(PROPERTIES COMPILE_DEFINITIONS_RELEASE "FOOBAR")
I get
./CMakeFiles/foo.dir/flags.make:CXX_DEFINES = -DFOOBAR
When configuring a Release build with the Makefiles generator.
Nils
More information about the CMake
mailing list