WindowsPaths.cmake 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. set(_programfiles "")
  25. foreach(v "ProgramW6432" "ProgramFiles" "ProgramFiles(x86)")
  26. if(DEFINED "ENV{${v}}")
  27. file(TO_CMAKE_PATH "$ENV{${v}}" _env_programfiles)
  28. list(APPEND _programfiles "${_env_programfiles}")
  29. unset(_env_programfiles)
  30. endif()
  31. endforeach()
  32. if(DEFINED "ENV{SystemDrive}")
  33. foreach(d "Program Files" "Program Files (x86)")
  34. if(EXISTS "$ENV{SystemDrive}/${d}")
  35. list(APPEND _programfiles "$ENV{SystemDrive}/${d}")
  36. endif()
  37. endforeach()
  38. endif()
  39. if(_programfiles)
  40. list(REMOVE_DUPLICATES _programfiles)
  41. list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${_programfiles})
  42. endif()
  43. unset(_programfiles)
  44. # Add the CMake install location.
  45. get_filename_component(_CMAKE_INSTALL_DIR "${CMAKE_ROOT}" PATH)
  46. get_filename_component(_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH)
  47. list(APPEND CMAKE_SYSTEM_PREFIX_PATH "${_CMAKE_INSTALL_DIR}")
  48. if (NOT CMAKE_FIND_NO_INSTALL_PREFIX)
  49. # Add other locations.
  50. list(APPEND CMAKE_SYSTEM_PREFIX_PATH
  51. # Project install destination.
  52. "${CMAKE_INSTALL_PREFIX}"
  53. )
  54. if (CMAKE_STAGING_PREFIX)
  55. list(APPEND CMAKE_SYSTEM_PREFIX_PATH
  56. # User-supplied staging prefix.
  57. "${CMAKE_STAGING_PREFIX}"
  58. )
  59. endif()
  60. endif()
  61. if(CMAKE_CROSSCOMPILING AND NOT CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
  62. # MinGW (useful when cross compiling from linux with CMAKE_FIND_ROOT_PATH set)
  63. list(APPEND CMAKE_SYSTEM_PREFIX_PATH /)
  64. endif()
  65. list(APPEND CMAKE_SYSTEM_INCLUDE_PATH
  66. )
  67. # mingw can also link against dlls which can also be in /bin, so list this too
  68. if (NOT CMAKE_FIND_NO_INSTALL_PREFIX)
  69. list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
  70. "${CMAKE_INSTALL_PREFIX}/bin"
  71. )
  72. if (CMAKE_STAGING_PREFIX)
  73. list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
  74. "${CMAKE_STAGING_PREFIX}/bin"
  75. )
  76. endif()
  77. endif()
  78. list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
  79. "${_CMAKE_INSTALL_DIR}/bin"
  80. /bin
  81. )
  82. list(APPEND CMAKE_SYSTEM_PROGRAM_PATH
  83. )