MantisBT - CMake
View Issue Details
0016014CMakeCMakepublic2016-03-12 11:472016-06-10 14:21
Nikolai 
 
urgentmajoralways
closedno change required 
WindowsWindows 10
CMake 3.5 
 
0016014: Cannot change "Target Platform Version" in MSVC2015
Based on source code for CMake 3.5. Now WindowsTargetPlatformVersion is set using cmGlobalVisualStudio14Generator::GetWindows10SDKVersion() function and there is no way to set it manualy. So it's impossible to build projects using SDK versions other than the latest one.

This feature was added in https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=3f077996 [^] It's said that "The :variable:`CMAKE_SYSTEM_VERSION` variable may be set to specify a
 version." But it obviously doesn't work it that case.

I propose to add checking for property CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION already set before trying to get it using GetWindows10SDKVersion(). Example solution is given in patch file attachment. Though I suppose it's not the best way to do it.
No tags attached.
patch 0001-Try-to-get-CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION-.patch (1,995) 2016-03-12 11:47
https://public.kitware.com/Bug/file/5641/0001-Try-to-get-CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION-.patch
Issue History
2016-03-12 11:47NikolaiNew Issue
2016-03-12 11:47NikolaiFile Added: 0001-Try-to-get-CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION-.patch
2016-03-12 11:58NikolaiNote Added: 0040664
2016-03-14 10:01Brad KingNote Added: 0040670
2016-03-14 10:01Brad KingStatusnew => resolved
2016-03-14 10:01Brad KingResolutionopen => no change required
2016-03-14 10:50NikolaiNote Added: 0040673
2016-03-14 10:53NikolaiNote Added: 0040675
2016-03-14 10:54Brad KingNote Added: 0040676
2016-03-14 11:00NikolaiNote Deleted: 0040675
2016-03-14 11:11NikolaiNote Added: 0040678
2016-06-10 14:21Kitware RobotNote Added: 0041229
2016-06-10 14:21Kitware RobotStatusresolved => closed

Notes
(0040664)
Nikolai   
2016-03-12 11:58   
Also, CMake with the given patch works fine for my purposes.
(0040670)
Brad King   
2016-03-14 10:01   
Setting CMAKE_SYSTEM_VERSION is the intended way to configure this value. It must be done either in the toolchain file or with an explicit -DCMAKE_SYSTEM_VERSION= on the first configuration of a build tree.
(0040673)
Nikolai   
2016-03-14 10:50   
I doubt it. Tag WindowsTargetPlatformVersion is written to MSVC project file only in one place:
cmVisualStudio10TargetGenerator.cxx 3289
`
  cmGlobalVisualStudio10Generator* gg =
    static_cast<cmGlobalVisualStudio10Generator*>(this->GlobalGenerator);
...
  std::string const& targetPlatformVersion =
    gg->GetWindowsTargetPlatformVersion();
  if (!targetPlatformVersion.empty())
    {
    this->WriteString("<WindowsTargetPlatformVersion>", 2);
    (*this->BuildFileStream) << cmVS10EscapeXML(targetPlatformVersion) <<
      "</WindowsTargetPlatformVersion>\n";
    }
`
In cmGlobalVisualStudio10Generator class:
`
  std::string const& GetWindowsTargetPlatformVersion() const
    { return this->WindowsTargetPlatformVersion; }
`
The only place WindowsTargetPlatformVersion is assigned to is in cmGlobalVisualStudio14Generator class in function 'bool cmGlobalVisualStudio14Generator::SelectWindows10SDK(cmMakefile* mf, bool required)' where it is searched in register and file system.
(0040676)
Brad King   
2016-03-14 10:54   
Yes, and WindowsTargetPlatformVersion is specifically meant to specify the SDK. It needs to specify an existing one or nothing can build. If you specify -DCMAKE_SYSTEM_VERSION= with an exact version of an existing SDK it will be used.
(0040678)
Nikolai   
2016-03-14 11:11   
Ok, my fault. Now I have understood the algorithm. It ony works when setting before the first configuration and there is no way to change it afterwards. It differs from the way other properties work and I got confused.
(0041229)
Kitware Robot   
2016-06-10 14:21   
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.