[CMake] set_source_files_properties per configuration

Simmons, Aaron asimmons at rosettastone.com
Mon Mar 22 18:40:21 EDT 2010


I have some flags I need to set for certain builds on a single source file.

For single-configuration generators (make, nmake) it's easy enough to look at CMAKE_BUILD_TYPE and use set_source_files_properties, like this:
        if (CMAKE_BUILD_TYPE STREQUAL Debug)
            set_source_files_properties( myfile.cpp PROPERTIES COMPILE_FLAGS -DMYFLAG=asdf )
        endif (CMAKE_BUILD_TYPE STREQUAL Debug)

However, for multi-configuration build types (msvc, xcode) I can't use CMAKE_BUILD_TYPE.  In fact, I'm not sure what function to use here.  I could modify the CMAKE_C_FLAGS_XXX/CMAKE_CXX_FLAGS_XXX variables, but that would affect all the source.  How can I specify a configuration type when using set_source_files_properties?  Is there some other api to use?



Thanks,
aaron


More information about the CMake mailing list