mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-23 09:37:51 +08:00
find_package: Add support for CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY
Extend the change from commit 1d00ba9ccf
(Find: find_package prefers
variable CMAKE_FIND_USE_REGISTRY, 2018-11-13, v3.16.0-rc1~461^2~1)
to cover the system package registry too.
Fixes: #19890
This commit is contained in:

committed by
Brad King

parent
c1d5d5eb11
commit
55df3954d3
@@ -353,8 +353,10 @@ enabled.
|
|||||||
|
|
||||||
8. Search paths stored in the CMake :ref:`System Package Registry`.
|
8. Search paths stored in the CMake :ref:`System Package Registry`.
|
||||||
This can be skipped if ``NO_CMAKE_SYSTEM_PACKAGE_REGISTRY`` is passed
|
This can be skipped if ``NO_CMAKE_SYSTEM_PACKAGE_REGISTRY`` is passed
|
||||||
or by setting the
|
or by setting the :variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY`
|
||||||
|
variable to ``FALSE`` or the deprecated variable
|
||||||
:variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` to ``TRUE``.
|
:variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` to ``TRUE``.
|
||||||
|
|
||||||
See the :manual:`cmake-packages(7)` manual for details on the system
|
See the :manual:`cmake-packages(7)` manual for details on the system
|
||||||
package registry.
|
package registry.
|
||||||
|
|
||||||
|
@@ -191,6 +191,7 @@ Variables that Change Behavior
|
|||||||
/variable/CMAKE_FIND_USE_PACKAGE_REGISTRY
|
/variable/CMAKE_FIND_USE_PACKAGE_REGISTRY
|
||||||
/variable/CMAKE_FIND_USE_PACKAGE_ROOT_PATH
|
/variable/CMAKE_FIND_USE_PACKAGE_ROOT_PATH
|
||||||
/variable/CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH
|
/variable/CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH
|
||||||
|
/variable/CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY
|
||||||
/variable/CMAKE_FRAMEWORK_PATH
|
/variable/CMAKE_FRAMEWORK_PATH
|
||||||
/variable/CMAKE_IGNORE_PATH
|
/variable/CMAKE_IGNORE_PATH
|
||||||
/variable/CMAKE_INCLUDE_DIRECTORIES_BEFORE
|
/variable/CMAKE_INCLUDE_DIRECTORIES_BEFORE
|
||||||
|
@@ -95,7 +95,9 @@ Commands
|
|||||||
|
|
||||||
* The :command:`find_package` command has learned to check the
|
* The :command:`find_package` command has learned to check the
|
||||||
:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` variable to control the default
|
:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` variable to control the default
|
||||||
behavior of searching the CMake user package registry.
|
behavior of searching the CMake user package registry and to check the
|
||||||
|
:variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY` variable to control
|
||||||
|
the default behavior of searching the CMake system package registry.
|
||||||
|
|
||||||
* The :command:`message` command learned indentation control with the new
|
* The :command:`message` command learned indentation control with the new
|
||||||
:variable:`CMAKE_MESSAGE_INDENT` variable.
|
:variable:`CMAKE_MESSAGE_INDENT` variable.
|
||||||
|
@@ -1,12 +1,23 @@
|
|||||||
CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY
|
CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY
|
||||||
---------------------------------------------
|
---------------------------------------------
|
||||||
|
|
||||||
Skip :ref:`System Package Registry` in :command:`find_package` calls.
|
.. deprecated:: 3.16
|
||||||
|
|
||||||
|
Use the :variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY` variable instead.
|
||||||
|
|
||||||
|
By default this variable is not set. If neither
|
||||||
|
:variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY` nor
|
||||||
|
``CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY`` is set, then
|
||||||
|
:command:`find_package()` will use the :ref:`System Package Registry`
|
||||||
|
unless the ``NO_CMAKE_SYSTEM_PACKAGE_REGISTRY`` option is provided.
|
||||||
|
|
||||||
|
``CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY`` is ignored if
|
||||||
|
:variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY` is set.
|
||||||
|
|
||||||
In some cases, it is not desirable to use the
|
In some cases, it is not desirable to use the
|
||||||
:ref:`System Package Registry` when searching for packages. If the
|
:ref:`System Package Registry` when searching for packages. If the
|
||||||
:variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` variable is
|
:variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` variable is
|
||||||
enabled, all the :command:`find_package` commands will skip
|
``TRUE``, all the :command:`find_package` commands will skip
|
||||||
the :ref:`System Package Registry` as if they were called with the
|
the :ref:`System Package Registry` as if they were called with the
|
||||||
``NO_CMAKE_SYSTEM_PACKAGE_REGISTRY`` argument.
|
``NO_CMAKE_SYSTEM_PACKAGE_REGISTRY`` argument.
|
||||||
|
|
||||||
|
@@ -19,5 +19,6 @@ take precedence over this variable.
|
|||||||
See also the :variable:`CMAKE_FIND_USE_CMAKE_PATH`,
|
See also the :variable:`CMAKE_FIND_USE_CMAKE_PATH`,
|
||||||
:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
|
:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
|
||||||
:variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`,
|
:variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`,
|
||||||
|
:variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY`,
|
||||||
:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`,
|
:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`,
|
||||||
and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
|
and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
|
||||||
|
@@ -19,5 +19,6 @@ take precedence over this variable.
|
|||||||
See also the :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
|
See also the :variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
|
||||||
:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
|
:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
|
||||||
:variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`,
|
:variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`,
|
||||||
|
:variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY`,
|
||||||
:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`,
|
:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`,
|
||||||
and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
|
and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
|
||||||
|
@@ -19,5 +19,6 @@ take precedence over this variable.
|
|||||||
See also the :variable:`CMAKE_FIND_USE_CMAKE_PATH`,
|
See also the :variable:`CMAKE_FIND_USE_CMAKE_PATH`,
|
||||||
:variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
|
:variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
|
||||||
:variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`,
|
:variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`,
|
||||||
|
:variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY`,
|
||||||
:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`,
|
:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`,
|
||||||
and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
|
and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
|
||||||
|
@@ -26,4 +26,5 @@ See also :ref:`Disabling the Package Registry` and the
|
|||||||
:variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
|
:variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
|
||||||
:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
|
:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
|
||||||
:variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`,
|
:variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`,
|
||||||
|
:variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY`,
|
||||||
and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
|
and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
|
||||||
|
@@ -18,4 +18,5 @@ See also the :variable:`CMAKE_FIND_USE_CMAKE_PATH`,
|
|||||||
:variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
|
:variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
|
||||||
:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
|
:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
|
||||||
:variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`,
|
:variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`,
|
||||||
|
:variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY`,
|
||||||
and :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` variables.
|
and :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` variables.
|
||||||
|
@@ -20,4 +20,5 @@ See also the :variable:`CMAKE_FIND_USE_CMAKE_PATH`,
|
|||||||
:variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
|
:variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
|
||||||
:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
|
:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
|
||||||
:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`,
|
:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`,
|
||||||
and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
|
:variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH`,
|
||||||
|
and :variable:`CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY` variables.
|
||||||
|
31
Help/variable/CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY.rst
Normal file
31
Help/variable/CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY.rst
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY
|
||||||
|
--------------------------------------
|
||||||
|
|
||||||
|
Controls searching the :ref:`System Package Registry` by the
|
||||||
|
:command:`find_package` command.
|
||||||
|
|
||||||
|
By default this variable is not set and the behavior will fall back
|
||||||
|
to that determined by the deprecated
|
||||||
|
:variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` variable.
|
||||||
|
If that is also not set, then :command:`find_package()` will use the
|
||||||
|
:ref:`System Package Registry` unless the ``NO_CMAKE_SYSTEM_PACKAGE_REGISTRY``
|
||||||
|
option is provided.
|
||||||
|
|
||||||
|
This variable takes precedence over
|
||||||
|
:variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` when both are set.
|
||||||
|
|
||||||
|
In some cases, for example to locate only user specific installations, it
|
||||||
|
is not desirable to use the :ref:`System Package Registry` when searching
|
||||||
|
for packages. If the ``CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY``
|
||||||
|
variable is ``FALSE``, all the :command:`find_package` commands will skip
|
||||||
|
the :ref:`System Package Registry` as if they were called with the
|
||||||
|
``NO_CMAKE_SYSTEM_PACKAGE_REGISTRY`` argument.
|
||||||
|
|
||||||
|
See also :ref:`Disabling the Package Registry`.
|
||||||
|
|
||||||
|
See also the :variable:`CMAKE_FIND_USE_CMAKE_PATH`,
|
||||||
|
:variable:`CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH`,
|
||||||
|
:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
|
||||||
|
:variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`,
|
||||||
|
:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`,
|
||||||
|
and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
|
@@ -201,7 +201,13 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if System Package Registry should be disabled
|
// Check if System Package Registry should be disabled
|
||||||
if (this->Makefile->IsOn("CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY")) {
|
// The `CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY` has
|
||||||
|
// priority over the deprecated CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY
|
||||||
|
if (const char* def = this->Makefile->GetDefinition(
|
||||||
|
"CMAKE_FIND_USE_SYSTEM_PACKAGE_REGISTRY")) {
|
||||||
|
this->NoSystemRegistry = !cmIsOn(def);
|
||||||
|
} else if (this->Makefile->IsOn(
|
||||||
|
"CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY")) {
|
||||||
this->NoSystemRegistry = true;
|
this->NoSystemRegistry = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user