为什么cmake在生成'NMake Makefiles'时在powershell与命令行中表现不同? [重复]

问题描述 投票:0回答:1

这个问题在这里已有答案:

当我加载开发人员工具时:

**********************************************************************
** Visual Studio 2017 Developer Command Prompt v15.9.7
** Copyright (c) 2017 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x64'

我尝试通过以下方式为CMD中的C ++ hello world应用程序生成构建文件:

cmake -G 'NMake Makefiles'

我明白了:

CMake Error: Could not create named generator 'NMake

Generators
Visual Studio 16 2019        = Generates Visual Studio 2019 project files.
                             Use -A option to specify architecture.
* Visual Studio 15 2017 [arch] = Generates Visual Studio 2017 project files.
                             Optional [arch] can be "Win64" or "ARM".
Visual Studio 14 2015 [arch] = Generates Visual Studio 2015 project files.
                             Optional [arch] can be "Win64" or "ARM".
Visual Studio 12 2013 [arch] = Generates Visual Studio 2013 project files.
                             Optional [arch] can be "Win64" or "ARM".
Visual Studio 11 2012 [arch] = Generates Visual Studio 2012 project files.
                             Optional [arch] can be "Win64" or "ARM".
Visual Studio 10 2010 [arch] = Generates Visual Studio 2010 project files.
                             Optional [arch] can be "Win64" or "IA64".
Visual Studio 9 2008 [arch]  = Generates Visual Studio 2008 project files.
                             Optional [arch] can be "Win64" or "IA64".
Borland Makefiles            = Generates Borland makefiles.
NMake Makefiles              = Generates NMake makefiles.
NMake Makefiles JOM          = Generates JOM makefiles.
Green Hills MULTI            = Generates Green Hills MULTI files
                             (experimental, work-in-progress).
MSYS Makefiles               = Generates MSYS makefiles.
MinGW Makefiles              = Generates a make file for use with
                             mingw32-make.

# etc.

但是如果我通过在CMD中编写powershell来切换到PowerShell并运行相同的命令:

cmake -G 'NMake Makefiles'

它工作正常:

-- The C compiler identification is MSVC 19.16.27027.1
-- The CXX compiler identification is MSVC 19.16.27027.1

# etc.

知道为什么cmake在PowerShell中工作而在CMD中工作吗?

powershell cmd cmake visual-studio-2017
1个回答
1
投票

Windows命令提示符不会将单引号识别为引用字符。您必须使用双引号。

更改

cmake -G 'NMake Makefiles'

cmake -G "NMake Makefiles"

问题就会消失。

© www.soinside.com 2019 - 2024. All rights reserved.