From 42f7e397894c5132b4706f478e62ce5d648119c1 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Mon, 21 Mar 2022 15:05:39 -0400 Subject: Find: Support per call disabling of CMAKE_INSTALL_PREFIX Fixes #23359 --- Modules/CMakeSystemSpecificInformation.cmake | 10 ++++++++++ Modules/Platform/CrayLinuxEnvironment.cmake | 1 + Modules/Platform/UnixPaths.cmake | 1 + Modules/Platform/WindowsPaths.cmake | 1 + 4 files changed, 13 insertions(+) (limited to 'Modules') diff --git a/Modules/CMakeSystemSpecificInformation.cmake b/Modules/CMakeSystemSpecificInformation.cmake index 0ded568835..59f552ab42 100644 --- a/Modules/CMakeSystemSpecificInformation.cmake +++ b/Modules/CMakeSystemSpecificInformation.cmake @@ -17,6 +17,16 @@ set(CYGWIN ) set(MSYS ) set(WIN32 ) +function(_cmake_record_install_prefix ) + set(_CMAKE_SYSTEM_PREFIX_PATH_INSTALL_PREFIX_VALUE "${CMAKE_INSTALL_PREFIX}" PARENT_SCOPE) + set(count 0) + foreach(value IN LISTS CMAKE_SYSTEM_PREFIX_PATH) + if(value STREQUAL CMAKE_INSTALL_PREFIX) + math(EXPR count "${count}+1") + endif() + endforeach() + set(_CMAKE_SYSTEM_PREFIX_PATH_INSTALL_PREFIX_COUNT "${count}" PARENT_SCOPE) +endfunction() # include Generic system information include(CMakeGenericSystem) diff --git a/Modules/Platform/CrayLinuxEnvironment.cmake b/Modules/Platform/CrayLinuxEnvironment.cmake index f2aaf3f710..b982b3f3cf 100644 --- a/Modules/Platform/CrayLinuxEnvironment.cmake +++ b/Modules/Platform/CrayLinuxEnvironment.cmake @@ -68,6 +68,7 @@ if (NOT CMAKE_FIND_NO_INSTALL_PREFIX) ) endif() endif() +_cmake_record_install_prefix() list(APPEND CMAKE_SYSTEM_INCLUDE_PATH $ENV{SYSROOT_DIR}/usr/include/X11 diff --git a/Modules/Platform/UnixPaths.cmake b/Modules/Platform/UnixPaths.cmake index b9381c3d7d..8a0ad23905 100644 --- a/Modules/Platform/UnixPaths.cmake +++ b/Modules/Platform/UnixPaths.cmake @@ -44,6 +44,7 @@ if (NOT CMAKE_FIND_NO_INSTALL_PREFIX) ) endif() endif() +_cmake_record_install_prefix() # Non "standard" but common install prefixes list(APPEND CMAKE_SYSTEM_PREFIX_PATH diff --git a/Modules/Platform/WindowsPaths.cmake b/Modules/Platform/WindowsPaths.cmake index b9e2f17979..de93338cf9 100644 --- a/Modules/Platform/WindowsPaths.cmake +++ b/Modules/Platform/WindowsPaths.cmake @@ -67,6 +67,7 @@ if (NOT CMAKE_FIND_NO_INSTALL_PREFIX) ) endif() endif() +_cmake_record_install_prefix() if(CMAKE_CROSSCOMPILING AND NOT CMAKE_HOST_SYSTEM_NAME MATCHES "Windows") # MinGW (useful when cross compiling from linux with CMAKE_FIND_ROOT_PATH set) -- cgit v1.2.1