How to build a program with 2 different values of a variable in CMake

后端 未结 2 1345
挽巷
挽巷 2021-02-06 05:03

I\'ve recently ported my Qt project from qmake to CMake. My main program contains a value which depends on a #define directiv

2条回答
  •  悲哀的现实
    2021-02-06 06:01

    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")
    

提交回复
热议问题