windows 在构建“Makefile 解决方案”之前为 NMAKE 设置环境变量

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2959473/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 14:34:44  来源:igfitidea点击:

Setting Environment Variables For NMAKE Before Building A 'Makefile Solution'

c++windowsvisual-c++

提问by John Dibling

I have an MSVC Makefile Projectin which I need to set an environment variable before running NMAKE. For x64 builds I needs to set it to one value, and for x86 builds I need to set it to something else.

我有一个 MSVC Makefile 项目,在运行 NMAKE 之前我需要在其中设置一个环境变量。对于 x64 构建,我需要将其设置为一个值,对于 x86 构建,我需要将其设置为其他值。

So for example, when doing a build I would want to SET PLATFORM=win64if I'm building a 64-bit compile, or SET PLATFORM=win32if I'm building 32-bit.

例如,在进行构建时,SET PLATFORM=win64如果我正在构建 64 位编译,或者SET PLATFORM=win32如果我正在构建 32 位,我会想要。

There does not appear to be an option to set environment variables or add a pre-build even for makefile projects.

即使对于 makefile 项目,似乎也没有设置环境变量或添加预构建的选项。

How do I do this?

我该怎么做呢?

EDIT: Running MSVC 2008

编辑:运行 MSVC 2008

回答by Hans Passant

Just edit the Configuration Properties + NMake + Build Command Line. Click the button with the dots and enter something like this:

只需编辑配置属性 + NMake + 构建命令行。单击带点的按钮并输入如下内容:

set PLATFORM=win32
nmake -f makefile.mak

Repeat for your 64-bit configuration.

对您的 64 位配置重复此操作。