mirror of
https://github.com/reactos/CMake.git
synced 2024-11-24 12:09:48 +00:00
Allow disabling adding the install prefix to the prefix search path.
In certain scenarios, it is preferable to keep a 'dirty' install prefix than to clear it, and to expect that content will not be found there. Add a CMAKE_FIND_NO_INSTALL_PREFIX variable that can be set to disable searching the install prefix.
This commit is contained in:
parent
047c1ec457
commit
fe057ab3cd
@ -88,6 +88,7 @@ Variables that Change Behavior
|
|||||||
/variable/CMAKE_FIND_LIBRARY_PREFIXES
|
/variable/CMAKE_FIND_LIBRARY_PREFIXES
|
||||||
/variable/CMAKE_FIND_LIBRARY_SUFFIXES
|
/variable/CMAKE_FIND_LIBRARY_SUFFIXES
|
||||||
/variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE
|
/variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE
|
||||||
|
/variable/CMAKE_FIND_NO_INSTALL_PREFIX
|
||||||
/variable/CMAKE_IGNORE_PATH
|
/variable/CMAKE_IGNORE_PATH
|
||||||
/variable/CMAKE_INCLUDE_PATH
|
/variable/CMAKE_INCLUDE_PATH
|
||||||
/variable/CMAKE_INSTALL_DEFAULT_COMPONENT_NAME
|
/variable/CMAKE_INSTALL_DEFAULT_COMPONENT_NAME
|
||||||
|
13
Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst
Normal file
13
Help/variable/CMAKE_FIND_NO_INSTALL_PREFIX.rst
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
CMAKE_FIND_NO_INSTALL_PREFIX
|
||||||
|
----------------------------
|
||||||
|
|
||||||
|
Ignore the :variable:`CMAKE_INSTALL_PREFIX` when searching for assets.
|
||||||
|
|
||||||
|
CMake adds the :variable:`CMAKE_INSTALL_PREFIX` to the
|
||||||
|
:variable:`CMAKE_SYSTEM_PREFIX_PATH` by default. This variable may be set
|
||||||
|
on the command line to control that behavior.
|
||||||
|
|
||||||
|
Set :variable:`CMAKE_FIND_NO_INSTALL_PREFIX` to TRUE to tell find_package not
|
||||||
|
to search in the :variable:`CMAKE_INSTALL_PREFIX` by default. Note that the
|
||||||
|
prefix may still be searched for other reasons, such as being the same prefix
|
||||||
|
as the CMake installation, or for being a built-in system prefix.
|
@ -37,10 +37,13 @@ list(APPEND CMAKE_SYSTEM_PREFIX_PATH
|
|||||||
|
|
||||||
# CMake install location
|
# CMake install location
|
||||||
"${_CMAKE_INSTALL_DIR}"
|
"${_CMAKE_INSTALL_DIR}"
|
||||||
|
|
||||||
# Project install destination.
|
|
||||||
"${CMAKE_INSTALL_PREFIX}"
|
|
||||||
)
|
)
|
||||||
|
if (NOT CMAKE_FIND_NO_INSTALL_PREFIX)
|
||||||
|
list(APPEND CMAKE_SYSTEM_PREFIX_PATH
|
||||||
|
# Project install destination.
|
||||||
|
"${CMAKE_INSTALL_PREFIX}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
# List common include file locations not under the common prefixes.
|
# List common include file locations not under the common prefixes.
|
||||||
list(APPEND CMAKE_SYSTEM_INCLUDE_PATH
|
list(APPEND CMAKE_SYSTEM_INCLUDE_PATH
|
||||||
|
@ -73,11 +73,13 @@ get_filename_component(_CMAKE_INSTALL_DIR "${CMAKE_ROOT}" PATH)
|
|||||||
get_filename_component(_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH)
|
get_filename_component(_CMAKE_INSTALL_DIR "${_CMAKE_INSTALL_DIR}" PATH)
|
||||||
list(APPEND CMAKE_SYSTEM_PREFIX_PATH "${_CMAKE_INSTALL_DIR}")
|
list(APPEND CMAKE_SYSTEM_PREFIX_PATH "${_CMAKE_INSTALL_DIR}")
|
||||||
|
|
||||||
# Add other locations.
|
if (NOT CMAKE_FIND_NO_INSTALL_PREFIX)
|
||||||
list(APPEND CMAKE_SYSTEM_PREFIX_PATH
|
# Add other locations.
|
||||||
# Project install destination.
|
list(APPEND CMAKE_SYSTEM_PREFIX_PATH
|
||||||
"${CMAKE_INSTALL_PREFIX}"
|
# Project install destination.
|
||||||
)
|
"${CMAKE_INSTALL_PREFIX}"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(CMAKE_CROSSCOMPILING AND NOT CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
|
if(CMAKE_CROSSCOMPILING AND NOT CMAKE_HOST_SYSTEM_NAME MATCHES "Windows")
|
||||||
# MinGW (useful when cross compiling from linux with CMAKE_FIND_ROOT_PATH set)
|
# MinGW (useful when cross compiling from linux with CMAKE_FIND_ROOT_PATH set)
|
||||||
@ -88,8 +90,12 @@ list(APPEND CMAKE_SYSTEM_INCLUDE_PATH
|
|||||||
)
|
)
|
||||||
|
|
||||||
# mingw can also link against dlls which can also be in /bin, so list this too
|
# 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"
|
||||||
|
)
|
||||||
|
endif()
|
||||||
list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
|
list(APPEND CMAKE_SYSTEM_LIBRARY_PATH
|
||||||
"${CMAKE_INSTALL_PREFIX}/bin"
|
|
||||||
"${_CMAKE_INSTALL_DIR}/bin"
|
"${_CMAKE_INSTALL_DIR}/bin"
|
||||||
/bin
|
/bin
|
||||||
)
|
)
|
||||||
|
@ -109,6 +109,7 @@ add_RunCMake_test(CMP0004)
|
|||||||
add_RunCMake_test(TargetPolicies)
|
add_RunCMake_test(TargetPolicies)
|
||||||
add_RunCMake_test(alias_targets)
|
add_RunCMake_test(alias_targets)
|
||||||
add_RunCMake_test(interface_library)
|
add_RunCMake_test(interface_library)
|
||||||
|
add_RunCMake_test(no_install_prefix)
|
||||||
|
|
||||||
find_package(Qt4 QUIET)
|
find_package(Qt4 QUIET)
|
||||||
find_package(Qt5Core QUIET)
|
find_package(Qt5Core QUIET)
|
||||||
|
3
Tests/RunCMake/no_install_prefix/CMakeLists.txt
Normal file
3
Tests/RunCMake/no_install_prefix/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
cmake_minimum_required(VERSION 2.8.4)
|
||||||
|
project(${RunCMake_TEST} NONE)
|
||||||
|
include(${RunCMake_TEST}.cmake)
|
15
Tests/RunCMake/no_install_prefix/RunCMakeTest.cmake
Normal file
15
Tests/RunCMake/no_install_prefix/RunCMakeTest.cmake
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
include(RunCMake)
|
||||||
|
|
||||||
|
set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX=${RunCMake_BINARY_DIR}/prefix")
|
||||||
|
|
||||||
|
file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/prefix")
|
||||||
|
file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/prefix/NoPrefix")
|
||||||
|
file(WRITE "${RunCMake_BINARY_DIR}/prefix/NoPrefix/NoPrefixConfig.cmake" "")
|
||||||
|
set(RunCMake_TEST_OPTIONS "-DCMAKE_INSTALL_PREFIX:PATH=${RunCMake_BINARY_DIR}/prefix")
|
||||||
|
run_cmake(with_install_prefix)
|
||||||
|
|
||||||
|
file(REMOVE_RECURSE "${RunCMake_BINARY_DIR}/prefix")
|
||||||
|
file(MAKE_DIRECTORY "${RunCMake_BINARY_DIR}/prefix/NoPrefix")
|
||||||
|
file(WRITE "${RunCMake_BINARY_DIR}/prefix/NoPrefix/NoPrefixConfig.cmake" "")
|
||||||
|
list(APPEND RunCMake_TEST_OPTIONS "-DCMAKE_FIND_NO_INSTALL_PREFIX=1")
|
||||||
|
run_cmake(no_install_prefix)
|
2
Tests/RunCMake/no_install_prefix/do_test.cmake
Normal file
2
Tests/RunCMake/no_install_prefix/do_test.cmake
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
find_package(NoPrefix REQUIRED)
|
@ -0,0 +1 @@
|
|||||||
|
1
|
@ -0,0 +1,18 @@
|
|||||||
|
CMake Error at do_test.cmake:2 \(find_package\):
|
||||||
|
By not providing "FindNoPrefix.cmake" in CMAKE_MODULE_PATH this project has
|
||||||
|
asked CMake to find a package configuration file provided by "NoPrefix",
|
||||||
|
but CMake did not find one.
|
||||||
|
|
||||||
|
Could not find a package configuration file provided by "NoPrefix" with any
|
||||||
|
of the following names:
|
||||||
|
|
||||||
|
NoPrefixConfig.cmake
|
||||||
|
noprefix-config.cmake
|
||||||
|
|
||||||
|
Add the installation prefix of "NoPrefix" to CMAKE_PREFIX_PATH or set
|
||||||
|
"NoPrefix_DIR" to a directory containing one of the above files. If
|
||||||
|
"NoPrefix" provides a separate development package or SDK, be sure it has
|
||||||
|
been installed.
|
||||||
|
Call Stack \(most recent call first\):
|
||||||
|
no_install_prefix.cmake:2 \(include\)
|
||||||
|
CMakeLists.txt:3 \(include\)
|
2
Tests/RunCMake/no_install_prefix/no_install_prefix.cmake
Normal file
2
Tests/RunCMake/no_install_prefix/no_install_prefix.cmake
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
include(do_test.cmake)
|
@ -0,0 +1 @@
|
|||||||
|
0
|
@ -0,0 +1 @@
|
|||||||
|
^$
|
@ -0,0 +1,2 @@
|
|||||||
|
|
||||||
|
include(do_test.cmake)
|
Loading…
Reference in New Issue
Block a user