diff options
author | Ben Boeckel <ben.boeckel@kitware.com> | 2022-11-19 00:44:44 (GMT) |
---|---|---|
committer | Ben Boeckel <ben.boeckel@kitware.com> | 2023-08-17 18:42:54 (GMT) |
commit | 457a12f3f9b68a548dd44d1dcb6f531e46a98314 (patch) | |
tree | 466331607d060edbcf67a1d32045ff0e3ab07764 | |
parent | 9b9ec70b5421e8cf91e000d8b6636d7b0b721d1a (diff) | |
download | CMake-457a12f3f9b68a548dd44d1dcb6f531e46a98314.zip CMake-457a12f3f9b68a548dd44d1dcb6f531e46a98314.tar.gz CMake-457a12f3f9b68a548dd44d1dcb6f531e46a98314.tar.bz2 |
Tests/RunCMake/CXXModules: add tests which use modules from imported targets
11 files changed, 102 insertions, 0 deletions
diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake index d2fb11f..0ca9945 100644 --- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake +++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake @@ -189,6 +189,18 @@ if ("export_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION) run_cxx_module_test(export-interface-build) run_cxx_module_test(export-usage-build) run_cxx_module_test(export-bmi-and-interface-build) + + if ("collation" IN_LIST CMake_TEST_MODULE_COMPILATION AND + "bmionly" IN_LIST CMake_TEST_MODULE_COMPILATION) + set(test_suffix export-interface-build) + run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-build") + + set(test_suffix export-interface-no-properties-build) + run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-build" -DNO_PROPERTIES=1) + + set(test_suffix export-bmi-and-interface-build) + run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-build" -DWITH_BMIS=1) + endif () endif () # All of the following tests perform installation. @@ -204,5 +216,19 @@ if ("install_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION) run_cxx_module_test(export-interface-install) run_cxx_module_test(export-usage-install) run_cxx_module_test(export-bmi-and-interface-install) + + if ("collation" IN_LIST CMake_TEST_MODULE_COMPILATION AND + "bmionly" IN_LIST CMake_TEST_MODULE_COMPILATION) + set(RunCMake_CXXModules_INSTALL 0) + set(test_suffix export-interface-install) + run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-install") + + set(test_suffix export-interface-no-properties-install) + run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-install" -DNO_PROPERTIES=1) + + set(test_suffix export-bmi-and-interface-install) + run_cxx_module_test(import-modules "import-modules-${test_suffix}" "-DCMAKE_PREFIX_PATH=${RunCMake_BINARY_DIR}/examples/${test_suffix}-install" -DWITH_BMIS=1) + set(RunCMake_CXXModules_INSTALL 1) + endif () endif () endif () diff --git a/Tests/RunCMake/CXXModules/examples/export-usage-build/importable.cxx b/Tests/RunCMake/CXXModules/examples/export-usage-build/importable.cxx index e0b1872..8dfc41b 100644 --- a/Tests/RunCMake/CXXModules/examples/export-usage-build/importable.cxx +++ b/Tests/RunCMake/CXXModules/examples/export-usage-build/importable.cxx @@ -1,6 +1,8 @@ export module importable; +extern "C++" { int forwarding(); +} export int from_import() { diff --git a/Tests/RunCMake/CXXModules/examples/export-usage-install/importable.cxx b/Tests/RunCMake/CXXModules/examples/export-usage-install/importable.cxx index e0b1872..8dfc41b 100644 --- a/Tests/RunCMake/CXXModules/examples/export-usage-install/importable.cxx +++ b/Tests/RunCMake/CXXModules/examples/export-usage-install/importable.cxx @@ -1,6 +1,8 @@ export module importable; +extern "C++" { int forwarding(); +} export int from_import() { diff --git a/Tests/RunCMake/CXXModules/examples/import-modules-export-bmi-and-interface-build-stderr.txt b/Tests/RunCMake/CXXModules/examples/import-modules-export-bmi-and-interface-build-stderr.txt new file mode 100644 index 0000000..71ee795 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/import-modules-export-bmi-and-interface-build-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at .*/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-build-build/export_bmi_and_interfaces-targets.cmake:[0-9]* \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +Call Stack \(most recent call first\): + .*/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-build-build/export_bmi_and_interfaces-config.cmake:1 \(include\) + CMakeLists.txt:15 \(find_package\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/import-modules-export-bmi-and-interface-install-stderr.txt b/Tests/RunCMake/CXXModules/examples/import-modules-export-bmi-and-interface-install-stderr.txt new file mode 100644 index 0000000..d22b2a1 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/import-modules-export-bmi-and-interface-install-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at .*/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-install-install/lib/cmake/export_bmi_and_interfaces/export_bmi_and_interfaces-targets.cmake:[0-9]* \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +Call Stack \(most recent call first\): + .*/Tests/RunCMake/CXXModules/examples/export-bmi-and-interface-install-install/lib/cmake/export_bmi_and_interfaces/export_bmi_and_interfaces-config.cmake:1 \(include\) + CMakeLists.txt:15 \(find_package\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-build-stderr.txt b/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-build-stderr.txt new file mode 100644 index 0000000..f79abbc --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-build-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at .*/Tests/RunCMake/CXXModules/examples/export-interface-build-build/export_interfaces-targets.cmake:[0-9]* \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +Call Stack \(most recent call first\): + .*/Tests/RunCMake/CXXModules/examples/export-interface-build-build/export_interfaces-config.cmake:1 \(include\) + CMakeLists.txt:15 \(find_package\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-install-stderr.txt b/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-install-stderr.txt new file mode 100644 index 0000000..32f9452 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-install-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at .*/Tests/RunCMake/CXXModules/examples/export-interface-install-install/lib/cmake/export_interfaces/export_interfaces-targets.cmake:[0-9]* \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +Call Stack \(most recent call first\): + .*/Tests/RunCMake/CXXModules/examples/export-interface-install-install/lib/cmake/export_interfaces/export_interfaces-config.cmake:1 \(include\) + CMakeLists.txt:15 \(find_package\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-no-properties-build-stderr.txt b/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-no-properties-build-stderr.txt new file mode 100644 index 0000000..9254936 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-no-properties-build-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at .*/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-build-build/export_interfaces_no_properties-targets.cmake:[0-9]* \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +Call Stack \(most recent call first\): + .*/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-build-build/export_interfaces_no_properties-config.cmake:1 \(include\) + CMakeLists.txt:15 \(find_package\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-no-properties-install-stderr.txt b/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-no-properties-install-stderr.txt new file mode 100644 index 0000000..71269f4 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/import-modules-export-interface-no-properties-install-stderr.txt @@ -0,0 +1,7 @@ +CMake Warning \(dev\) at .*/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-install-install/lib/cmake/export_interfaces_no_properties/export_interfaces_no_properties-targets.cmake:[0-9]* \(target_sources\): + CMake's C\+\+ module support is experimental. It is meant only for + experimentation and feedback to CMake developers. +Call Stack \(most recent call first\): + .*/Tests/RunCMake/CXXModules/examples/export-interface-no-properties-install-install/lib/cmake/export_interfaces_no_properties/export_interfaces_no_properties-config.cmake:1 \(include\) + CMakeLists.txt:15 \(find_package\) +This warning is for project developers. Use -Wno-dev to suppress it. diff --git a/Tests/RunCMake/CXXModules/examples/import-modules/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/import-modules/CMakeLists.txt new file mode 100644 index 0000000..3e6f379 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/import-modules/CMakeLists.txt @@ -0,0 +1,24 @@ +cmake_minimum_required(VERSION 3.24) +project(cxx_modules_import_interfaces CXX) + +include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake") + +if (NO_PROPERTIES) + set(package_name "export_interfaces_no_properties") +elseif (WITH_BMIS) + set(package_name "export_bmi_and_interfaces") +else () + set(package_name "export_interfaces") +endif () +set(target_name "CXXModules::${package_name}") + +find_package("${package_name}" REQUIRED) + +add_executable(use_import_interfaces) +target_sources(use_import_interfaces + PRIVATE + use.cxx) +target_compile_features(use_import_interfaces PRIVATE cxx_std_20) +target_link_libraries(use_import_interfaces PRIVATE "${target_name}") + +add_test(NAME use_import_interfaces COMMAND use_import_interfaces) diff --git a/Tests/RunCMake/CXXModules/examples/import-modules/use.cxx b/Tests/RunCMake/CXXModules/examples/import-modules/use.cxx new file mode 100644 index 0000000..feb38d2 --- /dev/null +++ b/Tests/RunCMake/CXXModules/examples/import-modules/use.cxx @@ -0,0 +1,6 @@ +import importable; + +int main(int argc, char* argv[]) +{ + return from_import(); +} |