msbuild: set a specific preprocessor #define in the command line

后端 未结 11 1637
借酒劲吻你
借酒劲吻你 2021-02-01 05:08

In a C++ file, I have a code like this:

#if ACTIVATE
#   pragma message( \"Activated\" )
#else
#   pragma message( \"Not Activated\")
#endif

I

11条回答
  •  借酒劲吻你
    2021-02-01 05:23

    Use the CL environment variable to define preprocessor macros

    Before calling MSBUILD, simply set the environment variable 'CL' with '/D' options like so:

    set CL=/DACTIVATE to define ACTIVATE

    You can use the '#' symbol to replace '=' sign

    set CL=/DACTIVATE#1 will define ACTIVATE=1

    Then make the call to MSBUILD

    More documentation on the CL Environment Variables can be found at: https://msdn.microsoft.com/en-us/library/kezkeayy(v=vs.140).aspx

提交回复
热议问题