set_target_properties(beman.exemplar PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON)
should be
set_target_properties(beman.exemplar PROPERTIES VERIFY_INTERFACE_HEADER_SETS ${PROJECT_IS_TOP_LEVEL})
and it should not be enabled if CXX_MODULES are compiled?
if(BOOST_USE_MODULES)
# Ensure CMAKE_CXX_STANDARD is set for module detection
if(NOT DEFINED CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 20)
endif()
add_library(boost_any)
target_sources(
boost_any
PUBLIC
FILE_SET modules_public
TYPE CXX_MODULES
FILES modules/boost_any.cppm
)
# Require C++20 for modules
target_compile_features(boost_any PUBLIC cxx_std_${CMAKE_CXX_STANDARD})
# Define macro indicating modules usage
target_compile_definitions(boost_any PUBLIC BOOST_USE_MODULES)
# Check if import std; is available for the current standard
if(${CMAKE_CXX_STANDARD} IN_LIST CMAKE_CXX_COMPILER_IMPORT_STD)
target_compile_definitions(boost_any PUBLIC BOOST_ANY_USE_STD_MODULE)
set_property(TARGET boost_any CXX_MODULE_STD ON)
message(STATUS "Boost.Any: Using `import std;`")
else()
message(WARNING "Boost.Any: `import std;` is not available for C++${CMAKE_CXX_STANDARD}")
endif()
set(__scope PUBLIC)
else()
# Modules disabled -> INTERFACE library
add_library(boost_any INTERFACE)
# If modules are disabled, require C++17 for headers
target_compile_features(boost_any INTERFACE cxx_std_17)
# Verify interface headers only at top level
if(PROJECT_IS_TOP_LEVEL)
set(CMAKE_VERIFY_INTERFACE_HEADER_SETS ON)
endif()
set(__scope INTERFACE)
endif()