summaryrefslogtreecommitdiff
path: root/Tests/RunCMake/CXXModules
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2022-06-15 17:14:43 -0400
committerBen Boeckel <ben.boeckel@kitware.com>2022-07-06 11:38:11 -0400
commit4d55f1422efe804a74e08e5f2a362077a0a9b938 (patch)
tree003922a722e8c89888da36a57330d408f05f872b /Tests/RunCMake/CXXModules
parenteff45f790daf0beb3441961678f40599caf7eded (diff)
downloadcmake-4d55f1422efe804a74e08e5f2a362077a0a9b938.tar.gz
RunCMake/CXXModules: test installation of BMIs and interfaces
Diffstat (limited to 'Tests/RunCMake/CXXModules')
-rw-r--r--Tests/RunCMake/CXXModules/RunCMakeTest.cmake19
-rw-r--r--Tests/RunCMake/CXXModules/examples/cxx-modules-find-bmi-and-interfaces.cmake22
-rw-r--r--Tests/RunCMake/CXXModules/examples/cxx-modules-find-bmi.cmake27
-rw-r--r--Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces-stderr.txt9
-rw-r--r--Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces/CMakeLists.txt27
-rw-r--r--Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces/check-for-bmi.cmake7
-rw-r--r--Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces/importable.cxx6
-rw-r--r--Tests/RunCMake/CXXModules/examples/install-bmi-stderr.txt9
-rw-r--r--Tests/RunCMake/CXXModules/examples/install-bmi/CMakeLists.txt25
-rw-r--r--Tests/RunCMake/CXXModules/examples/install-bmi/check-for-bmi.cmake4
-rw-r--r--Tests/RunCMake/CXXModules/examples/install-bmi/importable.cxx6
11 files changed, 161 insertions, 0 deletions
diff --git a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
index b5a0e5c184..3d841de540 100644
--- a/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
+++ b/Tests/RunCMake/CXXModules/RunCMakeTest.cmake
@@ -104,12 +104,22 @@ function (run_cxx_module_test directory)
set(RunCMake_TEST_OPTIONS -DCMAKE_BUILD_TYPE=Debug)
endif ()
+ if (RunCMake_CXXModules_INSTALL)
+ set(prefix "${RunCMake_BINARY_DIR}/examples/${test_name}-install")
+ file(REMOVE_RECURSE "${prefix}")
+ list(APPEND RunCMake_TEST_OPTIONS
+ "-DCMAKE_INSTALL_PREFIX=${prefix}")
+ endif ()
+
list(APPEND RunCMake_TEST_OPTIONS
"-DCMake_TEST_MODULE_COMPILATION_RULES=${CMake_TEST_MODULE_COMPILATION_RULES}"
${ARGN})
run_cmake("examples/${test_name}")
set(RunCMake_TEST_NO_CLEAN 1)
run_cmake_command("examples/${test_name}-build" "${CMAKE_COMMAND}" --build . --config Debug)
+ if (RunCMake_CXXModules_INSTALL)
+ run_cmake_command("examples/${test_name}-install" "${CMAKE_COMMAND}" --build . --target install --config Debug)
+ endif ()
run_cmake_command("examples/${test_name}-test" "${CMAKE_CTEST_COMMAND}" -C Debug --output-on-failure)
endfunction ()
@@ -136,3 +146,12 @@ endif ()
if ("internal_partitions" IN_LIST CMake_TEST_MODULE_COMPILATION)
run_cxx_module_test(internal-partitions)
endif ()
+
+# All of the following tests perform installation.
+set(RunCMake_CXXModules_INSTALL 1)
+
+# Tests which install BMIs
+if ("install_bmi" IN_LIST CMake_TEST_MODULE_COMPILATION)
+ run_cxx_module_test(install-bmi)
+ run_cxx_module_test(install-bmi-and-interfaces)
+endif ()
diff --git a/Tests/RunCMake/CXXModules/examples/cxx-modules-find-bmi-and-interfaces.cmake b/Tests/RunCMake/CXXModules/examples/cxx-modules-find-bmi-and-interfaces.cmake
new file mode 100644
index 0000000000..f99455b475
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/cxx-modules-find-bmi-and-interfaces.cmake
@@ -0,0 +1,22 @@
+function (check_for_bmi prefix destination name)
+ set(found 0)
+ foreach (ext IN ITEMS gcm)
+ if (EXISTS "${prefix}/${destination}/${name}.${ext}")
+ set(found 1)
+ break ()
+ endif ()
+ endforeach ()
+
+ if (NOT found)
+ message(SEND_ERROR
+ "Failed to find the ${name} BMI")
+ endif ()
+endfunction ()
+
+function (check_for_interface prefix destination subdir name)
+ set(found 0)
+ if (NOT EXISTS "${prefix}/${destination}/${subdir}/${name}")
+ message(SEND_ERROR
+ "Failed to find the ${name} module interface")
+ endif ()
+endfunction ()
diff --git a/Tests/RunCMake/CXXModules/examples/cxx-modules-find-bmi.cmake b/Tests/RunCMake/CXXModules/examples/cxx-modules-find-bmi.cmake
new file mode 100644
index 0000000000..8efe508426
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/cxx-modules-find-bmi.cmake
@@ -0,0 +1,27 @@
+function (check_for_bmi prefix destination name)
+ set(found 0)
+ foreach (ext IN ITEMS gcm)
+ if (EXISTS "${prefix}/${destination}/${name}.${ext}")
+ set(found 1)
+ break ()
+ endif ()
+ endforeach ()
+
+ if (NOT found)
+ message(SEND_ERROR
+ "Failed to find the ${name} BMI")
+ endif ()
+endfunction ()
+
+function (check_for_interface prefix destination subdir name)
+ set(found 0)
+ if (NOT EXISTS "${prefix}/${destination}/${subdir}/${name}")
+ message(SEND_ERROR
+ "Failed to find the ${name} module interface")
+ endif ()
+endfunction ()
+
+function (report_dirs prefix destination)
+ message("prefix: ${prefix}")
+ message("destination: ${destination}")
+endfunction ()
diff --git a/Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces-stderr.txt b/Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces-stderr.txt
new file mode 100644
index 0000000000..5e4392abc9
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces-stderr.txt
@@ -0,0 +1,9 @@
+CMake Warning \(dev\) at CMakeLists.txt:7 \(target_sources\):
+ CMake's C\+\+ module support is experimental. It is meant only for
+ experimentation and feedback to CMake developers.
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\):
+ C\+\+20 modules support via CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP is
+ experimental. It is meant only for compiler developers to try.
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces/CMakeLists.txt
new file mode 100644
index 0000000000..efaca0e110
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces/CMakeLists.txt
@@ -0,0 +1,27 @@
+cmake_minimum_required(VERSION 3.24)
+project(cxx_modules_install_bmi_and_interfaces CXX)
+
+include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
+
+add_library(install_bmi_and_interfaces STATIC)
+target_sources(install_bmi_and_interfaces
+ PUBLIC
+ FILE_SET CXX_MODULES
+ BASE_DIRS
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ FILES
+ importable.cxx)
+target_compile_features(install_bmi_and_interfaces PUBLIC cxx_std_20)
+
+install(TARGETS install_bmi_and_interfaces
+ ARCHIVE DESTINATION "lib"
+ CXX_MODULES_BMI DESTINATION "lib/cxx/bmi"
+ FILE_SET CXX_MODULES DESTINATION "lib/cxx/miu")
+
+add_test(NAME check-for-bmi
+ COMMAND
+ "${CMAKE_COMMAND}"
+ "-Dprefix=${CMAKE_INSTALL_PREFIX}"
+ "-Dbmi_destination=lib/cxx/bmi"
+ "-Dfs_destination=lib/cxx/miu"
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/check-for-bmi.cmake")
diff --git a/Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces/check-for-bmi.cmake b/Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces/check-for-bmi.cmake
new file mode 100644
index 0000000000..a8ff1ad6a7
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces/check-for-bmi.cmake
@@ -0,0 +1,7 @@
+include("${CMAKE_CURRENT_LIST_DIR}/../cxx-modules-find-bmi.cmake")
+
+report_dirs("${prefix}" "${bmi_destination}")
+check_for_bmi("${prefix}" "${bmi_destination}" importable)
+
+report_dirs("${prefix}" "${fs_destination}")
+check_for_interface("${prefix}" "${fs_destination}" "" importable.cxx)
diff --git a/Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces/importable.cxx b/Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces/importable.cxx
new file mode 100644
index 0000000000..607680a07c
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/install-bmi-and-interfaces/importable.cxx
@@ -0,0 +1,6 @@
+export module importable;
+
+export int from_import()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CXXModules/examples/install-bmi-stderr.txt b/Tests/RunCMake/CXXModules/examples/install-bmi-stderr.txt
new file mode 100644
index 0000000000..5e4392abc9
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/install-bmi-stderr.txt
@@ -0,0 +1,9 @@
+CMake Warning \(dev\) at CMakeLists.txt:7 \(target_sources\):
+ CMake's C\+\+ module support is experimental. It is meant only for
+ experimentation and feedback to CMake developers.
+This warning is for project developers. Use -Wno-dev to suppress it.
+
+CMake Warning \(dev\):
+ C\+\+20 modules support via CMAKE_EXPERIMENTAL_CXX_MODULE_DYNDEP is
+ experimental. It is meant only for compiler developers to try.
+This warning is for project developers. Use -Wno-dev to suppress it.
diff --git a/Tests/RunCMake/CXXModules/examples/install-bmi/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/install-bmi/CMakeLists.txt
new file mode 100644
index 0000000000..4e039f9f24
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/install-bmi/CMakeLists.txt
@@ -0,0 +1,25 @@
+cmake_minimum_required(VERSION 3.24)
+project(cxx_modules_install_bmi CXX)
+
+include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
+
+add_library(install_bmi STATIC)
+target_sources(install_bmi
+ PUBLIC
+ FILE_SET CXX_MODULES
+ BASE_DIRS
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ FILES
+ importable.cxx)
+target_compile_features(install_bmi PUBLIC cxx_std_20)
+
+install(TARGETS install_bmi
+ ARCHIVE DESTINATION "lib"
+ CXX_MODULES_BMI DESTINATION "lib/cxx/bmi")
+
+add_test(NAME check-for-bmi
+ COMMAND
+ "${CMAKE_COMMAND}"
+ "-Dprefix=${CMAKE_INSTALL_PREFIX}"
+ "-Ddestination=lib/cxx/bmi"
+ -P "${CMAKE_CURRENT_SOURCE_DIR}/check-for-bmi.cmake")
diff --git a/Tests/RunCMake/CXXModules/examples/install-bmi/check-for-bmi.cmake b/Tests/RunCMake/CXXModules/examples/install-bmi/check-for-bmi.cmake
new file mode 100644
index 0000000000..ff84ed637c
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/install-bmi/check-for-bmi.cmake
@@ -0,0 +1,4 @@
+include("${CMAKE_CURRENT_LIST_DIR}/../cxx-modules-find-bmi.cmake")
+
+report_dirs("${prefix}" "${destination}")
+check_for_bmi("${prefix}" "${destination}" importable)
diff --git a/Tests/RunCMake/CXXModules/examples/install-bmi/importable.cxx b/Tests/RunCMake/CXXModules/examples/install-bmi/importable.cxx
new file mode 100644
index 0000000000..607680a07c
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/install-bmi/importable.cxx
@@ -0,0 +1,6 @@
+export module importable;
+
+export int from_import()
+{
+ return 0;
+}