Skip to content

Commit ee9b41e

Browse files
committed
feat(cxx): introduce xmake option
1 parent f940d5e commit ee9b41e

File tree

5 files changed

+44
-3
lines changed

5 files changed

+44
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ All notable changes to this project will be documented in this file.
4848
- *(python)* Use uv for all scenario
4949
- *(python)* Only install uv at Dockerfile
5050
- *(python)* Add UV_INDEX_URL at Dockerfile
51+
- *(python)* Use debian bookworm
52+
- Introduce git-cliff to generate the changelog
5153

5254
## [1.0.0] - 2024-08-17
5355

template/cxx/cookiecutter.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
"email": "email@example.com",
88
"github_username": "your-org-or-username",
99

10-
11-
"cxx_cmake_version": "3.28",
10+
"cxx_build_tool": ["xmake", "cmake"],
1211
"cxx_standard_version": "20",
1312
"cxx_standard_required": true,
1413
"cxx_extensions_required": false,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import os
2+
3+
cxx_build_tool = "{{cookiecutter.cxx_build_tool}}"
4+
5+
cmake_file = "CMakeLists.txt"
6+
xmake_file = "xmake.lua"
7+
8+
if cxx_build_tool == "cmake":
9+
if os.path.exists(xmake_file):
10+
os.remove(xmake_file)
11+
elif cxx_build_tool == "xmake":
12+
if os.path.exists(cmake_file):
13+
os.remove(cmake_file)
14+
else:
15+
raise ValueError(f"Unknown cxx_build_tool: {cxx_build_tool}")

template/cxx/{{cookiecutter.project_slug}}/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION {{cookiecutter.cxx_cmake_version}})
1+
cmake_minimum_required(VERSION 3.28)
22
project({{cookiecutter.project_slug}} LANGUAGES CXX)
33

44
# C++ Standard settings
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
-- Set project name and language
2+
set_project("{{cookiecutter.project_slug}}")
3+
set_languages("c++{{cookiecutter.cxx_standard_version}}")
4+
5+
{% if cookiecutter.cxx_project_type == "binary" %}
6+
-- Binary project setup
7+
target("{{cookiecutter.project_slug}}")
8+
set_kind("binary")
9+
add_files("src/*.cpp")
10+
add_headerfiles("src/*.h")
11+
12+
{% if cookiecutter.cxx_share_enabled == "STATIC" %}
13+
-- Static link settings for non-macOS platforms
14+
if not is_plat("macosx") then
15+
add_ldflags("-static", {force = true})
16+
end
17+
{% endif %}
18+
19+
{% else %}
20+
-- Library project setup
21+
target("{{cookiecutter.project_slug}}")
22+
set_kind("{{cookiecutter.cxx_share_enabled | lower}}")
23+
add_files("src/*.cpp")
24+
add_headerfiles("src/*.h")
25+
{% endif %}

0 commit comments

Comments
 (0)