Commit 609fe390 authored by Robert Maynard's avatar Robert Maynard

FindPackage: Support `NO_[]_PATH` global call options

parent ff29c92d
......@@ -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
......
......@@ -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.
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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();
......
-- 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'
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}")
-- 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'
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}")
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment