diff --git a/README.md b/README.md index 2ed5a30..21eb3ec 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/cookiecutter.json b/cookiecutter.json index fab025e..154656e 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -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" } diff --git a/hooks/pre_gen_project.py b/hooks/pre_gen_project.py index 2c61972..65e504e 100644 --- a/hooks/pre_gen_project.py +++ b/hooks/pre_gen_project.py @@ -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" diff --git a/{{cookiecutter.project_slug}}/.github/workflows/ci.yml b/{{cookiecutter.project_slug}}/.github/workflows/ci.yml index 64bc4bb..1115ffa 100644 --- a/{{cookiecutter.project_slug}}/.github/workflows/ci.yml +++ b/{{cookiecutter.project_slug}}/.github/workflows/ci.yml @@ -108,7 +108,7 @@ jobs: - name: Run Python tests run: | python -m pytest --cov --cov-report=xml -{% else %} +{% endif %} - name: Configure cmake shell: bash @@ -120,7 +120,6 @@ jobs: - name: Build shell: bash run: cmake --build --preset test -{% endif %} - name: Run tests shell: bash @@ -138,4 +137,3 @@ jobs: fail_ci_if_error: true files: ${{ "{{github.workspace}}" }}/coverage.info{% if cookiecutter.python_bindings != "None" %},coverage.xml{% endif %} {% endif %} - diff --git a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml index ffe1710..e7773e8 100644 --- a/{{cookiecutter.project_slug}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_slug}}/.pre-commit-config.yaml @@ -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 @@ -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: diff --git a/{{cookiecutter.project_slug}}/CMakePresets.json b/{{cookiecutter.project_slug}}/CMakePresets.json index dba3963..beaad84 100644 --- a/{{cookiecutter.project_slug}}/CMakePresets.json +++ b/{{cookiecutter.project_slug}}/CMakePresets.json @@ -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 %} @@ -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" + } + ] + } ] } diff --git a/{{cookiecutter.project_slug}}/FILESTRUCTURE.md b/{{cookiecutter.project_slug}}/FILESTRUCTURE.md index 5906960..3a0fe3c 100644 --- a/{{cookiecutter.project_slug}}/FILESTRUCTURE.md +++ b/{{cookiecutter.project_slug}}/FILESTRUCTURE.md @@ -24,6 +24,7 @@ This is an explanation of the repository's file structure: the `CMakeLists.txt` file from the directory `` 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 diff --git a/{{cookiecutter.project_slug}}/README.md b/{{cookiecutter.project_slug}}/README.md index 0a7cf60..ed1f745 100644 --- a/{{cookiecutter.project_slug}}/README.md +++ b/{{cookiecutter.project_slug}}/README.md @@ -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 %} @@ -76,10 +76,16 @@ which can be set by adding `-D={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 . @@ -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 . @@ -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 @@ -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 diff --git a/{{cookiecutter.project_slug}}/TODO.md b/{{cookiecutter.project_slug}}/TODO.md index 539bea7..7feed05 100644 --- a/{{cookiecutter.project_slug}}/TODO.md +++ b/{{cookiecutter.project_slug}}/TODO.md @@ -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 %}