MantisBT - CMake
View Issue Details
0015674CMakeCMakepublic2015-07-30 12:362016-02-01 09:10
Christian Maaser 
Gilles Khouzam 
lowminoralways
closedfixed 
PCWindows
CMake 3.3 
CMake 3.4CMake 3.4 
0015674: Windows: Correctly determine Windows version for CMAKE_HOST_SYSTEM_VERSION
cmake is currently using the deprecated Windows API function GetVersionEx, which reports wrong information for versions later than WindowsXP. Instead, cmake should make use of RtlGetVersion, which works as expected on all versions of Windows (since Windows 2000).
Compare ${CMAKE_HOST_SYSTEM_VERSION} with the output of the "ver" console command.
https://msdn.microsoft.com/en-us/library/windows/desktop/ms724451(v=vs.85).aspx [^]
https://msdn.microsoft.com/en-us/library/windows/hardware/ff561910(v=vs.85).aspx [^]
No tags attached.
related to 0015670closed Gilles Khouzam Add support for setting "Windows target platform version" in VS2015 
patch cmake-3.3.0-cmake_host_system_version.patch (2,504) 2015-07-30 12:43
https://public.kitware.com/Bug/file/5497/cmake-3.3.0-cmake_host_system_version.patch
patch Issue15674.patch (15,614) 2015-09-10 16:54
https://public.kitware.com/Bug/file/5521/Issue15674.patch
Issue History
2015-07-30 12:36Christian MaaserNew Issue
2015-07-30 12:43Christian MaaserFile Added: cmake-3.3.0-cmake_host_system_version.patch
2015-07-30 12:43Christian MaaserNote Added: 0039201
2015-07-30 14:12Brad KingNote Added: 0039204
2015-07-30 14:22Brad KingNote Added: 0039205
2015-07-30 14:22Brad KingAssigned To => Brad King
2015-07-30 14:22Brad KingStatusnew => resolved
2015-07-30 14:22Brad KingResolutionopen => fixed
2015-07-30 14:22Brad KingFixed in Version => CMake 3.4
2015-07-30 14:22Brad KingTarget Version => CMake 3.4
2015-07-31 10:12Brad KingRelationship addedrelated to 0015670
2015-07-31 10:13Brad KingNote Edited: 0039205bug_revision_view_page.php?bugnote_id=39205#r1856
2015-09-10 08:39Brad KingNote Added: 0039390
2015-09-10 08:39Brad KingAssigned ToBrad King => Gilles Khouzam
2015-09-10 08:39Brad KingStatusresolved => assigned
2015-09-10 08:39Brad KingResolutionfixed => open
2015-09-10 08:39Brad KingFixed in VersionCMake 3.4 =>
2015-09-10 08:39Brad KingTarget VersionCMake 3.4 =>
2015-09-10 08:40Brad KingTarget Version => CMake 3.4
2015-09-10 16:05Brad KingNote Added: 0039402
2015-09-10 16:54Gilles KhouzamFile Added: Issue15674.patch
2015-09-18 14:21Brad KingNote Added: 0039442
2015-09-18 14:22Brad KingNote Added: 0039443
2015-09-21 09:03Brad KingNote Edited: 0039443bug_revision_view_page.php?bugnote_id=39443#r1909
2015-09-21 09:03Brad KingStatusassigned => resolved
2015-09-21 09:03Brad KingResolutionopen => fixed
2015-09-21 09:03Brad KingFixed in Version => CMake 3.4
2016-02-01 09:10Robert MaynardNote Added: 0040411
2016-02-01 09:10Robert MaynardStatusresolved => closed

Notes
(0039201)
Christian Maaser   
2015-07-30 12:43   
I wrote a patch against 3.3.0, which correctly sets the Windows version based on RtlGetVersion. In case the function fails it falls back to using the old behavior. This needs some testing and also might break existing projects, which rely on the previously reported wrong version number.

Also note that I decided to include to build number in the version string (e.g. "10.0.10240" on latest Windows 10).
(0039204)
Brad King   
2015-07-30 14:12   
For reference, there are some explanations about why GetVersionEx returns the older value on Windows >= 8.1:

 http://stackoverflow.com/questions/27246562/how-to-get-the-os-version-in-win8-1-as-getversion-getversionex-are-deprecated [^]
 http://stackoverflow.com/questions/19518670/winapi-deprecation-after-windows-8-1 [^]
(0039205)
Brad King   
2015-07-30 14:22   
(edited on: 2015-07-31 10:13)
Applied, thanks:

 Windows: Fix CMAKE_HOST_SYSTEM_VERSION on Windows >= 8.1
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=d4736d53 [^]

I tweaked it a bit to build on MinGW where RTL_OSVERSIONINFOEXW is not (readily) available.

(0039390)
Brad King   
2015-09-10 08:39   
According to:

 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/14201/focus=14296 [^]

The RtlGetVersion API is not meant for public use.
(0039402)
Brad King   
2015-09-10 16:05   
For now I've reverted the fix from 0015674:0039205:

 Revert "Windows: Fix CMAKE_HOST_SYSTEM_VERSION on Windows >= 8.1"
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=4c7744c8 [^]
(0039442)
Brad King   
2015-09-18 14:21   
Relevant mailing list thread:

 [PATCH] [CMake 0015674]: Windows: Correctly determine Windows version
 http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/14327 [^]
(0039443)
Brad King   
2015-09-18 14:22   
(edited on: 2015-09-21 09:03)
I added Windows *.manifest support to all generators with MSVC tools:

 Add support for *.manifest source files with MSVC tools
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=e134e53b [^]

Then I added the manifest patch sent in the linked mailing list threads:

 Windows: Fix CMAKE_HOST_SYSTEM_VERSION on Windows >= 8
 http://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=17009189 [^]

(0040411)
Robert Maynard   
2016-02-01 09:10   
Closing resolved issues that have not been updated in more than 4 months.