summaryrefslogtreecommitdiff
path: root/xmake/templates/c++/static
diff options
context:
space:
mode:
authorruki <[email protected]>2026-08-09 18:25:05 +0800
committerGitHub <[email protected]>2026-08-09 18:25:05 +0800
commitced7f2ae519bc9eca92bcf4f177fe177ddd0e747 (patch)
treeaf4d584b3c7badc1df56038cdb29099b4f3e99fd /xmake/templates/c++/static
parent6ac4ea833193a4319a1eb6e5f588d1877fd48064 (diff)
parent5f5daf64c504e1103a355f45bf925a5149b03e24 (diff)
Merge pull request #7699 from xmake-io/templates
move templates dir
Diffstat (limited to 'xmake/templates/c++/static')
-rw-r--r--xmake/templates/c++/static/src/foo.cpp5
-rw-r--r--xmake/templates/c++/static/src/foo.h9
-rw-r--r--xmake/templates/c++/static/src/main.cpp7
-rw-r--r--xmake/templates/c++/static/xmake.lua12
4 files changed, 33 insertions, 0 deletions
diff --git a/xmake/templates/c++/static/src/foo.cpp b/xmake/templates/c++/static/src/foo.cpp
new file mode 100644
index 000000000..1a1fb3425
--- /dev/null
+++ b/xmake/templates/c++/static/src/foo.cpp
@@ -0,0 +1,5 @@
+#include "foo.h"
+
+int add(int a, int b) {
+ return a + b;
+}
diff --git a/xmake/templates/c++/static/src/foo.h b/xmake/templates/c++/static/src/foo.h
new file mode 100644
index 000000000..d2506bca9
--- /dev/null
+++ b/xmake/templates/c++/static/src/foo.h
@@ -0,0 +1,9 @@
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int add(int a, int b);
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/xmake/templates/c++/static/src/main.cpp b/xmake/templates/c++/static/src/main.cpp
new file mode 100644
index 000000000..3834ee4d3
--- /dev/null
+++ b/xmake/templates/c++/static/src/main.cpp
@@ -0,0 +1,7 @@
+#include "foo.h"
+#include <iostream>
+
+int main(int argc, char **argv) {
+ std::cout << "add(1, 2) = " << add(1, 2) << std::endl;
+ return 0;
+}
diff --git a/xmake/templates/c++/static/xmake.lua b/xmake/templates/c++/static/xmake.lua
new file mode 100644
index 000000000..2c15d36e8
--- /dev/null
+++ b/xmake/templates/c++/static/xmake.lua
@@ -0,0 +1,12 @@
+add_rules("mode.debug", "mode.release")
+
+target("foo")
+ set_kind("static")
+ add_files("src/foo.cpp")
+
+target("${TARGET_NAME}")
+ set_kind("binary")
+ add_deps("foo")
+ add_files("src/main.cpp")
+
+${FAQ}