Debian Codegraph @

Tests/RunCMake/CXXModulesCompile/exp-iface-install/test/CMakeLists.txt

raw
1 cmake_minimum_required(VERSION 3.24...3.28)
2 project(cxx_modules_library NONE)
3
4 find_package(export_interfaces REQUIRED)
5 find_package(export_interfaces_cps CONFIG REQUIRED)
6
7 function(test_target target set_name)
8 if (NOT TARGET ${target})
9 message(FATAL_ERROR
10 "Missing imported target")
11 endif ()
12
13 get_property(file_sets TARGET ${target}
14 PROPERTY INTERFACE_CXX_MODULE_SETS)
15
16 if (NOT file_sets STREQUAL set_name)
17 message(FATAL_ERROR
18 "Incorrect exported file sets in ${target}:\n ${file_sets}")
19 endif ()
20
21 get_property(file_set_files TARGET ${target}
22 PROPERTY CXX_MODULE_SET_${set_name})
23 set(expected_file_set_files
24 "${expected_source_dir}/importable.cxx"
25 "${expected_source_dir}/subdir/importable.cxx"
26 )
27 if (NOT file_set_files STREQUAL "${expected_file_set_files}")
28 message(FATAL_ERROR
29 "Incorrect exported file set paths in ${target}:\n ${file_set_files}")
30 endif ()
31
32 get_property(imported_modules TARGET ${target}
33 PROPERTY IMPORTED_CXX_MODULES_DEBUG)
34 set(expected_imported_modules
35 "importable=${expected_source_dir}/importable.cxx"
36 "subdir_importable=${expected_source_dir}/subdir/importable.cxx"
37 )
38 if (NOT imported_modules STREQUAL "${expected_imported_modules}")
39 message(FATAL_ERROR
40 "Incorrect exported modules in ${target}:\n"
41 " ${imported_modules}\n"
42 "does not match:\n"
43 " ${expected_imported_modules}"
44 )
45 endif ()
46 endfunction()
47
48 test_target(CXXModules::export_interfaces "modules")
49 test_target(export_interfaces_cps::export_interfaces "CXX_MODULES")