summaryrefslogtreecommitdiffstats
path: root/Modules/Platform/Windows-GNU.cmake
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2023-09-11 23:11:54 (GMT)
committerBrad King <brad.king@kitware.com>2023-09-13 12:35:59 (GMT)
commit5e5132e1b1a090b8d9f58e0316fced47479c9a53 (patch)
tree4d8d6d06322946788d16a73358c0424f0d2c542f /Modules/Platform/Windows-GNU.cmake
parenta273b7f5d4e68df5b1cbc20243491ff23f5d353c (diff)
downloadCMake-5e5132e1b1a090b8d9f58e0316fced47479c9a53.zip
CMake-5e5132e1b1a090b8d9f58e0316fced47479c9a53.tar.gz
CMake-5e5132e1b1a090b8d9f58e0316fced47479c9a53.tar.bz2
MinGW: Search for packages in standard MSYSTEM environment prefixes
MSYS2 and similar MinGW/MSYS distributions define development environments with a `MSYSTEM` environment variable. Each such environment has a documented installation prefix for its packages, often provided by a `MSYSTEM_PREFIX` environment variable. Since commit 84a25fc263 (cmake_host_system_information: Add MSYSTEM_PREFIX query, 2023-09-08) we can look up this prefix. Add `$MSYSTEM_PREFIX/local` and `$MSYSTEM_PREFIX` to our system search prefixes when targeting MinGW under `MSYSTEM` environments. This is their equivalent to `/usr/local` and `/usr`, which we search by default on UNIX systems. Issue: #24216
Diffstat (limited to 'Modules/Platform/Windows-GNU.cmake')
-rw-r--r--Modules/Platform/Windows-GNU.cmake19
1 files changed, 19 insertions, 0 deletions
diff --git a/Modules/Platform/Windows-GNU.cmake b/Modules/Platform/Windows-GNU.cmake
index 088b238..412af6b 100644
--- a/Modules/Platform/Windows-GNU.cmake
+++ b/Modules/Platform/Windows-GNU.cmake
@@ -10,6 +10,25 @@ set(__WINDOWS_GNU 1)
set(MINGW 1)
+# On Windows hosts, in MSYSTEM environments, search standard prefixes.
+if(CMAKE_HOST_WIN32)
+ # Bootstrap CMake does not have cmake_host_system_information.
+ if(COMMAND cmake_host_system_information)
+ cmake_host_system_information(RESULT _MSYSTEM_PREFIX QUERY MSYSTEM_PREFIX)
+ elseif(IS_DIRECTORY "$ENV{MSYSTEM_PREFIX}")
+ set(_MSYSTEM_PREFIX "$ENV{MSYSTEM_PREFIX}")
+ endif()
+
+ # Search this MSYSTEM environment's equivalent to /usr/local and /usr.
+ if(_MSYSTEM_PREFIX)
+ list(PREPEND CMAKE_SYSTEM_PREFIX_PATH "${_MSYSTEM_PREFIX}")
+ if(IS_DIRECTORY "${_MSYSTEM_PREFIX}/local")
+ list(PREPEND CMAKE_SYSTEM_PREFIX_PATH "${_MSYSTEM_PREFIX}/local")
+ endif()
+ endif()
+ unset(_MSYSTEM_PREFIX)
+endif()
+
set(CMAKE_IMPORT_LIBRARY_PREFIX "lib")
set(CMAKE_SHARED_LIBRARY_PREFIX "lib")
set(CMAKE_SHARED_MODULE_PREFIX "lib")