Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ The core features of our C++ Cookiecutter in a nutshell:

In order to use this C++ Project Cookiecutter you need the following software installed:

* Python `>= 3.6`
* Python `>= 3.10`
* [Cookiecutter](https://github.com/cookiecutter/cookiecutter) `>=2.1` e.g. by doing `pip install cookiecutter`.
* Git `>= 1.8.2`

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.23`
* CMake `>= 3.28`
* Doxygen (optional, but recommended)

# Using C++ Project Cookiecutter
Expand Down
4 changes: 2 additions & 2 deletions cookiecutter.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,6 @@
"local_extensions.CurrentDateExtension"
],
"__python_module": "{{ cookiecutter|modname }}",
"_catch_version": "3.15.3",
"_cibuildwheel_version": "4.2.0"
"_catch_version": "3.16.0",
"_cibuildwheel_version": "4.2.1"
}
5 changes: 5 additions & 0 deletions hooks/pre_gen_project.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ def fail_if(condition, message):
sys.exit(1)


fail_if(
"{{ cookiecutter.doxygen }}" == "No" and "{{ cookiecutter.readthedocs }}" == "Yes",
"Read the Docs requires Doxygen in this template; set doxygen to Yes"
)

fail_if(
"{{ cookiecutter.pypi_release }}" != "No" and "{{ cookiecutter.python_bindings }}" == "None",
"Can't do PyPI release without building Python bindings"
Expand Down
4 changes: 1 addition & 3 deletions {{cookiecutter.project_slug}}/.github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ jobs:
- name: Run Python tests
run: |
python -m pytest --cov --cov-report=xml
{% else %}
{% endif %}

- name: Configure cmake
shell: bash
Expand All @@ -120,7 +120,6 @@ jobs:
- name: Build
shell: bash
run: cmake --build --preset test
{% endif %}

- name: Run tests
shell: bash
Expand All @@ -138,4 +137,3 @@ jobs:
fail_ci_if_error: true
files: ${{ "{{github.workspace}}" }}/coverage.info{% if cookiecutter.python_bindings != "None" %},coverage.xml{% endif %}
{% endif %}

4 changes: 2 additions & 2 deletions {{cookiecutter.project_slug}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ repos:
{%- if cookiecutter.python_bindings != "None" %}
# Run Ruff - an extremely fast Python linter and code formatter
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.16.3
rev: v0.16.6
hooks:
# Run the linter
- id: ruff-check
Expand All @@ -14,7 +14,7 @@ repos:

# Format C++ code with Clang-Format - automatically applying the changes
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v22.1.8
rev: v23.1.0
hooks:
- id: clang-format
args:
Expand Down
70 changes: 69 additions & 1 deletion {{cookiecutter.project_slug}}/CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,16 @@
"name": "release",
"configurePreset": "release"
},
{% if cookiecutter.doxygen == "Yes" or cookiecutter.readthedocs == "Yes" %}
{% if cookiecutter.doxygen == "Yes" %}
{
"name": "documentation",
"configurePreset": "documentation",
"targets": [
{% if cookiecutter.readthedocs == "Yes" %}
"{{ cookiecutter.project_slug }}-sphinx-doc"
{% else %}
"{{ cookiecutter.project_slug }}-doxygen"
{% endif %}
]
},
{% endif %}
Expand All @@ -91,5 +95,69 @@
"outputOnFailure": true
}
}
],
"workflowPresets": [
{
"name": "debug",
"displayName": "Configure and build in debug mode",
"steps": [
{
"type": "configure",
"name": "debug"
},
{
"type": "build",
"name": "debug"
}
]
},
{
"name": "release",
"displayName": "Configure and build in release mode",
"steps": [
{
"type": "configure",
"name": "release"
},
{
"type": "build",
"name": "release"
}
]
},
{% if cookiecutter.doxygen == "Yes" %}
{
"name": "documentation",
"displayName": "Configure and build documentation",
"steps": [
{
"type": "configure",
"name": "documentation"
},
{
"type": "build",
"name": "documentation"
}
]
},
{% endif %}
{
"name": "test",
"displayName": "Configure, build, and test",
"steps": [
{
"type": "configure",
"name": "test"
},
{
"type": "build",
"name": "test"
},
{
"type": "test",
"name": "test"
}
]
}
]
}
1 change: 1 addition & 0 deletions {{cookiecutter.project_slug}}/FILESTRUCTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ This is an explanation of the repository's file structure:
the `CMakeLists.txt` file from the directory `<dir>` is immediately executed. A comprehensive
reference of CMake's capabilities can be found in the [official CMake docs](https://cmake.org/documentation/).
A well-written, opinionated book for beginners and experts is [Modern CMake](https://cliutils.gitlab.io/modern-cmake/).
* `CMakePresets.json` defines convenient presets for the configuration, building, testing and workflow stages. Available presets can be queried with `cmake --list-presets=all`.
{% if cookiecutter.external_dependency != "None" %}
* `{{ cookiecutter.project_slug }}Config.cmake.in` provides a template for the configuration
installed alongside your project. This is required to implement the transitivity of your dependency
Expand Down
25 changes: 13 additions & 12 deletions {{cookiecutter.project_slug}}/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
Building {{ cookiecutter.project_name }} requires the following software installed:

* A C++{{ cookiecutter.cxx_minimum_standard }}-compliant compiler
* CMake `>= 3.23`
* CMake `>= 3.28`
{% if cookiecutter.external_dependency != "None" %}
* {{ cookiecutter.external_dependency }}
{% endif %}
Expand Down Expand Up @@ -76,10 +76,16 @@ which can be set by adding `-D<var>={ON, OFF}` to the `cmake` call:
* `{{ cookiecutter.project_slug }}_BUILD_PYTHON`: Enable building the Python bindings (default: `ON`)
{% endif %}

Alternatively, the available CMake presets can be displayed via `cmake --list-presets=all`. For example, the test workflow preset can be invoked with

```
cmake --workflow --preset test
```

It configures the project in debug mode, builds the test executables, and runs the tests, all in one go.

{% if cookiecutter.python_bindings != "None" %}
If you wish to build and install the project as a Python project without
having access to C++ build artifacts like libraries and executables, you
can do so using `pip` from the root directory:
If you wish to build and install the project as a Python project without having access to C++ build artifacts like libraries and executables, you can do so using `pip` from the root directory:

```
python -m pip install .
Expand All @@ -97,8 +103,7 @@ cd build
ctest
```
{% if cookiecutter.python_bindings != "None" %}
The Python test suite can be run by first `pip`-installing the Python package
and then running `pytest` from the top-level directory:
The Python test suite can be run by first `pip`-installing the Python package and then running `pytest` from the top-level directory:

```
python -m pip install .
Expand All @@ -108,9 +113,7 @@ pytest

# Documentation
{% if cookiecutter.readthedocs == "Yes" %}
{{ cookiecutter.project_name }} provides a Sphinx-based documentation, that can
be browsed [online at readthedocs.org](https://{{ cookiecutter.project_slug }}.readthedocs.io).
To build it locally, first ensure the requirements are installed by running this command from the top-level source directory:
{{ cookiecutter.project_name }} provides a Sphinx-based documentation, that can be browsed [online at readthedocs.org](https://{{ cookiecutter.project_slug }}.readthedocs.io). To build it locally, first ensure the requirements are installed by running this command from the top-level source directory:

```
pip install -r doc/requirements.txt
Expand All @@ -124,9 +127,7 @@ cmake --build build --target sphinx-doc

The web documentation can then be browsed by opening `build/doc/sphinx/index.html` in your browser.
{% elif cookiecutter.doxygen == "Yes" %}
{{ cookiecutter.project_name }} provides a Doxygen documentation. You can build
the documentation locally by making sure that `Doxygen` is installed on your system
and running this command from the top-level build directory:
{{ cookiecutter.project_name }} provides a Doxygen documentation. You can build the documentation locally by making sure that `Doxygen` is installed on your system and running this command from the top-level build directory:

```
cmake --build . --target doxygen
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.project_slug}}/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The following tasks need to be done to get a fully working project:
{%- endif %}
* Make sure that the following software is installed on your computer:
* A C++-{{ cookiecutter.cxx_minimum_standard}}-compliant C++ compiler
* CMake `>= 3.23`
* CMake `>= 3.28`
{%- if cookiecutter.use_submodules == "No" %}
* The testing framework [Catch2](https://github.com/catchorg/Catch2)
{%- endif %}
Expand Down