Debian Codegraph @

Tests/RunCMake/CXXModulesCompile/exp-iface-build/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 REQUIRED)
6
7 function(test_target target set_name has_bmi)
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 if (NOT file_sets STREQUAL "${set_name}")
16 message(FATAL_ERROR
17 "Incorrect exported file sets in ${target}:\n ${file_sets}")
18 endif ()
19
20 get_property(file_set_files TARGET ${target}
21 PROPERTY CXX_MODULE_SET_${set_name})
22 set(expected_file_set_files
23 "${expected_source_dir}/importable.cxx"
24 "${expected_source_dir}/subdir/importable.cxx"
25 )
26 if (NOT file_set_files STREQUAL "${expected_file_set_files}")
27 message(FATAL_ERROR
28 "Incorrect exported file set paths in ${target}:\n ${file_set_files}")
29 endif ()
30
31 get_property(imported_modules TARGET ${target}
32 PROPERTY IMPORTED_CXX_MODULES_DEBUG)
33 if(has_bmi)
34 set(expected_imported_modules
35 "importable=${expected_source_dir}/importable.cxx,${expected_binary_dir}/CMakeFiles/export_interfaces.dir(/Debug)?/importable.(gcm|pcm|ifc)"
36 "subdir_importable=${expected_source_dir}/subdir/importable.cxx,${expected_binary_dir}/CMakeFiles/export_interfaces.dir(/Debug)?/subdir_importable.(gcm|pcm|ifc)"
37 )
38 else()
39 set(expected_imported_modules
40 "importable=${expected_source_dir}/importable.cxx"
41 "subdir_importable=${expected_source_dir}/subdir/importable.cxx"
42 )
43 endif()
44 if (NOT imported_modules MATCHES "^${expected_imported_modules}$")
45 message(FATAL_ERROR
46 "Incorrect exported modules in ${target}:\n"
47 " ${imported_modules}\n"
48 "does not match:\n"
49 " ${expected_imported_modules}"
50 )
51 endif ()
52 endfunction()
53
54 test_target(CXXModules::export_interfaces "modules" TRUE)
55 test_target(export_interfaces_cps::export_interfaces "CXX_MODULES" FALSE)