View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0010722CMakeCMakepublic2010-05-17 07:092013-07-01 09:36
ReporterThomas Laguzzi 
Assigned ToBrad King 
PrioritynormalSeveritytrivialReproducibilityN/A
StatusclosedResolutionfixed 
PlatformOSOS Version
Product VersionCMake-2-8 
Target VersionCMake 2.8.11Fixed in VersionCMake 2.8.11 
Summary0010722: Add PlatformToolset support to Visual Studio 2010 generator
DescriptionIn VC10 it is possible to select the platform toolset, that allows to use the VC9 compiler instead of the V10 one.
Such a thing could be dangerous since CMAKE would do a configure with MSVC10 but it then use the VC9 compiler.
 Anyway, the compilers are really similar so on the meantime it would be nice to have such an option available.
 
The patch would be simple:
- Find a global variable name to handle such a thing, like the one for MFC support

- in the cmVisualStudio10TargetGenerator.cxx
 add a block near line 243 that handles that var.
 the output result should be
 <PlatformToolset>v90</PlatformToolset>
It is similar to the MFC handling.
 
 I don't know enought of cmake to apply a patch (i.e. convetions used for vars in such multi-value cases).
 but it should be simple to get something working.
TagsNo tags attached.
Attached Files

 Relationships
related to 0009125closedDavid Cole Add support to set GCC Version and Deployment Target for XCode projects 
has duplicate 0012876closedBrad King Recognizing a PLATFORM_TOOLSET property for Visual Studio builds! 
related to 0009981closedBrad King refering to 0009746: Visual Studio 2010 generator does not work with VS2010 Beta2 
related to 0006929closedKitware Robot Intel C++ project generation 
related to 0013774closedBrad King Support v110_xp target with MSVC 2012 Update 1 
related to 0009831closedBrad King Need method to set properties on every target / set defaults 

  Notes
(0020794)
Thomas Laguzzi (reporter)
2010-05-20 02:16

I have successfully done a patch to 2.8.1
I could publish it, but I don't know the used conventions for these cases. I should use a global variable?
It would be better a flag variable or a value variable.
Like
SET(VS_USE_PLATFORM_V90 "1")
or
SET(VS_PLATFORM_TOOLSET "v90")

also, how this applies to targets?
(0020845)
Brad King (manager)
2010-05-27 13:41

Interesting. It is easy to put the <PlatformToolset> element in the project files, but there is a lot more involved for this feature.

(1) CMake has a 10 year history with a one-to-one mapping between VS generators and VS versions. Tests like if(MSVC90) have been written both for recognizing the VS IDE version and the compiler version. There is no distinction. Even if the project to be built contains no such tests, CMake's own modules do contain some.

(2) CMake's VS generators map from user-specified compiler flags to the IDE project file XML elements and attributes. This mapping is specific to the VS version because the IDE internally maps them back to flags during the build. It is not clear how this mapping is affected by the PlatformToolset option.

(3) By convention, CMake projects generally adapt to the compiler environment specified by the user at configuration and build time. There must be a way to select the compiler without modifying the project source code or CMakeLists.txt files. (Note also that the global MFC selection variable is left from an ancient interface design that we no longer use for new features.)

These concerns are off the top of my head. Unfortunately I think this is a big can of worms. Anyone who investigates this further will doubtlessly find additional roadblocks.
(0020881)
Thomas Laguzzi (reporter)
2010-06-01 02:39

Your considerations are totally right , but I'd like to suggest to not ignore this aspect because this is something that future visual studio version will continue to have and people will start using it. A similar feature allows to use a newer (and presumably better) IDE with an estabilished compiler set. For example, we'd like to use it because VS 2010 has better intellisense.

Surely this a big feature to implement, and it will work only by adding a specific support.
Just to add some considerations:

(1) and (2) - Teorically you should use the VC2010 XML mapping, but the ABI and compiler features should be tested with the previous version. I don't know how compiler detection works, but if you enable the flag during the ABI detection there should be no problems, the compiler will automatically report the feature level of the previous version.
(3) - Could be there an additional generator that sets the <PlatformToolset>?

--
(sorry for my bad english)
(0020917)
Brad King (manager)
2010-06-03 13:19
edited on: 2010-06-03 13:20

Currently I have no time to investigate this further, but I have a few more thoughts to record for anyone who investigates it:

This may not be quite as hard as I previously thought:

(a) This affects only the VS 10 generator and generators for future VS versions.

(b) Platform variables like MSVC90 can be set based on the actual compiler while the generator name reflects the IDE version. This may be a reasonable distinction.

(c) If the user does not ask for PlatformToolset to be used the behavior is unchanged so existing cases will still work.

I think the tricky part for the interface design is concern (3) I mentioned previously. Previously CMake only supported compiler specification for Makefile generators. Other generators (VS, Xcode) assume a single IDE <-> compiler correspondence. There is already an open problem for specifying the compiler used by Xcode projects. Whatever solution we use should work for both VS and Xcode.

(0020918)
Brad King (manager)
2010-06-03 13:21

Issue 0009125 requests compiler selection for Xcode. The interface added by the current fix for that issue to set GCC_VERSION is very Xcode-specific. Something more general will be needed for both.
(0021526)
RolandSchulz (reporter)
2010-07-28 15:11

Compiling x64 binaries with VC10 express requires to also install SDK 7.1 and choosing the Windows7.1SDK as Platform toolset. Because Cmake doesn't allow to specify the toolset one has to run cmake after running the SetEnv.Cmd (part of the SDK) which makes the SDK the default toolset. Because Cmake doesn't record the used toolset, if one compiles in VC10 without the SetEnv.CMD run first, the toolset doesn't match with that used to configure the compiler.

