Use variable from CMAKE in C++

后端 未结 3 1072
感动是毒
感动是毒 2021-01-27 03:16

I want to use a value declared in my CMakeLists.txt in my C++ code. I\'ve tried to do like that :

ADD_DEFINITIONS( -D_MYVAR=1 )

and

<         


        
3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-27 04:14

    add_definitions ( -DVARNAME=... )
    

    is the correct way of using add_definitions.

    To check for a constant then, use

    #ifdef VARNAME
    ...
    #endif
    

提交回复
热议问题