WindowsPaths.cmake 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #=============================================================================
  2. # Copyright 2006-2009 Kitware, Inc.
  3. #
  4. # Distributed under the OSI-approved BSD License (the "License");
  5. # see accompanying file Copyright.txt for details.
  6. #
  7. # This software is distributed WITHOUT ANY WARRANTY; without even the
  8. # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. # See the License for more information.
  10. #=============================================================================
  11. # (To distribute this file outside of CMake, substitute the full
  12. # License text for the above reference.)
  13. # Block multiple inclusion because "CMakeCInformation.cmake" includes
  14. # "Platform/${CMAKE_SYSTEM_NAME}" even though the generic module
  15. # "CMakeSystemSpecificInformation.cmake" already included it.
  16. # The extra inclusion is a work-around documented next to the include()
  17. # call, so this can be removed when the work-around is removed.
  18. if(__WINDOWS_PATHS_INCLUDED)
  19. return()
  20. endif()
  21. set(__WINDOWS_PATHS_INCLUDED 1)
  22. # Add the program-files folder(s) to the list of installation
  23. # prefixes.
  24. #
  25. # Windows 64-bit Binary:
  26. # ENV{ProgramFiles(x86)} = [C:\Program Files (x86)]
  27. # ENV{ProgramFiles} = [C:\Program Files]
  28. # ENV{ProgramW6432} = <not set>
  29. # (executed from cygwin):
  30. # ENV{ProgramFiles(x86)} = <not set>
  31. # ENV{ProgramFiles} = [C:\Program Files]
  32. # ENV{ProgramW6432} = <not set>
  33. #
  34. # Windows 32-bit Binary:
  35. # ENV{ProgramFiles(x86)} = [C:\Program Files (x86)]
  36. # ENV{ProgramFiles} = [C:\Program Files (x86)]
  37. # ENV{ProgramW6432} = [C:\Program Files]
  38. # (executed from cygwin):
  39. # ENV{ProgramFiles(x86)} = <not set>
  40. # ENV{ProgramFiles} = [C:\Program Files (x86)]
  41. # ENV{ProgramW6432} = [C:\Program Files]
  42. if(DEFINED "ENV{ProgramW6432}")
  43. # 32-bit binary on 64-bit windows.
  44. # The 64-bit program files are in ProgramW6432.
  45. list(APPEND CMAKE_SYSTEM_PREFIX_PATH "$ENV{ProgramW6432}")
  46. # The 32-bit program files are in ProgramFiles.
  47. if(DEFINED "ENV{ProgramFiles}")
  48. list(APPEND CMAKE_SYSTEM_PREFIX_PATH "$ENV{ProgramFiles}")
  49. endif()
  50. else()
  51. # 64-bit binary, or 32-bit binary on 32-bit windows.
  52. if(DEFINED "ENV{ProgramFiles}")
  53. list(APPEND CMAKE_SYSTEM_PREFIX_PATH "$ENV{ProgramFiles}")
  54. endif()
  55. set(programfilesx86 "ProgramFiles(x86)")
  56. if(DEFINED "ENV{${programfilesx86}}")
  57. # 64-bit binary. 32-bit program files are in ProgramFiles(x86).
  58. list(APPEND CMAKE_SYSTEM_PREFIX_PATH "$ENV{${programfilesx86}}")
  59. elseif(DEFINED "ENV{SystemDrive}")
  60. # Guess the 32-bit program files location.
  61. if(EXISTS "$ENV{SystemDrive}/Program Files (x86)")
  62. list(APPEND CMAKE_SYSTEM_PREFIX_PATH
  63. "$ENV{SystemDrive}/Program Files (x86)")
  64. endif()
  65. endif()
  66. endif()
  67. # Add the CMake install location.
  68. get_filename_component(_CMAKE_INSTALL_DIR "${CMAKE_ROOT}" PATH)
  69. get_filename_component(_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH)
  70. list(APPEND CMAKE_SYSTEM_PREFIX_PATH "${_CMAKE_INSTALL_DIR}")
  71. if (NOT CMAKE_FIND_NO_INSTALL_PREFIX)
  72. # Add other locations.
  73. list(APPEND CMAKE_SYSTEM_PREFIX_PATH
  74. # Project install destination.
  75. "${CMAKE_INSTALL_PREFIX}"
  76. )
  77. if (CMAKE_STAGING_PREFIX)
  78. list(APPEND CMAKE_SYSTEM_PREFIX_PATH
  79. # User-supplied staging prefix.
  80. "${CMAKE_STAGING_PREFIX}"
  81. )
  82. endif()
  83. endif()
  84. if(CMAKE_CROSSCOMPILING AND NOT CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
  85. # MinGW (useful when cross compiling from linux with CMAKE_FIND_ROOT_PATH set)
  86. list(APPEND CMAKE_SYSTEM_PREFIX_PATH /)
  87. endif()
  88. list(APPEND CMAKE_SYSTEM_INCLUDE_PATH
  89. )
  90. # mingw can also link against dlls which can also be in /bin, so list this too
  91. if (NOT CMAKE_FIND_NO_INSTALL_PREFIX)
  92. list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
  93. "${CMAKE_INSTALL_PREFIX}/bin"
  94. )
  95. if (CMAKE_STAGING_PREFIX)
  96. list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
  97. "${CMAKE_STAGING_PREFIX}/bin"
  98. )
  99. endif()
  100. endif()
  101. list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
  102. "${_CMAKE_INSTALL_DIR}/bin"
  103. /bin
  104. )
  105. list(APPEND CMAKE_SYSTEM_PROGRAM_PATH
  106. )