├── .bumpversion.cfg ├── .circleci └── config.yml ├── .gitignore ├── .travis.yml ├── CONTRIBUTING.rst ├── LICENSE.txt ├── README.rst ├── azure-pipelines.yml ├── cookiecutter.json ├── cpp_cookiecutter-dev-requirements.yml ├── docs ├── .gitignore ├── CMakeLists.txt ├── Makefile ├── environment.yml ├── make.bat └── source │ ├── _templates │ └── layout.html │ ├── basic_usage.rst │ ├── benchmark.rst │ ├── changelog.rst │ ├── conda_recipe.rst │ ├── conf.py │ ├── examples.rst │ ├── folder_structure.rst │ ├── index.rst │ ├── python.rst │ └── unit_tests.rst ├── hooks ├── post_gen_project.py └── pre_gen_project.py ├── readthedocs.yml ├── setup.py ├── tests ├── cookiecutter_config.yaml ├── test_project.sh └── toy_project │ ├── .gitignore │ ├── CMakeLists.txt │ └── main.cpp └── {{cookiecutter.github_project_name}} ├── .bumpversion.cfg ├── .circleci └── config.yml ├── .github └── ISSUE_TEMPLATE.md ├── .travis.yml ├── CMakeLists.txt ├── CONTRIBUTING.rst ├── LICENCE.txt ├── README.rst ├── azure-pipelines.yml ├── benchmark ├── CMakeLists.txt ├── benchmark_{{cookiecutter.cmake_project_name}}.cpp ├── copyGBenchmark.cmake.in ├── downloadGBenchmark.cmake.in └── main.cpp ├── binder └── Dockerfile ├── cmake └── modules │ ├── FindDOCTEST.cmake │ ├── FindNUMPY.cmake │ └── FindSphinx.cmake ├── docker └── Dockerfile ├── docs ├── CMakeLists.txt ├── Doxyfile ├── Makefile ├── make.bat └── source │ ├── _templates │ └── layout.html │ ├── basic_usage.rst │ ├── benchmark.rst │ ├── changelog.rst │ ├── cmake_path.py.in │ ├── conda_recipe.rst │ ├── conf.py │ ├── contributing.rst │ ├── examples.rst │ ├── features.rst │ ├── folder_structure.rst │ ├── index.rst │ ├── installation.rst │ ├── pyapi │ └── fu │ ├── python.rst │ ├── readme.rst │ └── unit_tests.rst ├── examples ├── CMakeLists.txt ├── hello_world.cpp └── {{cookiecutter.package_name}}_version.cpp ├── include └── {{cookiecutter.cpp_root_folder_name}} │ ├── {{ cookiecutter.package_name}}.hpp │ ├── {{ cookiecutter.package_name}}_config.hpp │ ├── {{ cookiecutter.package_name}}_version_major.hpp │ ├── {{ cookiecutter.package_name}}_version_minor.hpp │ └── {{ cookiecutter.package_name}}_version_patch.hpp ├── python ├── CMakeLists.txt ├── module │ └── {{cookiecutter.python_package_name}} │ │ └── __init__.py ├── notebooks │ └── hello_world.ipynb ├── src │ ├── CMakeLists.txt │ ├── def_build_config.cpp │ ├── def_myclass.cpp │ └── main.cpp └── tests │ └── test_build_configuration.py ├── readthedocs.yml ├── recipe ├── bld.bat ├── build.sh └── meta.yaml ├── test ├── CMakeLists.txt ├── copyDoctest.cmake.in ├── downloadDoctest.cmake.in ├── main.cpp └── test_{{cookiecutter.package_name}}_config.cpp ├── {{cookiecutter.cmake_project_name}}.pc.in ├── {{cookiecutter.cmake_project_name}}Config.cmake.in └── {{cookiecutter.package_name}}-dev-requirements.yml /.bumpversion.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 0.5.0 3 | commit = True 4 | tag = True 5 | 6 | [bumpversion:file:setup.py] 7 | search = version='{current_version}' 8 | replace = version='{new_version}' 9 | 10 | -------------------------------------------------------------------------------- /.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | variables: 3 | 4 | install_build_essential: &install_build_essential 5 | run: 6 | name: Install Build essential 7 | command: | 8 | apt-get update 9 | apt-get install -y build-essential 10 | 11 | prepare_conda: &prepare_conda 12 | run: 13 | name: Config and Update Conda 14 | command: | 15 | conda config --set always_yes yes --set changeps1 no 16 | conda update -q conda 17 | conda install cookiecutter -c conda-forge 18 | 19 | run_test_conda_build: &run_test_conda_build 20 | run: 21 | name: Run tests 22 | command: | 23 | conda install conda-build make 24 | cd .. 25 | cookiecutter repo --overwrite-if-exists --no-input 26 | cd cpptools 27 | conda build recipe -c conda-forge 28 | 29 | update_conda: &update_conda 30 | run: 31 | name: update conda 32 | command: | 33 | conda update -q conda 34 | conda init bash 35 | 36 | run_test_script: &run_test_script 37 | run: 38 | name: Run test scripts 39 | command: | 40 | conda init bash 41 | chmod +x tests/test_project.sh 42 | ./tests/test_project.sh repo source 43 | 44 | 45 | jobs: 46 | test_job: 47 | docker: 48 | - image: continuumio/miniconda3:4.5.12 49 | working_directory: ~/repo 50 | steps: 51 | - checkout 52 | - *install_build_essential 53 | - *update_conda 54 | - *run_test_script 55 | 56 | test_conda_build_job: 57 | docker: 58 | - image: continuumio/miniconda3:4.5.12 59 | working_directory: ~/repo 60 | steps: 61 | - checkout 62 | - *install_build_essential 63 | - *prepare_conda 64 | - *run_test_conda_build 65 | 66 | push_to_cpptools_job: 67 | docker: 68 | - image: continuumio/miniconda3:4.5.12 69 | working_directory: ~/repo 70 | steps: 71 | - checkout 72 | - add_ssh_keys: 73 | fingerprints: 74 | - "a1:57:78:c8:fd:8d:58:13:09:02:4b:6e:4b:0a:ec:68" 75 | - *prepare_conda 76 | - run: 77 | name: clone cpptools 78 | command: | 79 | cd .. 80 | rm -rf cpptools 81 | echo "CIRCLE_BRANCH $CIRCLE_BRANCH" 82 | echo "CIRCLE_USERNAME $CIRCLE_USERNAME" 83 | if [[ "$CIRCLE_BRANCH $CIRCLE_USERNAME" == "master DerThorsten" ]]; then 84 | echo "IN master" 85 | git clone https://github.com/DerThorsten/cpptools 86 | else 87 | echo "NOT IN master" 88 | git clone https://github.com/DerThorsten/cpptools -b tests 89 | fi 90 | conda install --yes cookiecutter -c conda-forge 91 | cookiecutter repo --overwrite-if-exists --no-input --config-file ~/repo/tests/cookiecutter_config.yaml 92 | cd cpptools 93 | 94 | GIT_TAG=v_$(date +%Y_%m_%d_%H_%M_%S) 95 | if [[ "$CIRCLE_BRANCH $CIRCLE_USERNAME" == "master DerThorsten" ]]; then 96 | sed -i "s/v0.1.0/$GIT_TAG/g" binder/Dockerfile 97 | fi 98 | git config user.email "derthorsten@gmail.com" 99 | git config user.name "DerThorsten" 100 | git add . 101 | git commit -am "continous integration auto updated" --allow-empty 102 | if [[ "$CIRCLE_BRANCH $CIRCLE_USERNAME" == "master DerThorsten" ]]; then 103 | echo "IN master" 104 | git push --force origin master 105 | git tag -a $GIT_TAG -m '$GIT_TAG' 106 | git push origin $GIT_TAG 107 | else 108 | echo "NOT IN master" 109 | git push --force origin tests 110 | fi 111 | 112 | 113 | 114 | 115 | workflows: 116 | version: 2 117 | 118 | my_test: 119 | jobs: 120 | - test_job 121 | - test_conda_build_job 122 | - push_to_cpptools_job 123 | 124 | nightly-test: 125 | triggers: 126 | - schedule: 127 | cron: "0 0 * * *" 128 | filters: 129 | branches: 130 | only: 131 | - master 132 | jobs: 133 | - test_job 134 | - test_conda_build_job 135 | - push_to_cpptools_job 136 | 137 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | # Compiled Object files 5 | *.slo 6 | *.lo 7 | *.o 8 | *.obj 9 | 10 | # Precompiled Headers 11 | *.gch 12 | *.pch 13 | 14 | # Compiled Dynamic libraries 15 | *.so 16 | *.dylib 17 | *.dll 18 | 19 | # Fortran module files 20 | *.mod 21 | *.smod 22 | 23 | # Compiled Static libraries 24 | *.lai 25 | *.la 26 | *.a 27 | *.lib 28 | 29 | # Executables 30 | *.exe 31 | *.out 32 | *.app 33 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | dist: precise 3 | env: 4 | matrix: 5 | fast_finish: true 6 | include: 7 | - os: linux 8 | addons: 9 | apt: 10 | sources: 11 | - ubuntu-toolchain-r-test 12 | packages: 13 | - g++-4.9 14 | env: COMPILER=gcc GCC=4.9 15 | - os: linux 16 | addons: 17 | apt: 18 | sources: 19 | - ubuntu-toolchain-r-test 20 | packages: 21 | - g++-5 22 | env: COMPILER=gcc GCC=5 23 | - os: linux 24 | addons: 25 | apt: 26 | sources: 27 | - ubuntu-toolchain-r-test 28 | packages: 29 | - g++-6 30 | env: COMPILER=gcc GCC=6 31 | - os: linux 32 | addons: 33 | apt: 34 | sources: 35 | - ubuntu-toolchain-r-test 36 | - llvm-toolchain-precise-3.6 37 | packages: 38 | - clang-3.6 39 | env: COMPILER=clang CLANG=3.6 40 | - os: linux 41 | addons: 42 | apt: 43 | sources: 44 | - ubuntu-toolchain-r-test 45 | - llvm-toolchain-precise-3.7 46 | packages: 47 | - clang-3.7 48 | env: COMPILER=clang CLANG=3.7 49 | - os: linux 50 | addons: 51 | apt: 52 | sources: 53 | - ubuntu-toolchain-r-test 54 | - llvm-toolchain-precise-3.9 55 | packages: 56 | - clang-3.9 57 | env: COMPILER=clang CLANG=3.9 58 | - os: osx 59 | osx_image: xcode8 60 | compiler: clang 61 | env: 62 | global: 63 | - MINCONDA_VERSION="latest" 64 | - MINCONDA_LINUX="Linux-x86_64" 65 | - MINCONDA_OSX="MacOSX-x86_64" 66 | before_install: 67 | - | 68 | # Configure build variables 69 | if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 70 | if [[ "$COMPILER" == "gcc" ]]; then 71 | export CXX=g++-$GCC CC=gcc-$GCC; 72 | fi 73 | if [[ "$COMPILER" == "clang" ]]; then 74 | export CXX=clang++-$CLANG CC=clang-$CLANG; 75 | fi 76 | elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 77 | export CXX=clang++ CC=clang; 78 | fi 79 | install: 80 | # Define the version of miniconda to download 81 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 82 | MINCONDA_OS=$MINCONDA_LINUX; 83 | elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 84 | MINCONDA_OS=$MINCONDA_OSX; 85 | fi 86 | - wget "http://repo.continuum.io/miniconda/Miniconda3-$MINCONDA_VERSION-$MINCONDA_OS.sh" -O miniconda.sh; 87 | - bash miniconda.sh -b -p $HOME/miniconda 88 | - export PATH="$HOME/miniconda/bin:$PATH" 89 | - hash -r 90 | - conda config --set always_yes yes --set changeps1 no 91 | - conda update -q conda 92 | 93 | script: 94 | - chmod +x tests/test_project.sh 95 | - ./tests/test_project.sh cpp_cookiecutter source 96 | -------------------------------------------------------------------------------- /CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | .. highlight:: shell 2 | 3 | ============ 4 | Contributing 5 | ============ 6 | 7 | Contributions are welcome, and they are greatly appreciated! Every 8 | little bit helps, and credit will always be given. 9 | 10 | You can contribute in many ways: 11 | 12 | Types of Contributions 13 | ---------------------- 14 | 15 | Report Bugs 16 | ~~~~~~~~~~~ 17 | 18 | Report bugs at https://github.com/DerThorsten/cpp_cookiecutter/issues. 19 | 20 | If you are reporting a bug, please include: 21 | 22 | * Your operating system name and version. 23 | * Any details about your local setup that might be helpful in troubleshooting. 24 | * Detailed steps to reproduce the bug. 25 | 26 | Fix Bugs 27 | ~~~~~~~~ 28 | 29 | Look through the GitHub issues for bugs. Anything tagged with "bug" 30 | and "help wanted" is open to whoever wants to implement it. 31 | 32 | Implement Features 33 | ~~~~~~~~~~~~~~~~~~ 34 | 35 | Look through the GitHub issues for features. Anything tagged with "enhancement" 36 | and "help wanted" is open to whoever wants to implement it. 37 | 38 | Write Documentation 39 | ~~~~~~~~~~~~~~~~~~~ 40 | cpp_cookiecutter could always use more documentation. 41 | Submit Feedback 42 | ~~~~~~~~~~~~~~~ 43 | 44 | The best way to send feedback is to file an issue at https://github.com/DerThorsten/cpp_cookiecutter/issues. 45 | 46 | If you are proposing a feature: 47 | 48 | * Explain in detail how it would work. 49 | * Keep the scope as narrow as possible, to make it easier to implement. 50 | * Remember that this is a volunteer-driven project, and that contributions 51 | are welcome :) 52 | 53 | 54 | Pull Request Guidelines 55 | ----------------------- 56 | 57 | Before you submit a pull request, check that it meets these guidelines: 58 | 59 | 1. The pull request should include tests. 60 | 2. If the pull request adds functionality, the docs should be updated. Put 61 | your new functionality into a function / classes with a proper documentation, and add the 62 | feature to the list in README.rst. 63 | 64 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2018, Thorsten Beier 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.rst: -------------------------------------------------------------------------------- 1 | ================================================= 2 | Cpp Cookiecutter 3 | ================================================= 4 | 5 | 6 | .. image:: https://readthedocs.org/projects/cpp-cookiecutter/badge/?version=latest 7 | :target: https://cpp-cookiecutter.readthedocs.io/en/latest/?badge=latest 8 | :alt: Documentation Status 9 | 10 | 11 | .. image:: https://travis-ci.org/DerThorsten/cpp_cookiecutter.svg?branch=master 12 | :target: https://travis-ci.org/DerThorsten/cpp_cookiecutter 13 | 14 | .. image:: https://circleci.com/gh/DerThorsten/cpp_cookiecutter/tree/master.svg?style=svg 15 | :target: https://circleci.com/gh/DerThorsten/cpp_cookiecutter/tree/master 16 | 17 | .. image:: https://dev.azure.com/derthorstenbeier/cpp_cookiecutter/_apis/build/status/DerThorsten.cpp_cookiecutter?branchName=master 18 | :target: https://dev.azure.com/derthorstenbeier/cpp_cookiecutter/_build/latest?definitionId=1&branchName=master 19 | 20 | 21 | 22 | 23 | Demo Project 24 | ------------------------ 25 | Have a look at `github.com/DerThorsten/cpptools `_, an 26 | unmodified example project created with this cpp_cookiecutter. 27 | 28 | Features 29 | -------- 30 | 31 | Current features include: 32 | * Readme on `readthedocs.org `_ 33 | * Modern C++ 14 34 | * Build system with modern CMake 35 | * `preconfigured conda recipe included `_ 36 | * Rendered projects have pre-configured CI scripts for: travis-ci circleci and azure-pipelines 37 | * Rendering of projects itself is tested on several continuous integration plattforms as `travis-ci `_ `circleci `_ and `azure-pipelines `_ 38 | * `C++ unit tests with cpp doctest `_ 39 | * `Benchmark code with google benchmark `_ 40 | * Docs with sphinx breathe and readthedocs support 41 | * `Google Benchmark `_ and `Doctest `_ are downloaded at cmake-config time via external-projects 42 | since these dependencies are just for testing and benchmarking (and those are not yet available on conda) 43 | * bumpversion 44 | * `Python bindings are created via pybind11 `_ 45 | * An demo project `github.com/DerThorsten/cpptools `_ created by this cookiecutter, and automatically kept up to date via continuous integration 46 | 47 | 48 | .. _rtd_unit_test: 49 | 50 | 51 | 52 | 53 | 54 | 55 | Usage: 56 | -------- 57 | 58 | Install _cookiecutter 59 | 60 | .. code-block:: shell 61 | 62 | $ pip install cookiecutter 63 | 64 | 65 | After installing cookiecutter, use the cpp-cookiecutter: 66 | 67 | .. code-block:: shell 68 | 69 | $ cookiecutter https://github.com/DerThorsten/cpp_cookiecutter 70 | 71 | 72 | This cookiecutter is bet used in conjunction with conda: 73 | Assuming your package is named cpptools the following script 74 | shows the usage of the generated project cookiecutter on Linux/MacOS 75 | 76 | .. code-block:: shell 77 | 78 | cd cpptools 79 | conda env create -f cpptools-dev-requirements.yml 80 | source activate cpptools-dev-requirements 81 | mkdir build 82 | cd build 83 | cmake .. 84 | make -j2 85 | make cpp-test 86 | make python-test 87 | cd examples 88 | ./hello_world 89 | cd .. 90 | cd benchmark 91 | ./benchmark_cpptools 92 | 93 | 94 | On a windows machine this looks like: 95 | 96 | .. code-block:: shell 97 | 98 | cd cpptools 99 | call activate cpptools-dev-requirements 100 | mkdir build 101 | cd build 102 | cmake .. -G"Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release ^ 103 | -DDEPENDENCY_SEARCH_PREFIX="%CONDA_PREFIX%\Library" -DCMAKE_PREFIX_PATH="%CONDA_PREFIX%\Library" 104 | call activate cpptools-dev-requirements 105 | cmake --build . --target ALL_BUILD 106 | cmake --build . --target python-test 107 | cmake --build . --target cpp-test 108 | 109 | .. code-block:: shell 110 | 111 | cd cpptools 112 | call activate cpptools-dev-requirements 113 | mkdir build 114 | cd build 115 | cmake .. -G"Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release ^ 116 | -DDEPENDENCY_SEARCH_PREFIX="%CONDA_PREFIX%\Library" -DCMAKE_PREFIX_PATH="%CONDA_PREFIX%\Library" 117 | call activate cpptools-dev-requirements 118 | cmake --build . --target ALL_BUILD 119 | cmake --build . --target python-test 120 | cmake --build . --target cpp-test 121 | 122 | 123 | -------------------------------------------------------------------------------- /azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | jobs: 2 | - job: Linux 3 | pool: 4 | vmImage: 'ubuntu-16.04' 5 | strategy: 6 | maxParallel: 2 7 | variables: 8 | repoDir: '$(Build.Repository.LocalPath)' 9 | 10 | steps: 11 | - task: CondaEnvironment@1 12 | inputs: 13 | updateConda: false 14 | - script: | 15 | chmod +x tests/test_project.sh || exit 1 16 | ./tests/test_project.sh $(repoDir) source || exit 1 17 | 18 | - job: macOS 19 | pool: 20 | vmImage: 'xcode9-macos10.13' 21 | strategy: 22 | maxParallel: 2 23 | variables: 24 | repoDir: '$(Build.Repository.LocalPath)' 25 | steps: 26 | - bash: echo "##vso[task.prependpath]$CONDA/bin" 27 | displayName: Add conda to PATH 28 | 29 | - script: | 30 | chmod +x tests/test_project.sh || exit 1 31 | ./tests/test_project.sh $(repoDir) source || exit 1 32 | 33 | - job: 34 | displayName: Windows 35 | pool: 36 | vmImage: 'vs2017-win2016' 37 | strategy: 38 | maxParallel: 2 39 | # matrix: 40 | # py36: 41 | # PY_VERSION: 3.6 42 | # VS_VERSION: 2015 43 | # # py27: 44 | # # PY_VERSION: 2.7 45 | variables: 46 | repoDir: '$(Build.Repository.LocalPath)' 47 | steps: 48 | - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" 49 | displayName: Add conda to PATH 50 | 51 | - script: conda create --yes --quiet --name myroot|| exit 1 52 | displayName: Create Anaconda environment 53 | 54 | - script: | 55 | call activate myroot || exit 1 56 | conda install --yes --quiet --name myroot cookiecutter -c conda-forge || exit 1 57 | displayName: Install Anaconda packages 58 | 59 | - script: | 60 | echo "activate" || exit 1 61 | call activate myroot || exit 1 62 | echo "cd" || exit 1 63 | cd .. || exit 1 64 | echo "run cookiecutter" || exit 1 65 | cookiecutter %repoDir% --overwrite-if-exists --no-input || exit 1 66 | displayName: generating project from cookiecutter 67 | 68 | - script: | 69 | echo "activate" || exit 1 70 | call activate myroot || exit 1 71 | echo "cd path" || exit 1 72 | cd .. || exit 1 73 | cd cpptools || exit 1 74 | echo "create" || exit 1 75 | conda env create -f cpptools-dev-requirements.yml || exit 1 76 | echo "done" || exit 1 77 | displayName: create dev requirements env 78 | 79 | - script: | 80 | echo "cd path" || exit 1 81 | cd ..\cpptools || exit 1 82 | echo "activate" || exit 1 83 | call activate cpptools-dev-requirements || exit 1 84 | echo "mkdir" || exit 1 85 | mkdir build || exit 1 86 | cd build || exit 1 87 | echo "cmake gen" || exit 1 88 | cmake .. -G"Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release ^ 89 | -DDEPENDENCY_SEARCH_PREFIX="%CONDA_PREFIX%\Library" -DCMAKE_PREFIX_PATH="%CONDA_PREFIX%\Library" || exit 1 90 | displayName: configure project 91 | 92 | - script: | 93 | echo "cd path" || exit 1 94 | cd ..\cpptools\build || exit 1 95 | echo "activate" || exit 1 96 | call activate cpptools-dev-requirements || exit 1 97 | cmake --build . --target ALL_BUILD || exit 1 98 | displayName: build project 99 | 100 | - script: | 101 | echo "cd path" || exit 1 102 | cd ..\cpptools\build || exit 1 103 | echo "activate" || exit 1 104 | call activate cpptools-dev-requirements || exit 1 105 | echo "run tests" || exit 1 106 | cmake --build . --target python-test || exit 1 107 | cmake --build . --target cpp-test || exit 1 108 | displayName: run tests 109 | 110 | 111 | schedules: 112 | - cron: "0 0 * * *" 113 | displayName: Daily midnight build 114 | branches: 115 | include: 116 | - master 117 | always: true 118 | 119 | -------------------------------------------------------------------------------- /cookiecutter.json: -------------------------------------------------------------------------------- 1 | { 2 | "full_name": "John Doe", 3 | "email": "john@doe.de", 4 | "project_name": "cpptools", 5 | "project_slug": "{{ cookiecutter.project_name|lower|replace(' ', '-') }}", 6 | "package_name": "{{ cookiecutter.project_slug|replace('-', '_') }}", 7 | "conda_package_name": "{{ cookiecutter.package_name|replace('-', '_') }}", 8 | "readthedocs_package_name": "{{ cookiecutter.package_name|replace('-', '_') }}", 9 | "cpp_namespace": "{{ cookiecutter.package_name }}", 10 | "cpp_root_folder_name": "{{ cookiecutter.package_name }}", 11 | "cpp_macro_prefix": "{{ cookiecutter.project_name|upper|replace(' ', '_')|replace('-', '_') }}", 12 | "cpp_standart": ["C++14", "C++11", "NotSpecified"], 13 | "cmake_project_name": "{{ cookiecutter.package_name }}", 14 | "cmake_interface_library_name": "{{ cookiecutter.package_name }}", 15 | "github_project_name": "{{ cookiecutter.project_slug }}", 16 | "python_bindings": ["yes", "no"], 17 | "python_package_name": "{{ cookiecutter.project_name|lower|replace(' ', '_')|replace('-', '_') }}", 18 | "github_user_name": "JohnDoe", 19 | "azure_user_name": "{{cookiecutter.github_user_name}}", 20 | "dockerhub_user_name": "{{cookiecutter.github_user_name|lower}}", 21 | "dockerhub_project_name": "{{cookiecutter.github_project_name}}", 22 | "open_source_license": ["MIT license", "BSD license", "ISC license", "Apache Software License 2.0", "GNU General Public License v3", "Not open source"], 23 | "summary": "{{ cookiecutter.package_name }} is a modern C++ library", 24 | "description": "{{ cookiecutter.summary }}", 25 | "_copy_without_render": [ 26 | "docs/source/_templates/*.html", 27 | "docs/source/_templates/*.css", 28 | "docs/source/_templates/*.rst", 29 | "docs/source/_static/css/*.css" 30 | ] 31 | } -------------------------------------------------------------------------------- /cpp_cookiecutter-dev-requirements.yml: -------------------------------------------------------------------------------- 1 | name: cpp_cookiecutter-dev-requirements 2 | 3 | channels: 4 | - anaconda 5 | - conda-forge 6 | dependencies: 7 | - cookiecutter 8 | - sphinx 9 | - sphinx_rtd_theme 10 | - sphinxcontrib-apidoc 11 | - pip 12 | - pip: 13 | - exhale -------------------------------------------------------------------------------- /docs/.gitignore: -------------------------------------------------------------------------------- 1 | build -------------------------------------------------------------------------------- /docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(COPY ${CMAKE_SOURCE_DIR}/docs DESTINATION ${CMAKE_BINARY_DIR}/docs_bld) -------------------------------------------------------------------------------- /docs/Makefile: -------------------------------------------------------------------------------- 1 | # You can set these variables from the command line. 2 | SPHINXOPTS = 3 | SPHINXBUILD = sphinx-build 4 | PAPER = 5 | BUILDDIR = build 6 | 7 | # User-friendly check for sphinx-build 8 | ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) 9 | $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) 10 | endif 11 | 12 | # Internal variables. 13 | PAPEROPT_a4 = -D latex_paper_size=a4 14 | PAPEROPT_letter = -D latex_paper_size=letter 15 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 16 | # the i18n builder cannot share the environment and doctrees with the others 17 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 18 | 19 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext api 20 | 21 | default: html 22 | 23 | help: 24 | @echo "Please use \`make ' where is one of" 25 | @echo " html to make standalone HTML files" 26 | @echo " dirhtml to make HTML files named index.html in directories" 27 | @echo " singlehtml to make a single large HTML file" 28 | @echo " pickle to make pickle files" 29 | @echo " json to make JSON files" 30 | @echo " htmlhelp to make HTML files and a HTML help project" 31 | @echo " qthelp to make HTML files and a qthelp project" 32 | @echo " applehelp to make an Apple Help Book" 33 | @echo " devhelp to make HTML files and a Devhelp project" 34 | @echo " epub to make an epub" 35 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 36 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 37 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 38 | @echo " text to make text files" 39 | @echo " man to make manual pages" 40 | @echo " texinfo to make Texinfo files" 41 | @echo " info to make Texinfo files and run them through makeinfo" 42 | @echo " gettext to make PO message catalogs" 43 | @echo " changes to make an overview of all changed/added/deprecated items" 44 | @echo " xml to make Docutils-native XML files" 45 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 46 | @echo " linkcheck to check all external links for integrity" 47 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 48 | @echo " coverage to run coverage check of the documentation (if enabled)" 49 | 50 | clean: 51 | rm -rf $(BUILDDIR)/* 52 | rm -rf xml 53 | 54 | html: 55 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 56 | @echo 57 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 58 | 59 | dirhtml: 60 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 61 | @echo 62 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 63 | 64 | singlehtml: 65 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 66 | @echo 67 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 68 | 69 | pickle: 70 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 71 | @echo 72 | @echo "Build finished; now you can process the pickle files." 73 | 74 | json: 75 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 76 | @echo 77 | @echo "Build finished; now you can process the JSON files." 78 | 79 | htmlhelp: 80 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 81 | @echo 82 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 83 | ".hhp project file in $(BUILDDIR)/htmlhelp." 84 | 85 | epub: 86 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 87 | @echo 88 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 89 | 90 | latex: 91 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 92 | @echo 93 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 94 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 95 | "(use \`make latexpdf' here to do that automatically)." 96 | 97 | latexpdf: 98 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 99 | @echo "Running LaTeX files through pdflatex..." 100 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 101 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 102 | 103 | latexpdfja: 104 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 105 | @echo "Running LaTeX files through platex and dvipdfmx..." 106 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 107 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 108 | 109 | text: 110 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 111 | @echo 112 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 113 | 114 | man: 115 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 116 | @echo 117 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 118 | 119 | texinfo: 120 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 121 | @echo 122 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 123 | @echo "Run \`make' in that directory to run these through makeinfo" \ 124 | "(use \`make info' here to do that automatically)." 125 | 126 | info: 127 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 128 | @echo "Running Texinfo files through makeinfo..." 129 | make -C $(BUILDDIR)/texinfo info 130 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 131 | 132 | gettext: 133 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 134 | @echo 135 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 136 | 137 | changes: 138 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 139 | @echo 140 | @echo "The overview file is in $(BUILDDIR)/changes." 141 | 142 | linkcheck: 143 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 144 | @echo 145 | @echo "Link check complete; look for any errors in the above output " \ 146 | "or in $(BUILDDIR)/linkcheck/output.txt." 147 | 148 | doctest: 149 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 150 | @echo "Testing of doctests in the sources finished, look at the " \ 151 | "results in $(BUILDDIR)/doctest/output.txt." 152 | 153 | coverage: 154 | $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage 155 | @echo "Testing of coverage in the sources finished, look at the " \ 156 | "results in $(BUILDDIR)/coverage/python.txt." 157 | 158 | xml: 159 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 160 | @echo 161 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 162 | 163 | pseudoxml: 164 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 165 | @echo 166 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 167 | -------------------------------------------------------------------------------- /docs/environment.yml: -------------------------------------------------------------------------------- 1 | name: cpp_cookiecutter-docs 2 | 3 | channels: 4 | - anaconda 5 | - conda-forge 6 | dependencies: 7 | - cookiecutter 8 | - sphinx 9 | - sphinx_rtd_theme -------------------------------------------------------------------------------- /docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source 10 | set I18NSPHINXOPTS=%SPHINXOPTS% source 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. xml to make Docutils-native XML files 37 | echo. pseudoxml to make pseudoxml-XML files for display purposes 38 | echo. linkcheck to check all external links for integrity 39 | echo. doctest to run all doctests embedded in the documentation if enabled 40 | echo. coverage to run coverage check of the documentation if enabled 41 | goto end 42 | ) 43 | 44 | if "%1" == "clean" ( 45 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 46 | del /q /s %BUILDDIR%\* 47 | goto end 48 | ) 49 | 50 | 51 | REM Check if sphinx-build is available and fallback to Python version if any 52 | %SPHINXBUILD% 1>NUL 2>NUL 53 | if errorlevel 9009 goto sphinx_python 54 | goto sphinx_ok 55 | 56 | :sphinx_python 57 | 58 | set SPHINXBUILD=python -m sphinx.__init__ 59 | %SPHINXBUILD% 2> nul 60 | if errorlevel 9009 ( 61 | echo. 62 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 63 | echo.installed, then set the SPHINXBUILD environment variable to point 64 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 65 | echo.may add the Sphinx directory to PATH. 66 | echo. 67 | echo.If you don't have Sphinx installed, grab it from 68 | echo.http://sphinx-doc.org/ 69 | exit /b 1 70 | ) 71 | 72 | :sphinx_ok 73 | 74 | 75 | if "%1" == "html" ( 76 | doxygen 77 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 78 | if errorlevel 1 exit /b 1 79 | echo. 80 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 81 | goto end 82 | ) 83 | 84 | if "%1" == "dirhtml" ( 85 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 86 | if errorlevel 1 exit /b 1 87 | echo. 88 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 89 | goto end 90 | ) 91 | 92 | if "%1" == "singlehtml" ( 93 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 94 | if errorlevel 1 exit /b 1 95 | echo. 96 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 97 | goto end 98 | ) 99 | 100 | if "%1" == "pickle" ( 101 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 102 | if errorlevel 1 exit /b 1 103 | echo. 104 | echo.Build finished; now you can process the pickle files. 105 | goto end 106 | ) 107 | 108 | if "%1" == "json" ( 109 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 110 | if errorlevel 1 exit /b 1 111 | echo. 112 | echo.Build finished; now you can process the JSON files. 113 | goto end 114 | ) 115 | 116 | if "%1" == "htmlhelp" ( 117 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 118 | if errorlevel 1 exit /b 1 119 | echo. 120 | echo.Build finished; now you can run HTML Help Workshop with the ^ 121 | .hhp project file in %BUILDDIR%/htmlhelp. 122 | goto end 123 | ) 124 | 125 | if "%1" == "qthelp" ( 126 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 127 | if errorlevel 1 exit /b 1 128 | echo. 129 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 130 | .qhcp project file in %BUILDDIR%/qthelp, like this: 131 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\packagename.qhcp 132 | echo.To view the help file: 133 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\packagename.ghc 134 | goto end 135 | ) 136 | 137 | if "%1" == "devhelp" ( 138 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 139 | if errorlevel 1 exit /b 1 140 | echo. 141 | echo.Build finished. 142 | goto end 143 | ) 144 | 145 | if "%1" == "epub" ( 146 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 147 | if errorlevel 1 exit /b 1 148 | echo. 149 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 150 | goto end 151 | ) 152 | 153 | if "%1" == "latex" ( 154 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 155 | if errorlevel 1 exit /b 1 156 | echo. 157 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 158 | goto end 159 | ) 160 | 161 | if "%1" == "latexpdf" ( 162 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 163 | cd %BUILDDIR%/latex 164 | make all-pdf 165 | cd %~dp0 166 | echo. 167 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 168 | goto end 169 | ) 170 | 171 | if "%1" == "latexpdfja" ( 172 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 173 | cd %BUILDDIR%/latex 174 | make all-pdf-ja 175 | cd %~dp0 176 | echo. 177 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 178 | goto end 179 | ) 180 | 181 | if "%1" == "text" ( 182 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 183 | if errorlevel 1 exit /b 1 184 | echo. 185 | echo.Build finished. The text files are in %BUILDDIR%/text. 186 | goto end 187 | ) 188 | 189 | if "%1" == "man" ( 190 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 191 | if errorlevel 1 exit /b 1 192 | echo. 193 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 194 | goto end 195 | ) 196 | 197 | if "%1" == "texinfo" ( 198 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 199 | if errorlevel 1 exit /b 1 200 | echo. 201 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 202 | goto end 203 | ) 204 | 205 | if "%1" == "gettext" ( 206 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 207 | if errorlevel 1 exit /b 1 208 | echo. 209 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 210 | goto end 211 | ) 212 | 213 | if "%1" == "changes" ( 214 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 215 | if errorlevel 1 exit /b 1 216 | echo. 217 | echo.The overview file is in %BUILDDIR%/changes. 218 | goto end 219 | ) 220 | 221 | if "%1" == "linkcheck" ( 222 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 223 | if errorlevel 1 exit /b 1 224 | echo. 225 | echo.Link check complete; look for any errors in the above output ^ 226 | or in %BUILDDIR%/linkcheck/output.txt. 227 | goto end 228 | ) 229 | 230 | if "%1" == "doctest" ( 231 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 232 | if errorlevel 1 exit /b 1 233 | echo. 234 | echo.Testing of doctests in the sources finished, look at the ^ 235 | results in %BUILDDIR%/doctest/output.txt. 236 | goto end 237 | ) 238 | 239 | if "%1" == "coverage" ( 240 | %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage 241 | if errorlevel 1 exit /b 1 242 | echo. 243 | echo.Testing of coverage in the sources finished, look at the ^ 244 | results in %BUILDDIR%/coverage/python.txt. 245 | goto end 246 | ) 247 | 248 | if "%1" == "xml" ( 249 | %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml 250 | if errorlevel 1 exit /b 1 251 | echo. 252 | echo.Build finished. The XML files are in %BUILDDIR%/xml. 253 | goto end 254 | ) 255 | 256 | if "%1" == "pseudoxml" ( 257 | %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml 258 | if errorlevel 1 exit /b 1 259 | echo. 260 | echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. 261 | goto end 262 | ) 263 | 264 | :end 265 | -------------------------------------------------------------------------------- /docs/source/_templates/layout.html: -------------------------------------------------------------------------------- 1 | {# layout.html #} 2 | {# Import the theme's layout. #} 3 | {% extends "!layout.html" %} 4 | 5 | {% set css_files = css_files + ['_static/pygments.css'] %} -------------------------------------------------------------------------------- /docs/source/basic_usage.rst: -------------------------------------------------------------------------------- 1 | Basic usage 2 | =========== 3 | 4 | Install cookiecutter 5 | ********************** 6 | Install _cookiecutter via conda (recommended) 7 | 8 | .. code-block:: shell 9 | 10 | $ conda install cookiecutter -c conda-forge 11 | 12 | or 13 | 14 | .. code-block:: shell 15 | 16 | $ pip install cookiecutter 17 | 18 | Create Project With Cookiecutter 19 | ******************************************** 20 | 21 | After installing cookiecutter, use the cpp-cookiecutter: 22 | 23 | .. code-block:: shell 24 | 25 | $ cookiecutter https://github.com/DerThorsten/cpp_cookiecutter 26 | 27 | There you need to specify the variables of the cpp_cookiecutter which are explained 28 | in the table below: 29 | 30 | .. list-table:: Title 31 | :widths: 25 25 50 32 | :header-rows: 1 33 | 34 | * - Cookiecutter variable 35 | - Description 36 | - Default 37 | * - full_name 38 | - Author Name 39 | - John Doe 40 | * - email 41 | - email of author 42 | - john@doe.de 43 | * - project_name 44 | - name of the project 45 | - cpptools 46 | * - project_slug 47 | - url friendly version of package name 48 | - cpptools 49 | * - package_name 50 | - package name 51 | - cpptools 52 | * - conda_package_name 53 | - conda package name 54 | - cpptools 55 | * - readthedocs_package_name 56 | - readthedocs package name 57 | - cpptools 58 | * - cpp_namespace 59 | - name of C++ namespace 60 | - cpptools 61 | * - cpp_root_folder_name 62 | - name of the root C++ folder 63 | - cpptools 64 | * - cpp_macro_prefix 65 | - prefix for all macros in C++ 66 | - CPPTOOLS 67 | * - cpp_standart 68 | - which C++ standard should be used 69 | - 14 70 | * - cmake_project_name 71 | - name of the project within cmake 72 | - cpptools 73 | * - cmake_interface_library_name 74 | - name of the cmake interface library 75 | - cpptools 76 | * - github_project_name 77 | - name of the project on github 78 | - cpptools 79 | * - python_bindings 80 | - should python bindings be included 81 | - Yes 82 | * - python_package_name 83 | - name of the python package 84 | - cpptools 85 | * - github_user_name 86 | - authors github user name 87 | - JohnDoe 88 | * - dockerhub_user_name 89 | - authors dockerhub user name 90 | - johndoe 91 | * - dockerhub_project_name 92 | - name for this project on dockerhub 93 | - johndoe 94 | * - azure_user_name 95 | - authors user name on microsoft azure 96 | - JohnDoe 97 | * - open_source_license 98 | - which license shall be used 99 | - MIT LICENCE 100 | * - summary 101 | - a short summary of the project 102 | - cpptools is a modern C++ Library 103 | * - description 104 | - a short description of the project 105 | - cpptools is a modern C++ Library 106 | 107 | 108 | Build Generated Project 109 | ******************************************** 110 | 111 | This cookiecutter is best used in conjunction with conda: 112 | Assuming your package is named cpptools the following script 113 | shows the usage of the generated project cookiecutter on Linux/MacOS 114 | 115 | .. code-block:: shell 116 | 117 | cd cpptools 118 | conda env create -f cpptools-dev-requirements.yml 119 | source activate cpptools-dev-requirements 120 | mkdir build 121 | cd build 122 | cmake .. 123 | make -j2 124 | make cpp-test 125 | make python-test 126 | cd examples 127 | ./hello_world 128 | cd .. 129 | cd benchmark 130 | ./benchmark_cpptools 131 | 132 | 133 | On a windows machine this looks like: 134 | 135 | .. code-block:: shell 136 | 137 | cd cpptools 138 | conda env create -f cpptools-dev-requirements.yml 139 | call activate cpptools-dev-requirements 140 | mkdir build 141 | cd build 142 | cmake .. -G"Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release ^ 143 | -DDEPENDENCY_SEARCH_PREFIX="%CONDA_PREFIX%\Library" -DCMAKE_PREFIX_PATH="%CONDA_PREFIX%\Library" 144 | call activate cpptools-dev-requirements 145 | cmake --build . --target ALL_BUILD 146 | cmake --build . --target python-test 147 | cmake --build . --target cpp-test 148 | 149 | Install dev requirements 150 | ========================= 151 | 152 | To install all dev requirements install the dependencies via the requirements yaml file 153 | 154 | .. code-block:: shell 155 | 156 | $ conda env create -f cpp_cookiecutter-dev-requiremnts.yml 157 | 158 | This will create a fresh conda environments with all dependencies to use the cookiecutter and 159 | to build the documentation of this project. -------------------------------------------------------------------------------- /docs/source/benchmark.rst: -------------------------------------------------------------------------------- 1 | Benchmark 2 | ========= 3 | 4 | 5 | We use gbench_ to create a benchmark for the C++ code. 6 | 7 | 8 | The benchmark subfolder contains all the code related 9 | to the benchmarks. 10 | In main.cpp the actual benchmarks are implemented. 11 | 12 | :: 13 | 14 | project 15 | ├── ... 16 | ├── benchmark 17 | │ ├── main.cpp 18 | ├── ... 19 | 20 | 21 | .. _gbench: https://github.com/google/benchmark 22 | -------------------------------------------------------------------------------- /docs/source/changelog.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | Changelog 4 | ========= 5 | 6 | 0.4.0 7 | ------ 8 | 9 | - added ci pipeline scripts in rendered projects 10 | 11 | 12 | 0.5.0 13 | ------ 14 | 15 | - added documentation on readthedocs.org -------------------------------------------------------------------------------- /docs/source/conda_recipe.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | Conda Recipe 4 | ================= 5 | 6 | The recipe subfolder contains all the code related 7 | to the conda recipe 8 | 9 | :: 10 | 11 | project 12 | ├── ... 13 | ├── recipe 14 | │ ├── bld.bat 15 | │ ├── build.sh 16 | │ ├── meta.tml 17 | ├── ... 18 | -------------------------------------------------------------------------------- /docs/source/conf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import os 5 | 6 | import sys 7 | import os 8 | import sphinx_rtd_theme 9 | 10 | 11 | 12 | 13 | html_theme = "sphinx_rtd_theme" 14 | #html_theme = "classic" 15 | html_theme_path = [ 16 | sphinx_rtd_theme.get_html_theme_path(), 17 | 'mytheme', 18 | '.' 19 | ] 20 | 21 | 22 | # html_theme_options = { 23 | # "codebgcolor": 'black' 24 | # } 25 | 26 | 27 | #html_static_path = ['_static'] 28 | 29 | extensions = [] 30 | 31 | templates_path = ['_template'] 32 | source_suffix = '.rst' 33 | master_doc = 'index' 34 | project = 'cpp_cookiecutter' 35 | copyright = '2019 , Thorsten Beier' 36 | author = 'Thorsten Beier' 37 | 38 | 39 | exclude_patterns = [] 40 | highlight_language = 'python' 41 | pygments_style = 'sphinx' 42 | todo_include_todos = False 43 | htmlhelp_basename = 'cpp_cookiecutter_doc' -------------------------------------------------------------------------------- /docs/source/examples.rst: -------------------------------------------------------------------------------- 1 | .. role:: bash(code) 2 | :language: bash 3 | 4 | Examples 5 | ================= 6 | 7 | The examples subfolder contains C++ examples which 8 | shall show the usage of the C++ library. 9 | 10 | :: 11 | 12 | project 13 | ├── ... 14 | ├── examples 15 | │ ├── CMakeLists.txt 16 | │ ├── hello_world.cpp 17 | ├── ... 18 | 19 | 20 | Build System 21 | ********************** 22 | 23 | There is a meta target called :bash:`examples` which bundles the 24 | build process of all cpp files in the folder examples in one target. 25 | Assuming your cmake-build directory is called :bash:`bld` the following 26 | will build all examples. 27 | 28 | .. code-block:: shell 29 | 30 | $ cd bld 31 | $ make examples 32 | 33 | 34 | Adding New Examples 35 | ********************** 36 | 37 | To add new examples just add a new cpp file to the example 38 | folder and update the :bash:`CMakeLists.txt`. 39 | Assuming we named the new cpp file :bash:`my_new_example.cpp`, 40 | the relevant part in the :bash:`CMakeLists.txt` shall look like this: 41 | 42 | .. code-block:: cmake 43 | 44 | # all examples 45 | set(CPP_EXAMPLE_FILES 46 | hello_world.cpp 47 | my_new_example.cpp 48 | ) 49 | 50 | 51 | 52 | 53 | After changing the :bash:`CMakeLists.txt` cmake needs to be rerun 54 | to configure the build again. 55 | After that :bash:`make examples` will build all examples including the 56 | freshly added examples. 57 | 58 | .. code-block:: shell 59 | 60 | $ cd bld 61 | $ cmake . 62 | $ make examples -------------------------------------------------------------------------------- /docs/source/folder_structure.rst: -------------------------------------------------------------------------------- 1 | .. role:: bash(code) 2 | :language: bash 3 | 4 | Folder Structure 5 | ================= 6 | 7 | The generated project has the following folder structure 8 | 9 | :: 10 | 11 | {{cookiecutter.cmake_project_name}} 12 | ├──azure-pipelines.yml # Ci script 13 | │ 14 | ├──benchmark # C++ benchmark code 15 | │ └── ... 16 | │ 17 | ├──binder # dockerfile for mybinder.org 18 | │ └── Dockerfile 19 | │ 20 | ├──cmake # Cmake script/modules 21 | │ └── ... 22 | │ 23 | ├──CMakeLists.txt # Main cmake list 24 | │ 25 | ├──CONTRIBUTING.rst # Introduction how to constribute 26 | │ 27 | ├──{{cookiecutter.cmake_project_name}}Config.cmake.in # Script to make find_package(...) 28 | │ # work for this package 29 | │ 30 | ├──{{cookiecutter.cmake_project_name}}.pc.in # Packaging info 31 | │ 32 | ├──{{cookiecutter.package_name}}-dev-requirements.yml # List of development conda dependencies 33 | │ 34 | ├──docker # dockerfile for dockerhub 35 | │ └── Dockerfile 36 | │ 37 | ├──docs # Sources for sphinx documentation 38 | │ └── ... 39 | │ 40 | ├──examples # C++ examples 41 | │ └── ... 42 | │ 43 | ├──include # C++ include directory for this folder 44 | │ └── ... 45 | │ 46 | ├──LICENCE.txt # License file 47 | │ 48 | ├──python # Python binding source code 49 | │ └── ... 50 | │ 51 | ├──README.rst # Readme shown on github 52 | │ 53 | ├──readthedocs.yml # Entry point for automated 54 | │ # documentation build on readthedocs.org 55 | │ 56 | ├──recipe # Folder for conda recipes 57 | │ └── ... 58 | │ 59 | └──test # Folder containing C++ unit tests 60 | └── ... 61 | 62 | -------------------------------------------------------------------------------- /docs/source/index.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | Introduction 4 | ---------------- 5 | cpp_cookiecutter is cookiecutter template for a modern C++ project with python bindings 6 | 7 | 8 | Demo Project 9 | ------------------------ 10 | Have a look at `github.com/DerThorsten/cpptools `_, an 11 | unmodified example project created with this cpp_cookiecutter. 12 | 13 | 14 | Licensing 15 | ----------------- 16 | This software is licensed under the BSD 3-Clause License. See the LICENSE.txt file for details. 17 | 18 | 19 | .. toctree:: 20 | :caption: Usage 21 | :maxdepth: 2 22 | 23 | basic_usage 24 | 25 | .. toctree:: 26 | :caption: Folder Structure 27 | :maxdepth: 2 28 | 29 | folder_structure 30 | 31 | .. toctree:: 32 | :caption: Components 33 | :maxdepth: 2 34 | 35 | unit_tests 36 | benchmark 37 | python 38 | examples 39 | conda_recipe 40 | 41 | .. toctree:: 42 | :caption: Changelog 43 | :maxdepth: 0 44 | 45 | changelog 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /docs/source/python.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | Python Module 4 | ================= 5 | 6 | Here we document how to use and extend the python bindings for a project created with this cookiecutter. 7 | See `cpptools.readthedocs.io/en/latest/python.html https://cpptools.readthedocs.io/en/latest/python.html>`_ 8 | for the python documentation of a sample project created with this cookiecutter. 9 | 10 | Folder Structure 11 | ********************** 12 | 13 | We use pybind11_ to create the python bindings. 14 | The python subfolder contains all the code related 15 | to the python bindings. 16 | The :code:`module/{{cookiecutter.python_package_name}}` subfolder contains all the :code:`*.py` files of the module. 17 | The src folder contains the :code:`*.cpp` files used to export the C++ functionality to python via pybind11_. 18 | The :code:`test` folder contains all python tests. 19 | 20 | :: 21 | 22 | {{cookiecutter.github_project_name}} 23 | ├── ... 24 | ├── python 25 | │ ├── module 26 | │ │ └── {{cookiecutter.python_package_name}} 27 | │ │ ├── __init__.py 28 | │ │ └── ... 29 | │ ├── src 30 | │ │ ├── CMakeLists.txt 31 | │ │ ├── main.cpp 32 | │ │ ├── def_build_config.cpp 33 | │ │ ├── ... 34 | │ └── test 35 | │ ├── test_build_configuration.py 36 | │ └── ... 37 | └── ... 38 | 39 | 40 | 41 | 42 | 43 | Build System 44 | ********************** 45 | 46 | To build the python package use the :code:`python-module` target. 47 | 48 | .. code-block:: shell 49 | 50 | make python-module 51 | 52 | This will build the :code:`*.cpp` files in the :code:`src` folder and copy the folder :code:`module/{{cookiecutter.python_package_name}}` folder to build location of the python module, namely :code:`${CMAKE_BINARY_DIR}/python/module/` where :code:`${CMAKE_BINARY_DIR}` is the build directory. 53 | 54 | 55 | Usage 56 | ********************** 57 | 58 | After a successfully building and installing the python module can be 59 | imported like the following: 60 | 61 | .. code-block:: python 62 | 63 | import {{cookiecutter.python_package_name}} 64 | 65 | config = {{cookiecutter.python_package_name}}.BuildConfiguration 66 | print(config.VERSION_MAJOR) 67 | 68 | 69 | 70 | Run Python Tests 71 | ******************************************** 72 | 73 | To run the python test suite use the `python-test` target: 74 | 75 | .. code-block:: shell 76 | 77 | make python-test 78 | 79 | 80 | 81 | Adding New Python Functionality 82 | ******************************************** 83 | 84 | We use pybind11_ to export functionality from C++ to Python. 85 | pybind11_ can create modules from C++ without the use of any :code:`*.py` files. 86 | Nevertheless we prefer to have a regular Python package with a proper :code:`__init__.py`. From the :code:`__init__.py` we import all the C++ / pybind11_ exported functionality from the build submodule named :code:`_{{cookiecutter.python_package_name}}`. 87 | This allows us to add new functionality in different ways: 88 | * new functionality from c++ via pybind11_ 89 | * new puren python functionality 90 | 91 | Add New Python Functionality from C++ 92 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 93 | To export functionality from C++ to python via pybind11_ it is 94 | good practice to split functionality in multiple :code:`def_*.cpp` files. 95 | This allow for readable code, and parallel builds. 96 | To add news functionality we create a new file, for example :code:`def_new_stuff.cpp`. 97 | 98 | 99 | .. code-block:: cpp 100 | 101 | #include "pybind11/pybind11.h" 102 | #include "pybind11/numpy.h" 103 | 104 | #include 105 | #include 106 | 107 | #define FORCE_IMPORT_ARRAY 108 | #include "xtensor-python/pyarray.hpp" 109 | #include "xtensor-python/pytensor.hpp" 110 | 111 | // our headers 112 | #include "{{cookiecutter.cpp_root_folder_name}}/{{ cookiecutter.package_name}}.hpp" 113 | 114 | namespace py = pybind11; 115 | 116 | 117 | namespace {{cookiecutter.cpp_namespace}} { 118 | 119 | void def_new_stuff(py::module & m) 120 | { 121 | py::def('new_stuff',[](xt::pytensor<1,double> values){ 122 | return values * 42.0; 123 | }); 124 | } 125 | 126 | } 127 | 128 | Next we need to declare and call the :code:`def_new_stuff` from :code:`main.cpp`. 129 | To declare the function modify the following block in :code:`main.cpp` 130 | 131 | .. code-block:: cpp 132 | 133 | namespace {{cookiecutter.cpp_namespace}} { 134 | 135 | // .... 136 | // .... 137 | // .... 138 | 139 | // implementation in def_myclass.cpp 140 | void def_class(py::module & m); 141 | 142 | // implementation in def_myclass.cpp 143 | void def_build_config(py::module & m); 144 | 145 | // implementation in def.cpp 146 | void def_build_config(py::module & m); 147 | 148 | // implementation in def.cpp 149 | void def_build_config(py::module & m); 150 | 151 | // implementation in def_new_stuff.cpp 152 | void def_new_stuff(py::module & m); // <- our new functionality 153 | 154 | } 155 | 156 | After declaring the function :code:`def_new_stuff`, we can call :code:`def_new_stuff`. We modify the :code:`PYBIND11_MODULE` in 157 | code:`main.cpp`: 158 | 159 | 160 | .. code-block:: cpp 161 | 162 | // Python Module and Docstrings 163 | PYBIND11_MODULE(_{{cookiecutter.python_package_name}} , module) 164 | { 165 | xt::import_numpy(); 166 | 167 | module.doc() = R"pbdoc( 168 | _{{cookiecutter.python_package_name}} python bindings 169 | 170 | .. currentmodule:: _{{cookiecutter.python_package_name}} 171 | 172 | .. autosummary:: 173 | :toctree: _generate 174 | 175 | BuildConfiguration 176 | MyClass 177 | new_stuff 178 | )pbdoc"; 179 | 180 | {{cookiecutter.cpp_namespace}}::def_build_config(module); 181 | {{cookiecutter.cpp_namespace}}::def_class(module); 182 | {{cookiecutter.cpp_namespace}}::def_new_stuff(module); // <- our new functionality 183 | 184 | // make version string 185 | std::stringstream ss; 186 | ss<<{{cookiecutter.cpp_macro_prefix}}_VERSION_MAJOR<<"." 187 | <<{{cookiecutter.cpp_macro_prefix}}_VERSION_MINOR<<"." 188 | <<{{cookiecutter.cpp_macro_prefix}}_VERSION_PATCH; 189 | module.attr("__version__") = ss.str(); 190 | } 191 | 192 | 193 | We need to add this file to the :code:`CMakeLists.txt` file at 194 | :code:`{cookiecutter.github_project_name}}/python/src/CMakeLists.txt` 195 | The file needs to be passed as an argument to the :code:`pybind11_add_module` function. 196 | 197 | .. code-block:: cmake 198 | 199 | # add the python library 200 | pybind11_add_module(${PY_MOD_LIB_NAME} 201 | main.cpp 202 | def_build_config.cpp 203 | def_myclass.cpp 204 | def_new_stuff.cpp # <- our new functionality 205 | ) 206 | 207 | 208 | 209 | Now we are ready to build the freshly added functionality. 210 | 211 | .. code-block:: shell 212 | 213 | make python-test 214 | 215 | 216 | After a successful build we can use the new functionality from python. 217 | 218 | 219 | .. code-block:: python 220 | 221 | import numpy as np 222 | import {{cookiecutter.python_package_name}} 223 | 224 | {{cookiecutter.python_package_name}}.new_stuff(numpy.arange(5), dtype='float64') 225 | 226 | 227 | 228 | Add New Pure Python Functionality 229 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 230 | To add new pure Python functionality, 231 | just add the desired function / classes to 232 | a new :code:`*.py` file and put this file to the 233 | :code:`module/{{cookiecutter.python_package_name}}` subfolder. 234 | After adding the new file, cmake needs to be rerun since we copy the content :code:`module/{{cookiecutter.python_package_name}}` during the build process. 235 | 236 | 237 | 238 | 239 | Adding New Python Tests 240 | ******************************************** 241 | 242 | We use pytest_ as python test framework. 243 | To add new tests, just add new :code:`test_*.py` files 244 | to the test subfolder. 245 | To run the actual test use the :code:`python-test` target 246 | 247 | .. code-block:: shell 248 | 249 | make python-test 250 | 251 | 252 | .. _pybind11: https://github.com/pybind/pybind11 253 | .. _pytest: https://docs.pytest.org/en/latest/ -------------------------------------------------------------------------------- /docs/source/unit_tests.rst: -------------------------------------------------------------------------------- 1 | .. role:: bash(code) 2 | :language: bash 3 | 4 | 5 | Unit Tests 6 | ================= 7 | 8 | We use doctest_ to create a benchmark for the C++ code. 9 | 10 | 11 | The test subfolder contains all the code related 12 | to the C++ unit tests. 13 | In :bash:`main.cpp` implements the benchmarks runner, 14 | The unit tets are implemented in :bash:`test_*.cpp`. 15 | Assuming your project is names :bash:`cpptools`, the test 16 | folder looks like. 17 | 18 | :: 19 | 20 | project 21 | ├── ... 22 | ├── test 23 | │ ├── CMakeLists.txt 24 | │ ├── main.cpp 25 | │ ├── test_cpptools_config.cpp 26 | └── ... 27 | 28 | 29 | 30 | 31 | Build System 32 | ********************** 33 | 34 | There is a meta target called :bash:`test_cpptools` (assuming your cpptools is the package name) which bundles the 35 | build process of unit tests. 36 | Assuming you cmake-build directory is called :bash:`bld` the following 37 | will build all examples. 38 | 39 | .. code-block:: shell 40 | 41 | $ cd bld 42 | $ make test_cpptools 43 | 44 | To run the actual test you can use the target :bash:`cpp_tests` 45 | 46 | .. code-block:: shell 47 | 48 | $ cd bld 49 | $ make cpp_tests 50 | 51 | 52 | Adding New Tests 53 | ********************** 54 | 55 | To add new tests just add a new cpp file to the test 56 | folder and update the :bash:`CMakeLists.txt`. 57 | Assuming we named the new cpp file :bash:`test_my_new_feture.cpp`, 58 | the relevant part in the :bash:`CMakeLists.txt` shall look like this: 59 | 60 | .. code-block:: cmake 61 | 62 | # all tests 63 | set(${PROJECT_NAME}_TESTS 64 | test_cpptools_config.cpp 65 | test_my_new_feture.cpp 66 | ) 67 | 68 | 69 | 70 | 71 | After changing the :bash:`CMakeLists.txt` cmake needs to be rerun 72 | to configure the build again. 73 | After that :bash:`make examples` will build all examples including the 74 | freshly added examples. 75 | 76 | .. code-block:: shell 77 | 78 | $ cd bld 79 | $ cmake . 80 | $ make examples 81 | 82 | 83 | .. _doctest: https://github.com/google/benchmark 84 | -------------------------------------------------------------------------------- /hooks/post_gen_project.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | import os 3 | import os.path 4 | import shutil 5 | 6 | PROJECT_NAME = "{{cookiecutter.github_project_name}}" 7 | HOOK_DIR = os.path.realpath(os.path.curdir) 8 | PROJECT_DIRECTORY = os.path.join(HOOK_DIR,'..',PROJECT_NAME) 9 | 10 | 11 | LICENCE = "{{cookiecutter.open_source_license}}" 12 | NOT_OPEN_SOURCE = LICENCE == "Not open source" 13 | 14 | 15 | # from https://github.com/audreyr/cookiecutter/issues/723 16 | def delete_resource(resource): 17 | if os.path.isfile(resource): 18 | print("removing file: {}".format(resource)) 19 | os.remove(resource) 20 | elif os.path.isdir(resource): 21 | print("removing directory: {}".format(resource)) 22 | shutil.rmtree(resource) 23 | 24 | 25 | 26 | if __name__ == '__main__': 27 | build_python_binding = ("{{cookiecutter.python_bindings}}" == 'yes') 28 | 29 | if not build_python_binding: 30 | py_dir = os.path.join(PROJECT_DIRECTORY, 'python') 31 | delete_resource(py_dir) 32 | 33 | if NOT_OPEN_SOURCE: 34 | licence_file = os.path.join(PROJECT_DIRECTORY, 'LICENCE.txt') 35 | delete_resource(licence_file) 36 | -------------------------------------------------------------------------------- /hooks/pre_gen_project.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DerThorsten/cpp_cookiecutter/541840d9a9d10654d88f78aed2057e67984e9782/hooks/pre_gen_project.py -------------------------------------------------------------------------------- /readthedocs.yml: -------------------------------------------------------------------------------- 1 | conda: 2 | file: docs/environment.yml -------------------------------------------------------------------------------- /setup.py: -------------------------------------------------------------------------------- 1 | # !/usr/bin/env python 2 | from distutils.core import setup 3 | setup( 4 | name='cpp_cookiecutter', 5 | packages=[], 6 | version='0.5.0', 7 | description='Cookiecutter template for a C++ package', 8 | author='Thorsten Beier', 9 | license='BSD 3-Clause License', 10 | author_email='derthorstenbeier@gmail.com', 11 | url='https://github.com/DerThorsten/cpp_cookiecutter', 12 | keywords=['cookiecutter', 'template', 'package', ], 13 | classifiers=[ 14 | 'Development Status :: 4 - Beta', 15 | 'Environment :: Console', 16 | 'Intended Audience :: Developers', 17 | 'Natural Language :: English', 18 | 'License :: OSI Approved :: BSD 3-Clause License', 19 | 'Programming Language :: C', 20 | 'Programming Language :: C++ :: 2.7', 21 | 'Programming Language :: C++ :: 3', 22 | 'Programming Language :: Python', 23 | 'Programming Language :: Python :: 3.4', 24 | 'Programming Language :: Python :: 3.6', 25 | 'Programming Language :: Python :: 3.7', 26 | 'Topic :: Software Development', 27 | ], 28 | ) -------------------------------------------------------------------------------- /tests/cookiecutter_config.yaml: -------------------------------------------------------------------------------- 1 | default_context: 2 | full_name: "Thorsten Beier" 3 | email: "derthorstenbeier@gmail.com" 4 | github_user_name: "DerThorsten" 5 | azure_user_name: "derthorstenbeier" -------------------------------------------------------------------------------- /tests/test_project.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | TEMPLATE_FOLDER=$1 5 | SOURCE=$2 6 | 7 | echo "------------------------------------------------------------" 8 | echo "template folder dir: $TEMPLATE_FOLDER" 9 | echo "conda source command: $SOURCE activate" 10 | echo "------------------------------------------------------------" 11 | 12 | 13 | echo "------------------------------------------------------------" 14 | echo "create cpp_cookiecutter-dev-requirements conda env" 15 | echo "------------------------------------------------------------" 16 | conda env create -f cpp_cookiecutter-dev-requirements.yml || exit 1 17 | 18 | echo "------------------------------------------------------------" 19 | echo "activate cpp_cookiecutter-dev-requirements conda env" 20 | echo "------------------------------------------------------------" 21 | $SOURCE activate cpp_cookiecutter-dev-requirements || exit 1 22 | 23 | echo "------------------------------------------------------------" 24 | echo "take one step back" 25 | echo "------------------------------------------------------------" 26 | cd .. || exit 1 27 | 28 | echo "------------------------------------------------------------" 29 | echo "render coookiecutter template" 30 | echo "------------------------------------------------------------" 31 | cookiecutter $TEMPLATE_FOLDER --overwrite-if-exists --no-input || exit 1 32 | 33 | echo "------------------------------------------------------------" 34 | echo "go into cpp tools" 35 | echo "------------------------------------------------------------" 36 | cd cpptools || exit 1 37 | 38 | echo "------------------------------------------------------------" 39 | echo "create cpptools-dev-requirements conda env" 40 | echo "------------------------------------------------------------" 41 | conda env create -f cpptools-dev-requirements.yml || exit 1 42 | 43 | echo "------------------------------------------------------------" 44 | echo "activate cpptools-dev-requirements conda env" 45 | echo "------------------------------------------------------------" 46 | $SOURCE activate cpptools-dev-requirements || exit 1 47 | 48 | 49 | echo "------------------------------------------------------------" 50 | echo "setup intall prefix" 51 | echo "------------------------------------------------------------" 52 | INSTALL_PREFIX=$(conda info --base)/envs/cpptools-dev-requirements 53 | 54 | 55 | 56 | echo "------------------------------------------------------------" 57 | echo "create build dir" 58 | echo "------------------------------------------------------------" 59 | mkdir build || exit 1 60 | 61 | echo "------------------------------------------------------------" 62 | echo "go into build dir" 63 | echo "------------------------------------------------------------" 64 | cd build || exit 1 65 | 66 | echo "------------------------------------------------------------" 67 | echo "run cmake with INSTALL_PREFIX=$INSTALL_PREFIX" 68 | echo "------------------------------------------------------------" 69 | cmake .. -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX|| exit 1 70 | 71 | echo "------------------------------------------------------------" 72 | echo "build project" 73 | echo "------------------------------------------------------------" 74 | make -j2 || exit 1 75 | 76 | echo "------------------------------------------------------------" 77 | echo "run cpp tests" 78 | echo "------------------------------------------------------------" 79 | make cpp-test || exit 1 80 | 81 | echo "------------------------------------------------------------" 82 | echo "run python tests" 83 | echo "------------------------------------------------------------" 84 | make python-test || exit 1 85 | 86 | 87 | echo "------------------------------------------------------------" 88 | echo "run example" 89 | echo "------------------------------------------------------------" 90 | cd examples || exit 1 91 | ./hello_world || exit 1 92 | cd .. || exit 1 93 | 94 | echo "------------------------------------------------------------" 95 | echo "run benchmark" 96 | echo "------------------------------------------------------------" 97 | cd benchmark || exit 1 98 | ./benchmark_cpptools || exit 1 99 | cd .. || exit 1 100 | 101 | 102 | echo "------------------------------------------------------------" 103 | echo "build docs" 104 | echo "------------------------------------------------------------" 105 | make docs 106 | 107 | 108 | echo "------------------------------------------------------------" 109 | echo "make install" 110 | echo "------------------------------------------------------------" 111 | make install 112 | 113 | 114 | echo "------------------------------------------------------------" 115 | echo "go to toy project" 116 | echo "------------------------------------------------------------" 117 | cd ../../$TEMPLATE_FOLDER/tests/toy_project 118 | 119 | 120 | echo "------------------------------------------------------------" 121 | echo "run cmake for toy project depending on rendered project" 122 | echo "------------------------------------------------------------" 123 | cmake . || 0 124 | 125 | 126 | echo "------------------------------------------------------------" 127 | echo "build toy project depending on rendered project" 128 | echo "------------------------------------------------------------" 129 | make || 0 130 | 131 | 132 | echo "------------------------------------------------------------" 133 | echo "Completed test script successfully" 134 | echo "------------------------------------------------------------" 135 | -------------------------------------------------------------------------------- /tests/toy_project/.gitignore: -------------------------------------------------------------------------------- 1 | bld -------------------------------------------------------------------------------- /tests/toy_project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project (toy_project) 3 | 4 | find_package(cpptools CONFIG REQUIRED) 5 | add_executable(main main.cpp) 6 | target_link_libraries(main PUBLIC cpptools) -------------------------------------------------------------------------------- /tests/toy_project/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(){ 6 | 7 | } -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/.bumpversion.cfg: -------------------------------------------------------------------------------- 1 | [bumpversion] 2 | current_version = 0.1.0 3 | commit = True 4 | tag = True 5 | 6 | message = Bump version: {current_version} → {new_version} 7 | 8 | 9 | [bumpversion:file:include/{{cookiecutter.cpp_root_folder_name}}/{{cookiecutter.package_name}}_version_major.hpp] 10 | 11 | parse = (?P\d+) 12 | serialize = {major} 13 | 14 | search = {{cookiecutter.cpp_macro_prefix}}_VERSION_MAJOR {current_version} 15 | replace = {{cookiecutter.cpp_macro_prefix}}_VERSION_MAJOR {new_version} 16 | 17 | 18 | [bumpversion:file:include/{{cookiecutter.cpp_root_folder_name}}/{{cookiecutter.package_name}}_version_minor.hpp] 19 | 20 | parse = (?P\d+) 21 | serialize = {minor} 22 | search = {{cookiecutter.cpp_macro_prefix}}_VERSION_MINOR {current_version} 23 | replace = {{cookiecutter.cpp_macro_prefix}}_VERSION_MINOR {new_version} 24 | 25 | 26 | [bumpversion:file:include/{{cookiecutter.cpp_root_folder_name}}/{{cookiecutter.package_name}}_version_patch.hpp] 27 | 28 | parse = (?P\d+) 29 | serialize = {patch} 30 | search = {{cookiecutter.cpp_macro_prefix}}_VERSION_PATCH {current_version} 31 | replace = {{cookiecutter.cpp_macro_prefix}}_VERSION_PATCH {new_version} -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/.circleci/config.yml: -------------------------------------------------------------------------------- 1 | version: 2 2 | variables: 3 | 4 | 5 | install_build_essential: &install_build_essential 6 | run: 7 | name: Install from dev-requirements.yml 8 | command: | 9 | apt-get update 10 | apt-get install -y build-essential 11 | 12 | 13 | prepare_conda: &prepare_conda 14 | run: 15 | name: Install from dev-requirements.yml 16 | command: | 17 | conda config --set always_yes yes --set changeps1 no 18 | conda update -q conda 19 | conda install cookiecutter -c conda-forge 20 | 21 | 22 | run_tests: &run_tests 23 | run: 24 | name: Run tests 25 | command: | 26 | conda env create -f {{cookiecutter.package_name}}-dev-requirements.yml 27 | source activate {{cookiecutter.package_name}}-dev-requirements 28 | mkdir build 29 | cd build 30 | cmake .. 31 | make -j2 32 | make cpp-test 33 | {% if cookiecutter.python_bindings == 'yes' -%} 34 | make python-test 35 | {% endif %} 36 | cd examples 37 | ./hello_world 38 | cd .. 39 | cd benchmark 40 | ./benchmark_{{cookiecutter.cmake_project_name}} 41 | cd .. 42 | 43 | run_test_conda_build: &run_test_conda_build 44 | run: 45 | name: Run tests 46 | command: | 47 | conda install conda-build make 48 | conda build recipe -c conda-forge 49 | 50 | 51 | jobs: 52 | test_job: 53 | docker: 54 | - image: continuumio/miniconda3:4.5.12 55 | working_directory: ~/repo 56 | steps: 57 | - checkout 58 | - *install_build_essential 59 | - *prepare_conda 60 | - *run_tests 61 | 62 | test_conda_build_job: 63 | docker: 64 | - image: continuumio/miniconda3:4.5.12 65 | working_directory: ~/repo 66 | steps: 67 | - checkout 68 | - *install_build_essential 69 | - *prepare_conda 70 | - *run_test_conda_build 71 | 72 | 73 | workflows: 74 | version: 2 75 | 76 | my_test: 77 | jobs: 78 | - test_job 79 | - test_conda_build_job 80 | 81 | nightly-test: 82 | triggers: 83 | - schedule: 84 | cron: "0 0 * * *" 85 | filters: 86 | branches: 87 | only: 88 | - master 89 | jobs: 90 | - test_job 91 | - test_conda_build_job -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/.github/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | * {{cookiecutter.project_name}} version: 2 | * Operating System: 3 | * Compiler: 4 | 5 | ### Description 6 | 7 | Describe what you were trying to get done. 8 | Tell us what happened, what went wrong, and what you expected to happen. 9 | 10 | ### What I Did 11 | 12 | ``` 13 | Paste the command(s) you ran and the output. 14 | If there was a crash, please include the traceback here. 15 | ``` 16 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | dist: precise 3 | env: 4 | matrix: 5 | fast_finish: true 6 | include: 7 | - os: linux 8 | addons: 9 | apt: 10 | sources: 11 | - ubuntu-toolchain-r-test 12 | packages: 13 | - g++-4.9 14 | env: COMPILER=gcc GCC=4.9 15 | - os: linux 16 | addons: 17 | apt: 18 | sources: 19 | - ubuntu-toolchain-r-test 20 | packages: 21 | - g++-5 22 | env: COMPILER=gcc GCC=5 23 | - os: linux 24 | addons: 25 | apt: 26 | sources: 27 | - ubuntu-toolchain-r-test 28 | packages: 29 | - g++-6 30 | env: COMPILER=gcc GCC=6 31 | # - os: linux 32 | # addons: 33 | # apt: 34 | # sources: 35 | # - ubuntu-toolchain-r-test 36 | # - llvm-toolchain-precise-3.6 37 | # packages: 38 | # - clang-3.6 39 | # env: COMPILER=clang CLANG=3.6 40 | - os: linux 41 | addons: 42 | apt: 43 | sources: 44 | - ubuntu-toolchain-r-test 45 | - llvm-toolchain-precise-3.7 46 | packages: 47 | - clang-3.7 48 | env: COMPILER=clang CLANG=3.7 49 | - os: linux 50 | addons: 51 | apt: 52 | sources: 53 | - ubuntu-toolchain-r-test 54 | - llvm-toolchain-precise-3.9 55 | packages: 56 | - clang-3.9 57 | env: COMPILER=clang CLANG=3.9 58 | - os: osx 59 | osx_image: xcode8 60 | compiler: clang 61 | env: 62 | global: 63 | - MINCONDA_VERSION="latest" 64 | - MINCONDA_LINUX="Linux-x86_64" 65 | - MINCONDA_OSX="MacOSX-x86_64" 66 | before_install: 67 | - | 68 | # Configure build variables 69 | if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 70 | if [[ "$COMPILER" == "gcc" ]]; then 71 | export CXX=g++-$GCC CC=gcc-$GCC; 72 | fi 73 | if [[ "$COMPILER" == "clang" ]]; then 74 | export CXX=clang++-$CLANG CC=clang-$CLANG; 75 | fi 76 | elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 77 | export CXX=clang++ CC=clang; 78 | fi 79 | install: 80 | # depedency installation 81 | # Define the version of miniconda to download 82 | - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then 83 | MINCONDA_OS=$MINCONDA_LINUX; 84 | elif [[ "$TRAVIS_OS_NAME" == "osx" ]]; then 85 | MINCONDA_OS=$MINCONDA_OSX; 86 | fi 87 | - wget "http://repo.continuum.io/miniconda/Miniconda3-$MINCONDA_VERSION-$MINCONDA_OS.sh" -O miniconda.sh; 88 | - bash miniconda.sh -b -p $HOME/miniconda 89 | - export PATH="$HOME/miniconda/bin:$PATH" 90 | - hash -r 91 | - conda config --set always_yes yes --set changeps1 no 92 | - conda update -q conda 93 | 94 | # create enviroment 95 | - conda env create -f {{cookiecutter.package_name}}-dev-requirements.yml 96 | 97 | 98 | script: 99 | # build step 100 | # activate 101 | - source activate {{cookiecutter.package_name}}-dev-requirements 102 | 103 | - mkdir build 104 | - cd build 105 | - cmake .. 106 | - make -j2 107 | - make cpp-test 108 | {% if cookiecutter.python_bindings == 'yes' -%} 109 | - make python-test 110 | {% endif %} 111 | # test the actual test-suite 112 | - cd test 113 | - ./test_{{cookiecutter.cmake_project_name}} 114 | - cd .. 115 | # test the examples 116 | - cd examples 117 | - ./hello_world 118 | - cd .. 119 | # test the benchmark 120 | - cd benchmark 121 | - ./benchmark_{{cookiecutter.cmake_project_name}} 122 | - cd .. 123 | # # test the conda recipe 124 | # - cd .. 125 | # - conda config --set anaconda_upload no 126 | # - conda build recipe 127 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 3.1) 3 | set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) 4 | project ({{cookiecutter.cmake_project_name}}) 5 | 6 | 7 | set(PROJECT_INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include) 8 | set(CPP_ROOT_FOLDER_NAME {{cookiecutter.cpp_root_folder_name}}) 9 | include_directories(${PROJECT_INCLUDE_DIR}) 10 | 11 | {% if cookiecutter.cpp_standart == 'C++14' -%} 12 | # C++ 14 13 | # =========== 14 | include(CheckCXXCompilerFlag) 15 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") 16 | CHECK_CXX_COMPILER_FLAG("-std=c++14" HAS_CPP14_FLAG) 17 | if (HAS_CPP14_FLAG) 18 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14") 19 | else() 20 | message(FATAL_ERROR "Unsupported compiler -- C++14 support required!") 21 | endif() 22 | endif() 23 | {% elif cookiecutter.cpp_standart == 'C++11' -%} 24 | include(CheckCXXCompilerFlag) 25 | if (CMAKE_CXX_COMPILER_ID MATCHES "Clang" OR CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Intel") 26 | CHECK_CXX_COMPILER_FLAG("-std=c++11" HAS_CPP11_FLAG) 27 | if (HAS_CPP11_FLAG) 28 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 29 | else() 30 | message(FATAL_ERROR "Unsupported compiler -- C++11 support required!") 31 | endif() 32 | endif() 33 | {% elif cookiecutter.cpp_standart == 'NotSpecified' -%} 34 | {% endif %} 35 | 36 | # Versionning 37 | # =========== 38 | set(CPP_CONFIG_HEADER_NAME {{ cookiecutter.package_name}}_config.hpp) 39 | set(PROJECT_CONFIG_FILE ${PROJECT_INCLUDE_DIR}/${CPP_ROOT_FOLDER_NAME}/${CPP_CONFIG_HEADER_NAME}) 40 | 41 | file(STRINGS ${PROJECT_CONFIG_FILE} project_version_defines 42 | REGEX "#define {{cookiecutter.cpp_macro_prefix}}_VERSION_(MAJOR|MINOR|PATCH)") 43 | message(STATUS ${PROJECT_CONFIG_FILE}) 44 | 45 | foreach(ver ${project_version_defines}) 46 | if(ver MATCHES "#define {{cookiecutter.cpp_macro_prefix}}_VERSION_(MAJOR|MINOR|PATCH) +([^ ]+)$") 47 | set(${PROJECT_NAME}_VERSION_${CMAKE_MATCH_1} "${CMAKE_MATCH_2}" CACHE INTERNAL "") 48 | endif() 49 | endforeach() 50 | 51 | set(${PROJECT_NAME}_VERSION 52 | ${${PROJECT_NAME}_VERSION_MAJOR}.${${PROJECT_NAME}_VERSION_MINOR}.${${PROJECT_NAME}_VERSION_PATCH}) 53 | message(STATUS "Building project v${${PROJECT_NAME}_VERSION}") 54 | 55 | # Dependencies 56 | # ============ 57 | find_package(xtl REQUIRED) 58 | find_package(xtensor REQUIRED) 59 | 60 | # # Build 61 | # # ===== 62 | 63 | 64 | SET(INTERFACE_LIB_NAME {{cookiecutter.cmake_interface_library_name}}) 65 | 66 | 67 | 68 | file(GLOB_RECURSE ${PROJECT_NAME}_HEADERS ${PROJECT_INCLUDE_DIR}/*.hpp) 69 | 70 | 71 | add_library(${INTERFACE_LIB_NAME} INTERFACE) 72 | 73 | message(STATUS "INSTALL_INTERFACE: ${CMAKE_INSTALL_INCLUDEDIR}") 74 | target_include_directories(${INTERFACE_LIB_NAME} INTERFACE 75 | $ 76 | $) 77 | 78 | 79 | 80 | target_link_libraries(${INTERFACE_LIB_NAME} 81 | INTERFACE xtensor) 82 | 83 | 84 | 85 | # Benchmark 86 | # ============ 87 | OPTION(BUILD_DOCS "build docs" ON) 88 | 89 | OPTION(BUILD_BENCHMARK "${PROJECT_NAME} test suite" ON) 90 | OPTION(DOWNLOAD_GOOGLE_BENCHMARK "build google benchmark from downloaded sources" ON) 91 | 92 | if(DOWNLOAD_GOOGLE_BENCHMARK) 93 | set(BUILD_BENCHMARK ON) 94 | endif() 95 | 96 | if(BUILD_BENCHMARK) 97 | add_subdirectory(benchmark) 98 | endif() 99 | 100 | if(BUILD_DOCS) 101 | add_subdirectory(docs) 102 | endif() 103 | 104 | {% if cookiecutter.python_bindings == 'yes' -%} 105 | # Python 106 | # ============ 107 | OPTION(BUILD_PYTHON "${PROJECT_NAME} python binding" ON) 108 | if(BUILD_PYTHON) 109 | add_subdirectory(python) 110 | endif() 111 | {% endif %} 112 | 113 | 114 | # Tests 115 | ########### 116 | 117 | OPTION(BUILD_TESTS "${PROJECT_NAME} test suite" ON) 118 | # OPTION(DOWNLOAD_DOCTEST "build doctest from downloaded sources" ON) 119 | 120 | # if(DOWNLOAD_DOCTEST) 121 | # set(BUILD_TESTS ON) 122 | # endif() 123 | 124 | if(BUILD_TESTS) 125 | add_subdirectory(test) 126 | endif() 127 | 128 | # Examples 129 | # ============ 130 | OPTION(BUILD_EXAMPLES "${PROJECT_NAME} test suite" ON) 131 | 132 | 133 | if(BUILD_EXAMPLES) 134 | add_subdirectory(examples) 135 | endif() 136 | 137 | 138 | 139 | # Installation 140 | # ============ 141 | 142 | include(GNUInstallDirs) 143 | include(CMakePackageConfigHelpers) 144 | 145 | 146 | set(${PROJECT_NAME}_CMAKECONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" CACHE 147 | STRING "install path for ${PROJECT_NAME}Config.cmake") 148 | 149 | 150 | message(STATUS "DEST ${${PROJECT_NAME}_CMAKECONFIG_INSTALL_DIR}" ) 151 | 152 | 153 | install(TARGETS ${INTERFACE_LIB_NAME} 154 | EXPORT ${INTERFACE_LIB_NAME}-targets) 155 | 156 | install(EXPORT ${INTERFACE_LIB_NAME}-targets 157 | FILE ${INTERFACE_LIB_NAME}Targets.cmake 158 | #NAMESPACE ${PROJECT_NAME}:: 159 | DESTINATION lib/cmake/${PROJECT_NAME} 160 | ) 161 | 162 | 163 | install(DIRECTORY ${PROJECT_INCLUDE_DIR}/${CPP_ROOT_FOLDER_NAME} 164 | DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) 165 | 166 | 167 | 168 | 169 | configure_package_config_file(${PROJECT_NAME}Config.cmake.in 170 | "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake" 171 | INSTALL_DESTINATION ${${PROJECT_NAME}_CMAKECONFIG_INSTALL_DIR}) 172 | 173 | 174 | # ${PROJECT_NAME} is header-only and does not depend on the architecture. 175 | # Remove CMAKE_SIZEOF_VOID_P from ${PROJECT_NAME}ConfigVersion.cmake so that an ${PROJECT_NAME}Config.cmake 176 | # generated for a 64 bit target can be used for 32 bit targets and vice versa. 177 | set(_${PROJECT_NAME}_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P}) 178 | unset(CMAKE_SIZEOF_VOID_P) 179 | write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake 180 | VERSION ${${PROJECT_NAME}_VERSION} 181 | COMPATIBILITY AnyNewerVersion) 182 | set(CMAKE_SIZEOF_VOID_P ${_${PROJECT_NAME}_CMAKE_SIZEOF_VOID_P}) 183 | install(FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.cmake 184 | ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake 185 | DESTINATION ${${PROJECT_NAME}_CMAKECONFIG_INSTALL_DIR}) 186 | 187 | install(EXPORT ${PROJECT_NAME}-targets 188 | FILE ${PROJECT_NAME}Targets.cmake 189 | DESTINATION ${${PROJECT_NAME}_CMAKECONFIG_INSTALL_DIR}) 190 | 191 | configure_file(${PROJECT_NAME}.pc.in 192 | "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" 193 | @ONLY) 194 | install(FILES "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc" 195 | DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig/") 196 | 197 | 198 | 199 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/CONTRIBUTING.rst: -------------------------------------------------------------------------------- 1 | .. highlight:: shell 2 | 3 | ============ 4 | Contributing 5 | ============ 6 | 7 | Contributions are welcome, and they are greatly appreciated! Every 8 | little bit helps, and credit will always be given. 9 | 10 | You can contribute in many ways: 11 | 12 | Types of Contributions 13 | ---------------------- 14 | 15 | Report Bugs 16 | ~~~~~~~~~~~ 17 | 18 | Report bugs at https://github.com/{{cookiecutter.github_user_name}}/{{cookiecutter.github_project_name}}/issues. 19 | 20 | If you are reporting a bug, please include: 21 | 22 | * Your operating system name and version. 23 | * Any details about your local setup that might be helpful in troubleshooting. 24 | * Detailed steps to reproduce the bug. 25 | 26 | Fix Bugs 27 | ~~~~~~~~ 28 | 29 | Look through the GitHub issues for bugs. Anything tagged with "bug" 30 | and "help wanted" is open to whoever wants to implement it. 31 | 32 | Implement Features 33 | ~~~~~~~~~~~~~~~~~~ 34 | 35 | Look through the GitHub issues for features. Anything tagged with "enhancement" 36 | and "help wanted" is open to whoever wants to implement it. 37 | 38 | Write Documentation 39 | ~~~~~~~~~~~~~~~~~~~ 40 | 41 | {{cookiecutter.project_name}} could always use more documentation, whether as part of the 42 | official {{cookiecutter.project_name}} docs, in docstrings, or even on the web in blog posts, 43 | articles, and such. 44 | 45 | Submit Feedback 46 | ~~~~~~~~~~~~~~~ 47 | 48 | The best way to send feedback is to file an issue at https://github.com/{{cookiecutter.github_user_name}}/{{cookiecutter.github_project_name}}/issues. 49 | 50 | If you are proposing a feature: 51 | 52 | * Explain in detail how it would work. 53 | * Keep the scope as narrow as possible, to make it easier to implement. 54 | * Remember that this is a volunteer-driven project, and that contributions 55 | are welcome :) 56 | 57 | 58 | 59 | Pull Request Guidelines 60 | ----------------------- 61 | 62 | Before you submit a pull request, check that it meets these guidelines: 63 | 64 | 1. The pull request should include tests. 65 | 2. If the pull request adds functionality, the docs should be updated. Put 66 | your new functionality into a function / classes with a proper documentation, and add the 67 | feature to the list in README.rst. -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/LICENCE.txt: -------------------------------------------------------------------------------- 1 | 2 | {% if cookiecutter.open_source_license == 'MIT license' -%} 3 | MIT License 4 | 5 | Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notice and this permission notice shall be included in all 15 | copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | SOFTWARE. 24 | {% elif cookiecutter.open_source_license == 'BSD license' %} 25 | 26 | BSD License 27 | 28 | Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} 29 | All rights reserved. 30 | 31 | Redistribution and use in source and binary forms, with or without modification, 32 | are permitted provided that the following conditions are met: 33 | 34 | * Redistributions of source code must retain the above copyright notice, this 35 | list of conditions and the following disclaimer. 36 | 37 | * Redistributions in binary form must reproduce the above copyright notice, this 38 | list of conditions and the following disclaimer in the documentation and/or 39 | other materials provided with the distribution. 40 | 41 | * Neither the name of the copyright holder nor the names of its 42 | contributors may be used to endorse or promote products derived from this 43 | software without specific prior written permission. 44 | 45 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 46 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 47 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 48 | IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 49 | INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 50 | BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 51 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 52 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE 53 | OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 54 | OF THE POSSIBILITY OF SUCH DAMAGE. 55 | {% elif cookiecutter.open_source_license == 'ISC license' -%} 56 | ISC License 57 | 58 | Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} 59 | 60 | Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies. 61 | 62 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. 63 | {% elif cookiecutter.open_source_license == 'Apache Software License 2.0' -%} 64 | Apache Software License 2.0 65 | 66 | Copyright (c) {% now 'local', '%Y' %}, {{ cookiecutter.full_name }} 67 | 68 | Licensed under the Apache License, Version 2.0 (the "License"); 69 | you may not use this file except in compliance with the License. 70 | You may obtain a copy of the License at 71 | 72 | http://www.apache.org/licenses/LICENSE-2.0 73 | 74 | Unless required by applicable law or agreed to in writing, software 75 | distributed under the License is distributed on an "AS IS" BASIS, 76 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 77 | See the License for the specific language governing permissions and 78 | limitations under the License. 79 | {% elif cookiecutter.open_source_license == 'GNU General Public License v3' -%} 80 | GNU GENERAL PUBLIC LICENSE 81 | Version 3, 29 June 2007 82 | 83 | {{ cookiecutter.summary }} 84 | Copyright (C) {% now 'local', '%Y' %} {{ cookiecutter.full_name }} 85 | 86 | This program is free software: you can redistribute it and/or modify 87 | it under the terms of the GNU General Public License as published by 88 | the Free Software Foundation, either version 3 of the License, or 89 | (at your option) any later version. 90 | 91 | This program is distributed in the hope that it will be useful, 92 | but WITHOUT ANY WARRANTY; without even the implied warranty of 93 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 94 | GNU General Public License for more details. 95 | 96 | You should have received a copy of the GNU General Public License 97 | along with this program. If not, see . 98 | 99 | Also add information on how to contact you by electronic and paper mail. 100 | 101 | You should also get your employer (if you work as a programmer) or school, 102 | if any, to sign a "copyright disclaimer" for the program, if necessary. 103 | For more information on this, and how to apply and follow the GNU GPL, see 104 | . 105 | 106 | The GNU General Public License does not permit incorporating your program 107 | into proprietary programs. If your program is a subroutine library, you 108 | may consider it more useful to permit linking proprietary applications with 109 | the library. If this is what you want to do, use the GNU Lesser General 110 | Public License instead of this License. But first, please read 111 | . 112 | {% endif %} -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/README.rst: -------------------------------------------------------------------------------- 1 | ================================================= 2 | {{cookiecutter.project_name}} 3 | ================================================= 4 | 5 | .. image:: https://readthedocs.org/projects/{{cookiecutter.readthedocs_package_name}}/badge/?version=latest 6 | :target: http://{{cookiecutter.readthedocs_package_name}}.readthedocs.io/en/latest/?badge=latest 7 | :alt: Documentation Status 8 | 9 | .. image:: https://img.shields.io/travis/{{cookiecutter.github_user_name}}/{{cookiecutter.github_project_name}}.svg 10 | :target: https://travis-ci.org/{{cookiecutter.github_user_name}}/{{cookiecutter.github_project_name}} 11 | 12 | .. image:: https://travis-ci.org/{{cookiecutter.github_user_name}}/{{cookiecutter.github_project_name}}.svg?branch=master 13 | :target: https://travis-ci.org/{{cookiecutter.github_user_name}}/{{cookiecutter.github_project_name}} 14 | 15 | .. image:: https://circleci.com/gh/{{cookiecutter.github_user_name}}/{{cookiecutter.github_project_name}}/tree/master.svg?style=svg 16 | :target: https://circleci.com/gh/{{cookiecutter.github_user_name}}/{{cookiecutter.github_project_name}}/tree/master 17 | 18 | .. image:: https://dev.azure.com/{{cookiecutter.azure_user_name}}/{{cookiecutter.github_project_name}}/_apis/build/status/{{cookiecutter.github_user_name}}.{{cookiecutter.github_project_name}}?branchName=master 19 | :target: https://dev.azure.com/{{cookiecutter.azure_user_name}}/{{cookiecutter.github_project_name}}/_build/latest?definitionId=1&branchName=master 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | Features 29 | -------- 30 | 31 | Current features include: 32 | * modern C++ 14 33 | * build system with modernish CMake 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/azure-pipelines.yml: -------------------------------------------------------------------------------- 1 | # Pipelines are made of one or more jobs and may include resources and variables. 2 | # Jobs are made of one or more steps plus some job-specific data. Steps can be 3 | # tasks, scripts, or references to external templates. 4 | 5 | jobs: 6 | - job: Linux 7 | pool: 8 | vmImage: 'ubuntu-16.04' 9 | strategy: 10 | maxParallel: 2 11 | # matrix: 12 | # py36: 13 | # PY_VERSION: 3.6 14 | # py37: 15 | # PY_VERSION: 3.7 16 | variables: 17 | repoDir: '$(Build.Repository.LocalPath)' 18 | 19 | steps: 20 | # NOTE: On Linux, there is no write permission in the miniconda installation, 21 | # and the CondaEnvironment@1 does not honor a prefix. Therefore we can *not* 22 | # use the conda that comes with Azure as we do on Windows. This is also 23 | # documented in the following issue: https://github.com/Microsoft/vsts-tasks/issues/8299 24 | # Therefore we need to create our own conda environment from scratch. 25 | - task: CondaEnvironment@1 26 | inputs: 27 | updateConda: false 28 | - script: | 29 | conda config --set always_yes yes --set changeps1 no || exit 1 30 | conda update -q conda || exit 1 31 | conda env create -f {{cookiecutter.package_name}}-dev-requirements.yml || exit 1 32 | source activate {{cookiecutter.package_name}}-dev-requirements || exit 1 33 | mkdir build || exit 1 34 | cd build || exit 1 35 | cmake .. || exit 1 36 | make -j2 || exit 1 37 | make cpp-test || exit 1 38 | {% if cookiecutter.python_bindings == 'yes' -%} 39 | make python-test || exit 1 40 | {% endif %} 41 | echo "run cpp example" || exit 1 42 | cd examples || exit 1 43 | ./hello_world || exit 1 44 | cd .. || exit 1 45 | echo "run cpp benchmark" || exit 1 46 | cd benchmark || exit 1 47 | ./benchmark_{{cookiecutter.cmake_project_name}} || exit 1 48 | cd .. || exit 1 49 | echo "Completed script successfully" || exit 1 50 | 51 | 52 | - job: macOS 53 | pool: 54 | vmImage: 'xcode9-macos10.13' 55 | strategy: 56 | maxParallel: 2 57 | # matrix: 58 | # py36: 59 | # PY_VERSION: 3.6 60 | # py37: 61 | # PY_VERSION: 3.7 62 | variables: 63 | repoDir: '$(Build.Repository.LocalPath)' 64 | steps: 65 | - bash: echo "##vso[task.prependpath]$CONDA/bin" 66 | displayName: Add conda to PATH 67 | 68 | - script: | 69 | conda config --set always_yes yes --set changeps1 no || exit 1 70 | conda env create -f {{cookiecutter.package_name}}-dev-requirements.yml || exit 1 71 | echo "source conda env" || exit 1 72 | source activate {{cookiecutter.package_name}}-dev-requirements || exit 1 73 | mkdir build || exit 1 74 | cd build || exit 1 75 | echo "cmake" || exit 1 76 | cmake .. || exit 1 77 | echo "make" || exit 1 78 | make -j2 || exit 1 79 | {% if cookiecutter.python_bindings == 'yes' -%} 80 | make python-test || exit 1 81 | {% endif %} 82 | echo "Completed script successfully" || exit 1 83 | 84 | 85 | 86 | - job: 87 | displayName: vs2017-win2016 88 | pool: 89 | vmImage: 'vs2017-win2016' 90 | strategy: 91 | maxParallel: 2 92 | # matrix: 93 | # py36: 94 | # PY_VERSION: 3.6 95 | # VS_VERSION: 2015 96 | # # py27: 97 | # # PY_VERSION: 2.7 98 | variables: 99 | repoDir: '$(Build.Repository.LocalPath)' 100 | steps: 101 | - powershell: Write-Host "##vso[task.prependpath]$env:CONDA\Scripts" 102 | displayName: Add conda to PATH 103 | 104 | - script: | 105 | echo "create" 106 | conda env create -f {{cookiecutter.package_name}}-dev-requirements.yml 107 | echo "done" 108 | displayName: create dev requirements env 109 | 110 | - script: | 111 | echo "activate" || exit 1 112 | call activate {{cookiecutter.package_name}}-dev-requirements || exit 1 113 | echo "mkdir" || exit 1 114 | mkdir build || exit 1 115 | cd build || exit 1 116 | echo "cmake gen" || exit 1 117 | cmake .. -G"Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release ^ 118 | -DDEPENDENCY_SEARCH_PREFIX="%CONDA_PREFIX%\Library" -DCMAKE_PREFIX_PATH="%CONDA_PREFIX%\Library" || exit 1 119 | 120 | displayName: configure project 121 | - script: | 122 | echo "cd path" 123 | cd build 124 | echo "activate" 125 | call activate {{cookiecutter.package_name}}-dev-requirements 126 | cmake --build . --target ALL_BUILD 127 | 128 | displayName: build project 129 | - script: | 130 | echo "cd path" || exit 1 131 | cd build || exit 1 132 | echo "activate" || exit 1 133 | call activate {{cookiecutter.package_name}}-dev-requirements || exit 1 134 | echo "run tests" || exit 1 135 | cmake --build . --target python-test || exit 1 136 | cmake --build . --target cpp-test || exit 1 137 | 138 | displayName: run tests 139 | 140 | 141 | 142 | 143 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/benchmark/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(EVENT__DISABLE_TESTS ON) 2 | if(DOWNLOAD_GOOGLE_BENCHMARK OR GOOGLE_BENCHMARK_SRC_DIR) 3 | 4 | 5 | 6 | configure_file(downloadGBenchmark.cmake.in googlebenchmark-download/CMakeLists.txt) 7 | execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . 8 | RESULT_VARIABLE result 9 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googlebenchmark-download ) 10 | execute_process(COMMAND ${CMAKE_COMMAND} --build . 11 | RESULT_VARIABLE result 12 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googlebenchmark-download ) 13 | 14 | # Add googlebenchmark directly to our build. This defines 15 | # the gtest and gtest_main targets. 16 | add_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googlebenchmark-src 17 | ${CMAKE_CURRENT_BINARY_DIR}/googlebenchmark-build 18 | EXCLUDE_FROM_ALL) 19 | 20 | 21 | set(GBENCHMARK_INCLUDE_DIRS "${googlebenchmark_SOURCE_DIR}/include") 22 | set(GBENCHMARK_LIBRARIES benchmark) 23 | 24 | 25 | else() 26 | find_package(GOOGLE_BENCHMARK REQUIRED) 27 | endif() 28 | set(EVENT__DISABLE_TESTS OFF) 29 | 30 | file(GLOB_RECURSE ${PROJECT_NAME}_BENCHMARKS 31 | RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *.cpp) 32 | list(REMOVE_ITEM ${PROJECT_NAME}_BENCHMARKS main.cpp) 33 | set(${PROJECT_NAME}_BENCHMARK_TARGET benchmark_${PROJECT_NAME}) 34 | 35 | 36 | # all benchmarks 37 | set(${PROJECT_NAME}_BENCHMARKS 38 | benchmark_{{cookiecutter.cmake_project_name}}.cpp 39 | ) 40 | 41 | 42 | 43 | add_executable( ${${PROJECT_NAME}_BENCHMARK_TARGET} 44 | main.cpp 45 | ${${PROJECT_NAME}_BENCHMARKS} 46 | ) 47 | 48 | SET(BENCHMARK_INCLUDE_DIRS ${GBENCHMARK_INCLUDE_DIRS} ) 49 | target_include_directories( ${${PROJECT_NAME}_BENCHMARK_TARGET} PRIVATE 50 | "$" 51 | ) 52 | 53 | target_link_libraries( ${${PROJECT_NAME}_BENCHMARK_TARGET} 54 | ${INTERFACE_LIB_NAME} 55 | ${GBENCHMARK_LIBRARIES} 56 | xtensor 57 | ) 58 | 59 | if (NOT CMAKE_CXX_COMPILER_ID MATCHES "Clang" ) 60 | # if flags ffast-math is defined, __extern_always_inline 61 | # gives errors on clang 62 | target_compile_options(${${PROJECT_NAME}_BENCHMARK_TARGET} 63 | PRIVATE -ffast-math -Ofast -march=native -pthread) 64 | endif() -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/benchmark/benchmark_{{cookiecutter.cmake_project_name}}.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | #include 5 | 6 | // our headers 7 | #include "{{cookiecutter.cpp_root_folder_name}}/{{ cookiecutter.package_name}}.hpp" 8 | 9 | 10 | static void BM_SomeBenchmark(benchmark::State& state) 11 | { 12 | 13 | 14 | while (state.KeepRunning()) 15 | { 16 | std::string empty_string; 17 | } 18 | } 19 | // Register the function as a benchmark 20 | BENCHMARK(BM_SomeBenchmark); 21 | 22 | 23 | 24 | 25 | 26 | static void BM_SomeBenchmark2(benchmark::State& state) 27 | { 28 | std::size_t s = state.range(0); 29 | 30 | while (state.KeepRunning()) 31 | { 32 | benchmark::DoNotOptimize( 33 | std::vector(s) 34 | ); 35 | } 36 | } 37 | // Register the function as a benchmark 38 | // Now arguments generated are [ 8, 16, 32, 64, 128, 256, 512, 1024, 2k, 4k, 8k ]. 39 | BENCHMARK(BM_SomeBenchmark2)->RangeMultiplier(2)->Range(8, 8<<12); -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/benchmark/copyGBenchmark.cmake.in: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.2) 2 | 3 | project(googlebenchmark-download NONE) 4 | 5 | include(ExternalProject) 6 | ExternalProject_Add(benchmark 7 | URL "${googlebenchmark_SRC_DIR}" 8 | SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googlebenchmark-src" 9 | BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googlebenchmark-build" 10 | CONFIGURE_COMMAND "" 11 | BUILD_COMMAND "" 12 | INSTALL_COMMAND "" 13 | TEST_COMMAND "" 14 | ) -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/benchmark/downloadGBenchmark.cmake.in: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.2) 2 | 3 | project(googlebenchmark-download NONE) 4 | 5 | include(ExternalProject) 6 | ExternalProject_Add(googlebenchmark 7 | GIT_REPOSITORY https://github.com/google/benchmark.git 8 | GIT_TAG v1.2.0 9 | SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/googlebenchmark-src" 10 | BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/googlebenchmark-build" 11 | CONFIGURE_COMMAND "" 12 | BUILD_COMMAND "" 13 | INSTALL_COMMAND "" 14 | TEST_COMMAND "" 15 | ) -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/benchmark/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include 4 | 5 | 6 | int main(int argc, char** argv) 7 | { 8 | 9 | benchmark::Initialize(&argc, argv); 10 | if (benchmark::ReportUnrecognizedArguments(argc, argv)) return 1; 11 | benchmark::RunSpecifiedBenchmarks(); 12 | } 13 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/binder/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM {{cookiecutter.dockerhub_user_name}}/{{cookiecutter.dockerhub_project_name}}:v0.1.0 2 | 3 | 4 | ########################################## 5 | # BINDER 6 | ########################################## 7 | RUN pip install --no-cache-dir notebook==5.* 8 | 9 | ARG NB_USER=jovyan 10 | ARG NB_UID=1000 11 | ENV USER ${NB_USER} 12 | ENV NB_UID ${NB_UID} 13 | ENV HOME /home/${NB_USER} 14 | 15 | RUN adduser --disabled-password \ 16 | --gecos "Default user" \ 17 | --uid ${NB_UID} \ 18 | ${NB_USER} 19 | 20 | 21 | # Make sure the contents of our repo are in ${HOME} 22 | COPY . ${HOME} 23 | USER root 24 | RUN chown -R ${NB_UID} ${HOME} 25 | USER ${NB_USER} -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/cmake/modules/FindDOCTEST.cmake: -------------------------------------------------------------------------------- 1 | find_path(DOCTEST_INCLUDE_DIR doctest.h) 2 | 3 | include(FindPackageHandleStandardArgs) 4 | find_package_handle_standard_args(DOCTEST DEFAULT_MSG DOCTEST_INCLUDE_DIR) 5 | 6 | if(DOCTEST_FOUND) 7 | set(DOCTEST_INCLUDE_DIRS ${DOCTEST_INCLUDE_DIR}) 8 | endif(DOCTEST_FOUND) 9 | 10 | mark_as_advanced( DOCTEST_INCLUDE_DIR) 11 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/cmake/modules/FindNUMPY.cmake: -------------------------------------------------------------------------------- 1 | # Find the Python NumPy package 2 | # PYTHON_NUMPY_INCLUDE_DIR 3 | # NUMPY_FOUND 4 | # will be set by this script 5 | 6 | 7 | find_package(pybind11 REQUIRED) 8 | include_directories(${pybind11_INCLUDE_DIRS}) 9 | 10 | 11 | if(NUMPY_FIND_QUIETLY) 12 | find_package(PythonInterp) 13 | else() 14 | find_package(PythonInterp QUIET) 15 | set(_numpy_out 1) 16 | endif() 17 | 18 | if (PYTHON_EXECUTABLE) 19 | # write a python script that finds the numpy path 20 | file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/FindNumpyPath.py 21 | "from __future__ import print_function\n" 22 | "try: import numpy; print(numpy.get_include())\nexcept:pass\n") 23 | 24 | # execute the find script 25 | exec_program("${PYTHON_EXECUTABLE}" ${CMAKE_CURRENT_BINARY_DIR} 26 | ARGS "FindNumpyPath.py" 27 | OUTPUT_VARIABLE NUMPY_PATH) 28 | elseif(_numpy_out) 29 | message(STATUS "Python executable not found.") 30 | endif(PYTHON_EXECUTABLE) 31 | 32 | 33 | 34 | 35 | 36 | 37 | find_path(PYTHON_NUMPY_INCLUDE_DIR numpy/arrayobject.h 38 | "${NUMPY_PATH}" 39 | "${PYTHON_INCLUDE_PATH}" 40 | /usr/include/python2.7/ 41 | /usr/include/python2.6/ 42 | /usr/include/python2.5/ 43 | /usr/include/python2.4/) 44 | 45 | #message(STATUS "the numpy path is: ${NUMPY_PATH}") 46 | 47 | if(PYTHON_NUMPY_INCLUDE_DIR) 48 | set(PYTHON_NUMPY_FOUND 1 CACHE INTERNAL "Python numpy found") 49 | endif(PYTHON_NUMPY_INCLUDE_DIR) 50 | 51 | #include(FindPackageHandleStandardArgs) 52 | find_package_handle_standard_args( NUMPY DEFAULT_MSG PYTHON_NUMPY_INCLUDE_DIR) -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/cmake/modules/FindSphinx.cmake: -------------------------------------------------------------------------------- 1 | # - This module looks for Sphinx 2 | # Find the Sphinx documentation generator 3 | # 4 | # This modules defines 5 | # SPHINX_EXECUTABLE 6 | # SPHINX_FOUND 7 | 8 | set(_python_paths ) 9 | if(PYTHON_EXECUTABLE) 10 | get_filename_component(_python_dir "${PYTHON_EXECUTABLE}" DIRECTORY) 11 | list(APPEND _python_paths 12 | "${_python_dir}" 13 | "${_python_dir}/Scripts" 14 | ) 15 | endif() 16 | 17 | 18 | find_program(SPHINX_EXECUTABLE 19 | NAMES 20 | sphinx-build sphinx-build.exe 21 | HINTS 22 | ${_python_paths} 23 | PATHS 24 | /usr/bin 25 | /usr/local/bin 26 | /opt/local/bin 27 | DOC "Sphinx documentation generator" 28 | ) 29 | 30 | if( NOT SPHINX_EXECUTABLE ) 31 | set(_Python_VERSIONS 32 | 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0 1.6 1.5 33 | ) 34 | 35 | foreach( _version ${_Python_VERSIONS} ) 36 | set( _sphinx_NAMES sphinx-build-${_version} ) 37 | 38 | find_program( SPHINX_EXECUTABLE 39 | NAMES ${_sphinx_NAMES} 40 | PATHS 41 | /usr/bin 42 | /usr/local/bin 43 | /opt/loca/bin 44 | DOC "Sphinx documentation generator" 45 | ) 46 | endforeach() 47 | endif() 48 | 49 | include(FindPackageHandleStandardArgs) 50 | 51 | find_package_handle_standard_args(Sphinx DEFAULT_MSG 52 | SPHINX_EXECUTABLE 53 | ) 54 | 55 | 56 | option( SPHINX_HTML_OUTPUT "Build a single HTML with the whole content." ON ) 57 | option( SPHINX_DIRHTML_OUTPUT "Build HTML pages, but with a single directory per document." OFF ) 58 | option( SPHINX_HTMLHELP_OUTPUT "Build HTML pages with additional information for building a documentation collection in htmlhelp." OFF ) 59 | option( SPHINX_QTHELP_OUTPUT "Build HTML pages with additional information for building a documentation collection in qthelp." OFF ) 60 | option( SPHINX_DEVHELP_OUTPUT "Build HTML pages with additional information for building a documentation collection in devhelp." OFF ) 61 | option( SPHINX_EPUB_OUTPUT "Build HTML pages with additional information for building a documentation collection in epub." OFF ) 62 | option( SPHINX_LATEX_OUTPUT "Build LaTeX sources that can be compiled to a PDF document using pdflatex." OFF ) 63 | option( SPHINX_MAN_OUTPUT "Build manual pages in groff format for UNIX systems." OFF ) 64 | option( SPHINX_TEXT_OUTPUT "Build plain text files." OFF ) 65 | 66 | 67 | mark_as_advanced( 68 | SPHINX_EXECUTABLE 69 | SPHINX_HTML_OUTPUT 70 | SPHINX_DIRHTML_OUTPUT 71 | SPHINX_HTMLHELP_OUTPUT 72 | SPHINX_QTHELP_OUTPUT 73 | SPHINX_DEVHELP_OUTPUT 74 | SPHINX_EPUB_OUTPUT 75 | SPHINX_LATEX_OUTPUT 76 | SPHINX_MAN_OUTPUT 77 | SPHINX_TEXT_OUTPUT 78 | ) 79 | 80 | function( Sphinx_add_target target_name builder conf source destination ) 81 | add_custom_target( ${target_name} ALL 82 | COMMAND ${SPHINX_EXECUTABLE} -b ${builder} 83 | -c ${conf} 84 | ${source} 85 | ${destination} 86 | COMMENT "Generating sphinx documentation: ${builder}" 87 | ) 88 | 89 | set_property( 90 | DIRECTORY APPEND PROPERTY 91 | ADDITIONAL_MAKE_CLEAN_FILES 92 | ${destination} 93 | ) 94 | endfunction() 95 | 96 | # Target dependencies can be optionally listed at the end. 97 | function( Sphinx_add_targets target_base_name conf source base_destination ) 98 | 99 | set( _dependencies ) 100 | 101 | foreach( arg IN LISTS ARGN ) 102 | set( _dependencies ${_dependencies} ${arg} ) 103 | endforeach() 104 | 105 | if( ${SPHINX_HTML_OUTPUT} ) 106 | Sphinx_add_target( ${target_base_name}_html html ${conf} ${source} ${base_destination}/html ) 107 | 108 | add_dependencies( ${target_base_name}_html ${_dependencies} ) 109 | endif() 110 | 111 | if( ${SPHINX_DIRHTML_OUTPUT} ) 112 | Sphinx_add_target( ${target_base_name}_dirhtml dirhtml ${conf} ${source} ${base_destination}/dirhtml ) 113 | 114 | add_dependencies( ${target_base_name}_dirhtml ${_dependencies} ) 115 | endif() 116 | 117 | if( ${SPHINX_QTHELP_OUTPUT} ) 118 | Sphinx_add_target( ${target_base_name}_qthelp qthelp ${conf} ${source} ${base_destination}/qthelp ) 119 | 120 | add_dependencies( ${target_base_name}_qthelp ${_dependencies} ) 121 | endif() 122 | 123 | if( ${SPHINX_DEVHELP_OUTPUT} ) 124 | Sphinx_add_target( ${target_base_name}_devhelp devhelp ${conf} ${source} ${base_destination}/devhelp ) 125 | 126 | add_dependencies( ${target_base_name}_devhelp ${_dependencies} ) 127 | endif() 128 | 129 | if( ${SPHINX_EPUB_OUTPUT} ) 130 | Sphinx_add_target( ${target_base_name}_epub epub ${conf} ${source} ${base_destination}/epub ) 131 | 132 | add_dependencies( ${target_base_name}_epub ${_dependencies} ) 133 | endif() 134 | 135 | if( ${SPHINX_LATEX_OUTPUT} ) 136 | Sphinx_add_target( ${target_base_name}_latex latex ${conf} ${source} ${base_destination}/latex ) 137 | 138 | add_dependencies( ${target_base_name}_latex ${_dependencies} ) 139 | endif() 140 | 141 | if( ${SPHINX_MAN_OUTPUT} ) 142 | Sphinx_add_target( ${target_base_name}_man man ${conf} ${source} ${base_destination}/man ) 143 | 144 | add_dependencies( ${target_base_name}_man ${_dependencies} ) 145 | endif() 146 | 147 | if( ${SPHINX_TEXT_OUTPUT} ) 148 | Sphinx_add_target( ${target_base_name}_text text ${conf} ${source} ${base_destination}/text ) 149 | 150 | add_dependencies( ${target_base_name}_text ${_dependencies} ) 151 | endif() 152 | 153 | if( ${BUILD_TESTING} ) 154 | sphinx_add_target( ${target_base_name}_linkcheck linkcheck ${conf} ${source} ${base_destination}/linkcheck ) 155 | 156 | add_dependencies( ${target_base_name}_linkcheck ${_dependencies} ) 157 | endif() 158 | endfunction() 159 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM continuumio/anaconda3:5.0.1 2 | 3 | # install sys requirements 4 | RUN apt-get update 5 | RUN apt-get install -y build-essential git 6 | 7 | # clone in repo 8 | RUN git clone https://github.com/{{cookiecutter.github_user_name}}/{{cookiecutter.github_project_name}} 9 | 10 | # update conda 11 | RUN conda update --yes conda 12 | 13 | # go into repo 14 | RUN cd {{cookiecutter.github_project_name}} && conda env create -f {{cookiecutter.package_name}}-dev-requirements.yml 15 | 16 | # activate 17 | RUN echo "source activate {{cookiecutter.package_name}}-dev-requirements" > ~/.bash 18 | ENV PATH /opt/conda/envs/{{cookiecutter.package_name}}-dev-requirements/bin:$PATH 19 | 20 | # activate 21 | #RUN conda activate {{cookiecutter.github_project_name}}-dev-requirements 22 | 23 | # make build dir 24 | RUN cd {{cookiecutter.github_project_name}} && mkdir build 25 | 26 | # run cmake 27 | RUN cd {{cookiecutter.github_project_name}}/build && \ 28 | cmake .. -DCMAKE_INSTALL_PREFIX=$(conda info --base)/envs/{{cookiecutter.github_project_name}}-dev-requirements 29 | 30 | # build and install project 31 | RUN cd {{cookiecutter.github_project_name}}/build && \ 32 | make -j2 install -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(COPY ${CMAKE_SOURCE_DIR}/docs DESTINATION ${CMAKE_BINARY_DIR}/docs_bld) 2 | 3 | 4 | set(PY_MOD_NAME {{cookiecutter.python_package_name}} ) 5 | set(PY_MOD_LIB_NAME _${PY_MOD_NAME}) 6 | set(PYTHON_TMP_MODULE_DIR ${CMAKE_BINARY_DIR}/python/module) 7 | set(INCLUDE_PATH ${CMAKE_SOURCE_DIR}/include) 8 | 9 | configure_file( 10 | ${CMAKE_SOURCE_DIR}/docs/source/cmake_path.py.in 11 | ${CMAKE_BINARY_DIR}/docs_bld/docs/source/cmake_path.py 12 | ) 13 | 14 | find_package(Sphinx REQUIRED) 15 | 16 | if(NOT DEFINED SPHINX_THEME) 17 | set(SPHINX_THEME default) 18 | endif() 19 | 20 | if(NOT DEFINED SPHINX_THEME_DIR) 21 | set(SPHINX_THEME_DIR) 22 | endif() 23 | 24 | 25 | 26 | # configured documentation tools and intermediate build results 27 | set(BINARY_BUILD_DIR "${CMAKE_BINARY_DIR}/docs_bld/docs/source") 28 | 29 | # Sphinx cache with pickled ReST documents 30 | set(SPHINX_CACHE_DIR "${CMAKE_BINARY_DIR}/docs_bld/docs/_doctrees") 31 | 32 | # HTML output directory 33 | set(SPHINX_HTML_DIR "${CMAKE_BINARY_DIR}/docs_bld/html") 34 | 35 | add_custom_target(docs 36 | ${SPHINX_EXECUTABLE} 37 | -q -b html 38 | -c "${BINARY_BUILD_DIR}" 39 | -d "${SPHINX_CACHE_DIR}" 40 | "${CMAKE_BINARY_DIR}/docs_bld/docs/source" 41 | "${SPHINX_HTML_DIR}" 42 | COMMENT "Building HTML documentation with Sphinx") 43 | 44 | add_dependencies(docs ${PY_MOD_LIB_NAME}) -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/Doxyfile: -------------------------------------------------------------------------------- 1 | PROJECT_NAME = "{{cookiecutter.project_name}}" 2 | XML_OUTPUT = xml 3 | INPUT = ../include 4 | GENERATE_LATEX = NO 5 | GENERATE_MAN = NO 6 | GENERATE_RTF = NO 7 | CASE_SENSE_NAMES = NO 8 | GENERATE_HTML = NO 9 | GENERATE_XML = YES 10 | RECURSIVE = YES 11 | QUIET = YES 12 | JAVADOC_AUTOBRIEF = YES 13 | WARN_IF_UNDOCUMENTED = NO 14 | MACRO_EXPANSION = YES 15 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/Makefile: -------------------------------------------------------------------------------- 1 | # You can set these variables from the command line. 2 | SPHINXOPTS = 3 | SPHINXBUILD = sphinx-build 4 | PAPER = 5 | BUILDDIR = build 6 | 7 | # User-friendly check for sphinx-build 8 | ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) 9 | $(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) 10 | endif 11 | 12 | # Internal variables. 13 | PAPEROPT_a4 = -D latex_paper_size=a4 14 | PAPEROPT_letter = -D latex_paper_size=letter 15 | ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 16 | # the i18n builder cannot share the environment and doctrees with the others 17 | I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source 18 | 19 | .PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext api 20 | 21 | default: html 22 | 23 | help: 24 | @echo "Please use \`make ' where is one of" 25 | @echo " html to make standalone HTML files" 26 | @echo " dirhtml to make HTML files named index.html in directories" 27 | @echo " singlehtml to make a single large HTML file" 28 | @echo " pickle to make pickle files" 29 | @echo " json to make JSON files" 30 | @echo " htmlhelp to make HTML files and a HTML help project" 31 | @echo " qthelp to make HTML files and a qthelp project" 32 | @echo " applehelp to make an Apple Help Book" 33 | @echo " devhelp to make HTML files and a Devhelp project" 34 | @echo " epub to make an epub" 35 | @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" 36 | @echo " latexpdf to make LaTeX files and run them through pdflatex" 37 | @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" 38 | @echo " text to make text files" 39 | @echo " man to make manual pages" 40 | @echo " texinfo to make Texinfo files" 41 | @echo " info to make Texinfo files and run them through makeinfo" 42 | @echo " gettext to make PO message catalogs" 43 | @echo " changes to make an overview of all changed/added/deprecated items" 44 | @echo " xml to make Docutils-native XML files" 45 | @echo " pseudoxml to make pseudoxml-XML files for display purposes" 46 | @echo " linkcheck to check all external links for integrity" 47 | @echo " doctest to run all doctests embedded in the documentation (if enabled)" 48 | @echo " coverage to run coverage check of the documentation (if enabled)" 49 | 50 | clean: 51 | rm -rf $(BUILDDIR)/* 52 | rm -rf xml 53 | 54 | html: 55 | doxygen 56 | $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html 57 | @echo 58 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." 59 | 60 | dirhtml: 61 | doxygen 62 | $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml 63 | @echo 64 | @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." 65 | 66 | singlehtml: 67 | doxygen 68 | $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml 69 | @echo 70 | @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." 71 | 72 | pickle: 73 | doxygen 74 | $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle 75 | @echo 76 | @echo "Build finished; now you can process the pickle files." 77 | 78 | json: 79 | doxygen 80 | $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json 81 | @echo 82 | @echo "Build finished; now you can process the JSON files." 83 | 84 | htmlhelp: 85 | doxygen 86 | $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp 87 | @echo 88 | @echo "Build finished; now you can run HTML Help Workshop with the" \ 89 | ".hhp project file in $(BUILDDIR)/htmlhelp." 90 | 91 | epub: 92 | doxygen 93 | $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub 94 | @echo 95 | @echo "Build finished. The epub file is in $(BUILDDIR)/epub." 96 | 97 | latex: 98 | doxygen 99 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 100 | @echo 101 | @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." 102 | @echo "Run \`make' in that directory to run these through (pdf)latex" \ 103 | "(use \`make latexpdf' here to do that automatically)." 104 | 105 | latexpdf: 106 | doxygen 107 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 108 | @echo "Running LaTeX files through pdflatex..." 109 | $(MAKE) -C $(BUILDDIR)/latex all-pdf 110 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 111 | 112 | latexpdfja: 113 | doxygen 114 | $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex 115 | @echo "Running LaTeX files through platex and dvipdfmx..." 116 | $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja 117 | @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." 118 | 119 | text: 120 | doxygen 121 | $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text 122 | @echo 123 | @echo "Build finished. The text files are in $(BUILDDIR)/text." 124 | 125 | man: 126 | doxygen 127 | $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man 128 | @echo 129 | @echo "Build finished. The manual pages are in $(BUILDDIR)/man." 130 | 131 | texinfo: 132 | doxygen 133 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 134 | @echo 135 | @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." 136 | @echo "Run \`make' in that directory to run these through makeinfo" \ 137 | "(use \`make info' here to do that automatically)." 138 | 139 | info: 140 | doxygen 141 | $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo 142 | @echo "Running Texinfo files through makeinfo..." 143 | make -C $(BUILDDIR)/texinfo info 144 | @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." 145 | 146 | gettext: 147 | doxygen 148 | $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale 149 | @echo 150 | @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." 151 | 152 | changes: 153 | doxygen 154 | $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes 155 | @echo 156 | @echo "The overview file is in $(BUILDDIR)/changes." 157 | 158 | linkcheck: 159 | doxygen 160 | $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck 161 | @echo 162 | @echo "Link check complete; look for any errors in the above output " \ 163 | "or in $(BUILDDIR)/linkcheck/output.txt." 164 | 165 | doctest: 166 | doxygen 167 | $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest 168 | @echo "Testing of doctests in the sources finished, look at the " \ 169 | "results in $(BUILDDIR)/doctest/output.txt." 170 | 171 | coverage: 172 | doxygen 173 | $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage 174 | @echo "Testing of coverage in the sources finished, look at the " \ 175 | "results in $(BUILDDIR)/coverage/python.txt." 176 | 177 | xml: 178 | doxygen 179 | $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml 180 | @echo 181 | @echo "Build finished. The XML files are in $(BUILDDIR)/xml." 182 | 183 | pseudoxml: 184 | doxygen 185 | $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml 186 | @echo 187 | @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." 188 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/make.bat: -------------------------------------------------------------------------------- 1 | @ECHO OFF 2 | 3 | REM Command file for Sphinx documentation 4 | 5 | if "%SPHINXBUILD%" == "" ( 6 | set SPHINXBUILD=sphinx-build 7 | ) 8 | set BUILDDIR=build 9 | set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source 10 | set I18NSPHINXOPTS=%SPHINXOPTS% source 11 | if NOT "%PAPER%" == "" ( 12 | set ALLSPHINXOPTS=-D latex_paper_size=%PAPER% %ALLSPHINXOPTS% 13 | set I18NSPHINXOPTS=-D latex_paper_size=%PAPER% %I18NSPHINXOPTS% 14 | ) 15 | 16 | if "%1" == "" goto help 17 | 18 | if "%1" == "help" ( 19 | :help 20 | echo.Please use `make ^` where ^ is one of 21 | echo. html to make standalone HTML files 22 | echo. dirhtml to make HTML files named index.html in directories 23 | echo. singlehtml to make a single large HTML file 24 | echo. pickle to make pickle files 25 | echo. json to make JSON files 26 | echo. htmlhelp to make HTML files and a HTML help project 27 | echo. qthelp to make HTML files and a qthelp project 28 | echo. devhelp to make HTML files and a Devhelp project 29 | echo. epub to make an epub 30 | echo. latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter 31 | echo. text to make text files 32 | echo. man to make manual pages 33 | echo. texinfo to make Texinfo files 34 | echo. gettext to make PO message catalogs 35 | echo. changes to make an overview over all changed/added/deprecated items 36 | echo. xml to make Docutils-native XML files 37 | echo. pseudoxml to make pseudoxml-XML files for display purposes 38 | echo. linkcheck to check all external links for integrity 39 | echo. doctest to run all doctests embedded in the documentation if enabled 40 | echo. coverage to run coverage check of the documentation if enabled 41 | goto end 42 | ) 43 | 44 | if "%1" == "clean" ( 45 | for /d %%i in (%BUILDDIR%\*) do rmdir /q /s %%i 46 | del /q /s %BUILDDIR%\* 47 | goto end 48 | ) 49 | 50 | 51 | REM Check if sphinx-build is available and fallback to Python version if any 52 | %SPHINXBUILD% 1>NUL 2>NUL 53 | if errorlevel 9009 goto sphinx_python 54 | goto sphinx_ok 55 | 56 | :sphinx_python 57 | 58 | set SPHINXBUILD=python -m sphinx.__init__ 59 | %SPHINXBUILD% 2> nul 60 | if errorlevel 9009 ( 61 | echo. 62 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx 63 | echo.installed, then set the SPHINXBUILD environment variable to point 64 | echo.to the full path of the 'sphinx-build' executable. Alternatively you 65 | echo.may add the Sphinx directory to PATH. 66 | echo. 67 | echo.If you don't have Sphinx installed, grab it from 68 | echo.http://sphinx-doc.org/ 69 | exit /b 1 70 | ) 71 | 72 | :sphinx_ok 73 | 74 | 75 | if "%1" == "html" ( 76 | doxygen 77 | %SPHINXBUILD% -b html %ALLSPHINXOPTS% %BUILDDIR%/html 78 | if errorlevel 1 exit /b 1 79 | echo. 80 | echo.Build finished. The HTML pages are in %BUILDDIR%/html. 81 | goto end 82 | ) 83 | 84 | if "%1" == "dirhtml" ( 85 | %SPHINXBUILD% -b dirhtml %ALLSPHINXOPTS% %BUILDDIR%/dirhtml 86 | if errorlevel 1 exit /b 1 87 | echo. 88 | echo.Build finished. The HTML pages are in %BUILDDIR%/dirhtml. 89 | goto end 90 | ) 91 | 92 | if "%1" == "singlehtml" ( 93 | %SPHINXBUILD% -b singlehtml %ALLSPHINXOPTS% %BUILDDIR%/singlehtml 94 | if errorlevel 1 exit /b 1 95 | echo. 96 | echo.Build finished. The HTML pages are in %BUILDDIR%/singlehtml. 97 | goto end 98 | ) 99 | 100 | if "%1" == "pickle" ( 101 | %SPHINXBUILD% -b pickle %ALLSPHINXOPTS% %BUILDDIR%/pickle 102 | if errorlevel 1 exit /b 1 103 | echo. 104 | echo.Build finished; now you can process the pickle files. 105 | goto end 106 | ) 107 | 108 | if "%1" == "json" ( 109 | %SPHINXBUILD% -b json %ALLSPHINXOPTS% %BUILDDIR%/json 110 | if errorlevel 1 exit /b 1 111 | echo. 112 | echo.Build finished; now you can process the JSON files. 113 | goto end 114 | ) 115 | 116 | if "%1" == "htmlhelp" ( 117 | %SPHINXBUILD% -b htmlhelp %ALLSPHINXOPTS% %BUILDDIR%/htmlhelp 118 | if errorlevel 1 exit /b 1 119 | echo. 120 | echo.Build finished; now you can run HTML Help Workshop with the ^ 121 | .hhp project file in %BUILDDIR%/htmlhelp. 122 | goto end 123 | ) 124 | 125 | if "%1" == "qthelp" ( 126 | %SPHINXBUILD% -b qthelp %ALLSPHINXOPTS% %BUILDDIR%/qthelp 127 | if errorlevel 1 exit /b 1 128 | echo. 129 | echo.Build finished; now you can run "qcollectiongenerator" with the ^ 130 | .qhcp project file in %BUILDDIR%/qthelp, like this: 131 | echo.^> qcollectiongenerator %BUILDDIR%\qthelp\packagename.qhcp 132 | echo.To view the help file: 133 | echo.^> assistant -collectionFile %BUILDDIR%\qthelp\packagename.ghc 134 | goto end 135 | ) 136 | 137 | if "%1" == "devhelp" ( 138 | %SPHINXBUILD% -b devhelp %ALLSPHINXOPTS% %BUILDDIR%/devhelp 139 | if errorlevel 1 exit /b 1 140 | echo. 141 | echo.Build finished. 142 | goto end 143 | ) 144 | 145 | if "%1" == "epub" ( 146 | %SPHINXBUILD% -b epub %ALLSPHINXOPTS% %BUILDDIR%/epub 147 | if errorlevel 1 exit /b 1 148 | echo. 149 | echo.Build finished. The epub file is in %BUILDDIR%/epub. 150 | goto end 151 | ) 152 | 153 | if "%1" == "latex" ( 154 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 155 | if errorlevel 1 exit /b 1 156 | echo. 157 | echo.Build finished; the LaTeX files are in %BUILDDIR%/latex. 158 | goto end 159 | ) 160 | 161 | if "%1" == "latexpdf" ( 162 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 163 | cd %BUILDDIR%/latex 164 | make all-pdf 165 | cd %~dp0 166 | echo. 167 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 168 | goto end 169 | ) 170 | 171 | if "%1" == "latexpdfja" ( 172 | %SPHINXBUILD% -b latex %ALLSPHINXOPTS% %BUILDDIR%/latex 173 | cd %BUILDDIR%/latex 174 | make all-pdf-ja 175 | cd %~dp0 176 | echo. 177 | echo.Build finished; the PDF files are in %BUILDDIR%/latex. 178 | goto end 179 | ) 180 | 181 | if "%1" == "text" ( 182 | %SPHINXBUILD% -b text %ALLSPHINXOPTS% %BUILDDIR%/text 183 | if errorlevel 1 exit /b 1 184 | echo. 185 | echo.Build finished. The text files are in %BUILDDIR%/text. 186 | goto end 187 | ) 188 | 189 | if "%1" == "man" ( 190 | %SPHINXBUILD% -b man %ALLSPHINXOPTS% %BUILDDIR%/man 191 | if errorlevel 1 exit /b 1 192 | echo. 193 | echo.Build finished. The manual pages are in %BUILDDIR%/man. 194 | goto end 195 | ) 196 | 197 | if "%1" == "texinfo" ( 198 | %SPHINXBUILD% -b texinfo %ALLSPHINXOPTS% %BUILDDIR%/texinfo 199 | if errorlevel 1 exit /b 1 200 | echo. 201 | echo.Build finished. The Texinfo files are in %BUILDDIR%/texinfo. 202 | goto end 203 | ) 204 | 205 | if "%1" == "gettext" ( 206 | %SPHINXBUILD% -b gettext %I18NSPHINXOPTS% %BUILDDIR%/locale 207 | if errorlevel 1 exit /b 1 208 | echo. 209 | echo.Build finished. The message catalogs are in %BUILDDIR%/locale. 210 | goto end 211 | ) 212 | 213 | if "%1" == "changes" ( 214 | %SPHINXBUILD% -b changes %ALLSPHINXOPTS% %BUILDDIR%/changes 215 | if errorlevel 1 exit /b 1 216 | echo. 217 | echo.The overview file is in %BUILDDIR%/changes. 218 | goto end 219 | ) 220 | 221 | if "%1" == "linkcheck" ( 222 | %SPHINXBUILD% -b linkcheck %ALLSPHINXOPTS% %BUILDDIR%/linkcheck 223 | if errorlevel 1 exit /b 1 224 | echo. 225 | echo.Link check complete; look for any errors in the above output ^ 226 | or in %BUILDDIR%/linkcheck/output.txt. 227 | goto end 228 | ) 229 | 230 | if "%1" == "doctest" ( 231 | %SPHINXBUILD% -b doctest %ALLSPHINXOPTS% %BUILDDIR%/doctest 232 | if errorlevel 1 exit /b 1 233 | echo. 234 | echo.Testing of doctests in the sources finished, look at the ^ 235 | results in %BUILDDIR%/doctest/output.txt. 236 | goto end 237 | ) 238 | 239 | if "%1" == "coverage" ( 240 | %SPHINXBUILD% -b coverage %ALLSPHINXOPTS% %BUILDDIR%/coverage 241 | if errorlevel 1 exit /b 1 242 | echo. 243 | echo.Testing of coverage in the sources finished, look at the ^ 244 | results in %BUILDDIR%/coverage/python.txt. 245 | goto end 246 | ) 247 | 248 | if "%1" == "xml" ( 249 | %SPHINXBUILD% -b xml %ALLSPHINXOPTS% %BUILDDIR%/xml 250 | if errorlevel 1 exit /b 1 251 | echo. 252 | echo.Build finished. The XML files are in %BUILDDIR%/xml. 253 | goto end 254 | ) 255 | 256 | if "%1" == "pseudoxml" ( 257 | %SPHINXBUILD% -b pseudoxml %ALLSPHINXOPTS% %BUILDDIR%/pseudoxml 258 | if errorlevel 1 exit /b 1 259 | echo. 260 | echo.Build finished. The pseudo-XML files are in %BUILDDIR%/pseudoxml. 261 | goto end 262 | ) 263 | 264 | :end 265 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/source/_templates/layout.html: -------------------------------------------------------------------------------- 1 | {# layout.html #} 2 | {# Import the theme's layout. #} 3 | {% extends "!layout.html" %} 4 | 5 | {% set css_files = css_files + ['_static/pygments.css'] %} -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/source/basic_usage.rst: -------------------------------------------------------------------------------- 1 | Basic Usage 2 | ============ 3 | 4 | 5 | .. code-block:: shell 6 | 7 | cd {{cookiecutter.github_project_name}} 8 | conda env create -f {{cookiecutter.project_name}}-dev-requirements.yml 9 | source activate {{cookiecutter.project_name}}-dev-requirements 10 | mkdir build 11 | cd build 12 | cmake .. 13 | make -j2 14 | make cpp-test 15 | make python-test 16 | make install 17 | cd examples 18 | ./hello_world 19 | cd .. 20 | cd benchmark 21 | ./benchmark_cpptools 22 | 23 | 24 | On a windows machine this looks like: 25 | 26 | .. code-block:: shell 27 | 28 | cd {{cookiecutter.github_project_name}} 29 | conda env create -f {{cookiecutter.project_name}}-dev-requirements.yml 30 | call activate {{cookiecutter.project_name}}-dev-requirements 31 | mkdir build 32 | cd build 33 | cmake .. -G"Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release ^ 34 | -DDEPENDENCY_SEARCH_PREFIX="%CONDA_PREFIX%\Library" -DCMAKE_PREFIX_PATH="%CONDA_PREFIX%\Library" 35 | call activate cpptools-dev-requirements 36 | cmake --build . --target ALL_BUILD 37 | cmake --build . --target python-test 38 | cmake --build . --target cpp-test 39 | cmake --build . --target install 40 | 41 | 42 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/source/benchmark.rst: -------------------------------------------------------------------------------- 1 | Benchmark 2 | ========= 3 | 4 | 5 | We use gbench_ to create a benchmark for the C++ code. 6 | 7 | 8 | The benchmark subfolder contains all the code related 9 | to the benchmarks. 10 | In main.cpp the actual benchmarks are implemented. 11 | 12 | :: 13 | 14 | {{cookiecutter.github_project_name}} 15 | ├── ... 16 | ├── benchmark 17 | │ ├── main.cpp 18 | ├── ... 19 | 20 | 21 | .. _gbench: https://github.com/google/benchmark 22 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/source/changelog.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | Changelog 4 | ========= 5 | 6 | 0.1.0 7 | ------ 8 | 9 | - inital version -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/source/cmake_path.py.in: -------------------------------------------------------------------------------- 1 | py_mod_path = "@PYTHON_TMP_MODULE_DIR@" 2 | include_path = "@INCLUDE_PATH@" -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/source/conda_recipe.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | Conda Recipe 4 | ================= 5 | 6 | The recipe subfolder contains all the code related 7 | to the conda recipe 8 | 9 | :: 10 | 11 | project 12 | ├── ... 13 | ├── recipe 14 | │ ├── bld.bat 15 | │ ├── build.sh 16 | │ ├── meta.tml 17 | ├── ... 18 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/source/conf.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # -*- coding: utf-8 -*- 3 | 4 | import os 5 | import subprocess 6 | import sys 7 | import os 8 | import shutil 9 | import fnmatch 10 | import sphinx_rtd_theme 11 | 12 | 13 | on_rtd = os.environ.get('READTHEDOCS', None) == 'True' 14 | on_travis = os.environ.get('TRAVIS', None) == 'True' 15 | on_ci = on_rtd or on_travis 16 | 17 | 18 | 19 | def erase_folder_content(folder): 20 | for file_object in os.listdir(folder): 21 | file_object_path = os.path.join(folder, file_object) 22 | if os.path.isfile(file_object_path): 23 | os.unlink(file_object_path) 24 | else: 25 | shutil.rmtree(file_object_path) 26 | 27 | def patch_apidoc(folder): 28 | for root, dirnames, filenames in os.walk(folder): 29 | for filename in fnmatch.filter(filenames, '*.rst'): 30 | fname = os.path.join(root, filename) 31 | 32 | # Read in the file 33 | with open(fname, 'r') as file : 34 | filedata = file.read() 35 | 36 | # Replace the target string 37 | filedata = filedata.replace(' :members:', ' :members:\n :imported-members:') 38 | 39 | # Write the file out again 40 | with open(fname, 'w') as file: 41 | file.write(filedata) 42 | 43 | 44 | # build everything 45 | package_name = "{{cookiecutter.python_package_name}}" 46 | this_dir = os.path.dirname(__file__) 47 | py_mod_path = os.path.join(this_dir, '../../python/module') 48 | 49 | if on_ci: 50 | 51 | cmake_defs = "-DBUILD_PYTHON=ON -DBUILD_DOCS=OFF -DBUILD_TESTS=OFF -DBUILD_EXAMPLES=OFF -DDOWNLOAD_GOOGLE_BENCHMARK=OFF -DBUILD_EXAMPLES=OFF -DBUILD_BENCHMARK=OFF" 52 | cmake_py_ver = "-DPYTHON_EXECUTABLE=%s"%(str(sys.executable),) 53 | subprocess.call('cd ../.. && cmake . %s %s && make -j2'%(cmake_defs, cmake_py_ver), shell=True) 54 | 55 | # append python path to contain module from build dir 56 | import sys 57 | import os 58 | this_dir = os.path.dirname(__file__) 59 | py_mod_path = os.path.join(this_dir, '../../python/module') 60 | package_dir = os.path.join(py_mod_path, package_name) 61 | sys.path.append(py_mod_path) 62 | package_dir = os.path.join(py_mod_path, package_name) 63 | input_arg = "INPUT = ../../include" 64 | else: 65 | import runpy 66 | f = os.path.join(this_dir, 'cmake_path.py') 67 | res_dict = runpy.run_path(f) 68 | py_mod_path = res_dict['py_mod_path'] 69 | include_path = res_dict['include_path'] 70 | sys.path.append(py_mod_path) 71 | package_dir = os.path.join(py_mod_path, package_name) 72 | input_arg = "INPUT = {}".format(include_path) 73 | 74 | 75 | apidoc_out_folder = os.path.join(this_dir, 'pyapi') 76 | template_dir = os.path.join(this_dir, '_template') 77 | erase_folder_content(apidoc_out_folder) 78 | arglist = ['sphinx-apidoc','-o',apidoc_out_folder,package_dir,'-P'] 79 | print(arglist) 80 | subprocess.call(arglist, shell=False) 81 | 82 | 83 | # patch apidoc (the conda version does not support -t / --templatedir opt) 84 | patch_apidoc(apidoc_out_folder) 85 | 86 | 87 | 88 | 89 | html_theme = "sphinx_rtd_theme" 90 | #html_theme = "classic" 91 | html_theme_path = [ 92 | sphinx_rtd_theme.get_html_theme_path(), 93 | 'mytheme', 94 | '.' 95 | ] 96 | 97 | 98 | #html_static_path = ['_static'] 99 | extensions = ['breathe','exhale','sphinx.ext.todo', 'sphinx.ext.viewcode', 'sphinx.ext.autodoc','sphinx.ext.napoleon'] 100 | breathe_projects = { '{{cookiecutter.project_name}}': '../xml/' } 101 | 102 | 103 | 104 | exhale_args = { 105 | # These arguments are required 106 | "containmentFolder": "./api", 107 | "rootFileName": "{{cookiecutter.project_name}}_api.rst", 108 | "rootFileTitle": "{{cookiecutter.project_name}} API", 109 | "doxygenStripFromPath": "..", 110 | # Suggested optional arguments 111 | "createTreeView": True, 112 | # TIP: if using the sphinx-bootstrap-theme, you need 113 | # "treeViewIsBootstrap": True, 114 | "exhaleExecutesDoxygen": True, 115 | "exhaleDoxygenStdin": "INPUT = ../../include" 116 | } 117 | 118 | # Tell sphinx what the primary language being documented is. 119 | primary_domain = 'cpp' 120 | 121 | # Tell sphinx what the pygments highlight language should be. 122 | highlight_language = 'cpp' 123 | 124 | 125 | breathe_default_project = '{{cookiecutter.project_name}}' 126 | 127 | templates_path = ['_template'] 128 | source_suffix = '.rst' 129 | master_doc = 'index' 130 | project = '{{cookiecutter.project_name}}' 131 | copyright = ' {% now 'local', '%Y' %} , {{cookiecutter.full_name}}' 132 | author = '{{cookiecutter.full_name}}' 133 | 134 | 135 | exclude_patterns = [] 136 | highlight_language = 'c++' 137 | pygments_style = 'sphinx' 138 | todo_include_todos = False 139 | htmlhelp_basename = '{{cookiecutter.project_name}}_doc' -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/source/contributing.rst: -------------------------------------------------------------------------------- 1 | 2 | .. include:: ../../CONTRIBUTING.rst -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/source/examples.rst: -------------------------------------------------------------------------------- 1 | .. role:: bash(code) 2 | :language: bash 3 | 4 | Examples 5 | ================= 6 | 7 | 8 | Folder Structure 9 | ********************** 10 | 11 | The examples subfolder contains C++ examples which 12 | shall show the usage of the C++ library. 13 | 14 | :: 15 | 16 | {{cookiecutter.github_project_name}} 17 | ├── ... 18 | ├── examples 19 | │ ├── CMakeLists.txt 20 | │ ├── hello_world.cpp 21 | ├── ... 22 | 23 | 24 | Build System 25 | ********************** 26 | 27 | There is a meta target called :bash:`examples` which bundles the 28 | build process of all cpp files in the folder examples in one target. 29 | Assuming you cmake-build directory is called :bash:`bld` the following 30 | will build all examples. 31 | 32 | .. code-block:: shell 33 | 34 | $ cd bld 35 | $ make examples 36 | 37 | 38 | Adding New Examples 39 | ********************** 40 | 41 | To add new examples just add a new cpp file to the example 42 | folder and update the :bash:`CMakeLists.txt`. 43 | Assuming we named the new cpp file :bash:`my_new_example.cpp`, 44 | the relevant part in the :bash:`CMakeLists.txt` shall look like this: 45 | 46 | .. code-block:: cmake 47 | 48 | # all examples 49 | set(CPP_EXAMPLE_FILES 50 | hello_world.cpp 51 | my_new_example.cpp 52 | ) 53 | 54 | 55 | 56 | 57 | After changing the :bash:`CMakeLists.txt` cmake needs to be rerun 58 | to configure the build again. 59 | After that :bash:`make examples` will build all examples including the 60 | freshly added examples. 61 | 62 | .. code-block:: shell 63 | 64 | $ cd bld 65 | $ cmake . 66 | $ make examples -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/source/features.rst: -------------------------------------------------------------------------------- 1 | Features 2 | ============ 3 | 4 | 5 | * CMake build system 6 | * C++ Unit Tests with `Doctest `_ 7 | * `Benchmark code with google benchmark `_ 8 | * Continous Integration: 9 | * `azure-pipelines `_ 10 | * `circle-ci `_ 11 | * `travis-ci `_ 12 | * bumpversion for version handling 13 | * Documentation with sphinx breathe and on 14 | `readthedocs `_ 15 | * Conda Recipe Included 16 | * Python bindings are created via `pybind11 `_ 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/source/folder_structure.rst: -------------------------------------------------------------------------------- 1 | .. role:: bash(code) 2 | :language: bash 3 | 4 | Folder Structure 5 | ================= 6 | 7 | The generated project has the following folder structure 8 | 9 | :: 10 | 11 | {{cookiecutter.cmake_project_name}} 12 | ├──azure-pipelines.yml # Ci script 13 | │ 14 | ├──benchmark # C++ benchmark code 15 | │ └── ... 16 | │ 17 | ├──binder # dockerfile for mybinder.org 18 | │ └── Dockerfile 19 | │ 20 | ├──cmake # Cmake script/modules 21 | │ └── ... 22 | │ 23 | ├──CMakeLists.txt # Main cmake list 24 | │ 25 | ├──CONTRIBUTING.rst # Introduction how to constribute 26 | │ 27 | ├──{{cookiecutter.cmake_project_name}}Config.cmake.in # Script to make find_package(...) 28 | │ # work for this package 29 | │ 30 | ├──{{cookiecutter.cmake_project_name}}.pc.in # Packaging info 31 | │ 32 | ├──{{cookiecutter.package_name}}-dev-requirements.yml # List of development conda dependencies 33 | │ 34 | ├──docker # dockerfile for dockerhub 35 | │ └── Dockerfile 36 | ├──docs # Sources for sphinx documentation 37 | │ └── ... 38 | │ 39 | ├──examples # C++ examples 40 | │ └── ... 41 | │ 42 | ├──include # C++ include directory for this folder 43 | │ └── ... 44 | │ 45 | ├──LICENCE.txt # License file 46 | │ 47 | ├──python # Python binding source code 48 | │ └── ... 49 | │ 50 | ├──README.rst # Readme shown on github 51 | │ 52 | ├──readthedocs.yml # Entry point for automated 53 | │ # documentation build on readthedocs.org 54 | │ 55 | ├──recipe # Folder for conda recipes 56 | │ └── ... 57 | │ 58 | └──test # Folder containing C++ unit tests 59 | └── ... 60 | 61 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/source/index.rst: -------------------------------------------------------------------------------- 1 | Introduction 2 | ------------ 3 | 4 | {{cookiecutter.description}} 5 | 6 | 7 | {% if cookiecutter.open_source_license != 'Not open source' -%} 8 | Licensing 9 | --------- 10 | This software is licensed under the {{cookiecutter.open_source_license}} license. See the LICENSE.txt file for details. 11 | {% endif %} 12 | 13 | 14 | 15 | .. toctree:: 16 | :caption: Basics 17 | :maxdepth: 2 18 | 19 | features 20 | basic_usage 21 | 22 | .. toctree:: 23 | :caption: Folder Structure 24 | :maxdepth: 2 25 | 26 | folder_structure 27 | 28 | .. toctree:: 29 | :caption: Components 30 | :maxdepth: 2 31 | 32 | unit_tests 33 | benchmark 34 | python 35 | examples 36 | conda_recipe 37 | 38 | 39 | .. toctree:: 40 | :caption: Examples 41 | :maxdepth: 2 42 | 43 | examples.rst 44 | 45 | .. toctree:: 46 | :caption: C++ Api Reference 47 | :maxdepth: 2 48 | 49 | api/{{cookiecutter.project_name}}_api.rst 50 | 51 | .. toctree:: 52 | :caption: Python Reference 53 | :maxdepth: 2 54 | 55 | pyapi/modules.rst 56 | 57 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/source/installation.rst: -------------------------------------------------------------------------------- 1 | Installation 2 | ============ 3 | 4 | .. code-block:: shell 5 | 6 | cd {{cookiecutter.github_project_name}} 7 | conda env create -f {{cookiecutter.project_name}}-dev-requirements.yml 8 | source activate {{cookiecutter.project_name}}-dev-requirements 9 | mkdir build 10 | cd build 11 | cmake .. 12 | make -j2 13 | make cpp-test 14 | make python-test 15 | make install 16 | cd examples 17 | ./hello_world 18 | cd .. 19 | cd benchmark 20 | ./benchmark_cpptools 21 | 22 | 23 | On a windows machine this looks like: 24 | 25 | .. code-block:: shell 26 | 27 | cd {{cookiecutter.github_project_name}} 28 | conda env create -f {{cookiecutter.project_name}}-dev-requirements.yml 29 | call activate {{cookiecutter.project_name}}-dev-requirements 30 | mkdir build 31 | cd build 32 | cmake .. -G"Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Release ^ 33 | -DDEPENDENCY_SEARCH_PREFIX="%CONDA_PREFIX%\Library" -DCMAKE_PREFIX_PATH="%CONDA_PREFIX%\Library" 34 | call activate cpptools-dev-requirements 35 | cmake --build . --target ALL_BUILD 36 | cmake --build . --target python-test 37 | cmake --build . --target cpp-test 38 | cmake --build . --target install 39 | 40 | 41 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/source/pyapi/fu: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/DerThorsten/cpp_cookiecutter/541840d9a9d10654d88f78aed2057e67984e9782/{{cookiecutter.github_project_name}}/docs/source/pyapi/fu -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/source/python.rst: -------------------------------------------------------------------------------- 1 | 2 | 3 | Python Module 4 | ================= 5 | 6 | Folder Structure 7 | ********************** 8 | 9 | We use pybind11_ to create the python bindings. 10 | The python subfolder contains all the code related 11 | to the python bindings. 12 | The :code:`module/{{cookiecutter.python_package_name}}` subfolder contains all the :code:`*.py` files of the module. 13 | The src folder contains the :code:`*.cpp` files used to export the C++ functionality to python via pybind11_. 14 | The :code:`test` folder contains all python tests. 15 | 16 | :: 17 | 18 | {{cookiecutter.github_project_name}} 19 | ├── ... 20 | ├── python 21 | │ ├── module 22 | │ │ └── {{cookiecutter.python_package_name}} 23 | │ │ ├── __init__.py 24 | │ │ └── ... 25 | │ ├── src 26 | │ │ ├── CMakeLists.txt 27 | │ │ ├── main.cpp 28 | │ │ ├── def_build_config.cpp 29 | │ │ ├── ... 30 | │ └── test 31 | │ ├── test_build_configuration.py 32 | │ └── ... 33 | └── ... 34 | 35 | 36 | 37 | 38 | 39 | Build System 40 | ********************** 41 | 42 | To build the python package use the :code:`python-module` target. 43 | 44 | .. code-block:: shell 45 | 46 | make python-module 47 | 48 | This will build the :code:`*.cpp` files in the :code:`src` folder and copy the folder :code:`module/{{cookiecutter.python_package_name}}` folder to build location of the python module, namely :code:`${CMAKE_BINARY_DIR}/python/module/` where :code:`${CMAKE_BINARY_DIR}` is the build directory. 49 | 50 | 51 | Usage 52 | ********************** 53 | 54 | After a successfully building and installing the python module can be 55 | imported like the following: 56 | 57 | .. code-block:: python 58 | 59 | import {{cookiecutter.python_package_name}} 60 | 61 | config = {{cookiecutter.python_package_name}}.BuildConfiguration 62 | print(config.VERSION_MAJOR) 63 | 64 | 65 | 66 | Run Python Tests 67 | ******************************************** 68 | 69 | To run the python test suite use the `python-test` target: 70 | 71 | .. code-block:: shell 72 | 73 | make python-test 74 | 75 | 76 | 77 | Adding New Python Functionality 78 | ******************************************** 79 | 80 | We use pybind11_ to export functionality from C++ to Python. 81 | pybind11_ can create modules from C++ without the use of any :code:`*.py` files. 82 | Nevertheless we prefer to have a regular Python package with a proper :code:`__init__.py`. From the :code:`__init__.py` we import all the C++ / pybind11_ exported functionality from the build submodule named :code:`_{{cookiecutter.python_package_name}}`. 83 | This allows us to add new functionality in different ways: 84 | * new functionality from c++ via pybind11_ 85 | * new puren python functionality 86 | 87 | Add New Python Functionality from C++ 88 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 89 | To export functionality from C++ to python via pybind11_ it is 90 | good practice to split functionality in multiple :code:`def_*.cpp` files. 91 | This allow for readable code, and parallel builds. 92 | To add news functionality we create a new file, for example :code:`def_new_stuff.cpp`. 93 | 94 | 95 | .. code-block:: cpp 96 | 97 | #include "pybind11/pybind11.h" 98 | #include "pybind11/numpy.h" 99 | 100 | #include 101 | #include 102 | 103 | #define FORCE_IMPORT_ARRAY 104 | #include "xtensor-python/pyarray.hpp" 105 | #include "xtensor-python/pytensor.hpp" 106 | 107 | // our headers 108 | #include "{{cookiecutter.cpp_root_folder_name}}/{{ cookiecutter.package_name}}.hpp" 109 | 110 | namespace py = pybind11; 111 | 112 | 113 | namespace {{cookiecutter.cpp_namespace}} { 114 | 115 | void def_new_stuff(py::module & m) 116 | { 117 | py::def('new_stuff',[](xt::pytensor<1,double> values){ 118 | return values * 42.0; 119 | }); 120 | } 121 | 122 | } 123 | 124 | Next we need to declare and call the :code:`def_new_stuff` from :code:`main.cpp`. 125 | To declare the function modify the following block in :code:`main.cpp` 126 | 127 | .. code-block:: cpp 128 | 129 | namespace {{cookiecutter.cpp_namespace}} { 130 | 131 | // .... 132 | // .... 133 | // .... 134 | 135 | // implementation in def_myclass.cpp 136 | void def_class(py::module & m); 137 | 138 | // implementation in def_myclass.cpp 139 | void def_build_config(py::module & m); 140 | 141 | // implementation in def.cpp 142 | void def_build_config(py::module & m); 143 | 144 | // implementation in def.cpp 145 | void def_build_config(py::module & m); 146 | 147 | // implementation in def_new_stuff.cpp 148 | void def_new_stuff(py::module & m); // <- our new functionality 149 | 150 | } 151 | 152 | After declaring the function :code:`def_new_stuff`, we can call :code:`def_new_stuff`. We modify the :code:`PYBIND11_MODULE` in 153 | code:`main.cpp`: 154 | 155 | 156 | .. code-block:: cpp 157 | 158 | // Python Module and Docstrings 159 | PYBIND11_MODULE(_{{cookiecutter.python_package_name}} , module) 160 | { 161 | xt::import_numpy(); 162 | 163 | module.doc() = R"pbdoc( 164 | _{{cookiecutter.python_package_name}} python bindings 165 | 166 | .. currentmodule:: _{{cookiecutter.python_package_name}} 167 | 168 | .. autosummary:: 169 | :toctree: _generate 170 | 171 | BuildConfiguration 172 | MyClass 173 | new_stuff 174 | )pbdoc"; 175 | 176 | {{cookiecutter.cpp_namespace}}::def_build_config(module); 177 | {{cookiecutter.cpp_namespace}}::def_class(module); 178 | {{cookiecutter.cpp_namespace}}::def_new_stuff(module); // <- our new functionality 179 | 180 | // make version string 181 | std::stringstream ss; 182 | ss<<{{cookiecutter.cpp_macro_prefix}}_VERSION_MAJOR<<"." 183 | <<{{cookiecutter.cpp_macro_prefix}}_VERSION_MINOR<<"." 184 | <<{{cookiecutter.cpp_macro_prefix}}_VERSION_PATCH; 185 | module.attr("__version__") = ss.str(); 186 | } 187 | 188 | 189 | We need to add this file to the :code:`CMakeLists.txt` file at 190 | :code:`{cookiecutter.github_project_name}}/python/src/CMakeLists.txt` 191 | The file needs to be passed as an argument to the :code:`pybind11_add_module` function. 192 | 193 | .. code-block:: cmake 194 | 195 | # add the python library 196 | pybind11_add_module(${PY_MOD_LIB_NAME} 197 | main.cpp 198 | def_build_config.cpp 199 | def_myclass.cpp 200 | def_new_stuff.cpp # <- our new functionality 201 | ) 202 | 203 | 204 | 205 | Now we are ready to build the freshly added functionality. 206 | 207 | .. code-block:: shell 208 | 209 | make python-test 210 | 211 | 212 | After a successful build we can use the new functionality from python. 213 | 214 | 215 | .. code-block:: python 216 | 217 | import numpy as np 218 | import {{cookiecutter.python_package_name}} 219 | 220 | {{cookiecutter.python_package_name}}.new_stuff(numpy.arange(5), dtype='float64') 221 | 222 | 223 | 224 | Add New Pure Python Functionality 225 | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 226 | To add new pure Python functionality, 227 | just add the desired function / classes to 228 | a new :code:`*.py` file and put this file to the 229 | :code:`module/{{cookiecutter.python_package_name}}` subfolder. 230 | After adding the new file, cmake needs to be rerun since we copy the content :code:`module/{{cookiecutter.python_package_name}}` during the build process. 231 | 232 | 233 | 234 | 235 | Adding New Python Tests 236 | ******************************************** 237 | 238 | We use pytest_ as python test framework. 239 | To add new tests, just add new :code:`test_*.py` files 240 | to the test subfolder. 241 | To run the actual test use the :code:`python-test` target 242 | 243 | .. code-block:: shell 244 | 245 | make python-test 246 | 247 | 248 | .. _pybind11: https://github.com/pybind/pybind11 249 | .. _pytest: https://docs.pytest.org/en/latest/ -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/source/readme.rst: -------------------------------------------------------------------------------- 1 | 2 | .. include:: ../../README.rst -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/docs/source/unit_tests.rst: -------------------------------------------------------------------------------- 1 | .. role:: bash(code) 2 | :language: bash 3 | 4 | 5 | Unit Tests 6 | ================= 7 | 8 | We use doctest_ to create a benchmark for the C++ code. 9 | 10 | 11 | The test subfolder contains all the code related 12 | to the C++ unit tests. 13 | In :bash:`main.cpp` implements the benchmarks runner, 14 | The unit tets are implemented in :bash:`test_*.cpp`. 15 | The test older looks like. 16 | 17 | :: 18 | 19 | {{cookiecutter.github_project_name}} 20 | ├── ... 21 | ├── test 22 | │ ├── CMakeLists.txt 23 | │ ├── main.cpp 24 | │ ├── test_{{cookiecutter.package_name}}_config.cpp 25 | ├── ... 26 | 27 | 28 | 29 | 30 | Build System 31 | ********************** 32 | 33 | There is a meta target called :bash:`test_{{cookiecutter.package_name}}` which bundles the 34 | build process of unit tests. 35 | Assuming you cmake-build directory is called :bash:`bld` the following 36 | will build all examples. 37 | 38 | .. code-block:: shell 39 | 40 | $ cd bld 41 | $ make test_cpptools 42 | 43 | To run the actual test you can use the target :bash:`cpp_tests` 44 | .. code-block:: shell 45 | 46 | $ cd bld 47 | $ make cpp_tests 48 | 49 | 50 | Adding New Tests 51 | ********************** 52 | 53 | To add new tests just add a new cpp file to the test 54 | folder and update the :bash:`CMakeLists.txt`. 55 | Assuming we named the new cpp file :bash:`test_my_new_feture.cpp`, 56 | the relevant part in the :bash:`CMakeLists.txt` shall look like this: 57 | 58 | .. code-block:: cmake 59 | 60 | # all tests 61 | set(${PROJECT_NAME}_TESTS 62 | test_cpptools_config.cpp 63 | test_my_new_feture.cpp 64 | ) 65 | 66 | 67 | 68 | 69 | After changing the :bash:`CMakeLists.txt` cmake needs to be rerun 70 | to configure the build again. 71 | After that :bash:`make examples` will build all examples including the 72 | freshly added examples. 73 | 74 | .. code-block:: shell 75 | 76 | $ cd bld 77 | $ cmake . 78 | $ make examples 79 | 80 | 81 | .. _doctest: https://github.com/google/benchmark 82 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | 3 | # all examples 4 | set(CPP_EXAMPLE_FILES 5 | hello_world.cpp 6 | ) 7 | 8 | 9 | 10 | # custom target for `make examples` 11 | add_custom_target(examples) 12 | 13 | foreach(CPP_EXAMPLE_FILE ${CPP_EXAMPLE_FILES}) 14 | 15 | # get the filename without extension 16 | get_filename_component(EXAMPLE_TARGET_NAME_WITH_EXT ${CPP_EXAMPLE_FILE} NAME) 17 | string(REGEX MATCH "^(.*)\\.[^.]*$" dummy ${EXAMPLE_TARGET_NAME_WITH_EXT}) 18 | set(EXAMPLE_TARGET_NAME ${CMAKE_MATCH_1}) 19 | 20 | 21 | add_executable( ${EXAMPLE_TARGET_NAME} 22 | ${CPP_EXAMPLE_FILE} 23 | ) 24 | 25 | # target_include_directories( ${EXAMPLE_TARGET_NAME} PRIVATE 26 | # "$" 27 | # ) 28 | 29 | target_link_libraries( ${EXAMPLE_TARGET_NAME} 30 | PRIVATE ${INTERFACE_LIB_NAME} 31 | ) 32 | 33 | # add example to custom target for `make examples` 34 | add_dependencies(examples ${EXAMPLE_TARGET_NAME}) 35 | 36 | endforeach(CPP_EXAMPLE_FILE) 37 | 38 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/examples/hello_world.cpp: -------------------------------------------------------------------------------- 1 | #include "{{cookiecutter.cpp_root_folder_name}}/{{cookiecutter.package_name}}.hpp" 2 | #include "{{cookiecutter.cpp_root_folder_name}}/{{cookiecutter.package_name}}_config.hpp" 3 | 4 | 5 | 6 | int main(int argc, char *argv[]){ 7 | 8 | } -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/examples/{{cookiecutter.package_name}}_version.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "{{cookiecutter.cpp_root_folder_name}}/{{cookiecutter.package_name}}.hpp" 4 | #include "{{cookiecutter.cpp_root_folder_name}}/{{cookiecutter.package_name}}_config.hpp" 5 | 6 | int main(int argc, char *argv[]){ 7 | std::cout<<"{{cookiecutter.cpp_macro_prefix}}_VERSION_MAJOR "<<{{cookiecutter.cpp_macro_prefix}}_VERSION_MAJOR<<"\n"; 8 | std::cout<<"{{cookiecutter.cpp_macro_prefix}}_VERSION_MINOR "<<{{cookiecutter.cpp_macro_prefix}}_VERSION_MINOR<<"\n"; 9 | std::cout<<"{{cookiecutter.cpp_macro_prefix}}_VERSION_PATCH "<<{{cookiecutter.cpp_macro_prefix}}_VERSION_PATCH<<"\n"; 10 | } -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/include/{{cookiecutter.cpp_root_folder_name}}/{{ cookiecutter.package_name}}.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef {{ cookiecutter.cpp_macro_prefix }}_{{cookiecutter.package_name|upper}}_HPP 3 | #define {{ cookiecutter.cpp_macro_prefix }}_{{cookiecutter.package_name|upper}}_HPP 4 | 5 | #include 6 | #include 7 | 8 | namespace {{ cookiecutter.cpp_namespace }} { 9 | 10 | class MyClass 11 | { 12 | public: 13 | MyClass(const uint64_t size) 14 | : m_size(size) 15 | { 16 | 17 | } 18 | 19 | void hello_world() 20 | { 21 | std::cout<<"Hello World!\n"; 22 | } 23 | private: 24 | uint64_t m_size; 25 | }; 26 | 27 | } // end namespace {{cookiecutter.cpp_namespace}} 28 | 29 | 30 | #endif // {{ cookiecutter.cpp_macro_prefix }}_{{cookiecutter.package_name|upper}}_HPP -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/include/{{cookiecutter.cpp_root_folder_name}}/{{ cookiecutter.package_name}}_config.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef {{ cookiecutter.cpp_macro_prefix }}_{{cookiecutter.package_name|upper}}_CONFIG_HPP 3 | #define {{ cookiecutter.cpp_macro_prefix }}_{{cookiecutter.package_name|upper}}_CONFIG_HPP 4 | 5 | 6 | 7 | 8 | #include "{{cookiecutter.cpp_root_folder_name}}/{{cookiecutter.package_name}}_version_major.hpp" 9 | #include "{{cookiecutter.cpp_root_folder_name}}/{{cookiecutter.package_name}}_version_minor.hpp" 10 | #include "{{cookiecutter.cpp_root_folder_name}}/{{cookiecutter.package_name}}_version_patch.hpp" 11 | 12 | 13 | namespace {{ cookiecutter.cpp_namespace }} { 14 | 15 | 16 | } // end namespace {{cookiecutter.cpp_namespace}} 17 | 18 | 19 | #endif // {{ cookiecutter.cpp_macro_prefix }}_{{cookiecutter.package_name|upper}}_CONFIG_HPP -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/include/{{cookiecutter.cpp_root_folder_name}}/{{ cookiecutter.package_name}}_version_major.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef {{ cookiecutter.cpp_macro_prefix }}_{{cookiecutter.package_name|upper}}_VERSION_MAJOR_HPP 3 | #define {{ cookiecutter.cpp_macro_prefix }}_{{cookiecutter.package_name|upper}}_VERSION_MAJOR_HPP 4 | 5 | 6 | 7 | #define {{cookiecutter.cpp_macro_prefix}}_VERSION_MAJOR 0 8 | 9 | 10 | namespace {{ cookiecutter.cpp_namespace }} { 11 | 12 | 13 | } // end namespace {{cookiecutter.cpp_namespace}} 14 | 15 | 16 | #endif // {{ cookiecutter.cpp_macro_prefix }}_{{cookiecutter.package_name|upper}}_VERSION_MAJOR_HPP -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/include/{{cookiecutter.cpp_root_folder_name}}/{{ cookiecutter.package_name}}_version_minor.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef {{ cookiecutter.cpp_macro_prefix }}_{{cookiecutter.package_name|upper}}_VERSION_MINOR_HPP 3 | #define {{ cookiecutter.cpp_macro_prefix }}_{{cookiecutter.package_name|upper}}_VERSION_MINOR_HPP 4 | 5 | #define {{cookiecutter.cpp_macro_prefix}}_VERSION_MINOR 1 6 | 7 | 8 | namespace {{ cookiecutter.cpp_namespace }} { 9 | 10 | 11 | } // end namespace {{cookiecutter.cpp_namespace}} 12 | 13 | 14 | #endif // {{ cookiecutter.cpp_macro_prefix }}_{{cookiecutter.package_name|upper}}_VERSION_MINOR_HPP -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/include/{{cookiecutter.cpp_root_folder_name}}/{{ cookiecutter.package_name}}_version_patch.hpp: -------------------------------------------------------------------------------- 1 | #pragma once 2 | #ifndef {{ cookiecutter.cpp_macro_prefix }}_{{cookiecutter.package_name|upper}}_VERSION_PATCH_HPP 3 | #define {{ cookiecutter.cpp_macro_prefix }}_{{cookiecutter.package_name|upper}}_VERSION_PATCH_HPP 4 | 5 | 6 | 7 | #define {{cookiecutter.cpp_macro_prefix}}_VERSION_PATCH 0 8 | 9 | namespace {{ cookiecutter.cpp_namespace }} { 10 | 11 | 12 | } // end namespace {{cookiecutter.cpp_namespace}} 13 | 14 | 15 | #endif // {{ cookiecutter.cpp_macro_prefix }}_{{cookiecutter.package_name|upper}}_VERSION_PATCH_HPP -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/python/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | #------------------------------------------------------------------------------------------------------------------- 3 | # Setup python bindings 4 | #------------------------------------------------------------------------------------------------------------------- 5 | find_package(NUMPY REQUIRED) 6 | find_package(pybind11 CONFIG REQUIRED) 7 | 8 | 9 | 10 | IF(NOT DEFINED PYTHON_MODULE_INSTALL_DIR OR PYTHON_MODULE_INSTALL_DIR MATCHES "") 11 | 12 | execute_process( 13 | COMMAND "${PYTHON_EXECUTABLE}" -c "from __future__ import print_function; from distutils.sysconfig import get_python_lib; print(get_python_lib())" 14 | OUTPUT_VARIABLE PYTHON_SITE 15 | OUTPUT_STRIP_TRAILING_WHITESPACE) 16 | SET(PYTHON_MODULE_INSTALL_DIR ${PYTHON_SITE}) 17 | 18 | endif() 19 | 20 | SET(PYTHON_MODULE_INSTALL_DIR ${PYTHON_MODULE_INSTALL_DIR} 21 | CACHE PATH "where to install the Python package" FORCE) 22 | 23 | 24 | # temporary python module dir 25 | 26 | file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/python/module/${PY_MOD_NAME}) 27 | 28 | 29 | add_subdirectory(src) 30 | 31 | 32 | file(COPY ${CMAKE_SOURCE_DIR}/python/module/${PY_MOD_NAME} DESTINATION ${CMAKE_BINARY_DIR}/python/module) 33 | 34 | 35 | 36 | 37 | install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/module/ 38 | DESTINATION ${PYTHON_MODULE_INSTALL_DIR}) 39 | 40 | 41 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/python/module/{{cookiecutter.python_package_name}}/__init__.py: -------------------------------------------------------------------------------- 1 | from . _{{cookiecutter.python_package_name}} import * 2 | 3 | 4 | 5 | def pure_python(): 6 | """ 7 | hello 8 | """ 9 | pass -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/python/notebooks/hello_world.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "code", 5 | "execution_count": null, 6 | "metadata": {}, 7 | "outputs": [], 8 | "source": [ 9 | "import {{cookiecutter.python_package_name}}" 10 | ] 11 | } 12 | ], 13 | "metadata": { 14 | "kernelspec": { 15 | "display_name": "Python 3", 16 | "language": "python", 17 | "name": "python3" 18 | }, 19 | "language_info": { 20 | "codemirror_mode": { 21 | "name": "ipython", 22 | "version": 3 23 | }, 24 | "file_extension": ".py", 25 | "mimetype": "text/x-python", 26 | "name": "python", 27 | "nbconvert_exporter": "python", 28 | "pygments_lexer": "ipython3", 29 | "version": "3.7.1" 30 | } 31 | }, 32 | "nbformat": 4, 33 | "nbformat_minor": 2 34 | } 35 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/python/src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | #------------------------------------------------------------------------------------------------------------------- 2 | # Add The module 3 | #------------------------------------------------------------------------------------------------------------------- 4 | find_package(xtl REQUIRED) 5 | find_package(xtensor REQUIRED) 6 | find_package(xtensor-python CONFIG REQUIRED) 7 | 8 | 9 | 10 | set(PY_MOD_NAME {{cookiecutter.python_package_name}} ) 11 | set(PY_MOD_LIB_NAME _${PY_MOD_NAME}) 12 | 13 | 14 | # add the python library 15 | pybind11_add_module(${PY_MOD_LIB_NAME} 16 | main.cpp 17 | def_build_config.cpp 18 | def_myclass.cpp 19 | ) 20 | 21 | 22 | 23 | # `link` against pybind11 interface module 24 | target_link_libraries(${PY_MOD_LIB_NAME} PUBLIC 25 | ${INTERFACE_LIB_NAME} 26 | pybind11::module) 27 | 28 | # include directories for non-modern cmake 29 | set(PY_INCLUDE_DIRS 30 | ${PYTHON_NUMPY_INCLUDE_DIR} 31 | ${xtensor-python_INCLUDE_DIRS} 32 | ) 33 | target_include_directories(${PY_MOD_LIB_NAME} PUBLIC ${PY_INCLUDE_DIRS}) 34 | 35 | # custom target for `make python-module` 36 | add_custom_target(python-module DEPENDS ${PY_MOD_LIB_NAME}) 37 | 38 | 39 | 40 | add_custom_command(TARGET ${PY_MOD_LIB_NAME} POST_BUILD 41 | COMMAND "${CMAKE_COMMAND}" -E copy 42 | "$" 43 | "${CMAKE_BINARY_DIR}/python/module/${PY_MOD_NAME}/$" 44 | COMMENT "Copying to output directory") 45 | 46 | 47 | 48 | 49 | add_custom_target(python-test COMMAND ${PYTHON_EXECUTABLE} -m pytest "${CMAKE_SOURCE_DIR}/python/tests" WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/python/module" ) 50 | add_dependencies(python-test ${PY_MOD_LIB_NAME} ) 51 | 52 | 53 | install(TARGETS ${PY_MOD_LIB_NAME} 54 | DESTINATION ${PYTHON_MODULE_INSTALL_DIR}/${PY_MOD_NAME}/) -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/python/src/def_build_config.cpp: -------------------------------------------------------------------------------- 1 | #include "pybind11/pybind11.h" 2 | #include "pybind11/numpy.h" 3 | 4 | #include 5 | #include 6 | 7 | 8 | // our headers 9 | #include "{{cookiecutter.cpp_root_folder_name}}/{{ cookiecutter.package_name}}.hpp" 10 | #include "{{cookiecutter.cpp_root_folder_name}}/{{ cookiecutter.package_name}}_config.hpp" 11 | 12 | 13 | namespace py = pybind11; 14 | 15 | 16 | 17 | namespace {{cookiecutter.cpp_namespace}} { 18 | 19 | void def_build_config(py::module & m) 20 | { 21 | 22 | struct BuildConfiguration { 23 | 24 | }; 25 | 26 | 27 | py::class_(m, "BuildConfiguration", 28 | "This class show the compile/build configuration\n" 29 | "Of {{cookiecutter.python_package_name}}\n" 30 | ) 31 | .def_property_readonly_static("VERSION_MAJOR", [](py::object /* self */) { 32 | return {{cookiecutter.cpp_macro_prefix}}_VERSION_MAJOR ; 33 | }) 34 | .def_property_readonly_static("VERSION_MINOR", [](py::object /* self */) { 35 | return {{cookiecutter.cpp_macro_prefix}}_VERSION_MINOR ; 36 | }) 37 | .def_property_readonly_static("VERSION_PATCH", [](py::object /* self */) { 38 | return {{cookiecutter.cpp_macro_prefix}}_VERSION_MAJOR ; 39 | }) 40 | .def_property_readonly_static("DEBUG", [](py::object /* self */) { 41 | #ifdef NDEBUG 42 | return false; 43 | #else 44 | return true; 45 | #endif 46 | }) 47 | 48 | ; 49 | 50 | 51 | 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/python/src/def_myclass.cpp: -------------------------------------------------------------------------------- 1 | #include "pybind11/pybind11.h" 2 | #include "pybind11/numpy.h" 3 | 4 | #include 5 | #include 6 | 7 | 8 | // our headers 9 | #include "{{cookiecutter.cpp_root_folder_name}}/{{ cookiecutter.package_name}}.hpp" 10 | 11 | namespace py = pybind11; 12 | 13 | 14 | 15 | namespace {{cookiecutter.cpp_namespace}} { 16 | 17 | void def_class(py::module & m) 18 | { 19 | py::class_(m, "MyClass") 20 | .def(py::init(),py::arg("size")) 21 | .def("hello_world", &MyClass::hello_world) 22 | ; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/python/src/main.cpp: -------------------------------------------------------------------------------- 1 | #include "pybind11/pybind11.h" 2 | 3 | #include "xtensor/xmath.hpp" 4 | #include "xtensor/xarray.hpp" 5 | 6 | #define FORCE_IMPORT_ARRAY 7 | #include "xtensor-python/pyarray.hpp" 8 | #include "xtensor-python/pyvectorize.hpp" 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | 16 | // our headers 17 | #include "{{cookiecutter.cpp_root_folder_name}}/{{ cookiecutter.package_name}}.hpp" 18 | #include "{{cookiecutter.cpp_root_folder_name}}/{{ cookiecutter.package_name}}_config.hpp" 19 | 20 | namespace py = pybind11; 21 | 22 | 23 | 24 | namespace {{cookiecutter.cpp_namespace}} { 25 | 26 | 27 | // implementation in def_myclass.cpp 28 | void def_class(py::module & m); 29 | 30 | // implementation in def_myclass.cpp 31 | void def_build_config(py::module & m); 32 | 33 | // implementation in def.cpp 34 | void def_build_config(py::module & m); 35 | 36 | } 37 | 38 | 39 | // Python Module and Docstrings 40 | PYBIND11_MODULE(_{{cookiecutter.python_package_name}} , module) 41 | { 42 | xt::import_numpy(); 43 | 44 | module.doc() = R"pbdoc( 45 | _{{cookiecutter.python_package_name}} python bindings 46 | 47 | .. currentmodule:: _{{cookiecutter.python_package_name}} 48 | 49 | .. autosummary:: 50 | :toctree: _generate 51 | 52 | BuildConfiguration 53 | MyClass 54 | )pbdoc"; 55 | 56 | {{cookiecutter.cpp_namespace}}::def_build_config(module); 57 | {{cookiecutter.cpp_namespace}}::def_class(module); 58 | 59 | // make version string 60 | std::stringstream ss; 61 | ss<<{{cookiecutter.cpp_macro_prefix}}_VERSION_MAJOR<<"." 62 | <<{{cookiecutter.cpp_macro_prefix}}_VERSION_MINOR<<"." 63 | <<{{cookiecutter.cpp_macro_prefix}}_VERSION_PATCH; 64 | module.attr("__version__") = ss.str().c_str(); 65 | } -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/python/tests/test_build_configuration.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | import {{cookiecutter.python_package_name}} 3 | 4 | 5 | 6 | class TestBuildConfig(unittest.TestCase): 7 | 8 | def test_version(self): 9 | config = {{cookiecutter.python_package_name}}.BuildConfiguration 10 | self.assertEqual(config.VERSION_MAJOR, 0) 11 | self.assertEqual(config.VERSION_MINOR, 1) 12 | self.assertEqual(config.VERSION_PATCH, 0) 13 | 14 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/readthedocs.yml: -------------------------------------------------------------------------------- 1 | conda: 2 | file: {{cookiecutter.package_name}}-dev-requirements.yml -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/recipe/bld.bat: -------------------------------------------------------------------------------- 1 | cmake -G "NMake Makefiles" -D BUILD_DOCS=OFF -D CMAKE_INSTALL_PREFIX=%LIBRARY_PREFIX% %SRC_DIR% 2 | if errorlevel 1 exit 1 3 | 4 | nmake 5 | if errorlevel 1 exit 1 6 | 7 | nmake install 8 | if errorlevel 1 exit 1 9 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/recipe/build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | EXTRA_CMAKE_ARGS="" 4 | if [[ `uname` == 'Darwin' ]]; 5 | then 6 | EXTRA_CMAKE_ARGS="-DCMAKE_OSX_DEPLOYMENT_TARGET=${CMAKE_OSX_DEPLOYMENT_TARGET}" 7 | else 8 | export CXXFLAGS="-pthread ${CXXFLAGS}" 9 | fi 10 | export EXTRA_CMAKE_ARGS 11 | 12 | export _CXX_FLAGS="${CXXFLAGS}" 13 | export _LDFLAGS="${CXX_LDFLAGS} -Wl,-rpath,${PREFIX}/lib -L${PREFIX}/lib" 14 | 15 | 16 | 17 | cmake \ 18 | -DCMAKE_INSTALL_PREFIX=${PREFIX} \ 19 | -DCMAKE_PREFIX_PATH=${PREFIX} \ 20 | \ 21 | -DCMAKE_CXX_LINK_FLAGS="${_LDFLAGS}" \ 22 | -DCMAKE_EXE_LINKER_FLAGS="${_LDFLAGS}" \ 23 | -DCMAKE_CXX_FLAGS="${_CXX_FLAGS}" \ 24 | -DCMAKE_CXX_FLAGS_RELEASE="${_CXX_FLAGS_RELEASE}" \ 25 | -DCMAKE_CXX_FLAGS_DEBUG="${_CXX_FLAGS}" \ 26 | -DBUILD_DOCS=OFF\ 27 | 28 | make -j${CPU_COUNT} 29 | 30 | make install 31 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/recipe/meta.yaml: -------------------------------------------------------------------------------- 1 | package: 2 | name: {{cookiecutter.conda_package_name}} 3 | version: 0.1.0 4 | 5 | source: 6 | path: ../ 7 | 8 | build: 9 | number: 0 10 | 11 | requirements: 12 | build: 13 | - cmake>=3.1 14 | - conda-forge::xtl 15 | - conda-forge::xtensor 16 | {% if cookiecutter.python_bindings == 'yes' -%} 17 | - python>=3.6 18 | - numpy>=1.16 19 | - conda-forge::pybind11 20 | - conda-forge::xtensor-python 21 | {% endif %} 22 | run: 23 | {% if cookiecutter.python_bindings == 'yes' -%} 24 | - numpy>=1.16 25 | - python>=3.6 26 | {% endif %} 27 | test: 28 | {% if cookiecutter.python_bindings == 'yes' -%} 29 | requires: 30 | - pytest 31 | imports: 32 | - {{cookiecutter.conda_package_name}} 33 | {% endif %} 34 | commands: 35 | - test -d ${PREFIX}/include/{{cookiecutter.cpp_root_folder_name}} # [unix] 36 | - test -f ${PREFIX}/include/{{cookiecutter.cpp_root_folder_name}}/{{ cookiecutter.package_name}}.hpp # [unix] 37 | - if exist %LIBRARY_PREFIX%\include\{{cookiecutter.cpp_root_folder_name}}\{{ cookiecutter.package_name}}.hpp (exit 0) else (exit 1) # [win] 38 | # - make cpp-test 39 | # - make python-test 40 | 41 | about: 42 | home: https://github.com/{{cookiecutter.github_user_name}}/{{cookiecutter.github_project_name}} 43 | {% if cookiecutter.open_source_license == 'MIT license' -%} 44 | license: MIT 45 | license_family: MIT 46 | {% elif cookiecutter.open_source_license == 'BSD license' %} 47 | license: BSD 3-Clause 48 | license_family: BSD 49 | {% elif cookiecutter.open_source_license == 'ISC license' -%} 50 | license: ISC 51 | license_family: ISC 52 | {% elif cookiecutter.open_source_license == 'Apache Software License 2.0' -%} 53 | license: Apache 54 | license_family: Apache 55 | {% elif cookiecutter.open_source_license == 'GNU General Public License v3' -%} 56 | license: GPL 57 | license_family: GPL 58 | {% endif %} 59 | summary: '{{cookiecutter.summary}}' 60 | description: '{{cookiecutter.description}}' 61 | documentation_url: https://readthedocs.org/projects/{{cookiecutter.readthedocs_package_name}}/ 62 | dev_url: https://github.com/{{cookiecutter.github_user_name}}/{{cookiecutter.github_project_name}} 63 | 64 | extra: 65 | recipe-maintainers: 66 | - {{cookiecutter.full_name}} 67 | 68 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(DOCTEST) 2 | if(FOUND_DOCTEST) 3 | # nothing 4 | else() 5 | 6 | # Download and unpack doctest at configure time 7 | configure_file(downloadDoctest.cmake.in doctest-download/CMakeLists.txt) 8 | 9 | execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . 10 | RESULT_VARIABLE result 11 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doctest-download ) 12 | if(result) 13 | message(FATAL_ERROR "CMake step for doctest failed: ${result}") 14 | endif() 15 | execute_process(COMMAND ${CMAKE_COMMAND} --build . 16 | RESULT_VARIABLE result 17 | WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doctest-download ) 18 | if(result) 19 | message(FATAL_ERROR "Build step for doctest failed: ${result}") 20 | endif() 21 | 22 | set(DOCTEST_INCLUDE_DIR ${CMAKE_CURRENT_BINARY_DIR}/doctest-src/doctest) 23 | 24 | endif() 25 | 26 | set(${PROJECT_NAME}_TEST_TARGET test_${PROJECT_NAME}) 27 | 28 | 29 | 30 | # all tests 31 | set(${PROJECT_NAME}_TESTS 32 | test_{{cookiecutter.package_name}}_config.cpp 33 | ) 34 | 35 | add_executable( ${${PROJECT_NAME}_TEST_TARGET} 36 | main.cpp 37 | ${${PROJECT_NAME}_TESTS} 38 | ) 39 | 40 | target_link_libraries(${${PROJECT_NAME}_TEST_TARGET} 41 | ${INTERFACE_LIB_NAME} 42 | xtensor 43 | ) 44 | 45 | target_include_directories( ${${PROJECT_NAME}_TEST_TARGET} PRIVATE 46 | "$" 47 | ) 48 | 49 | add_custom_target(cpp-test COMMAND ${${PROJECT_NAME}_TEST_TARGET} WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/test" ) 50 | add_dependencies(cpp-test ${${PROJECT_NAME}_TEST_TARGET} ) -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/test/copyDoctest.cmake.in: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.2) 2 | 3 | project(doctest-download NONE) 4 | 5 | include(ExternalProject) 6 | ExternalProject_Add(doctest 7 | URL "${DOCTEST_SRC_DIR}" 8 | SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/doctest-src" 9 | BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/doctest-build" 10 | CONFIGURE_COMMAND "" 11 | BUILD_COMMAND "" 12 | INSTALL_COMMAND "" 13 | TEST_COMMAND "" 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/test/downloadDoctest.cmake.in: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.2) 2 | project(doctest-download NONE) 3 | 4 | include(ExternalProject) 5 | ExternalProject_Add(doctest 6 | GIT_REPOSITORY https://github.com/onqtam/doctest.git 7 | GIT_TAG 1.2.7 8 | SOURCE_DIR "${CMAKE_CURRENT_BINARY_DIR}/doctest-src" 9 | BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}/doctest-build" 10 | CONFIGURE_COMMAND "" 11 | BUILD_COMMAND "" 12 | INSTALL_COMMAND "" 13 | TEST_COMMAND "" 14 | ) 15 | 16 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/test/main.cpp: -------------------------------------------------------------------------------- 1 | #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN 2 | #include "doctest.h" -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/test/test_{{cookiecutter.package_name}}_config.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "{{cookiecutter.cpp_root_folder_name}}/{{cookiecutter.package_name}}.hpp" 4 | #include "{{cookiecutter.cpp_root_folder_name}}/{{cookiecutter.package_name}}_config.hpp" 5 | 6 | 7 | 8 | TEST_SUITE_BEGIN("core"); 9 | 10 | TEST_CASE("check version"){ 11 | 12 | #ifndef {{cookiecutter.cpp_macro_prefix}}_VERSION_MAJOR 13 | #error "{{cookiecutter.cpp_macro_prefix}}_VERSION_MAJOR is undefined" 14 | #endif 15 | 16 | 17 | #ifndef {{cookiecutter.cpp_macro_prefix}}_VERSION_MINOR 18 | #error "{{cookiecutter.cpp_macro_prefix}}_VERSION_MINOR is undefined" 19 | #endif 20 | 21 | 22 | #ifndef {{cookiecutter.cpp_macro_prefix}}_VERSION_PATCH 23 | #error "{{cookiecutter.cpp_macro_prefix}}_VERSION_PATCH is undefined" 24 | #endif 25 | 26 | CHECK_EQ({{cookiecutter.cpp_macro_prefix}}_VERSION_MAJOR , 0); 27 | CHECK_EQ({{cookiecutter.cpp_macro_prefix}}_VERSION_MINOR , 1); 28 | CHECK_EQ({{cookiecutter.cpp_macro_prefix}}_VERSION_PATCH , 0); 29 | } 30 | 31 | 32 | 33 | TEST_SUITE_END(); // end of testsuite core 34 | -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/{{cookiecutter.cmake_project_name}}.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ 3 | includedir=${prefix}/include 4 | 5 | Name: {{cookiecutter.cmake_project_name}} 6 | Description: {{cookiecutter.description}} 7 | Version: @{{cookiecutter.cmake_project_name}}_VERSION@ 8 | Cflags: -I${includedir} -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/{{cookiecutter.cmake_project_name}}Config.cmake.in: -------------------------------------------------------------------------------- 1 | set(${PN}_INCLUDE_DIR "${INC_DIRS}") 2 | 3 | 4 | get_filename_component(SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) 5 | get_filename_component(TOP_DIR "${SELF_DIR}/../../../" ABSOLUTE) 6 | SET(INC_DIRS "${TOP_DIR}/include/") 7 | 8 | 9 | 10 | 11 | 12 | @PACKAGE_INIT@ 13 | if(NOT TARGET @PROJECT_NAME@) 14 | find_package(xtensor REQUIRED) 15 | include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") 16 | set_target_properties( {{cookiecutter.cmake_interface_library_name}} PROPERTIES 17 | INTERFACE_INCLUDE_DIRECTORIES ${INC_DIRS} 18 | ) 19 | SET(@PROJECT_NAME@_INCLUDE_DIRS ${INC_DIRS}) 20 | endif() -------------------------------------------------------------------------------- /{{cookiecutter.github_project_name}}/{{cookiecutter.package_name}}-dev-requirements.yml: -------------------------------------------------------------------------------- 1 | name: {{cookiecutter.package_name}}-dev-requirements 2 | 3 | channels: 4 | - anaconda 5 | - conda-forge 6 | dependencies: 7 | - make 8 | - cmake >=3.1 9 | - sphinx 10 | - sphinx_rtd_theme 11 | - sphinxcontrib-apidoc 12 | - breathe 13 | - doxygen 14 | - pytest 15 | - xtl 16 | - xtensor 17 | - sphinx 18 | - doxygen 19 | - breathe 20 | {% if cookiecutter.python_bindings == 'yes' -%} 21 | - python >=3.6 22 | - numpy 23 | - xtensor-python 24 | - pybind11 25 | {% endif %} 26 | - pip 27 | - pip: 28 | - exhale --------------------------------------------------------------------------------