Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
5d2dc12
Modernize CMake configuration and clean up build scripts
thomasisensee Dec 8, 2025
a52bf5a
Remove setting CMP0074 to NEW explicitly, as it the default for CMake…
thomasisensee Dec 8, 2025
ec150ef
Since Catch2 is installed via FetchContent or included as a git submo…
thomasisensee Dec 17, 2025
7bf6b40
Reflect changed available C++ standards, with C++14 being the default…
thomasisensee Dec 18, 2025
ab0cf74
cmake: namespace targets, scope options, and guard app/docs builds
thomasisensee Dec 18, 2025
79c8a65
enable modern pybind11 FindPython
thomasisensee Dec 18, 2025
0e86c22
Format CMLs such that baked projects have always exactly one blank li…
thomasisensee Dec 18, 2025
a2841d0
Remove cmake-format and cmake-lint pre-commit hooks
thomasisensee Dec 18, 2025
1596acf
Modernize target exports and installation
thomasisensee Jan 19, 2026
1173129
Bump CI python versions to 3.10 and 3.14, bump actions/checkout to v6
thomasisensee Jan 19, 2026
51f0c6c
Install doxygen and pybind11 in baked project's CI
thomasisensee Jan 19, 2026
49ba529
Set _BUILD_PYTHON CMake option to OFF when building with cmake only, …
thomasisensee Jan 19, 2026
89282a1
Enable PIC only when python bindings are requested
thomasisensee Jan 29, 2026
7ca662f
Ignore coverage error for unused exclude patterns
thomasisensee Jan 29, 2026
33878bd
Configure Catch2 via add_subdirectory() and find_package() when using…
thomasisensee Jan 29, 2026
dfd7c9b
set CMAKE_POSITION_INDEPENDENT_CODE on target instead of globally
thomasisensee Feb 2, 2026
484bd85
Add option for switching building tests on or off
thomasisensee Feb 2, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 4 additions & 31 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,18 @@ on:
schedule:
- cron: "0 5 * * 1"

env:
CATCH2_VERSION: 3.11.0

jobs:
test:
name: Testing on ${{ matrix.os }} with Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# We test on the oldest and newest supported Python versions
# Unfortenately, we can't test on the latest Python version, as the
# pytest-virtualenv plugin does not support it yet, see
# https://github.com/man-group/pytest-plugins/issues/220
python-version: ["3.9", "3.13"]
python-version: ["3.10", "3.14"]

steps:
- name: Checking out the cookie cutter repository
uses: actions/checkout@v5
uses: actions/checkout@v6

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
Expand All @@ -46,26 +39,6 @@ jobs:

- uses: ssciwr/doxygen-install@v1

- name: Install Catch2 (Linux + MacOS)
if: runner.os != 'Windows'
run: |
git clone -b v$CATCH2_VERSION https://github.com/catchorg/Catch2.git
cd Catch2
mkdir build
cd build
cmake -DBUILD_TESTING=OFF ..
sudo cmake --build . --target install

- name: Install Catch2 (Windows)
if: runner.os == 'Windows'
run: |
git clone -b v$Env:CATCH2_VERSION https://github.com/catchorg/Catch2.git
cd Catch2
mkdir build
cd build
cmake -DBUILD_TESTING=OFF ..
cmake --build . --target install

- name: Set up git identity
run: |
git config --global user.email "ssc@citestuser.com"
Expand All @@ -86,11 +59,11 @@ jobs:

steps:
- name: Checking out the cookie cutter repository
uses: actions/checkout@v5
uses: actions/checkout@v6

- uses: actions/setup-python@v6
with:
python-version: "3.13"
python-version: "3.14"

- name: Install test requirements
run: |
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ In order to use this C++ Project Cookiecutter you need the following software in
In addition, the project that is generated from this cookiecutter will require the following software:

* A C++ compiler, e.g. `g++` or `clang++`
* CMake `>= 3.9`
* CMake `>= 3.23`
* Doxygen (optional, but recommended)

