MantisBT - CMake
View Issue Details
0013961CMakeCMakepublic2013-02-27 18:102016-06-10 14:31
skislins 
Kitware Robot 
normalfeaturealways
closedmoved 
VS 2012Windows7
CMake 2.8.11 
 
0013961: VS per-target PlatformToolset
Especially when using VS 2012, the ability to choose a platform toolset is very import (e.g., compiling for WinXP, or using compiler updates for C++11 features).

In the current developer branch, CMAKE_GENERATOR_TOOLSET can be found for that purpose and I guess it will be included in CMake 2.8.11. However, it causes an error during cache deletion which makes it necessary to delete the build directory and, in addition, to restart CMake GUI.
# PREREQUISITE: Install Visual C++ Compiler November 2012 CTP.
#
# (1) Open CMake GUI.
# (2) Configure with Visual Studio 11 (Win64) generator.
# (3) Compiler identification is MSVC 17.0.51106.1.
# (4) Delete cache.
# (5) Configure again with Visual Studio 11 (Win64) generator.
# (6) Compiler identification is MSVC 17.0.51025.0 now.
# (7) Check for working C compiler fails!
#
# IMPORTANT: Fails until the build directory is deleted or changed AND
# CMake GUI is restarted!

cmake_minimum_required(VERSION 2.8.10.20130220)
project(Test)

if(NOT MSVC_VERSION OR MSVC_VERSION LESS 1700)
  message(FATAL_ERROR "Select Visual Studio 11 (Win64) generator!")
endif()

# Enable C++11 features of the newest compiler
set(CMAKE_GENERATOR_TOOLSET "v120_CTP_Nov2012" CACHE STRING "" FORCE)
Compiler updates are an important new strategy of MS to add new C++11 features step-by-step to VS 2012. Hence, please don't be too tentative regarding first class support/integration of this feature into CMake.
No tags attached.
Issue History
2013-02-27 18:10skislinsNew Issue
2013-02-28 07:11Brad KingNote Added: 0032407
2013-02-28 07:19Brad KingNote Added: 0032408
2013-02-28 07:20Brad KingProduct VersionCMake 2.8.10.2 => CMake 2.8.11
2013-02-28 08:01skislinsNote Added: 0032409
2013-02-28 12:56Brad KingNote Added: 0032415
2013-02-28 12:56Brad KingSeveritymajor => feature
2013-02-28 12:56Brad KingStatusnew => backlog
2013-02-28 12:56Brad KingSummaryCMAKE_GENERATOR_TOOLSET error for VS 2012 => VS per-target PlatformToolset
2016-06-10 14:28Kitware RobotNote Added: 0042241
2016-06-10 14:28Kitware RobotStatusbacklog => resolved
2016-06-10 14:28Kitware RobotResolutionopen => moved
2016-06-10 14:28Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0032407)
Brad King   
2013-02-28 07:11   
Set it before the project() command.

The value is really meant to be set by users when running CMake, not by the project. It is like trying to set CMAKE_GENERATOR from inside the project.

Note that devenv does not seem to understand project files with the v120_CTP_Nov2012 toolchain. You need to also set CMAKE_MAKE_PROGRAM to point to msbuild.
(0032408)
Brad King   
2013-02-28 07:19   
Re 0013961:0032407: Actually the project can't set it at all, not even before project(). The value is processed very early before even loading CMakeLists.txt:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmake.cxx;hb=7dab9977#l2307 [^]

The CMAKE_GENERATOR_TOOLSET documentation:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmDocumentVariables.cxx;hb=7dab9977#l257 [^]

says that it is for reporting what the user set.
(0032409)
skislins   
2013-02-28 08:01   
Thank you for your prompt answer, Brad.

If CMAKE_GENERATOR_TOOLSET is not meant to be set during configuration, do you have plans for a target property (i.e. a simple string) or something similar to set the platform toolset? I think that would be the correct place for that feature since one can set a platform toolset per project in a MSVC solution.
(0032415)
Brad King   
2013-02-28 12:56   
Re 0013961:0032409: CMAKE_GENERATOR_TOOLSET was designed to change the compiler with IDE generators like VS and Xcode. CMake does a lot of detection of information about the underlying toolchain and also uses this compiler setting for try_compile and other tests outside the scope of the CMakeLists.txt files.

A target property to alter the toolset for a specific target could be added, but all it could do is set PlatformToolset in the project file. There would be no guarantee that any other information CMake computes for the target would be correct for a toolchain that isn't project-wide.

Moving to backlog as a feature request for now.
(0042241)
Kitware Robot   
2016-06-10 14:28   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.