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
DESCRIPTION description # e.g., "Type-safe operators for enums"
65
65
NAMESPACE namespace # e.g., "stlab"
66
-
HEADERS header_list # List of header files
66
+
HEADERS header_list # List of header filenames (e.g., "your_header.hpp")
67
67
68
-
# Optional: source specification for non-header-only libraries
69
-
SOURCES source_list # List of source files (auto-detected from src/ if not provided)
68
+
# Source specification for non-header-only libraries
69
+
SOURCES source_list # List of source filenames (e.g., "your_library.cpp", omit for header-only libraries)
70
70
71
71
# Optional features
72
-
[EXAMPLES example_list] # Example executables to build
73
-
[TESTS test_list] # Test executables to build
72
+
[EXAMPLES example_list] # Example source files to build (e.g., "example.cpp example_fail.cpp")
73
+
[TESTS test_list] # Test source files to build (e.g., "tests.cpp")
74
74
[DOCS_EXCLUDE_SYMBOLS symbols] # Symbols to exclude from docs
75
75
[REQUIRES_CPP_VERSION 17|20|23] # C++ version (default: 17)
76
76
[FORCE_INIT] # Force regeneration of template files
77
77
)
78
78
```
79
79
80
-
**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()`. Version is automatically detected from git tags.
80
+
**Note**: The project name is automatically taken from `PROJECT_NAME` (set by the `project()`
81
+
command). You must call `project(your-library)` before `cpp_library_setup()`. Version is
82
+
automatically detected from git tags.
83
+
84
+
**NOTE**: Examples using doctest should have `test` in the name if you want them to be visible in
85
+
the TestMate test explorer.
86
+
87
+
### Path Conventions
88
+
89
+
The template uses consistent path conventions for all file specifications:
90
+
91
+
-**HEADERS**: Filenames only, automatically placed in `include/<namespace>/` directory
-**EXAMPLES**: Source files with `.cpp` extension, located in `examples/` directory
96
+
- Examples: `example.cpp`, `example_fail.cpp`
97
+
-**TESTS**: Source files with `.cpp` extension, located in `tests/` directory
98
+
- Examples: `tests.cpp`, `unit_tests.cpp`
99
+
100
+
The template automatically generates the full paths based on these conventions. HEADERS are placed in `include/<namespace>/` and SOURCES are placed in `src/`.
101
+
102
+
### Library Types
103
+
104
+
**Header-only libraries**: Specify only `HEADERS`, omit `SOURCES`
105
+
```cmake
106
+
cpp_library_setup(
107
+
DESCRIPTION "Header-only library"
108
+
NAMESPACE my_lib
109
+
HEADERS my_header.hpp
110
+
# No SOURCES needed for header-only
111
+
)
112
+
```
113
+
114
+
**Non-header-only libraries**: Specify both `HEADERS` and `SOURCES`
115
+
```cmake
116
+
cpp_library_setup(
117
+
DESCRIPTION "Library with implementation"
118
+
NAMESPACE my_lib
119
+
HEADERS my_header.hpp
120
+
SOURCES my_library.cpp implementation.cpp
121
+
)
122
+
```
81
123
82
124
## Features
83
125
### Non-Header-Only Library Support
84
126
85
-
-**Automatic detection of sources in `src/`**: If source files are present in `src/`, the template will build a regular (static) library instead of header-only INTERFACE target.
86
-
Specify sources manually with the `SOURCES` argument, or let the template auto-detect files in `src/`.
127
+
-**Non-header-only library support**: For libraries with source files, specify them explicitly with the `SOURCES` argument as filenames (e.g., `"your_library.cpp"`).
87
128
Both header-only and compiled libraries are supported seamlessly.
0 commit comments