summaryrefslogtreecommitdiffstats
path: root/Tests/RunCMake/CXXModules/examples/simple
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2022-06-14 19:30:42 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2022-06-16 14:28:34 (GMT)
commit8c5a53096ab596aa77623b19d94d9b84046213cc (patch)
tree348842f906f5063babcdae21bc86872a7ffdbc92 /Tests/RunCMake/CXXModules/examples/simple
parent4151547e2ffa45b50439f071353955e4566e0571 (diff)
downloadCMake-8c5a53096ab596aa77623b19d94d9b84046213cc.zip
CMake-8c5a53096ab596aa77623b19d94d9b84046213cc.tar.gz
CMake-8c5a53096ab596aa77623b19d94d9b84046213cc.tar.bz2
Tests/RunCMake/CXXModules: add module-using examples
This includes a number of examples that should work for various levels of support in a compiler. There are a number of tests which are gated on various features in the compilers. To enable the tests, set `CMake_TEST_MODULE_COMPILATION` to a comma-separated (to avoid `;`-escaping problems) to the list of features which are supported: - `named`: Named modules are supported. - `shared`: Shared libraries with module usage at the API boundary are supported. - `partitions`: Named module partitions are supported. - `internal_partitions`: Named module internal partitions are supported. Additionally, a `CMake_TEST_MODULE_COMPILATION_RULES` file must be passed which contains the rules for how to build modules using the provided compiler. It will be included in the tests to provide these rules. To verify that the file provided works as intended, it must set `CMake_TEST_CXXModules_UUID` to a specific version to indicate that it is an expected file.
Diffstat (limited to 'Tests/RunCMake/CXXModules/examples/simple')
-rw-r--r--Tests/RunCMake/CXXModules/examples/simple/CMakeLists.txt18
-rw-r--r--Tests/RunCMake/CXXModules/examples/simple/importable.cxx6
-rw-r--r--Tests/RunCMake/CXXModules/examples/simple/main.cxx6
3 files changed, 30 insertions, 0 deletions
diff --git a/Tests/RunCMake/CXXModules/examples/simple/CMakeLists.txt b/Tests/RunCMake/CXXModules/examples/simple/CMakeLists.txt
new file mode 100644
index 0000000..442e425
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/simple/CMakeLists.txt
@@ -0,0 +1,18 @@
+cmake_minimum_required(VERSION 3.24)
+project(cxx_modules_simple CXX)
+
+include("${CMAKE_SOURCE_DIR}/../cxx-modules-rules.cmake")
+
+add_executable(simple)
+target_sources(simple
+ PRIVATE
+ main.cxx
+ PRIVATE
+ FILE_SET CXX_MODULES
+ BASE_DIRS
+ "${CMAKE_CURRENT_SOURCE_DIR}"
+ FILES
+ importable.cxx)
+target_compile_features(simple PUBLIC cxx_std_20)
+
+add_test(NAME simple COMMAND simple)
diff --git a/Tests/RunCMake/CXXModules/examples/simple/importable.cxx b/Tests/RunCMake/CXXModules/examples/simple/importable.cxx
new file mode 100644
index 0000000..607680a
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/simple/importable.cxx
@@ -0,0 +1,6 @@
+export module importable;
+
+export int from_import()
+{
+ return 0;
+}
diff --git a/Tests/RunCMake/CXXModules/examples/simple/main.cxx b/Tests/RunCMake/CXXModules/examples/simple/main.cxx
new file mode 100644
index 0000000..feb38d2
--- /dev/null
+++ b/Tests/RunCMake/CXXModules/examples/simple/main.cxx
@@ -0,0 +1,6 @@
+import importable;
+
+int main(int argc, char* argv[])
+{
+ return from_import();
+}