c++ - 无法在 Visual Studio 2015 Update 1 CMake 中将工具集设置为新的 v140_clang_3_7

标签 c++ cmake visual-studio-2015 clang

所以我刚刚下载了新的 Visual Studio Update 1并试图让 CMake 生成正确的平台工具集。

更新 1 中有一个新工具集:带有 Microsoft CodeGen 的 Clang 3.7 enter image description here

非常令人兴奋,嗯!

无论如何,我正在尝试让 CMake 在这里生成正确的工具集。

假设 1:CMake 接受的工具集名称是 v140_clang_3_7。我假设这是因为这是括号中的内容,也是其他工具集中使用的内容,例如 v120 等。

所以我设置了一个简单的测试用例:

C:\Users\russe\Documents\TestCMAKECLANG>ls
CMakeLists.txt  main.cpp

C:\Users\russe\Documents\TestCMAKECLANG>cat CMakeLists.txt
cmake_minimum_required(VERSION 3.0)


add_executable(TestEXE main.cpp)
C:\Users\russe\Documents\TestCMAKECLANG>cat main.cpp


// use some fancy c++14 feature that VS doesn't have

template<typename T>
constexpr T doThing{};

int main(){}
C:\Users\russe\Documents\TestCMAKECLANG>

接下来,我使用正确的参数运行 CMake:

假设 2:我有正确的论点

C:\Users\russe\Documents\TestCMAKECLANG>cmake -G "Visual Studio 14 2015" -T "v140_clang_3_7"
-- The C compiler identification is unknown
-- The CXX compiler identification is unknown
CMake Error in :
  No CMAKE_C_COMPILER could be found.



CMake Error in :
  No CMAKE_CXX_COMPILER could be found.



-- Configuring incomplete, errors occurred!
See also "C:/Users/russe/Documents/TestCMAKECLANG/CMakeFiles/CMakeOutput.log".
See also "C:/Users/russe/Documents/TestCMAKECLANG/CMakeFiles/CMakeError.log".

C:\Users\russe\Documents\TestCMAKECLANG>

说什么!未找到 CMAKE_C_COMPILERCMAKE_CXX_COMPILER

所以那是行不通的。让我们看看,可能只是 -T 没有正常工作。让我们使用 v120

进行测试
C:\Users\russe\Documents\TestCMAKECLANG>cmake -G "Visual Studio 14 2015" -T "v120"
-- The C compiler identification is MSVC 18.0.31010.0
-- The CXX compiler identification is MSVC 18.0.31010.0
-- Check for working C compiler using: Visual Studio 14 2015
-- Check for working C compiler using: Visual Studio 14 2015 -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working CXX compiler using: Visual Studio 14 2015
-- Check for working CXX compiler using: Visual Studio 14 2015 -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Users/russe/Documents/TestCMAKECLANG

C:\Users\russe\Documents\TestCMAKECLANG>

enter image description here

像新生儿一样工作。嗯。

好的伙计们,下一步是什么?

最佳答案

我已经调查过了,看起来还不错。我先推了一个 prototype能够编译一个真正简单的程序。

我会继续努力解决问题,但希望它可以成为弄清楚所需的其余工作的开始。

调用 Clang 有两种方法。

第一个是从命令行指定工具集

cmake -G "Visual Studio 14 2015" -T v140_clang_3_7 ... 

第二个是在项目上设置目标属性,让该项目专门使用 Clang 工具链

set_property(TARGET ${project} PROPERTY VS_PLATFORM_TOOLSET_OVERRIDE "v140_clang_3_7") 

关于c++ - 无法在 Visual Studio 2015 Update 1 CMake 中将工具集设置为新的 v140_clang_3_7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34013469/

相关文章:

cmake - 自定义 cmake FindXXX.cmake 回退到默认位置

angularjs - DOM Explorer 和 JavaScript 控制台在 Visual Studio 2015 Community 中不工作

c# - Visual Studio 2015 花括号格式 : If, Else If, Else

c++ - C++ 中成员变量的关键字 mutable 的替代方法

c++ - 什么是 undefined reference /未解析的外部符号错误,我该如何解决?

c++ - 在quickfix中重置序列号

entity-framework - 如何使用 Powershell 在远程数据库上运行 Entity Framework 7 迁移?

c++ - 将数字合并到对象的名称

string - 在 CMake 中将字符串拆分为 3 个变量

cmake - 如何使CMake将Visual Studio链接器的选项“生成调试信息”设置为"is"?