| 1 |
cmake_minimum_required(VERSION 3.28) |
| 2 |
project(cxx_modules_library NONE) |
| 3 |
|
| 4 |
find_package(export_with_headers REQUIRED) |
| 5 |
find_package(export_with_headers_cps REQUIRED) |
| 6 |
|
| 7 |
set(include_dir "${CMAKE_CURRENT_SOURCE_DIR}") |
| 8 |
cmake_path(GET include_dir PARENT_PATH include_dir) |
| 9 |
string(APPEND include_dir "/include") |
| 10 |
|
| 11 |
function(test_target target incdir) |
| 12 |
|
| 13 |
if (NOT TARGET ${target}) |
| 14 |
message(FATAL_ERROR |
| 15 |
"Missing imported target") |
| 16 |
endif () |
| 17 |
|
| 18 |
get_property(iface_includes TARGET ${target} |
| 19 |
PROPERTY INTERFACE_INCLUDE_DIRECTORIES) |
| 20 |
if (NOT iface_includes STREQUAL incdir) |
| 21 |
message(FATAL_ERROR |
| 22 |
"Incorrect include interface for ${target}:\n ${iface_includes}") |
| 23 |
endif () |
| 24 |
|
| 25 |
endfunction(test_target) |
| 26 |
|
| 27 |
test_target(CXXModules::export_with_headers "${include_dir};$<BUILD_INTERFACE:${include_dir}>") |
| 28 |
test_target(export_with_headers_cps::export_with_headers "${include_dir}") |