summaryrefslogtreecommitdiff
path: root/tests/projects/c++/modules
diff options
context:
space:
mode:
authorruki <[email protected]>2025-04-06 22:03:58 +0800
committerruki <[email protected]>2025-04-08 15:31:58 +0800
commit43c3b8607775f7ee5b52e24a7f785b4c7a5ab292 (patch)
tree6d3d7546d3142faea4188fdbe59d9b04c068c397 /tests/projects/c++/modules
parent3b2e44ef7fce4baca2ede46bf1edb8cbf42734bb (diff)
add modules with pch test
Diffstat (limited to 'tests/projects/c++/modules')
-rw-r--r--tests/projects/c++/modules/hello_with_pch/src/hello.mpp10
-rw-r--r--tests/projects/c++/modules/hello_with_pch/src/main.cpp8
-rw-r--r--tests/projects/c++/modules/hello_with_pch/src/test.h1
-rw-r--r--tests/projects/c++/modules/hello_with_pch/test.lua1
-rw-r--r--tests/projects/c++/modules/hello_with_pch/xmake.lua7
5 files changed, 27 insertions, 0 deletions
diff --git a/tests/projects/c++/modules/hello_with_pch/src/hello.mpp b/tests/projects/c++/modules/hello_with_pch/src/hello.mpp
new file mode 100644
index 000000000..124bd72bc
--- /dev/null
+++ b/tests/projects/c++/modules/hello_with_pch/src/hello.mpp
@@ -0,0 +1,10 @@
+module;
+#include <cstdio>
+
+export module hello;
+
+export namespace hello {
+ void say(const char* str) {
+ printf("%s\n", str);
+ }
+}
diff --git a/tests/projects/c++/modules/hello_with_pch/src/main.cpp b/tests/projects/c++/modules/hello_with_pch/src/main.cpp
new file mode 100644
index 000000000..739309dd4
--- /dev/null
+++ b/tests/projects/c++/modules/hello_with_pch/src/main.cpp
@@ -0,0 +1,8 @@
+#include "test.h"
+
+import hello;
+
+int main() {
+ hello::say("hello module!");
+ return 0;
+}
diff --git a/tests/projects/c++/modules/hello_with_pch/src/test.h b/tests/projects/c++/modules/hello_with_pch/src/test.h
new file mode 100644
index 000000000..d5a732287
--- /dev/null
+++ b/tests/projects/c++/modules/hello_with_pch/src/test.h
@@ -0,0 +1 @@
+#include <string>
diff --git a/tests/projects/c++/modules/hello_with_pch/test.lua b/tests/projects/c++/modules/hello_with_pch/test.lua
new file mode 100644
index 000000000..7717f8049
--- /dev/null
+++ b/tests/projects/c++/modules/hello_with_pch/test.lua
@@ -0,0 +1 @@
+inherit(".test_base")
diff --git a/tests/projects/c++/modules/hello_with_pch/xmake.lua b/tests/projects/c++/modules/hello_with_pch/xmake.lua
new file mode 100644
index 000000000..79ddb6b58
--- /dev/null
+++ b/tests/projects/c++/modules/hello_with_pch/xmake.lua
@@ -0,0 +1,7 @@
+add_rules("mode.release", "mode.debug")
+set_languages("c++20")
+
+target("hello")
+ set_kind("binary")
+ set_pcxxheader("src/test.h")
+ add_files("src/*.cpp", "src/*.mpp")