[cmake-developers] [CMake 0012876]: Recognizing a PLATFORM_TOOLSET property for Visual Studio builds!

Mantis Bug Tracker mantis at public.kitware.com
Mon Jan 16 03:26:23 EST 2012


The following issue has been SUBMITTED. 
====================================================================== 
http://public.kitware.com/Bug/view.php?id=12876 
====================================================================== 
Reported By:                thesaint
Assigned To:                
====================================================================== 
Project:                    CMake
Issue ID:                   12876
Category:                   CMake
Reproducibility:            always
Severity:                   tweak
Priority:                   urgent
Status:                     new
====================================================================== 
Date Submitted:             2012-01-16 03:26 EST
Last Modified:              2012-01-16 03:26 EST
====================================================================== 
Summary:                    Recognizing a PLATFORM_TOOLSET property for Visual
Studio builds!
Description: 
Issue "http://public.kitware.com/Bug/view.php?id=6929" asks for Intel Compiler
support with Visual Studio. Instead of generating project files (which I found
rather complicated), it is often sufficient just to set the platform toolset
properly. This is already done by CMake for Visual Studio Express and now I just
want a way to set this property through CMakeLists.txt! I also added the
required, trivial code change below...

Resulting in the following usage:

set_target_properties(${YOUR TARGET} PROPERTIES PLATFORM_TOOLSET "Intel C++
Compiler XE 12.1")

This also supports the windows driver SDK in theory and whatever one can think
of. The bug potential is probably zero, so please include this in the main
branch, since I can not expect every one on Windows to configure and build a
custom CMake edition just to make my OpenSource project buildable on that
platform... (I need the Intel Compiler, because Microsoft's support for C++11
even in the next iteration VS2011, is god damn inferior to everything there is)

Thanks a bunch!
Christoph Husse

Additional Information: 
The thing you have to do is goto to the file
"cmVisualStudio10TargetGenerator.cxx" and method "void
cmVisualStudio10TargetGenerator::WriteProjectConfigurationValues()".

Now just patch the following code at the end of the method:

"
   if(const char* toolset = gg->GetPlatformToolset())
      {
      std::string pts = "<PlatformToolset>";
"

with this snippet:

"
   if(this->Target->GetProperty("PLATFORM_TOOLSET"))
      {
      this->WriteString(((std::string)"<PlatformToolset>" +
this->Target->GetProperty("PLATFORM_TOOLSET") + "</PlatformToolset>").c_str(),
2);
      }
   else if(const char* toolset = gg->GetPlatformToolset())
      {
          std::string pts = "<PlatformToolset>";
"

Now you can simply set the platform toolset from within a CMakeLists.txt file by
using:

"
set_target_properties(${YOUR TARGET} PROPERTIES PLATFORM_TOOLSET "Intel C++
Compiler XE 12.1")
"

I found this to be pretty slick, since now also the CMake macro can be used and
you don't have to edit anything manually... Additionally, you can set custom
toolsets for every single project.

This solves the Intel Compiler issue for me and additionally one can specify any
toolset this way, like windows driver SDK and stuff like that! 
====================================================================== 

Issue History 
Date Modified    Username       Field                    Change               
====================================================================== 
2012-01-16 03:26 thesaint       New Issue                                    
======================================================================




More information about the cmake-developers mailing list