1 Right now we have scripts that need to redirect their 2 output referencing the file written out by a custom 3 build target to indicate the current build type. We 4 might instead be able to pass that information in as 5 a define using the $<CONFIG> generator expression (or 6 maybe more than just that one if that's not enough 7 for MSVC). 8 9 CMakeLists.txt: 10 add_custom_command( 11 OUTPUT script_type.txt 12 COMMAND ${CMAKE_COMMAND} -DBUILD_TYPE="$<CONFIG>" -P ${CMAKE_SOURCE_DIR}/script.cmake 13 ) 14 add_custom_target(script DEPENDS script_type.txt) 15 16 script.cmake: 17 message("BUILD_TYPE: ${BUILD_TYPE}") 18 file(WRITE script_type.txt "${BUILD_TYPE}") 19 20 output: 21 22 cmake .. -DCMAKE_BUILD_TYPE=Debug && make script 23 [100%] Generating script_type.txt 24 BUILD_TYPE: Debug 25 [100%] Built target script 26 27 cmake .. -DCMAKE_BUILD_TYPE=Release && make script 28 [100%] Generating script_type.txt 29 BUILD_TYPE: Release 30 [100%] Built target script 31