summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2022-08-04 13:34:39 +0000
committerKitware Robot <kwrobot@kitware.com>2022-08-04 09:34:47 -0400
commit3a38f6c618aae0d8a656ae082bdffb3b82aa22e6 (patch)
tree140a59396af5825402ddbe46e2f64a41519f789f /Modules
parentae03cd71b3e05ac0cfe293dec959db6c90872bcf (diff)
parent2a9cc3e8e8254eb1703e7e0931fe062814067454 (diff)
downloadcmake-3a38f6c618aae0d8a656ae082bdffb3b82aa22e6.tar.gz
Merge topic 'fetchcontent-set-CMAKE_VERIFY_INTERFACE_HEADER_SETS' into release-3.24
2a9cc3e8e8 FetchContent: Disable header set verification for dependencies Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !7535
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FetchContent.cmake27
1 files changed, 27 insertions, 0 deletions
diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake
index 27070c05a4..d016fb5aed 100644
--- a/Modules/FetchContent.cmake
+++ b/Modules/FetchContent.cmake
@@ -364,6 +364,18 @@ Commands
FetchContent_Declare(other ...)
FetchContent_MakeAvailable(uses_other other)
+ Note that :variable:`CMAKE_VERIFY_INTERFACE_HEADER_SETS` is explicitly set
+ to false upon entry to ``FetchContent_MakeAvailable()``, and is restored to
+ its original value before the command returns. Developers typically only
+ want to verify header sets from the main project, not those from any
+ dependencies. This local manipulation of the
+ :variable:`CMAKE_VERIFY_INTERFACE_HEADER_SETS` variable provides that
+ intuitive behavior. You can use variables like
+ :variable:`CMAKE_PROJECT_INCLUDE` or
+ :variable:`CMAKE_PROJECT_<PROJECT-NAME>_INCLUDE` to turn verification back
+ on for all or some dependencies. You can also set the
+ :prop_tgt:`VERIFY_INTERFACE_HEADER_SETS` property of individual targets.
+
.. command:: FetchContent_Populate
.. note::
@@ -1814,6 +1826,13 @@ endfunction()
# calls will be available to the caller.
macro(FetchContent_MakeAvailable)
+ # We must append an item, even if the variable is unset, so prefix its value.
+ # We will strip that prefix when we pop the value at the end of the macro.
+ list(APPEND __cmake_fcCurrentVarsStack
+ "__fcprefix__${CMAKE_VERIFY_INTERFACE_HEADER_SETS}"
+ )
+ set(CMAKE_VERIFY_INTERFACE_HEADER_SETS FALSE)
+
get_property(__cmake_providerCommand GLOBAL PROPERTY
__FETCHCONTENT_MAKEAVAILABLE_SERIAL_PROVIDER
)
@@ -1965,10 +1984,18 @@ macro(FetchContent_MakeAvailable)
endif()
endforeach()
+ # Prefix will be "__fcprefix__"
+ list(POP_BACK __cmake_fcCurrentVarsStack __cmake_original_verify_setting)
+ string(SUBSTRING "${__cmake_original_verify_setting}"
+ 12 -1 __cmake_original_verify_setting
+ )
+ set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ${__cmake_original_verify_setting})
+
# clear local variables to prevent leaking into the caller's scope
unset(__cmake_contentName)
unset(__cmake_contentNameLower)
unset(__cmake_contentNameUpper)
unset(__cmake_providerCommand)
+ unset(__cmake_original_verify_setting)
endmacro()