mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-21 22:50:26 -06:00
find_package: Add variable to make package REQUIRED
Add a `CMAKE_REQUIRE_FIND_PACKAGE_<PackageName>` variable is complement to `CMAKE_DISABLE_FIND_PACKAGE_<PackageName>` with just the opposite behaviour: it turns non-required find_package call into the required one. While optional package dependencies usually result in simple and clean build logic, sometimes people want to be sure those optional dependencies will be found and used. Examples are reproducible builds and build instructions for 3rd parties. People choose to make find_package calls REQUIRED and put them behind an option(). Such workarounds blend build logic with build environment management and do not look elegant.
This commit is contained in:
committed by
Brad King
parent
d49b507bb6
commit
a2e9fe38e4
@@ -14,3 +14,5 @@ the package has already been found in a previous CMake run, the
|
||||
variables which have been stored in the cache will still be there. In
|
||||
that case it is recommended to remove the cache variables for this
|
||||
package from the cache using the cache editor or :manual:`cmake(1)` ``-U``
|
||||
|
||||
See also the :variable:`CMAKE_REQUIRE_FIND_PACKAGE_<PackageName>` variable.
|
||||
|
||||
14
Help/variable/CMAKE_REQUIRE_FIND_PACKAGE_PackageName.rst
Normal file
14
Help/variable/CMAKE_REQUIRE_FIND_PACKAGE_PackageName.rst
Normal file
@@ -0,0 +1,14 @@
|
||||
CMAKE_REQUIRE_FIND_PACKAGE_<PackageName>
|
||||
----------------------------------------
|
||||
|
||||
.. versionadded:: 3.22
|
||||
|
||||
Variable for making :command:`find_package` call ``REQUIRED``.
|
||||
|
||||
Every non-``REQUIRED`` :command:`find_package` call in a project can be
|
||||
turned into ``REQUIRED`` by setting the variable
|
||||
``CMAKE_REQUIRE_FIND_PACKAGE_<PackageName>`` to ``TRUE``.
|
||||
This can be used to assert assumptions about build environment and to
|
||||
ensure the build will fail early if they do not hold.
|
||||
|
||||
See also the :variable:`CMAKE_DISABLE_FIND_PACKAGE_<PackageName>` variable.
|
||||
Reference in New Issue
Block a user