summaryrefslogtreecommitdiffstats
path: root/Help/variable
diff options
context:
space:
mode:
authorCraig Scott <craig.scott@crascit.com>2022-08-02 12:42:08 (GMT)
committerCraig Scott <craig.scott@crascit.com>2022-08-03 23:43:10 (GMT)
commit2a9cc3e8e8254eb1703e7e0931fe062814067454 (patch)
tree2f7c16c2ec61e3cf58be9dcd538ec9d27b277994 /Help/variable
parenta2daa18237f2c3c58c37ab9d1c202c63e0f150a7 (diff)
downloadCMake-2a9cc3e8e8254eb1703e7e0931fe062814067454.zip
CMake-2a9cc3e8e8254eb1703e7e0931fe062814067454.tar.gz
CMake-2a9cc3e8e8254eb1703e7e0931fe062814067454.tar.bz2
FetchContent: Disable header set verification for dependencies
The CMAKE_VERIFY_INTERFACE_HEADER_SETS variable is intended to be under the control of the user. It doesn't discriminate between header sets defined in the main project and those defined by dependencies brought into the build directly via FetchContent. Developers will usually only be interested in verifying the main project's header sets, not those from dependencies. Make the variable effectively only enable header set verification of the main project by turning it off during FetchContent_MakeAvailable() calls. The user still has variables like CMAKE_PROJECT_INCLUDE and CMAKE_PROJECT_<projectName>_INCLUDE available to them if they want to enable verification of all or specific dependencies respectively. Fixes: #23808
Diffstat (limited to 'Help/variable')
-rw-r--r--Help/variable/CMAKE_VERIFY_INTERFACE_HEADER_SETS.rst24
1 files changed, 23 insertions, 1 deletions
diff --git a/Help/variable/CMAKE_VERIFY_INTERFACE_HEADER_SETS.rst b/Help/variable/CMAKE_VERIFY_INTERFACE_HEADER_SETS.rst
index 6f14e6f..3fb8817 100644
--- a/Help/variable/CMAKE_VERIFY_INTERFACE_HEADER_SETS.rst
+++ b/Help/variable/CMAKE_VERIFY_INTERFACE_HEADER_SETS.rst
@@ -7,11 +7,33 @@ This variable is used to initialize the
:prop_tgt:`VERIFY_INTERFACE_HEADER_SETS` property of targets when they are
created. Setting it to true enables header set verification.
-Projects should not set this variable, it is intended as a developer
+Projects should not normally set this variable, it is intended as a developer
control to be set on the :manual:`cmake(1)` command line or other
equivalent methods. The developer must have the ability to enable or
disable header set verification according to the capabilities of their own
machine and compiler.
+Verification of a dependency's header sets is not typically of interest
+to developers. Therefore, :command:`FetchContent_MakeAvailable` explicitly
+sets ``CMAKE_VERIFY_INTERFACE_HEADER_SETS`` to false for the duration of its
+call, but restores its original value before returning. If a project brings
+a dependency directly into the main build (e.g. calling
+:command:`add_subdirectory` on a vendored project from a git submodule), it
+should also do likewise. For example:
+
+.. code:: cmake
+
+ # Save original setting so we can restore it later
+ set(want_header_set_verification ${CMAKE_VERIFY_INTERFACE_HEADER_SETS})
+
+ # Include the vendored dependency with header set verification disabled
+ set(CMAKE_VERIFY_INTERFACE_HEADER_SETS OFF)
+ add_subdirectory(...) # Vendored sources, e.g. from git submodules
+
+ # Add the project's own sources. Restore the developer's original choice
+ # for whether to enable header set verification.
+ set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ${want_header_set_verification})
+ add_subdirectory(src)
+
By default, this variable is not set, which will result in header set
verification being disabled.