summaryrefslogtreecommitdiff
path: root/Modules/Platform/WindowsPaths.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/Platform/WindowsPaths.cmake')
-rw-r--r--Modules/Platform/WindowsPaths.cmake94
1 files changed, 44 insertions, 50 deletions
diff --git a/Modules/Platform/WindowsPaths.cmake b/Modules/Platform/WindowsPaths.cmake
index fc921d793..71cc6095a 100644
--- a/Modules/Platform/WindowsPaths.cmake
+++ b/Modules/Platform/WindowsPaths.cmake
@@ -1,16 +1,6 @@
+# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
+# file Copyright.txt or https://cmake.org/licensing for details.
-#=============================================================================
-# Copyright 2006-2009 Kitware, Inc.
-#
-# Distributed under the OSI-approved BSD License (the "License");
-# see accompanying file Copyright.txt for details.
-#
-# This software is distributed WITHOUT ANY WARRANTY; without even the
-# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-# See the License for more information.
-#=============================================================================
-# (To distribute this file outside of CMake, substitute the full
-# License text for the above reference.)
# Block multiple inclusion because "CMakeCInformation.cmake" includes
# "Platform/${CMAKE_SYSTEM_NAME}" even though the generic module
@@ -28,56 +18,51 @@ set(__WINDOWS_PATHS_INCLUDED 1)
# Windows 64-bit Binary:
# ENV{ProgramFiles(x86)} = [C:\Program Files (x86)]
# ENV{ProgramFiles} = [C:\Program Files]
-# ENV{ProgramW6432} = <not set>
-# (executed from cygwin):
-# ENV{ProgramFiles(x86)} = <not set>
-# ENV{ProgramFiles} = [C:\Program Files]
-# ENV{ProgramW6432} = <not set>
+# ENV{ProgramW6432} = [C:\Program Files] or <not set>
#
-# Windows 32-bit Binary:
+# Windows 32-bit Binary on 64-bit Windows:
# ENV{ProgramFiles(x86)} = [C:\Program Files (x86)]
# ENV{ProgramFiles} = [C:\Program Files (x86)]
# ENV{ProgramW6432} = [C:\Program Files]
-# (executed from cygwin):
-# ENV{ProgramFiles(x86)} = <not set>
-# ENV{ProgramFiles} = [C:\Program Files (x86)]
-# ENV{ProgramW6432} = [C:\Program Files]
-if(DEFINED "ENV{ProgramW6432}")
- # 32-bit binary on 64-bit windows.
- # The 64-bit program files are in ProgramW6432.
- list(APPEND CMAKE_SYSTEM_PREFIX_PATH "$ENV{ProgramW6432}")
-
- # The 32-bit program files are in ProgramFiles.
- if(DEFINED "ENV{ProgramFiles}")
- list(APPEND CMAKE_SYSTEM_PREFIX_PATH "$ENV{ProgramFiles}")
+set(_programfiles "")
+foreach(v "ProgramW6432" "ProgramFiles" "ProgramFiles(x86)")
+ if(DEFINED "ENV{${v}}")
+ file(TO_CMAKE_PATH "$ENV{${v}}" _env_programfiles)
+ list(APPEND _programfiles "${_env_programfiles}")
+ unset(_env_programfiles)
endif()
-else()
- # 64-bit binary, or 32-bit binary on 32-bit windows.
- if(DEFINED "ENV{ProgramFiles}")
- list(APPEND CMAKE_SYSTEM_PREFIX_PATH "$ENV{ProgramFiles}")
- endif()
- if(DEFINED "ENV{ProgramFiles(x86)}")
- # 64-bit binary. 32-bit program files are in ProgramFiles(x86).
- list(APPEND CMAKE_SYSTEM_PREFIX_PATH "$ENV{ProgramFiles(x86)}")
- elseif(DEFINED "ENV{SystemDrive}")
- # Guess the 32-bit program files location.
- if(EXISTS "$ENV{SystemDrive}/Program Files (x86)")
- list(APPEND CMAKE_SYSTEM_PREFIX_PATH
- "$ENV{SystemDrive}/Program Files (x86)")
+endforeach()
+if(DEFINED "ENV{SystemDrive}")
+ foreach(d "Program Files" "Program Files (x86)")
+ if(EXISTS "$ENV{SystemDrive}/${d}")
+ list(APPEND _programfiles "$ENV{SystemDrive}/${d}")
endif()
- endif()
+ endforeach()
endif()
+if(_programfiles)
+ list(REMOVE_DUPLICATES _programfiles)
+ list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${_programfiles})
+endif()
+unset(_programfiles)
# Add the CMake install location.
get_filename_component(_CMAKE_INSTALL_DIR "${CMAKE_ROOT}" PATH)
get_filename_component(_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH)
list(APPEND CMAKE_SYSTEM_PREFIX_PATH "${_CMAKE_INSTALL_DIR}")
-# Add other locations.
-list(APPEND CMAKE_SYSTEM_PREFIX_PATH
- # Project install destination.
- "${CMAKE_INSTALL_PREFIX}"
- )
+if (NOT CMAKE_FIND_NO_INSTALL_PREFIX)
+ # Add other locations.
+ list(APPEND CMAKE_SYSTEM_PREFIX_PATH
+ # Project install destination.
+ "${CMAKE_INSTALL_PREFIX}"
+ )
+ if (CMAKE_STAGING_PREFIX)
+ list(APPEND CMAKE_SYSTEM_PREFIX_PATH
+ # User-supplied staging prefix.
+ "${CMAKE_STAGING_PREFIX}"
+ )
+ endif()
+endif()
if(CMAKE_CROSSCOMPILING AND NOT CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
# MinGW (useful when cross compiling from linux with CMAKE_FIND_ROOT_PATH set)
@@ -88,8 +73,17 @@ list(APPEND CMAKE_SYSTEM_INCLUDE_PATH
)
# mingw can also link against dlls which can also be in /bin, so list this too
+if (NOT CMAKE_FIND_NO_INSTALL_PREFIX)
+ list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
+ "${CMAKE_INSTALL_PREFIX}/bin"
+ )
+ if (CMAKE_STAGING_PREFIX)
+ list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
+ "${CMAKE_STAGING_PREFIX}/bin"
+ )
+ endif()
+endif()
list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
- "${CMAKE_INSTALL_PREFIX}/bin"
"${_CMAKE_INSTALL_DIR}/bin"
/bin
)