Compile same file with different flags using CMAKE

后端 未结 1 1750
一向
一向 2021-02-12 15:10

I want to compile the same .cpp source file into two different target executables and I am using cmake. One will have some instrumentation code and the other won\'t. That way

相关标签:
1条回答
  • 2021-02-12 15:42

    You can set the COMPILE_DEFINITIONS property of one of the targets to have target-specific definitions:

    set_target_properties (instrumented_target PROPERTIES COMPILE_DEFINITIONS "INSTRUMENT")
    

    Update:

    Starting from CMake 2.8.11 you can also use target_compile_definitions for the same purpose.

    0 讨论(0)
提交回复
热议问题