Debian Codegraph @

Tests/RunCMake/CXXModulesCompile/imp-std-not-in-exp-install/test/CMakeLists.txt

raw
1 cmake_minimum_required(VERSION 3.29)
2 project(cxx_modules_library NONE)
3
4 find_package(import_std_not_in_export REQUIRED)
5
6 if (NOT TARGET CXXModules::import_std_not_in_export)
7 message(FATAL_ERROR
8 "Missing imported target")
9 endif ()
10
11 function (check_property expected property)
12 get_property(actual TARGET CXXModules::import_std_not_in_export
13 PROPERTY "${property}")
14 if (NOT DEFINED actual)
15 if (NOT expected STREQUAL "<UNDEF>")
16 message(SEND_ERROR
17 "Mismatch for ${property}:\n expected: ${expected}\n actual: NOT-DEFINED")
18 endif ()
19 elseif (NOT actual STREQUAL expected)
20 message(SEND_ERROR
21 "Mismatch for ${property}:\n expected: ${expected}\n actual: ${actual}")
22 endif ()
23 endfunction ()
24
25 check_property("<UNDEF>" "IMPORTED_CXX_MODULES_INCLUDE_DIRECTORIES")
26 check_property("<UNDEF>" "IMPORTED_CXX_MODULES_COMPILE_DEFINITIONS")
27 check_property("cxx_std_23" "IMPORTED_CXX_MODULES_COMPILE_FEATURES")
28 check_property("" "IMPORTED_CXX_MODULES_LINK_LIBRARIES")
29 check_property("<UNDEF>" "INTERFACE_LINK_LIBRARIES")
30 check_property("1" "CXX_MODULE_STD")
31
32 # Extract the export-dependent targets from the export file.
33 file(STRINGS "${import_std_not_in_export_DIR}/import_std_not_in_export-targets.cmake" usage_dependent_targets
34 REGEX "foreach._target ")
35 # Rudimentary argument splitting.
36 string(REPLACE " " ";" usage_dependent_targets "${usage_dependent_targets}")
37 # Remove exported "target" names.
38 list(FILTER usage_dependent_targets EXCLUDE REGEX "CXXModules::")
39 # Strip quotes.
40 string(REPLACE "\"" "" usage_dependent_targets "${usage_dependent_targets}")
41
42 if ("__CMAKE::CXX23" IN_LIST usage_dependent_targets)
43 message(SEND_ERROR
44 "The main export requires the '__CMAKE::CXX23' target")
45 endif ()