source: pacpussensors/trunk/Vislab/lib3dv-1.2.0/lib3dv/eigen/cmake/EigenDetermineOSVersion.cmake

Last change on this file was 136, checked in by ldecherf, 8 years ago

Doc

File size: 1.5 KB
Line 
1# The utility function DetermineOSVersion aims at providing an
2# improved version of the CMake variable ${CMAKE_SYSTEM} on Windows
3# machines.
4#
5# Usage:
6# include(EigenDetermineOSVersion)
7# DetermineOSVersion(OS_VERSION)
8# message("OS: ${OS_VERSION}")
9
10# - A little helper variable which should not be directly called
11function(DetermineShortWindowsName WIN_VERSION win_num_version)
12 if (${win_num_version} VERSION_EQUAL "6.1")
13 set(_version "win7")
14 elseif(${win_num_version} VERSION_EQUAL "6.0")
15 set(_version "winVista")
16 elseif(${win_num_version} VERSION_EQUAL "5.2")
17 set(_version "winXpProf")
18 elseif(${win_num_version} VERSION_EQUAL "5.1")
19 set(_version "winXp")
20 elseif(${win_num_version} VERSION_EQUAL "5.0")
21 set(_version "win2000Prof")
22 else()
23 set(_version "unknownWin")
24 endif()
25 set(${WIN_VERSION} ${_version} PARENT_SCOPE)
26endfunction()
27
28function(DetermineOSVersion OS_VERSION)
29 if (WIN32 AND CMAKE_HOST_SYSTEM_NAME MATCHES Windows)
30 file (TO_NATIVE_PATH "$ENV{COMSPEC}" SHELL)
31 exec_program( ${SHELL} ARGS "/c" "ver" OUTPUT_VARIABLE ver_output)
32
33 string(REGEX MATCHALL "[0-9]+"
34 ver_list "${ver_output}")
35 list(GET ver_list 0 _major)
36 list(GET ver_list 1 _minor)
37
38 set(win_num_version ${_major}.${_minor})
39 DetermineShortWindowsName(win_version "${win_num_version}")
40 if(win_version)
41 set(${OS_VERSION} ${win_version} PARENT_SCOPE)
42 endif()
43 else()
44 set(${OS_VERSION} ${CMAKE_SYSTEM} PARENT_SCOPE)
45 endif()
46endfunction()
Note: See TracBrowser for help on using the repository browser.