Hi, I have a problem, that I have a C++ project that uses select C++11/14 features that for the MSVC compiler are at best only present in the CTP_Nov2013 compiler toolset. I am aware that there is a very similar topic here , and that the most relevant answer was that the toolset must not be tinkered with from the script, as the end-user will want to tinker with it.
I have found a way to achieve what I wanted with the commands
set(CMAKE_GENERATOR_TOOLSET "CTP_Nov2013" CACHE STRING "Platform Toolset" FORCE)
set(CMAKE_VS_PLATFORM_TOOLSET "CTP_Nov2013" CACHE STRING "Platform Toolset" FORCE)
However the problem with this is that the script needs to be run twice in order for this to take effect. Since the cmake command-line is invoked using
cmake -G"Visual Studio 12 2013 Win64"
There is already a toolset selected, but I immediately wish to override the toolset incorporated into the x64 Configuration of the selected generator. Ultimately the user selects 32/64-bit builds from the command line as usual using the generator specification, but I wish to hide the incapabilities of the MSVC compiler from the "end-user" in case he/she has the CTP installed.
How can I write the script and invoke it from the command line so it works for both the Visual Studio and NMake Makefiles generators and for the first invocation of CMake?
Using the reply of @Tanuki and set_target_properties , you can force the usage of the platform toolset in your target
if (CMAKE_VS_PLATFORM_TOOLSET MATCHES "CTP_Nov2013")
set_target_properties(${your_target}
PROPERTIES
PLATFORM_TOOLSET "${CMAKE_VS_PLATFORM_TOOLSET}")
endif()
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.