summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/FetchContent
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 /Tests/RunCMake/FetchContent
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 'Tests/RunCMake/FetchContent')
-rw-r--r--Tests/RunCMake/FetchContent/RunCMakeTest.cmake1
-rw-r--r--Tests/RunCMake/FetchContent/VerifyHeaderSet-stdout.txt4
-rw-r--r--Tests/RunCMake/FetchContent/VerifyHeaderSet.cmake16
-rw-r--r--Tests/RunCMake/FetchContent/VerifyHeaderSet/CMakeLists.txt9
-rw-r--r--Tests/RunCMake/FetchContent/VerifyHeaderSet/blah.h1
5 files changed, 31 insertions, 0 deletions
diff --git a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake
index e83c45e..a7ccf83 100644
--- a/Tests/RunCMake/FetchContent/RunCMakeTest.cmake
+++ b/Tests/RunCMake/FetchContent/RunCMakeTest.cmake
@@ -15,6 +15,7 @@ run_cmake(UsesTerminalOverride)
run_cmake(MakeAvailable)
run_cmake(MakeAvailableTwice)
run_cmake(MakeAvailableUndeclared)
+run_cmake(VerifyHeaderSet)
run_cmake_with_options(ManualSourceDirectory
-D "FETCHCONTENT_SOURCE_DIR_WITHPROJECT=${CMAKE_CURRENT_LIST_DIR}/WithProject"
diff --git a/Tests/RunCMake/FetchContent/VerifyHeaderSet-stdout.txt b/Tests/RunCMake/FetchContent/VerifyHeaderSet-stdout.txt
new file mode 100644
index 0000000..354529d
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/VerifyHeaderSet-stdout.txt
@@ -0,0 +1,4 @@
+-- Before subproject, var = 'TRUE'
+-- Inside subproject, var = 'FALSE'
+-- After subproject, var = 'TRUE'
+-- Subproject target property VERIFY_INTERFACE_HEADER_SETS='FALSE'
diff --git a/Tests/RunCMake/FetchContent/VerifyHeaderSet.cmake b/Tests/RunCMake/FetchContent/VerifyHeaderSet.cmake
new file mode 100644
index 0000000..8adfcea
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/VerifyHeaderSet.cmake
@@ -0,0 +1,16 @@
+enable_language(C)
+
+set(CMAKE_VERIFY_INTERFACE_HEADER_SETS TRUE)
+
+include(FetchContent)
+FetchContent_Declare(verify_subproj
+ SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/VerifyHeaderSet
+)
+message(STATUS "Before subproject, var = '${CMAKE_VERIFY_INTERFACE_HEADER_SETS}'")
+FetchContent_MakeAvailable(verify_subproj)
+
+# Provide a way to verify the variable was reset back to its original value
+message(STATUS "After subproject, var = '${CMAKE_VERIFY_INTERFACE_HEADER_SETS}'")
+
+get_property(verify TARGET Blah PROPERTY VERIFY_INTERFACE_HEADER_SETS)
+message(STATUS "Subproject target property VERIFY_INTERFACE_HEADER_SETS='${verify}'")
diff --git a/Tests/RunCMake/FetchContent/VerifyHeaderSet/CMakeLists.txt b/Tests/RunCMake/FetchContent/VerifyHeaderSet/CMakeLists.txt
new file mode 100644
index 0000000..c6ba37e
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/VerifyHeaderSet/CMakeLists.txt
@@ -0,0 +1,9 @@
+cmake_minimum_required(VERSION 3.24)
+project(VerifyHeaderSet LANGUAGES C)
+
+message(STATUS "Inside subproject, var = '${CMAKE_VERIFY_INTERFACE_HEADER_SETS}'")
+
+add_library(Blah INTERFACE)
+target_sources(Blah
+ INTERFACE FILE_SET HEADERS FILES blah.h
+)
diff --git a/Tests/RunCMake/FetchContent/VerifyHeaderSet/blah.h b/Tests/RunCMake/FetchContent/VerifyHeaderSet/blah.h
new file mode 100644
index 0000000..5b47e14
--- /dev/null
+++ b/Tests/RunCMake/FetchContent/VerifyHeaderSet/blah.h
@@ -0,0 +1 @@
+#error Header was used