cmake/Tests/RunCMake/FetchContent/VerifyHeaderSet.cmake
Craig Scott b61637f90f
File sets: Add verification of private file sets
Add support for PRIVATE header sets, analogous to the existing
INTERFACE header sets support. A key difference between the two is
the way they handle build and usage requirements. INTERFACE
header sets rely on the original target's INTERFACE, whereas PRIVATE
header sets copy across various properties from the original target.

Generated files need special handling for PRIVATE header sets.
Add a dependency on the original target to the verification target to
ensure such generated files will exist.

Fixes: #23448
2026-01-16 18:10:17 +11:00

22 lines
1.0 KiB
CMake

enable_language(C)
set(CMAKE_VERIFY_INTERFACE_HEADER_SETS TRUE)
set(CMAKE_VERIFY_PRIVATE_HEADER_SETS TRUE)
include(FetchContent)
FetchContent_Declare(verify_subproj
SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/VerifyHeaderSet
)
message(STATUS "Before subproject, interface var = '${CMAKE_VERIFY_INTERFACE_HEADER_SETS}'")
message(STATUS "Before subproject, private var = '${CMAKE_VERIFY_PRIVATE_HEADER_SETS}'")
FetchContent_MakeAvailable(verify_subproj)
# Provide a way to verify the variable was reset back to its original value
message(STATUS "After subproject, interface var = '${CMAKE_VERIFY_INTERFACE_HEADER_SETS}'")
message(STATUS "After subproject, private var = '${CMAKE_VERIFY_PRIVATE_HEADER_SETS}'")
get_property(verify_interface TARGET Blah PROPERTY VERIFY_INTERFACE_HEADER_SETS)
get_property(verify_private TARGET Blah PROPERTY VERIFY_PRIVATE_HEADER_SETS)
message(STATUS "Subproject target property VERIFY_INTERFACE_HEADER_SETS='${verify_interface}'")
message(STATUS "Subproject target property VERIFY_PRIVATE_HEADER_SETS='${verify_private}'")