CMake 工具集规范似乎被忽略了

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

我正在尝试编译 instant-ngp,但 Windows 上存在一些错误,需要您强制 MSVC 为 14.25(已记录在本 GitHub 问题中。)

我试图用

-T version=14.25
-DCMAKE_GENERATOR_TOOLSET=version=14.25
来覆盖它,但它们就是不起作用。

> cmake . -B build -T 'version=14.25'
-- Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19044.
-- The C compiler identification is MSVC 19.29.30146.0
-- The CXX compiler identification is MSVC 19.29.30146.0
...
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
...
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
...

它肯定是使用 14.29 编译器构建的。 14.25 已安装,我知道 CMake 可以看到它,因为如果我尝试像 14.24 这样的版本,我会收到一条关于 that 未安装的错误消息,但 14.25 可以工作。

如何让 CMake 尊重此设置而不是立即忽略它?

visual-studio visual-c++ cmake
1个回答
0
投票

我在这里找到了有关此问题的一些信息:https://gitlab.kitware.com/cmake/cmake/-/issues/22420

事实证明,运行 vcvarsall.bat 或从“开发人员命令提示符”启动构建将设置各种环境变量,这些变量以 CMake 无法覆盖的方式强制设置工具集版本。

所以答案是从普通命令提示符运行 cmake 命令,而不是从“开发人员命令提示符”。

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