You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
1.5 KiB

  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. # - A little helper variable which should not be directly called
  10. function(DetermineShortWindowsName WIN_VERSION win_num_version)
  11. if (${win_num_version} VERSION_EQUAL "6.1")
  12. set(_version "win7")
  13. elseif(${win_num_version} VERSION_EQUAL "6.0")
  14. set(_version "winVista")
  15. elseif(${win_num_version} VERSION_EQUAL "5.2")
  16. set(_version "winXpProf")
  17. elseif(${win_num_version} VERSION_EQUAL "5.1")
  18. set(_version "winXp")
  19. elseif(${win_num_version} VERSION_EQUAL "5.0")
  20. set(_version "win2000Prof")
  21. else()
  22. set(_version "unknownWin")
  23. endif()
  24. set(${WIN_VERSION} ${_version} PARENT_SCOPE)
  25. endfunction()
  26. function(DetermineOSVersion OS_VERSION)
  27. if (WIN32)
  28. file (TO_NATIVE_PATH "$ENV{COMSPEC}" SHELL)
  29. exec_program( ${SHELL} ARGS "/c" "ver" OUTPUT_VARIABLE ver_output)
  30. string(REGEX MATCHALL "[0-9]+"
  31. ver_list "${ver_output}")
  32. list(GET ver_list 0 _major)
  33. list(GET ver_list 1 _minor)
  34. set(win_num_version ${_major}.${_minor})
  35. DetermineShortWindowsName(win_version "${win_num_version}")
  36. if(win_version)
  37. set(${OS_VERSION} ${win_version} PARENT_SCOPE)
  38. endif()
  39. else()
  40. set(${OS_VERSION} ${CMAKE_SYSTEM} PARENT_SCOPE)
  41. endif()
  42. endfunction()