You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+19-9Lines changed: 19 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,7 @@ Modern CMake template for C++ header-only libraries with comprehensive infrastru
11
11
12
12
`cpp-library` provides a standardized CMake infrastructure template for header-only C++ libraries. It eliminates boilerplate and provides consistent patterns for:
# Optional: add SOURCES for non-header-only libraries
@@ -60,11 +61,12 @@ cpp_library_setup(
60
61
```cmake
61
62
cpp_library_setup(
62
63
# Required parameters
63
-
NAME project_name # e.g., "stlab-enum-ops"
64
-
VERSION version_string # e.g., "1.0.0"
65
64
DESCRIPTION description # e.g., "Type-safe operators for enums"
66
65
NAMESPACE namespace # e.g., "stlab"
67
66
67
+
# Optional parameters
68
+
VERSION version_string # e.g., "1.0.0" (auto-detected from git tags if not provided)
69
+
68
70
# Header specification (one required)
69
71
HEADERS header_list # List of header files
70
72
HEADER_DIR directory # Directory to install recursively
@@ -87,6 +89,8 @@ cpp_library_setup(
87
89
)
88
90
```
89
91
92
+
**Note**: The project name is automatically taken from `PROJECT_NAME` (set by the `project()` command). You must call `project(your-library)` before `cpp_library_setup()`.
93
+
90
94
## Features
91
95
### Non-Header-Only Library Support
92
96
@@ -110,6 +114,7 @@ cpp_library_setup(
110
114
-**Debug** builds for testing, **Release** for default
111
115
-**Build isolation** with separate build directories
112
116
-**Two-mode operation**: Full infrastructure when top-level, lightweight when consumed
117
+
-**Automatic version detection**: Version is automatically extracted from git tags (e.g., `v1.2.3` becomes `1.2.3`)
113
118
114
119
### Testing Features
115
120
@@ -152,6 +157,13 @@ cpp_library_setup(
152
157
-**Version pinning** for reliable builds
153
158
-**Git tag versioning** for reliable updates
154
159
160
+
### Version Management
161
+
162
+
-**Automatic git tag detection**: Version is automatically extracted from the latest git tag
163
+
-**Fallback versioning**: Uses `0.0.0` if no git tag is found (with warning)
164
+
-**Manual override**: You can still specify `VERSION` parameter to override automatic detection
165
+
-**Tag format support**: Supports both `v1.2.3` and `1.2.3` tag formats
166
+
155
167
## Example Projects
156
168
157
169
This template is used by:
@@ -163,7 +175,6 @@ This template is used by:
163
175
164
176
```cmake
165
177
cmake_minimum_required(VERSION 3.20)
166
-
project(stlab-enum-ops VERSION 1.0.0 DESCRIPTION "Type-safe operators for enums" LANGUAGES CXX)
0 commit comments