Allow the Package Registry to be disabled (#14849)

When a project is packaged for redistribution the local package
registries should not be updated or consulted.  They are for developers.

Add variables to disable use of package registries globally:

* CMAKE_EXPORT_NO_PACKAGE_REGISTRY that disables the export(PACKAGE)
  command
* CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY that disables the User Package
  Registry in all the find_package calls.
* CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY that disables the
  System Package Registry in all the find_package calls.

Update documentation and unit tests.
This commit is contained in:
Daniele E. Domenichelli
2014-04-02 16:32:54 +02:00
committed by Brad King
parent d09fda5d91
commit be8ae96098
10 changed files with 115 additions and 4 deletions
+4 -1
View File
@@ -51,4 +51,7 @@ projects find and use a package from the current project's build tree
without help from the user. Note that the entry in the package
registry that this command creates works only in conjunction with a
package configuration file (<name>Config.cmake) that works with the
build tree.
build tree. In some cases, for example for packaging and for system
wide installations, it is not desirable to write the user package
registry. If the :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` variable
is enabled, the ``export(PACKAGE)`` command will do nothing.
+6 -2
View File
@@ -272,7 +272,9 @@ enabled.
(This step is implemented only on Windows.)
6. Search paths stored in the CMake :ref:`User Package Registry`.
This can be skipped if ``NO_CMAKE_PACKAGE_REGISTRY`` is passed.
This can be skipped if ``NO_CMAKE_PACKAGE_REGISTRY`` is passed or by
setting the :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY`
to ``TRUE``.
See the :manual:`cmake-packages(7)` manual for details on the user
package registry.
@@ -285,7 +287,9 @@ enabled.
CMAKE_SYSTEM_APPBUNDLE_PATH
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
:variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` to ``TRUE``.
See the :manual:`cmake-packages(7)` manual for details on the system
package registry.
+15
View File
@@ -564,6 +564,21 @@ containing the package configuration file.
There is no system package registry on non-Windows platforms.
.. _`Disabling the Package Registry`:
Disabling the Package Registry
------------------------------
In some cases using the Package Registries is not desirable. CMake
allows to disable them using the following variables:
* :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` disables the
:command:`export(PACKAGE)` command.
* :variable:`CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY` disables the
User Package Registry in all the :command:`find_package` calls.
* :variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` disables
the System Package Registry in all the :command:`find_package` calls.
Package Registry Example
------------------------
+3
View File
@@ -109,10 +109,13 @@ Variables that Change Behavior
/variable/CMAKE_DISABLE_FIND_PACKAGE_PackageName
/variable/CMAKE_ERROR_DEPRECATED
/variable/CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION
/variable/CMAKE_EXPORT_NO_PACKAGE_REGISTRY
/variable/CMAKE_SYSROOT
/variable/CMAKE_FIND_LIBRARY_PREFIXES
/variable/CMAKE_FIND_LIBRARY_SUFFIXES
/variable/CMAKE_FIND_NO_INSTALL_PREFIX
/variable/CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY
/variable/CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY
/variable/CMAKE_FIND_PACKAGE_WARN_NO_MODULE
/variable/CMAKE_FIND_ROOT_PATH
/variable/CMAKE_FIND_ROOT_PATH_MODE_INCLUDE
@@ -0,0 +1,11 @@
CMAKE_EXPORT_NO_PACKAGE_REGISTRY
--------------------------------
Disable the :command:`export(PACKAGE)` command.
In some cases, for example for packaging and for system wide
installations, it is not desirable to write the user package registry.
If the :variable:`CMAKE_EXPORT_NO_PACKAGE_REGISTRY` variable is enabled,
the :command:`export(PACKAGE)` command will do nothing.
See also :ref:`Disabling the Package Registry`.
@@ -0,0 +1,13 @@
CMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY
--------------------------------------
Skip :ref:`User Package Registry` in :command:`find_package` calls.
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_PACKAGE_NO_PACKAGE_REGISTRY`
variable is enabled, 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`.
@@ -0,0 +1,13 @@
CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY
---------------------------------------------
Skip :ref:`System Package Registry` in :command:`find_package` calls.
In some cases, it is not desirable to use the
:ref:`System Package Registry` when searching for packages. If the
:variable:`CMAKE_FIND_PACKAGE_NO_SYSTEM_PACKAGE_REGISTRY` variable is
enabled, 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`.