mirror of
https://github.com/Kitware/CMake.git
synced 2025-10-24 19:59:47 +08:00
Find: find_package prefers variable CMAKE_FIND_USE_REGISTRY
CMake's find control flags should all have a consistent name. To make this happen we are introducing `CMAKE_FIND_USE_REGISTRY` and deprecating `CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`.
This commit is contained in:
@@ -330,8 +330,10 @@ enabled.
|
|||||||
|
|
||||||
6. Search paths stored in the CMake :ref:`User Package Registry`.
|
6. Search paths stored in the CMake :ref:`User Package Registry`.
|
||||||
This can be skipped if ``NO_CMAKE_PACKAGE_REGISTRY`` is passed or by
|
This can be skipped if ``NO_CMAKE_PACKAGE_REGISTRY`` is passed or by
|
||||||
setting the :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`
|
setting the variable :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`
|
||||||
to ``TRUE``.
|
to ``FALSE`` or the deprecated variable
|
||||||
|
:variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` to ``TRUE``.
|
||||||
|
|
||||||
See the :manual:`cmake-packages(7)` manual for details on the user
|
See the :manual:`cmake-packages(7)` manual for details on the user
|
||||||
package registry.
|
package registry.
|
||||||
|
|
||||||
|
|||||||
@@ -654,8 +654,13 @@ allows one to disable them using the following variables:
|
|||||||
:command:`export(PACKAGE)` populates the user package registry unless
|
:command:`export(PACKAGE)` populates the user package registry unless
|
||||||
the :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` variable explicitly
|
the :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` variable explicitly
|
||||||
disables it.
|
disables it.
|
||||||
* :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` disables the
|
* :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` disables the
|
||||||
User Package Registry in all the :command:`find_package` calls.
|
User Package Registry in all the :command:`find_package` calls when
|
||||||
|
set to ``FALSE``.
|
||||||
|
* Deprecated :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` disables the
|
||||||
|
User Package Registry in all the :command:`find_package` calls when set
|
||||||
|
to ``TRUE``. This variable is ignored when
|
||||||
|
:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` has been set.
|
||||||
* :variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` disables
|
* :variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` disables
|
||||||
the System Package Registry in all the :command:`find_package` calls.
|
the System Package Registry in all the :command:`find_package` calls.
|
||||||
|
|
||||||
|
|||||||
@@ -183,6 +183,7 @@ Variables that Change Behavior
|
|||||||
/variable/CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH
|
/variable/CMAKE_FIND_USE_CMAKE_ENVIRONMENT_PATH
|
||||||
/variable/CMAKE_FIND_USE_CMAKE_PATH
|
/variable/CMAKE_FIND_USE_CMAKE_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_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_FRAMEWORK_PATH
|
/variable/CMAKE_FRAMEWORK_PATH
|
||||||
|
|||||||
11
Help/release/dev/add_cmake_find_use_package_registry.rst
Normal file
11
Help/release/dev/add_cmake_find_use_package_registry.rst
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
add_cmake_find_use_package_registry
|
||||||
|
-----------------------------------
|
||||||
|
|
||||||
|
* The :command:`find_package` command has learned to check the following
|
||||||
|
variables to control searching
|
||||||
|
|
||||||
|
* :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` - Controls the searching the
|
||||||
|
cmake user registry.
|
||||||
|
|
||||||
|
* The :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` has been deprecated.
|
||||||
|
Instead use :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`
|
||||||
@@ -1,12 +1,23 @@
|
|||||||
CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY
|
CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY
|
||||||
--------------------------------------
|
--------------------------------------
|
||||||
|
|
||||||
Skip :ref:`User Package Registry` in :command:`find_package` calls.
|
.. deprecated:: 3.16
|
||||||
|
|
||||||
|
Use the :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` variable instead.
|
||||||
|
|
||||||
|
By default this variable is not set. If neither
|
||||||
|
:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` nor
|
||||||
|
``CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`` is set, then
|
||||||
|
:command:`find_package()` will use the `User Package Registry` unless the
|
||||||
|
`NO_CMAKE_PACKAGE_REGISTRY` option is provided.
|
||||||
|
|
||||||
|
``CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`` is ignored if
|
||||||
|
:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` is set.
|
||||||
|
|
||||||
In some cases, for example to locate only system wide installations, it
|
In some cases, for example to locate only system wide installations, it
|
||||||
is not desirable to use the :ref:`User Package Registry` when searching
|
is not desirable to use the :ref:`User Package Registry` when searching
|
||||||
for packages. If the :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`
|
for packages. If the :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`
|
||||||
variable is enabled, all the :command:`find_package` commands will skip
|
variable is ``TRUE``, all the :command:`find_package` commands will skip
|
||||||
the :ref:`User Package Registry` as if they were called with the
|
the :ref:`User Package Registry` as if they were called with the
|
||||||
``NO_CMAKE_PACKAGE_REGISTRY`` argument.
|
``NO_CMAKE_PACKAGE_REGISTRY`` argument.
|
||||||
|
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ commands 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_PACKAGE_REGISTRY`,
|
||||||
and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
|
and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ commands 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_PACKAGE_REGISTRY`,
|
||||||
and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
|
and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ commands 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_PACKAGE_REGISTRY`,
|
||||||
and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
|
and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
|
||||||
|
|||||||
29
Help/variable/CMAKE_FIND_USE_PACKAGE_REGISTRY.rst
Normal file
29
Help/variable/CMAKE_FIND_USE_PACKAGE_REGISTRY.rst
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
CMAKE_FIND_USE_PACKAGE_REGISTRY
|
||||||
|
-------------------------------
|
||||||
|
|
||||||
|
Controls the searching the :ref:`User 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_PACKAGE_REGISTRY`
|
||||||
|
variable. If that is also not set, then `find_package()` will use the
|
||||||
|
`User Package Registry` unless the `NO_CMAKE_PACKAGE_REGISTRY` option
|
||||||
|
is provided.
|
||||||
|
|
||||||
|
This variable takes precedence over :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`
|
||||||
|
when both are set.
|
||||||
|
|
||||||
|
In some cases, for example to locate only system wide installations, it
|
||||||
|
is not desirable to use the :ref:`User Package Registry` when searching
|
||||||
|
for packages. If the :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`
|
||||||
|
variable is ``FALSE``, all the :command:`find_package` commands will skip
|
||||||
|
the :ref:`User Package Registry` as if they were called with the
|
||||||
|
``NO_CMAKE_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`,
|
||||||
|
and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
|
||||||
@@ -14,4 +14,5 @@ commands 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_CMAKE_SYSTEM_PATH`,
|
:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
|
||||||
and :variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH` variables.
|
:variable:`CMAKE_FIND_USE_SYSTEM_ENVIRONMENT_PATH`,
|
||||||
|
and :variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY` variables.
|
||||||
|
|||||||
@@ -14,4 +14,5 @@ commands 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_CMAKE_SYSTEM_PATH`,
|
:variable:`CMAKE_FIND_USE_CMAKE_SYSTEM_PATH`,
|
||||||
|
:variable:`CMAKE_FIND_USE_PACKAGE_REGISTRY`,
|
||||||
and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
|
and :variable:`CMAKE_FIND_USE_PACKAGE_ROOT_PATH` variables.
|
||||||
|
|||||||
@@ -188,7 +188,12 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if User Package Registry should be disabled
|
// Check if User Package Registry should be disabled
|
||||||
if (this->Makefile->IsOn("CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY")) {
|
// The `CMAKE_FIND_USE_PACKAGE_REGISTRY` has
|
||||||
|
// priority over the deprecated CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY
|
||||||
|
if (const char* def =
|
||||||
|
this->Makefile->GetDefinition("CMAKE_FIND_USE_PACKAGE_REGISTRY")) {
|
||||||
|
this->NoUserRegistry = !cmSystemTools::IsOn(def);
|
||||||
|
} else if (this->Makefile->IsOn("CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY")) {
|
||||||
this->NoUserRegistry = true;
|
this->NoUserRegistry = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -391,16 +391,44 @@ try_compile(EXPORTER_COMPILED
|
|||||||
message(STATUS "Searching for export(PACKAGE) test project")
|
message(STATUS "Searching for export(PACKAGE) test project")
|
||||||
set(CMakeTestExportPackage_DIR "" CACHE FILEPATH
|
set(CMakeTestExportPackage_DIR "" CACHE FILEPATH
|
||||||
"Wipe out find results for testing." FORCE)
|
"Wipe out find results for testing." FORCE)
|
||||||
find_package(CMakeTestExportPackage 1.${version} EXACT REQUIRED)
|
|
||||||
|
|
||||||
message(STATUS "Searching for export(PACKAGE) test project with CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=TRUE")
|
message(STATUS "Searching for export(PACKAGE) with CMAKE_FIND_USE_PACKAGE_REGISTRY=TRUE")
|
||||||
|
set(CMAKE_FIND_USE_PACKAGE_REGISTRY TRUE)
|
||||||
|
find_package(CMakeTestExportPackage 1.${version} EXACT REQUIRED)
|
||||||
|
if(NOT CMakeTestExportPackage_FOUND)
|
||||||
|
message(SEND_ERROR "CMakeTestExportPackage should be FOUND!")
|
||||||
|
endif()
|
||||||
|
unset(CMAKE_FIND_USE_PACKAGE_REGISTRY)
|
||||||
|
|
||||||
|
message(STATUS "Searching for export(PACKAGE) with CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=FALSE")
|
||||||
|
set(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY FALSE)
|
||||||
|
find_package(CMakeTestExportPackage 1.${version} EXACT REQUIRED)
|
||||||
|
if(NOT CMakeTestExportPackage_FOUND)
|
||||||
|
message(SEND_ERROR "CMakeTestExportPackage should be FOUND!")
|
||||||
|
endif()
|
||||||
|
unset(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY)
|
||||||
|
|
||||||
|
message(STATUS "Searching for export(PACKAGE) with CMAKE_FIND_USE_PACKAGE_REGISTRY=TRUE and CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=TRUE")
|
||||||
|
set(CMAKE_FIND_USE_PACKAGE_REGISTRY TRUE)
|
||||||
set(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY TRUE)
|
set(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY TRUE)
|
||||||
|
set(CMakeTestExportPackage_DIR FALSE)
|
||||||
|
find_package(CMakeTestExportPackage 1.${version} EXACT REQUIRED)
|
||||||
|
if(NOT CMakeTestExportPackage_FOUND)
|
||||||
|
message(SEND_ERROR "CMakeTestExportPackage should be FOUND!")
|
||||||
|
endif()
|
||||||
|
unset(CMAKE_FIND_USE_PACKAGE_REGISTRY)
|
||||||
|
unset(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY)
|
||||||
|
|
||||||
|
message(STATUS "Searching for export(PACKAGE) with CMAKE_FIND_USE_PACKAGE_REGISTRY=FALSE and CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY=FALSE")
|
||||||
|
set(CMAKE_FIND_USE_PACKAGE_REGISTRY FALSE)
|
||||||
|
set(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY FALSE)
|
||||||
set(CMakeTestExportPackage_DIR "" CACHE FILEPATH
|
set(CMakeTestExportPackage_DIR "" CACHE FILEPATH
|
||||||
"Wipe out find results for testing." FORCE)
|
"Wipe out find results for testing." FORCE)
|
||||||
find_package(CMakeTestExportPackage 1.${version} EXACT QUIET)
|
find_package(CMakeTestExportPackage 1.${version} EXACT QUIET)
|
||||||
if(CMakeTestExportPackage_FOUND)
|
if(CMakeTestExportPackage_FOUND)
|
||||||
message(SEND_ERROR "CMakeTestExportPackage should not be FOUND!")
|
message(SEND_ERROR "CMakeTestExportPackage should be not FOUND!")
|
||||||
endif()
|
endif()
|
||||||
|
unset(CMAKE_FIND_USE_PACKAGE_REGISTRY)
|
||||||
unset(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY)
|
unset(CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY)
|
||||||
|
|
||||||
message(STATUS "Remove export(PACKAGE) test project")
|
message(STATUS "Remove export(PACKAGE) test project")
|
||||||
|
|||||||
Reference in New Issue
Block a user