MantisBT - CMake
View Issue Details
0012876CMakeCMakepublic2012-01-16 03:262012-07-09 06:52
thesaint 
Brad King 
urgenttweakalways
closedduplicate 
Microsoft Windows
CMake 2.8.7 
 
0012876: Recognizing a PLATFORM_TOOLSET property for Visual Studio builds!
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
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!
No tags attached.
duplicate of 0010722closed Brad King Add PlatformToolset support to Visual Studio 2010 generator 
Issue History
2012-01-16 03:26thesaintNew Issue
2012-01-16 08:38Brad KingNote Added: 0028313
2012-01-16 08:38Brad KingRelationship addedduplicate of 0010722
2012-01-16 08:38Brad KingStatusnew => resolved
2012-01-16 08:38Brad KingResolutionopen => duplicate
2012-01-16 08:38Brad KingAssigned To => Brad King
2012-07-09 06:52David ColeNote Added: 0029956
2012-07-09 06:52David ColeStatusresolved => closed

Notes
(0028313)
Brad King   
2012-01-16 08:38   
Please see issue 0010722 where this was already requested.

In particular see comments 0010722:0020845, 0010722:0020917, and 0010722:0023645.
(0029956)
David Cole   
2012-07-09 06:52   
Closing resolved issues that have not been updated in more than 4 months.