I want to have a preprocessor symbol (GEN_OUTFILES) defined for all build
configurations except one (ReleaseNoOutfiles).  Before I added the
ReleaseNoOutfiles configuration I just had this line in my top level
CMakeLists.txt:

add_definitions(-DGEN_OUTFILES)

but now I have to have this complicated mess instead:

# Add preprocessor definition for GEN_OUTFILES to all project configurations
except ReleaseNoOutfiles
if (CMAKE_CONFIGURATION_TYPES)
        string(TOUPPER "${CMAKE_CONFIGURATION_TYPES}"
CMAKE_CONFIGURATION_TYPES_UPPER)
else()
        string(TOUPPER "${CMAKE_BUILD_TYPE}"
CMAKE_CONFIGURATION_TYPES_UPPER)
endif()

foreach(config ${CMAKE_CONFIGURATION_TYPES_UPPER})
        if (NOT (${config} MATCHES "RELEASENOOUTFILES"))
                set_property(DIRECTORY APPEND PROPERTY
COMPILE_DEFINITIONS_${config} GEN_OUTFILES)
        endif()
endforeach()

Is there a more elegant solution that I am missing ?  Ideally something
like:

add_definitions(CONFIG=Debug;Release;RelWithDebInfo;MinSizeRel
-DGEN_OUTFILES)

which I know doesn't exist but I really wish it did :-)

Initially I didn't have the if (CMAKE_CONFIGURATION_TYPES) check and it
didn't work on linux.  Why is CMAKE_CONFIGURATION_TYPES empty for linux
targets ?  I know that multiple build configs are not supported in the same
tree like they are under Visual Studio but you can configure multiple build
directories with CMAKE_BUILD_TYPE set to each value in
CMAKE_CONFIGURATION_TYPES.  The code in CMakeLists.txt files would be more
platform agnostic and easier to read if one could iterate over
CMAKE_CONFIGURATION_TYPES on linux to set configuration specific variables
like COMPILE_DEFINITIONS_XXX.

--
Glenn
_______________________________________________
Powered by www.kitware.com

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

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

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to