# Using C++ Project Cookiecutter
Expand Down Expand Up @@ -73,8 +73,8 @@ This cookiecutter accepts the following configuration options:
* `gitlab_ci`: Whether to add a CI workflow for GitLab CI
* `readthedocs`: Whether to create a Sphinx-documentation that can automatically be deployed to readthedocs.org
* `doxygen`: Whether a Doxygen documentation should be extracted from the project
* `cxx_minimum_standard`: The minimum C++ standard required for this project. It can be chosen from `11` (default), `14`, `17` and `20`.
`C++03` and earlier are not supported, because the generated project will depend on libraries that require `C++11` ([Catch2](https://github.com/catchorg/Catch2)
* `cxx_minimum_standard`: The minimum C++ standard required for this project. It can be chosen from `14` (default), `17`, `20` and `23`.
`C++11` and earlier are not supported, because the generated project will depend on libraries that require `C++14` ([Catch2](https://github.com/catchorg/Catch2)
for testing and [pybind11](https://github.com/pybind/pybind11) for potential Python bindings).
* `python_bindings`: Whether to automatically add a PyBind11-based Python binding package.
* `pypi_release`: Whether to add an automatic PyPI deploy workflow to the CI system.
Expand Down
4 changes: 2 additions & 2 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@
"local_extensions.CurrentDateExtension"
],
"__python_module": "{{ cookiecutter|modname }}",
"_catch_version": "3.11.0",
"_cibuildwheel_version": "3.3.0"
"_catch_version": "3.12.0",
"_cibuildwheel_version": "3.3.1"
}
1 change: 0 additions & 1 deletion hooks/post_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ def conditional_remove(condition, path):
conditional_remove("{{ cookiecutter.pypi_release }}" != "Yes", ".github/workflows/pypi.yml")
conditional_remove("{{ cookiecutter.codecovio }}" == "No", "codecov.yml")
conditional_remove("{{ cookiecutter.github_actions_ci }}" == "No", ".github")
conditional_remove("{{ cookiecutter.external_dependency }}" == "None", "{{ cookiecutter.project_slug }}Config.cmake.in")
conditional_remove(not {{ have_precommit }}, ".pre-commit-config.yaml")
conditional_remove(os.stat("TODO.md").st_size == 0, "TODO.md")

Expand Down
6 changes: 4 additions & 2 deletions tests/test_bake_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@ def test_readthedocs(cookies):
)
check_bake(bake)
with inside_bake(bake):
build_cmake(target='sphinx-doc')
project = bake.context['project_slug']
build_cmake(target=f'{project}-sphinx-doc')
assert os.path.exists(os.path.join(os.getcwd(), "doc", "sphinx", "index.html"))


Expand All @@ -136,7 +137,8 @@ def test_doxygen(cookies):
)
check_bake(bake)
with inside_bake(bake):
build_cmake(target='doxygen')
project = bake.context['project_slug']
build_cmake(target=f'{project}-doxygen')
assert os.path.exists(os.path.join(os.getcwd(), "doc", "html", "index.html"))


Expand Down
79 changes: 25 additions & 54 deletions {{cookiecutter.project_slug}}/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,6 @@ on:
# as well as upon manual triggers through the 'Actions' tab of the Github UI
workflow_dispatch:

{%- if cookiecutter.use_submodules == "No" %}
env:
CATCH2_VERSION: {{ cookiecutter._catch_version }}
{%- endif %}

jobs:
build-and-test:
name: Testing on ${{ "{{matrix.os}}" }}
Expand All @@ -31,43 +26,24 @@ jobs:
with:
submodules: 'recursive'
{%- endif %}

{% if cookiecutter.use_submodules == "No" %}
- name: Install Catch2 (Linux + MacOS)
if: runner.os != 'Windows'
run: |
git clone -b v$CATCH2_VERSION https://github.com/catchorg/Catch2.git
cd Catch2
mkdir build
cd build
cmake -DBUILD_TESTING=OFF ..
sudo cmake --build . --target install

- name: Install Catch2 (Windows)
if: runner.os == 'Windows'
run: |
git clone -b v$Env:CATCH2_VERSION https://github.com/catchorg/Catch2.git
cd Catch2
mkdir build
cd build
cmake -DBUILD_TESTING=OFF ..
cmake --build . --target install
{%- endif %}

- name: make build directory
{% if cookiecutter.doxygen == "Yes" %}
- name: Install Doxygen
uses: ssciwr/doxygen-install@v1
{% endif %}
- name: Make build directory
run: cmake -E make_directory ${{ "{{ github.workspace }}" }}/build

- name: configure cmake
- name: Configure cmake
shell: bash
working-directory: ${{ "{{ github.workspace }}" }}/build
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug -DBUILD_DOCS=OFF
run: cmake $GITHUB_WORKSPACE -DCMAKE_BUILD_TYPE=Debug -D{{ cookiecutter.project_slug }}_BUILD_DOCS=OFF -D{{ cookiecutter.project_slug }}_BUILD_PYTHON=OFF

- name: build
- name: Build
shell: bash
working-directory: ${{ "{{ github.workspace }}" }}/build
run: cmake --build .

- name: run tests
- name: Run tests
shell: bash
working-directory: ${{ "{{ github.workspace }}" }}/build
run: ctest
Expand All @@ -89,8 +65,11 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.13"

python-version: "3.14"
{% if cookiecutter.doxygen == "Yes" %}
- name: Install Doxygen
uses: ssciwr/doxygen-install@v1
{% endif %}
- name: Run Python tests
shell: bash
run: |
Expand All @@ -114,18 +93,10 @@ jobs:
- name: Install LCov
run: |
sudo apt-get install -y lcov

{% if cookiecutter.use_submodules == "No" %}
- name: Install Catch2
run: |
git clone -b v$CATCH2_VERSION https://github.com/catchorg/Catch2.git
cd Catch2
mkdir build
cd build
cmake -DBUILD_TESTING=OFF ..
sudo cmake --build . --target install
{%- endif %}

{% if cookiecutter.doxygen == "Yes" %}
- name: Install Doxygen
uses: ssciwr/doxygen-install@v1
{% endif %}
{% if cookiecutter.python_bindings == "Yes" %}
- name: Install Python package editable
run: |
Expand All @@ -137,31 +108,31 @@ jobs:
run: |
python -m pytest --cov --cov-report=xml
{% else %}
- name: Creat cmake build directory
- name: Create cmake build directory
run: cmake -E make_directory ${{ "{{ github.workspace }}" }}/build

- name: configure cmake
- name: Configure cmake
shell: bash
working-directory: ${{ "{{ github.workspace }}" }}/build
run: |
cmake $GITHUB_WORKSPACE -DCMAKE_CXX_FLAGS="--coverage" -DBUILD_DOCS=OFF
cmake $GITHUB_WORKSPACE -DCMAKE_CXX_FLAGS="--coverage" -D{{ cookiecutter.project_slug }}_BUILD_DOCS=OFF

- name: build
- name: Build
shell: bash
working-directory: ${{ "{{ github.workspace }}" }}/build
run: cmake --build .
{% endif %}

- name: run tests
- name: Run tests
shell: bash
working-directory: ${{ "{{ github.workspace }}" }}/build
run: ctest

- name: collect coverage report
- name: Collect coverage report
shell: bash
working-directory: ${{ "{{ github.workspace }}" }}
run: |
lcov --directory ./build{% if cookiecutter.header_only == "No" %}/src{% endif %} --capture --output-file coverage.info --ignore-errors mismatch --exclude '*/catch2/*'
lcov --directory ./build{% if cookiecutter.header_only == "No" %}/src{% endif %} --capture --output-file coverage.info --ignore-errors mismatch,unused --exclude '*/catch2/*'

- name: Upload C++ coverage to Codecov
uses: codecov/codecov-action@v5
Expand Down
23 changes: 6 additions & 17 deletions {{cookiecutter.project_slug}}/.gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
variables:
{%- if cookiecutter.use_submodules == "Yes" %}
GIT_SUBMODULE_STRATEGY: recursive
{%- else %}
CATCH2_VERSION: {{ cookiecutter._catch_version }}
{%- endif %}

.template: &template
Expand All @@ -14,22 +12,13 @@ variables:
{% if cookiecutter.python_bindings == "Yes" %}
- apt install -y python3-dev
{%- endif %}
{% if cookiecutter.use_submodules == "No" %}
- git clone -b v$CATCH2_VERSION https://github.com/catchorg/Catch2.git
- cd Catch2
- mkdir build
- cd build
- cmake -DBUILD_TESTING=OFF ..
- make install
- cd ../..
{%- endif %}
{% if cookiecutter.doxygen == "Yes" %}
- apt install -y doxygen
{% endif %}
script:
- cmake -E make_directory build
- cd build
- cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_DOCS=OFF ..
- cmake --build .
- ctest

- cmake -S . -B build -DCMAKE_BUILD_TYPE=Debug -D{{ cookiecutter.project_slug }}_BUILD_DOCS=OFF -D{{ cookiecutter.project_slug }}_BUILD_PYTHON=OFF
- cmake --build build
- ctest --test-dir build

# Note: You can use your own Docker images here that e.g. include relevant
# dependencies and development tools. We choose well-maintained images
Expand Down
6 changes: 0 additions & 6 deletions {{cookiecutter.project_slug}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,6 @@ repos:
# Unify file endings
- id: end-of-file-fixer

# CMake Formatting/Linting Utility
- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.13
hooks:
- id: cmake-format
- id: cmake-lint
{%- if cookiecutter.github_actions_ci == "Yes" %}

# GitHub Actions Workflow linter
Expand Down
Loading