【问题标题】:How to switch from VS9 to VS10 for NMake with CMake如何使用 CMake 为 NMake 从 VS9 切换到 VS10
【发布时间】:2011-03-11 10:09:10
【问题描述】:

在我的电脑上,我有 VS9 和 VS10 用于测试目的。 当我使用 VS9 或 VS10 配置我的项目时,我对 CMake 没有任何问题。

现在我想用 NMake 生成一个项目,但在配置过程中它使用 VS9 作为默认 C 编译器和 CXX 编译器,我想要 VS10。

任何人都知道我该如何做这样的事情?

我想从

切换
Projects>cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug
...
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio
9.0/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio
9.0/VC/bin/cl.exe -- works
...
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studi
o 9.0/VC/bin/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studi
o 9.0/VC/bin/cl.exe -- works

Projects>cmake .. -G "NMake Makefiles" -DCMAKE_BUILD_TYPE=Debug
...
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio
10/VC/bin/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio
10/VC/bin/cl.exe -- works
...
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studi
o 10/VC/bin/cl.exe
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studi
o 10/VC/bin/cl.exe -- works

谢谢:)

【问题讨论】:

  • 如果您还没有,您可以尝试在 CMake 邮件列表中询问。您可能很快就会在那里得到答案。

标签: c++ windows visual-studio compiler-construction cmake


【解决方案1】:

NMake Makefiles 生成器使用您的 shell 环境。在正常的 cmd 窗口中它会失败,并且您通常会为您感兴趣的版本打开 Visual Studio shell。您也可以运行适当的 vcvars。我现在不在 Windows 机器附近,但我会检查您正在使用的命令提示符。

【讨论】:

  • 从“Visual Studio 命令提示符”运行 cmake —— 每个版本的 VS 都有快捷方式,安装在“开始菜单”结构中以打开命令提示符,并针对该版本调整了环境变量VS 的。您可以在 VS 2010 的非 VS 命令提示符中通过键入“call "C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\vcvarsall.bat" x86' 来获得相同的效果”——另外,更改x86 到 x64 编译为 64 位程序。
【解决方案2】:

你也可以试试:

set CMAKE_MAKE_PROGRAM="C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe"

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-06-26
    • 1970-01-01
    • 2018-07-17
    • 1970-01-01
    • 1970-01-01
    • 2010-10-13
    • 2023-04-01
    相关资源
    最近更新 更多