WindowsPaths.cmake 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. # Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. # file Copyright.txt or https://cmake.org/licensing for details.
  3. # Block multiple inclusion because "CMakeCInformation.cmake" includes
  4. # "Platform/${CMAKE_SYSTEM_NAME}" even though the generic module
  5. # "CMakeSystemSpecificInformation.cmake" already included it.
  6. # The extra inclusion is a work-around documented next to the include()
  7. # call, so this can be removed when the work-around is removed.
  8. if(__WINDOWS_PATHS_INCLUDED)
  9. return()
  10. endif()
  11. set(__WINDOWS_PATHS_INCLUDED 1)
  12. # Add the program-files folder(s) to the list of installation
  13. # prefixes.
  14. #
  15. # Windows 64-bit Binary:
  16. # ENV{ProgramFiles(x86)} = [C:\Program Files (x86)]
  17. # ENV{ProgramFiles} = [C:\Program Files]
  18. # ENV{ProgramW6432} = [C:\Program Files] or <not set>
  19. #
  20. # Windows 32-bit Binary on 64-bit Windows:
  21. # ENV{ProgramFiles(x86)} = [C:\Program Files (x86)]
  22. # ENV{ProgramFiles} = [C:\Program Files (x86)]
  23. # ENV{ProgramW6432} = [C:\Program Files]
  24. #
  25. # Reminder when adding new locations computed from environment variables
  26. # please make sure to keep Help/variable/CMAKE_SYSTEM_PREFIX_PATH.rst
  27. # synchronized
  28. set(_programfiles "")
  29. foreach(v "ProgramW6432" "ProgramFiles" "ProgramFiles(x86)")
  30. if(DEFINED "ENV{${v}}")
  31. file(TO_CMAKE_PATH "$ENV{${v}}" _env_programfiles)
  32. list(APPEND _programfiles "${_env_programfiles}")
  33. unset(_env_programfiles)
  34. endif()
  35. endforeach()
  36. if(DEFINED "ENV{SystemDrive}")
  37. foreach(d "Program Files" "Program Files (x86)")
  38. if(EXISTS "$ENV{SystemDrive}/${d}")
  39. list(APPEND _programfiles "$ENV{SystemDrive}/${d}")
  40. endif()
  41. endforeach()
  42. endif()
  43. if(_programfiles)
  44. list(REMOVE_DUPLICATES _programfiles)
  45. list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${_programfiles})
  46. endif()
  47. unset(_programfiles)
  48. # Add the CMake install location.
  49. get_filename_component(_CMAKE_INSTALL_DIR "${CMAKE_ROOT}" PATH)
  50. get_filename_component(_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH)
  51. list(APPEND CMAKE_SYSTEM_PREFIX_PATH "${_CMAKE_INSTALL_DIR}")
  52. if (NOT CMAKE_FIND_NO_INSTALL_PREFIX)
  53. # Add other locations.
  54. list(APPEND CMAKE_SYSTEM_PREFIX_PATH
  55. # Project install destination.
  56. "${CMAKE_INSTALL_PREFIX}"
  57. )
  58. if (CMAKE_STAGING_PREFIX)
  59. list(APPEND CMAKE_SYSTEM_PREFIX_PATH
  60. # User-supplied staging prefix.
  61. "${CMAKE_STAGING_PREFIX}"
  62. )
  63. endif()
  64. endif()
  65. _cmake_record_install_prefix()
  66. if(CMAKE_CROSSCOMPILING AND NOT CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
  67. # MinGW (useful when cross compiling from linux with CMAKE_FIND_ROOT_PATH set)
  68. list(APPEND CMAKE_SYSTEM_PREFIX_PATH /)
  69. endif()
  70. list(APPEND CMAKE_SYSTEM_INCLUDE_PATH
  71. )
  72. # mingw can also link against dlls which can also be in /bin, so list this too
  73. if (NOT CMAKE_FIND_NO_INSTALL_PREFIX)
  74. list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
  75. "${CMAKE_INSTALL_PREFIX}/bin"
  76. )
  77. if (CMAKE_STAGING_PREFIX)
  78. list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
  79. "${CMAKE_STAGING_PREFIX}/bin"
  80. )
  81. endif()
  82. endif()
  83. list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
  84. "${_CMAKE_INSTALL_DIR}/bin"
  85. /bin
  86. )
  87. list(APPEND CMAKE_SYSTEM_PROGRAM_PATH
  88. )