I know you can use CMake\'s configure_file
to make CMake variables available to your program. For example, I can use
#define ${CMAKE_BUILD_TYPE}
Here is a fairly simple way to solve it:
In CMakesLists.txt
:
if (NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE Release)
endif (NOT CMAKE_BUILD_TYPE)
string (TOUPPER ${CMAKE_BUILD_TYPE} BUILD_TYPE_NAME)
configure_file (config.h.in config.h)
And in config.h.in
:
#define BUILD_TYPE_${BUILD_TYPE_NAME}
I am, however, still curious if there is a more elegant solution.