简体   繁体   中英

Cannot set toolset to the new v140_clang_3_7 in Visual Studio 2015 Update 1 CMake

So I just downloaded the new Visual Studio Update 1 and am trying to get CMake to generate the correct platform toolset.

New in Update 1 there is a new toolset: Clang 3.7 with Microsoft CodeGen 在此输入图像描述

Pretty exciting, huh!

Anyway, I am trying to get CMake to generate the correct toolset here.

ASSUMPTION 1: The name of the toolset that CMake would accept is v140_clang_3_7 . I assume this because that is what is in parenthesis, and that is what is used in other toolsets, like v120 etc.

So I setup a simple test case:

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>

Next, I run CMake with the correct arguments:

ASSUMPTION 2: I have the correct arguments

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>

Say WHAT! No CMAKE_C_COMPILER or CMAKE_CXX_COMPILER found.

So that doesn't work. Lets see, it could be just that -T isn't working properly. Lets test with 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>

在此输入图像描述

Works like a newborn baby. Hmm.

Alright guys, whats next?

I've looked into this and it doesn't look too bad. I've pushed a first prototype that's able to compile a real simple program.

I'll keep working on fixing things, but hopefully it can be a start to figure out the rest of the work needed.

There are two ways to invoke Clang.

The first one is to specify the toolset from the command-line

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

The second one is to set a target property on a project to have that one specifically use the Clang toolchain

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM