I\'ve recently ported my Qt project from qmake to CMake.
My main program contains a value which depends on a #define directiv
Are you sure that set_target_properties does not work? How about this one:
set_target_properties(myAppV1 PROPERTIES COMPILE_FLAGS "-DBUILDTYPE=1")
or:
set_target_properties(myAppV1 PROPERTIES COMPILE_DEFINITIONS "BUILDTYPE=1")
On my machine it works:
add_executable(myAppV1 main.cpp)
add_executable(myAppV2 main.cpp)
set_target_properties(myAppV1 PROPERTIES COMPILE_DEFINITIONS "BUILDTYPE=1")
set_target_properties(myAppV2 PROPERTIES COMPILE_DEFINITIONS "BUILDTYPE=2")
Another way could be:
mkdir two directory
buildflavor1
buildflavor2
In the first sub directory run:
cmake -DFLAVOR=OPTION1 ..
in the second run:
run cmake -DFLAVOR=OPTION2 ..
So two executable with same name with different compilation flag with is own feature .o and so on.