diff options
author | Robert Maynard <robert.maynard@kitware.com> | 2019-07-22 19:44:37 (GMT) |
---|---|---|
committer | Robert Maynard <robert.maynard@kitware.com> | 2019-07-22 21:17:02 (GMT) |
commit | 609fe39043f37366b50ee5ac0ae283b93af23492 (patch) | |
tree | 2c976feb6faa126bf03f279748b2e6fd690df9eb | |
parent | ff29c92df63ec9a9311b56537db285920c8faa30 (diff) | |
download | CMake-609fe39043f37366b50ee5ac0ae283b93af23492.zip CMake-609fe39043f37366b50ee5ac0ae283b93af23492.tar.gz CMake-609fe39043f37366b50ee5ac0ae283b93af23492.tar.bz2 |
FindPackage: Support `NO_[]_PATH` global call options
-rw-r--r-- | Help/command/find_package.rst | 15 | ||||
-rw-r--r-- | Help/release/dev/global-controls-over-find-locations.rst | 4 | ||||
-rw-r--r-- | Help/variable/CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH.rst | 2 | ||||
-rw-r--r-- | Help/variable/CMAKE_FIND_USE_CMAKE_PATH.rst | 2 | ||||
-rw-r--r-- | Help/variable/CMAKE_FIND_USE_CMAKE_SYSTEM_PATH.rst | 2 | ||||
-rw-r--r-- | Help/variable/CMAKE_FIND_USE_PACKAGE_ROOT_PATH.rst | 2 | ||||
-rw-r--r-- | Help/variable/CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH.rst | 2 | ||||
-rw-r--r-- | Source/cmFindPackageCommand.cxx | 3 | ||||
-rw-r--r-- | Tests/RunCMake/find_package/FromPATHEnv-stdout.txt | 9 | ||||
-rw-r--r-- | Tests/RunCMake/find_package/FromPATHEnv.cmake | 27 | ||||
-rw-r--r-- | Tests/RunCMake/find_package/FromPrefixPath-stdout.txt | 9 | ||||
-rw-r--r-- | Tests/RunCMake/find_package/FromPrefixPath.cmake | 29 | ||||
-rw-r--r-- | Tests/RunCMake/find_package/RunCMakeTest.cmake | 2 |
13 files changed, 96 insertions, 12 deletions
diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst index 6e1d232..2186bd8 100644 --- a/Help/command/find_package.rst +++ b/Help/command/find_package.rst @@ -293,13 +293,15 @@ enabled. The package root variables are maintained as a stack so if called from within a find module, root paths from the parent's find module will also be searched after paths for the current package. - This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed. + This can be skipped if ``NO_PACKAGE_ROOT_PATH`` is passed or by setting + the :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` to ``FALSE``. See policy :policy:`CMP0074`. 2. Search paths specified in cmake-specific cache variables. These are intended to be used on the command line with a ``-DVAR=value``. The values are interpreted as :ref:`semicolon-separated lists <CMake Language Lists>`. - This can be skipped if ``NO_CMAKE_PATH`` is passed:: + This can be skipped if ``NO_CMAKE_PATH`` is passed or by setting the + :variable:`CMAKE_FIND_USE_CMAKE_PATH` to ``FALSE``:: CMAKE_PREFIX_PATH CMAKE_FRAMEWORK_PATH @@ -309,7 +311,8 @@ enabled. These are intended to be set in the user's shell configuration, and therefore use the host's native path separator (``;`` on Windows and ``:`` on UNIX). - This can be skipped if ``NO_CMAKE_ENVIRONMENT_PATH`` is passed:: + This can be skipped if ``NO_CMAKE_ENVIRONMENT_PATH`` is passed or by setting + the :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH` to ``FALSE``:: <PackageName>_DIR CMAKE_PREFIX_PATH @@ -322,7 +325,8 @@ enabled. be specified with the ``PATHS`` option. 5. Search the standard system environment variables. This can be - skipped if ``NO_SYSTEM_ENVIRONMENT_PATH`` is passed. Path entries + skipped if ``NO_SYSTEM_ENVIRONMENT_PATH`` is passed or by setting the + :variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH` to ``FALSE``. Path entries ending in ``/bin`` or ``/sbin`` are automatically converted to their parent directories:: @@ -339,7 +343,8 @@ enabled. 7. Search cmake variables defined in the Platform files for the current system. This can be skipped if ``NO_CMAKE_SYSTEM_PATH`` is - passed:: + passed or by setting the :variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH` + to ``FALSE``:: CMAKE_SYSTEM_PREFIX_PATH CMAKE_SYSTEM_FRAMEWORK_PATH diff --git a/Help/release/dev/global-controls-over-find-locations.rst b/Help/release/dev/global-controls-over-find-locations.rst index 79bc869..1c0b226 100644 --- a/Help/release/dev/global-controls-over-find-locations.rst +++ b/Help/release/dev/global-controls-over-find-locations.rst @@ -2,8 +2,8 @@ global-controls-over-find-locations ----------------------------------- * The :command:`find_file`, :command:`find_library`, :command:`find_path`, - and :command:`find_program` commands have learned to check the following - variables to control searching + :command:`find_package`, and :command:`find_program` commands have learned to + check the following variables to control searching * :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH` - Controls the searching the cmake-specific environment variables. diff --git a/Help/variable/CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH.rst b/Help/variable/CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH.rst index 33514a0..2db5081 100644 --- a/Help/variable/CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH.rst +++ b/Help/variable/CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH.rst @@ -3,7 +3,7 @@ CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH Controls the searching the cmake-specific environment variables by the :command:`find_program`, :command:`find_library`, :command:`find_file`, -and :command:`find_path` commands. +:command:`find_path`, and command:`find_package` commands. This is useful in cross-compiling environments. By default this variable is not set, which is equivalent to it having diff --git a/Help/variable/CMAKE_FIND_USE_CMAKE_PATH.rst b/Help/variable/CMAKE_FIND_USE_CMAKE_PATH.rst index cefc645..4ca7ad1 100644 --- a/Help/variable/CMAKE_FIND_USE_CMAKE_PATH.rst +++ b/Help/variable/CMAKE_FIND_USE_CMAKE_PATH.rst @@ -3,7 +3,7 @@ CMAKE_FIND_USE_CMAKE_PATH Controls the searching the cmake-specific cache variables by the :command:`find_program`, :command:`find_library`, :command:`find_file`, -and :command:`find_path` commands. +:command:`find_path`, and command:`find_package` commands. This is useful in cross-compiling environments. By default this variable is not set, which is equivalent to it having diff --git a/Help/variable/CMAKE_FIND_USE_CMAKE_SYSTEM_PATH.rst b/Help/variable/CMAKE_FIND_USE_CMAKE_SYSTEM_PATH.rst index 2aa544d..d3259ae 100644 --- a/Help/variable/CMAKE_FIND_USE_CMAKE_SYSTEM_PATH.rst +++ b/Help/variable/CMAKE_FIND_USE_CMAKE_SYSTEM_PATH.rst @@ -3,7 +3,7 @@ CMAKE_FIND_USE_CMAKE_SYSTEM_PATH Controls the searching cmake platform specific variables by the :command:`find_program`, :command:`find_library`, :command:`find_file`, -and :command:`find_path` commands. +:command:`find_path`, and command:`find_package` commands. This is useful in cross-compiling environments. By default this variable is not set, which is equivalent to it having diff --git a/Help/variable/CMAKE_FIND_USE_PACKAGE_ROOT_PATH.rst b/Help/variable/CMAKE_FIND_USE_PACKAGE_ROOT_PATH.rst index 899e62e..e17fdcc 100644 --- a/Help/variable/CMAKE_FIND_USE_PACKAGE_ROOT_PATH.rst +++ b/Help/variable/CMAKE_FIND_USE_PACKAGE_ROOT_PATH.rst @@ -3,7 +3,7 @@ CMAKE_FIND_USE_PACKAGE_ROOT_PATH Controls the searching of :variable:`<PackageName>_ROOT` variables by the :command:`find_program`, :command:`find_library`, :command:`find_file`, -and :command:`find_path` commands. +:command:`find_path`, and command:`find_package` commands. This is useful in cross-compiling environments. By default this variable is not set, which is equivalent to it having diff --git a/Help/variable/CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH.rst b/Help/variable/CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH.rst index 604c710..71432f6 100644 --- a/Help/variable/CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH.rst +++ b/Help/variable/CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH.rst @@ -3,7 +3,7 @@ CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH Controls the searching the standard system environment variables by the :command:`find_program`, :command:`find_library`, :command:`find_file`, -and :command:`find_path` commands. +:command:`find_path`, and command:`find_package` commands. This is useful in cross-compiling environments. By default this variable is not set, which is equivalent to it having diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index c6d599e..e4551dd 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -225,6 +225,9 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args, this->SortDirection = strcmp(sd, "ASC") == 0 ? Asc : Dec; } + // Find what search path locations have been enabled/disable + this->SelectDefaultSearchModes(); + // Find the current root path mode. this->SelectDefaultRootPathMode(); diff --git a/Tests/RunCMake/find_package/FromPATHEnv-stdout.txt b/Tests/RunCMake/find_package/FromPATHEnv-stdout.txt new file mode 100644 index 0000000..2ead349 --- /dev/null +++ b/Tests/RunCMake/find_package/FromPATHEnv-stdout.txt @@ -0,0 +1,9 @@ +-- Resolved_FOUND='0' +-- Resolved_FOUND='1' +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' diff --git a/Tests/RunCMake/find_package/FromPATHEnv.cmake b/Tests/RunCMake/find_package/FromPATHEnv.cmake new file mode 100644 index 0000000..4822b13 --- /dev/null +++ b/Tests/RunCMake/find_package/FromPATHEnv.cmake @@ -0,0 +1,27 @@ +set(ENV_PATH "$ENV{PATH}") +foreach(path "/does_not_exist" "/PackageRoot" "") + unset(Resolved_FOUND CACHE) + set(Resolved_DIR "") + set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}") + find_package(Resolved QUIET) + message(STATUS "Resolved_FOUND='${Resolved_FOUND}'") +endforeach() + +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH OFF) +foreach(path "/does_not_exist" "/PackageRoot" "") + unset(Resolved_FOUND CACHE) + set(Resolved_DIR "") + set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}") + find_package(Resolved QUIET) + message(STATUS "Resolved_FOUND='${Resolved_FOUND}'") +endforeach() + +set(CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH ON) +foreach(path "/does_not_exist" "/PackageRoot" "") + unset(Resolved_FOUND CACHE) + set(Resolved_DIR "") + set(ENV{PATH} "${CMAKE_CURRENT_SOURCE_DIR}${path}") + find_package(Resolved NO_SYSTEM_ENVIRONMENT_PATH QUIET) + message(STATUS "Resolved_FOUND='${Resolved_FOUND}'") +endforeach() +set(ENV{PATH} "${ENV_PATH}") diff --git a/Tests/RunCMake/find_package/FromPrefixPath-stdout.txt b/Tests/RunCMake/find_package/FromPrefixPath-stdout.txt new file mode 100644 index 0000000..2ead349 --- /dev/null +++ b/Tests/RunCMake/find_package/FromPrefixPath-stdout.txt @@ -0,0 +1,9 @@ +-- Resolved_FOUND='0' +-- Resolved_FOUND='1' +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' +-- Resolved_FOUND='0' diff --git a/Tests/RunCMake/find_package/FromPrefixPath.cmake b/Tests/RunCMake/find_package/FromPrefixPath.cmake new file mode 100644 index 0000000..be853c1 --- /dev/null +++ b/Tests/RunCMake/find_package/FromPrefixPath.cmake @@ -0,0 +1,29 @@ +set(ENV_PATH "$ENV{PATH}") +set(ENV{PATH} "") +foreach(path "/does_not_exist" "/PackageRoot" "") + unset(Resolved_FOUND CACHE) + set(Resolved_DIR "") + set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}${path}") + find_package(Resolved QUIET) + message(STATUS "Resolved_FOUND='${Resolved_FOUND}'") +endforeach() + +set(CMAKE_FIND_USE_CMAKE_PATH OFF) +set(CMAKE_PREFIX_PATH ) +foreach(path "/does_not_exist" "/PackageRoot" "") + unset(Resolved_FOUND CACHE) + set(Resolved_DIR "") + set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}${path}") + find_package(Resolved QUIET) + message(STATUS "Resolved_FOUND='${Resolved_FOUND}'") +endforeach() + +set(CMAKE_FIND_USE_CMAKE_PATH ON) +foreach(path "/does_not_exist" "/PackageRoot" "") + unset(Resolved_FOUND CACHE) + set(Resolved_DIR "") + set(CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}${path}") + find_package(Resolved NO_CMAKE_PATH QUIET) + message(STATUS "Resolved_FOUND='${Resolved_FOUND}'") +endforeach() +set(ENV{PATH} "${ENV_PATH}") diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake index 066523e..208f83c 100644 --- a/Tests/RunCMake/find_package/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake @@ -3,6 +3,8 @@ include(RunCMake) run_cmake(CMP0074-WARN) run_cmake(CMP0074-OLD) run_cmake(ComponentRequiredAndOptional) +run_cmake(FromPATHEnv) +run_cmake(FromPrefixPath) run_cmake(MissingNormal) run_cmake(MissingNormalRequired) run_cmake(MissingNormalVersion) |