diff --git a/.cmake-format b/.cmake-format index 1fbbb020b01441bdb068a1865696cab156703875..ac81022f1c670d7df11d01f95776ab9f8f333198 100644 --- a/.cmake-format +++ b/.cmake-format @@ -47,13 +47,15 @@ additional_commands: PROPERTIES: "*" TEST_LIST: "*" DISCOVERY_TIMEOUT: "*" - setup_target_for_coverage_gcovr_html: + target_sources: + pargs: 1 kwargs: - BASE_DIRECTORY: "*" - EXCLUDE: "*" - EXECUTABLE: "*" - EXECUTABLE_ARGS: "*" - DEPENDENCIES: "*" + INTERFACE: + kwargs: + FILE_SET: 1 + TYPE: 1 + BASE_DIRS: "*" + FILES: "*" always_wrap: [] enable_sort: true autosort: false diff --git a/CMakeLists.txt b/CMakeLists.txt index edc325cf2b893a29b29297663f04c4ad11126709..fe89f1202e258ed7529c6b9a68b29046f101752b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ # SPDX-License-Identifier: EPL-2.0 ################################################################################ -cmake_minimum_required(VERSION 3.15.0 FATAL_ERROR) +cmake_minimum_required(VERSION 3.24.0 FATAL_ERROR) # Add the custom CMake modules to CMake's module path list(PREPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") @@ -75,12 +75,6 @@ CPMAddPackage( ) # Add library -file( - GLOB_RECURSE HEADERS - RELATIVE ${PROJECT_SOURCE_DIR}/include - CONFIGURE_DEPENDS "*.h" -) - add_library(MantleAPI INTERFACE) add_library(MantleAPI::MantleAPI ALIAS MantleAPI) @@ -95,6 +89,16 @@ target_include_directories( target_compile_features(MantleAPI INTERFACE cxx_std_17) +file(GLOB_RECURSE HEADERS CONFIGURE_DEPENDS "include/**/*.h") +target_sources( + MantleAPI + INTERFACE FILE_SET HEADERS + TYPE HEADERS + BASE_DIRS $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> + FILES ${HEADERS} +) +set_target_properties(MantleAPI PROPERTIES VERIFY_INTERFACE_HEADER_SETS ON) + # Configure export include(CMakePackageConfigHelpers) configure_package_config_file( @@ -111,8 +115,11 @@ write_basic_package_version_file( # Configure install if(MantleAPI_INSTALL) - install(DIRECTORY include/ TYPE INCLUDE) - install(TARGETS MantleAPI EXPORT MantleAPITargets) + install( + TARGETS MantleAPI + EXPORT MantleAPITargets + FILE_SET HEADERS + ) install( EXPORT MantleAPITargets