CMake command line for C++ #define

后端 未结 3 646
逝去的感伤
逝去的感伤 2021-02-11 14:52

I need to compile different versions of a certain project by adding compiler switches. Usually I would do this by using add_definitions or something like

set_p         


        
3条回答
  •  迷失自我
    2021-02-11 15:53

    To pass a C++ or C pre-processor define without modifying any CMake source files, use the environment variables CFLAGS for C or CXXFLAGS for C++ respectively, e.g.:

    $ export CXXFLAGS="-D_MY_DEFINE=1 -D_MY_OTHER_DEFINE=1"
    $ mkdir build
    $ cd build
    $ cmake ..
    

提交回复
热议问题