To summarize:
- Because cmake doesn't allow to select a toolset it is difficult to compile x64 with VC express
- Because cmakes doesn't record the used toolset the toolset might not be correct if the enviormnet variables are different.

Thus it would be very helpful if cmake supports selecting toolset and would record the toolset used for configuring.
(0023645)
Brad King (manager)
2010-12-01 13:50

I've added support for setting PlatformToolset to "Windows7.1SDK" specifically when the Visual Studio 10 Win64 generator detect the Express edition of the compiler:

http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=fb97ba62 [^]

When the generator detects this compiler it now looks for the Windows SDK v7.1. If not found it produces a straightforward error message.

This change enables 64-bit builds with VS 2010 Express but avoids opening the can of worms discussed above with allowing different compiler versions to be used.
(0027512)
ahoros (reporter)
2011-10-03 10:54

Hello Thomas,

What is the status of your patch?

I am trying to use Visual Studio 11 with CMake 2.8.5
and it fails because cmake (cmake -G "Visual Studio 10")
is passing (?) toolset v100 which results in this problem:


--------------------


-- Check for working C compiler using: Visual Studio 10
-- Check for working C compiler using: Visual Studio 10 -- broken
CMake Error at c:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/CMakeTestCCompiler.cmake:52 (MESSAGE):
  The C compiler "c:/Program Files (x86)/Microsoft Visual Studio
  11.0/VC/bin/cl.exe" is not able to compile a simple test program.

  It fails with the following output:

   Change Dir: C:/BAZAAR/buildVC11/CMakeFiles/CMakeTmp



  Run Build Command:C:\PROGRA~2\MICROS~1.0\Common7\IDE\devenv.com
  CMAKE_TRY_COMPILE.sln /build Debug /project cmTryCompileExec



  Microsoft (R) Visual Studio 11 Version 11.0.40825.2.

  Copyright (C) Microsoft Corp. All rights reserved.



  The evaluation period for Visual Studio Trial ends in 270 days.

  1>------ Build started: Project: cmTryCompileExec, Configuration: Debug
  Win32 ------

  1>Build started 2011-10-03 16:29:48.

  1>C:\Program Files
  (x86)\MSBuild\Microsoft.Cpp\v4.0\V110\Platforms\Win32\Microsoft.Cpp.Win32.Targets(32,5):
  error MSB8008: Specified platform toolset (v100) is not installed or
  invalid. Please make sure that a supported PlatformToolset value is
  selected.

  1>

  1>Build FAILED.

  1>

  1>Time Elapsed 00:00:00.02

  ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped
  ==========





  CMake will not be able to correctly generate this project.
Call Stack (most recent call first):
  CMakeLists.txt:1 (PROJECT)


-----------------------------------------

or in general how can I generate make files for VC11 ?
(0028314)
Brad King (manager)
2012-01-16 08:40

Moving to backlog awaiting someone with time to tackle the issues discussed in 0010722:0020845 and 0010722:0020917.
(0032229)
Brad King (manager)
2013-02-08 13:49

A new "generator toolset" feature has been added here:

 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7dab9977 [^]

One may now run CMake from the command line with

 -G "Visual Studio 10" -T "v90"

in order to build with a specific toolset. We've not yet added a first-class interface to cmake-gui for this, but one may add the cache entry "CMAKE_GENERATOR_TOOLSET" to contain the "-T" value before configuring.
(0033416)
Robert Maynard (manager)
2013-07-01 09:36

Closing resolved issues that have not been updated in more than 4 months.

 Issue History
Date Modified Username Field Change
2010-05-17 07:09 Thomas Laguzzi New Issue
2010-05-20 02:16 Thomas Laguzzi Note Added: 0020794
2010-05-26 13:23 Bill Hoffman Status new => assigned
2010-05-26 13:23 Bill Hoffman Assigned To => Brad King
2010-05-27 13:41 Brad King Note Added: 0020845
2010-06-01 02:39 Thomas Laguzzi Note Added: 0020881
2010-06-03 13:19 Brad King Note Added: 0020917
2010-06-03 13:20 Brad King Relationship added related to 0009125
2010-06-03 13:20 Brad King Note Edited: 0020917
2010-06-03 13:21 Brad King Note Added: 0020918
2010-07-28 15:11 RolandSchulz Note Added: 0021526
2010-12-01 13:46 Brad King Relationship added related to 0009981
2010-12-01 13:50 Brad King Note Added: 0023645
2011-10-03 10:54 ahoros Note Added: 0027512
2012-01-16 08:38 Brad King Relationship added has duplicate 0012876
2012-01-16 08:40 Brad King Note Added: 0028314
2012-01-16 08:40 Brad King Assigned To Brad King =>
2012-01-16 08:40 Brad King Status assigned => backlog
2012-01-16 09:22 Brad King Relationship added related to 0006929
2012-12-04 13:10 Brad King Relationship added related to 0013774
2013-02-08 13:49 Brad King Note Added: 0032229
2013-02-08 13:49 Brad King Assigned To => Brad King
2013-02-08 13:49 Brad King Status backlog => resolved
2013-02-08 13:49 Brad King Resolution open => fixed
2013-02-08 13:49 Brad King Fixed in Version => CMake 2.8.11
2013-02-08 13:49 Brad King Target Version => CMake 2.8.11
2013-02-08 13:52 Brad King Relationship added related to 0009831
2013-07-01 09:36 Robert Maynard Note Added: 0033416
2013-07-01 09:36 Robert Maynard Status resolved => closed


Copyright © 2000 - 2018 MantisBT Team