summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/find_file
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 /Tests/RunCMake/find_file
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 'Tests/RunCMake/find_file')
-rw-r--r--Tests/RunCMake/find_file/MSYSTEM_PREFIX-stdout.txt1
-rw-r--r--Tests/RunCMake/find_file/MSYSTEM_PREFIX.cmake5
-rw-r--r--Tests/RunCMake/find_file/MSYSTEM_PREFIX/include/msystem_prefix.h0
-rw-r--r--Tests/RunCMake/find_file/RunCMakeTest.cmake4
4 files changed, 10 insertions, 0 deletions
diff --git a/Tests/RunCMake/find_file/MSYSTEM_PREFIX-stdout.txt b/Tests/RunCMake/find_file/MSYSTEM_PREFIX-stdout.txt
new file mode 100644
index 0000000..ab9b9d5
--- /dev/null
+++ b/Tests/RunCMake/find_file/MSYSTEM_PREFIX-stdout.txt
@@ -0,0 +1 @@
+-- MSYSTEM_PREFIX_H='[^']*/Tests/RunCMake/find_file/MSYSTEM_PREFIX/include/msystem_prefix.h'
diff --git a/Tests/RunCMake/find_file/MSYSTEM_PREFIX.cmake b/Tests/RunCMake/find_file/MSYSTEM_PREFIX.cmake
new file mode 100644
index 0000000..08e4127
--- /dev/null
+++ b/Tests/RunCMake/find_file/MSYSTEM_PREFIX.cmake
@@ -0,0 +1,5 @@
+set(ENV{MSYSTEM} "FAKEMSYS")
+set(ENV{MSYSTEM_PREFIX} "${CMAKE_CURRENT_LIST_DIR}/MSYSTEM_PREFIX")
+enable_language(C)
+find_file(MSYSTEM_PREFIX_H NAMES msystem_prefix.h)
+message(STATUS "MSYSTEM_PREFIX_H='${MSYSTEM_PREFIX_H}'")
diff --git a/Tests/RunCMake/find_file/MSYSTEM_PREFIX/include/msystem_prefix.h b/Tests/RunCMake/find_file/MSYSTEM_PREFIX/include/msystem_prefix.h
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/Tests/RunCMake/find_file/MSYSTEM_PREFIX/include/msystem_prefix.h
diff --git a/Tests/RunCMake/find_file/RunCMakeTest.cmake b/Tests/RunCMake/find_file/RunCMakeTest.cmake
index 296bb71..2d59e38 100644
--- a/Tests/RunCMake/find_file/RunCMakeTest.cmake
+++ b/Tests/RunCMake/find_file/RunCMakeTest.cmake
@@ -12,6 +12,10 @@ run_cmake(VALIDATOR-undefined-function)
run_cmake(VALIDATOR-specify-macro)
run_cmake(VALIDATOR)
+if(CMAKE_HOST_WIN32 AND MINGW)
+ run_cmake(MSYSTEM_PREFIX)
+endif()
+
run_cmake_with_options(FromPATHEnvDebugVar --debug-find-var=PrefixInPATH_File)
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")