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:<br>
<br>add_definitions(-DGEN_OUTFILES)<br><br>but now I have to have this complicated mess instead:<br><br># Add preprocessor definition for GEN_OUTFILES to all project configurations except ReleaseNoOutfiles<br>if (CMAKE_CONFIGURATION_TYPES)<br>
string(TOUPPER "${CMAKE_CONFIGURATION_TYPES}" CMAKE_CONFIGURATION_TYPES_UPPER)<br>else()<br> string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_CONFIGURATION_TYPES_UPPER)<br>endif()<br><br>foreach(config ${CMAKE_CONFIGURATION_TYPES_UPPER})<br>
if (NOT (${config} MATCHES "RELEASENOOUTFILES"))<br> set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS_${config} GEN_OUTFILES)<br> endif()<br>endforeach()<br><br>Is there a more elegant solution that I am missing ? Ideally something like:<br>
<br>add_definitions(CONFIG=Debug;Release;RelWithDebInfo;MinSizeRel -DGEN_OUTFILES)<br><br>which I know doesn't exist but I really wish it did :-)<br><br>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.<br>
<br>--<br>Glenn<br><br>