c++ - 如何使用 CMake 将 NMake 从 VS9 切换到 VS10

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

在我的电脑上,我有 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

谢谢:)

最佳答案

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

关于c++ - 如何使用 CMake 将 NMake 从 VS9 切换到 VS10,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5271536/

相关文章:

c++ - 堆损坏但仅在笔记本电脑上编译时

c++ - boost::adaptor::filtered core dumps with boost::range_detail::default_constructible_unary_fn_wrapper "Assertion ` m_impl' 失败”

windows - USB 未在 mac OS 上的 oracle virtualbox 中检测到

visual-studio - 如何在我的自定义工具中写入 Visual Studio 输出窗口?

angularjs - 错误 405(方法不允许)

c++ - 二进制文件解释

windows - 我的 Windows 应用程序的图标应包含哪些图标大小?

c++ - 在 win32 (C++) 中打开、操作和渲染 SVG 文件

c# - 禁止使用给定的 .net 框架库

c# - 在 Windows 2012 上更改事件进程的处理器组