├── .clang-format ├── .github ├── ISSUE_TEMPLATE │ ├── bug_report.yml │ ├── config.yml │ └── feature_request.yml ├── pull_request_template.md └── workflows │ ├── install_prerequisites.yaml │ └── test_new_cxx_project.yml ├── .gitignore ├── .gitmodules ├── .readthedocs.yml ├── CMakeLists.txt ├── CODE_OF_CONDUCT.md ├── LICENCE ├── README.md ├── args.py ├── docker └── Dockerfile ├── docs ├── CODE_OF_CONDUCT.md ├── LICENCE.md ├── _templates │ └── layout.html ├── conf.py ├── index.md ├── requirements.in ├── requirements.txt └── source │ └── generated_files │ ├── cmake.rst │ └── vcpkg.rst ├── install_prerequisites.py ├── new_cxx_project.py ├── new_project ├── diagnostics.py ├── generate_cmake.py ├── generate_project.py └── import_templates.py ├── templates ├── .clang-format ├── .clang-tidy ├── .clangd ├── .github │ ├── ISSUE_TEMPLATE │ │ ├── bug_report.yml │ │ ├── config.yml │ │ └── feature_request.yml │ ├── pull_request_template.md │ └── workflows │ │ └── basic_ci.yml ├── .gitignore ├── .vscode │ ├── cmake-kits.json │ └── launch.json ├── CMakeLists.txt ├── CODE_OF_CONDUCT.md ├── LICENCE ├── README.md ├── config │ └── cmake │ │ ├── detail │ │ ├── add_targets.cmake │ │ ├── default_options.cmake │ │ ├── vcpkg.cmake │ │ └── vcpkg_toolchain_file.cmake.in │ │ ├── import_packages.cmake │ │ ├── install_targets.cmake │ │ ├── packages │ │ └── FindSphinx.cmake │ │ ├── project_options.cmake │ │ └── toolchains │ │ └── toolchain_base.cmake ├── docs │ ├── CMakeLists.txt │ ├── _templates │ │ └── layout.html │ ├── conf.py │ ├── requirements.in │ ├── requirements.txt │ └── source │ │ └── project │ │ ├── cmake.rst │ │ └── vcpkg.rst ├── source │ └── CMakeLists.txt └── vcpkg.json └── test ├── default-options ├── asan-only-changes │ └── source │ │ ├── CMakeLists.txt │ │ └── asan │ │ ├── CMakeLists.txt │ │ ├── greeter.cpp │ │ ├── greeter.hpp │ │ ├── hello.cpp │ │ └── test_greeter.cpp ├── changes │ ├── config │ │ └── cmake │ │ │ ├── import_packages.cmake │ │ │ └── install_targets.cmake │ ├── source │ │ ├── CMakeLists.txt │ │ ├── check.hpp │ │ ├── compile_options │ │ │ ├── CMakeLists.txt │ │ │ ├── greeter.cpp │ │ │ ├── greeter.hpp │ │ │ ├── hello.cpp │ │ │ └── test_greeter.cpp │ │ ├── define │ │ │ ├── CMakeLists.txt │ │ │ ├── greeter.cpp │ │ │ ├── greeter.hpp │ │ │ ├── hello.cpp │ │ │ └── test_greeter.cpp │ │ ├── header_only_library │ │ │ ├── CMakeLists.txt │ │ │ ├── fanciful.hpp │ │ │ ├── greeter.hpp │ │ │ ├── hello.cpp │ │ │ └── test_greeter.cpp │ │ ├── link_options │ │ │ ├── CMakeLists.txt │ │ │ ├── greeter.cpp │ │ │ ├── greeter.hpp │ │ │ ├── hello.cpp │ │ │ └── test_greeter.cpp │ │ ├── module_interface │ │ │ ├── CMakeLists.txt │ │ │ ├── greeter.cpp │ │ │ └── greeter_module.cpp │ │ ├── multi_file │ │ │ ├── CMakeLists.txt │ │ │ ├── check.hpp │ │ │ ├── greeter.cpp │ │ │ ├── greeter.hpp │ │ │ ├── greeter_impl.cpp │ │ │ ├── greeter_impl.hpp │ │ │ ├── hello.cpp │ │ │ └── test_greeter.cpp │ │ ├── object_library │ │ │ ├── CMakeLists.txt │ │ │ ├── greeter.cpp │ │ │ ├── greeter.hpp │ │ │ ├── hello.cpp │ │ │ └── test_greeter.cpp │ │ ├── plugin_library │ │ │ ├── CMakeLists.txt │ │ │ ├── greeter.cpp │ │ │ ├── greeter.hpp │ │ │ ├── hello.cpp │ │ │ ├── plugin_handler.hpp │ │ │ └── test_greeter.cpp │ │ ├── shared_library │ │ │ ├── CMakeLists.txt │ │ │ ├── fanciful.cpp │ │ │ ├── fanciful.hpp │ │ │ ├── greeter.cpp │ │ │ ├── greeter.hpp │ │ │ ├── hello.cpp │ │ │ └── test_greeter.cpp │ │ └── static_library │ │ │ ├── CMakeLists.txt │ │ │ ├── fanciful.cpp │ │ │ ├── fanciful.hpp │ │ │ ├── greeter.cpp │ │ │ ├── greeter.hpp │ │ │ ├── hello.cpp │ │ │ └── test_greeter.cpp │ └── vcpkg.json ├── expected-output │ ├── .clang-format │ ├── .clang-tidy │ ├── .clangd │ ├── CMakeLists.txt │ ├── CODE_OF_CONDUCT.md │ ├── LICENCE │ ├── README.md │ ├── config │ │ └── cmake │ │ │ ├── detail │ │ │ ├── add_targets.cmake │ │ │ └── default_options.cmake │ │ │ ├── install_targets.cmake │ │ │ ├── project_options.cmake │ │ │ └── toolchains │ │ │ ├── x86_64-unknown-linux-gnu.cmake │ │ │ └── x86_64-unknown-linux-llvm.cmake │ ├── docs │ │ └── CMakeLists.txt │ └── source │ │ └── CMakeLists.txt ├── tests │ ├── default_options │ │ ├── Debug.test │ │ ├── MinSizeRel.test │ │ ├── RelWithDebInfo.test │ │ ├── Release.test │ │ ├── expected-cmake.out │ │ ├── expected-ctest.out │ │ ├── expected-permissions.out │ │ └── expected-stdout.out │ ├── gnu │ │ ├── Debug.test │ │ ├── MinSizeRel.test │ │ ├── RelWithDebInfo.test │ │ ├── Release.test │ │ ├── expected-cmake.out │ │ ├── expected-ctest.out │ │ ├── expected-permissions.out │ │ └── expected-stdout.out │ └── llvm │ │ ├── Debug.test │ │ ├── MinSizeRel.test │ │ ├── RelWithDebInfo.test │ │ ├── Release.test │ │ ├── expected-cmake.out │ │ ├── expected-ctest.out │ │ ├── expected-permissions.out │ │ └── expected-stdout.out └── ubsan-only-changes │ └── source │ ├── CMakeLists.txt │ └── ubsan │ ├── CMakeLists.txt │ ├── greeter.cpp │ ├── greeter.hpp │ ├── hello.cpp │ └── test_greeter.cpp ├── diagnostics ├── COMPILE_OPTIONS-do-not-propagate │ ├── CMakeLists.txt │ ├── greeter.cpp │ ├── greeter.hpp │ ├── hello.cpp │ └── test.test ├── DEFINE-does-not-propagate │ ├── CMakeLists.txt │ ├── greeter.cpp │ ├── greeter.hpp │ ├── hello.cpp │ └── test.test ├── DEPENDS_ON-does-not-propagate │ ├── CMakeLists.txt │ ├── greeter.cpp │ ├── greeter.hpp │ ├── hello.cpp │ ├── make_fancy.cpp │ ├── make_fancy.hpp │ └── test.test ├── LINK_OPTIONS-do-not-propagate │ ├── CMakeLists.txt │ ├── greeter.cpp │ ├── greeter.hpp │ ├── greeter_impl.cpp │ ├── hello.cpp │ └── test.test ├── MODULE_INTERFACE-cannot-be-installed │ ├── CMakeLists.txt │ └── test.test ├── bad_github_remote.test ├── build-type-not-set.test ├── cxx_test-specifies-INSTALL_WITH │ ├── CMakeLists.txt │ └── test.test ├── invalid_name.test ├── library-type-errors │ ├── HEADER_ONLY-specifes-COMPILE_OPTIONS │ │ ├── CMakeLists.txt │ │ └── test.test │ ├── HEADER_ONLY-specifes-LINK_OPTIONS │ │ ├── CMakeLists.txt │ │ └── test.test │ ├── HEADER_ONLY-specifies-DEPENDS_ON │ │ ├── CMakeLists.txt │ │ └── test.test │ ├── HEADER_ONLY-specifies-HEADERS │ │ ├── CMakeLists.txt │ │ └── test.test │ ├── HEADER_ONLY-specifies-MODULE_INTERFACE │ │ ├── CMakeLists.txt │ │ └── test.test │ ├── HEADER_ONLY-specifies-SOURCES │ │ ├── CMakeLists.txt │ │ └── test.test │ ├── LIBRARY_TYPE-missing │ │ ├── CMakeLists.txt │ │ └── test.test │ ├── LIBRARY_TYPE-unknown │ │ ├── CMakeLists.txt │ │ └── test.test │ ├── OBJECT-specifes-LINK_OPTIONS │ │ ├── CMakeLists.txt │ │ └── test.test │ ├── OBJECT-specifies-DEPENDS_ON_INTERFACE │ │ ├── CMakeLists.txt │ │ └── test.test │ ├── OBJECT-specifies-HEADER_INTERFACE │ │ ├── CMakeLists.txt │ │ └── test.test │ ├── OBJECT-specifies-INSTALL_WITH │ │ ├── CMakeLists.txt │ │ └── test.test │ └── OBJECT-specifies-MODULE_INTERFACE │ │ ├── CMakeLists.txt │ │ └── test.test ├── no_args.test ├── preexisting_repo.test ├── source-not-set.test └── target-not-set.test ├── files ├── .github │ ├── ISSUE_TEMPLATE │ │ ├── bug_report.yml │ │ ├── config.yml │ │ └── feature_request.yml │ ├── pull_request_template.md │ └── workflows │ │ └── basic_ci.yml ├── copied-okay.test ├── expected │ ├── .clang-format │ ├── .clang-tidy │ ├── .clangd │ ├── .gitignore │ ├── .vscode │ │ ├── cmake-kits.json │ │ └── launch.json │ ├── CMakeLists.txt │ ├── CODE_OF_CONDUCT.md │ ├── LICENCE │ ├── README.md │ ├── config │ │ └── cmake │ │ │ ├── detail │ │ │ ├── add_targets.cmake │ │ │ └── default_options.cmake │ │ │ ├── import_packages.cmake │ │ │ ├── install_targets.cmake │ │ │ ├── packages │ │ │ └── FindSphinx.cmake │ │ │ ├── project_options.cmake │ │ │ └── toolchains │ │ │ ├── x86_64-unknown-linux-gnu.cmake │ │ │ └── x86_64-unknown-linux-llvm.cmake │ ├── docs │ │ ├── CMakeLists.txt │ │ ├── CODE_OF_CONDUCT.md │ │ ├── LICENCE.md │ │ ├── _templates │ │ │ └── layout.html │ │ ├── conf.py │ │ ├── index.md │ │ ├── requirements.in │ │ ├── requirements.txt │ │ └── source │ │ │ └── project │ │ │ └── cmake.rst │ └── source │ │ └── CMakeLists.txt ├── git-remote.test ├── git-status.test └── vcpkg-changes │ ├── .gitmodules │ ├── CMakeLists.txt │ ├── config │ └── cmake │ │ └── detail │ │ ├── vcpkg.cmake │ │ └── vcpkg_toolchain_file.cmake.in │ ├── docs │ └── source │ │ └── project │ │ └── vcpkg.rst │ └── vcpkg.json ├── lit.cfg.py ├── lit.rm.py └── lit.site.cfg.py.in /.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Toolchain bug report 3 | description: File a bug report regarding how we use the C++ tools (do not use for C++ toolchain bugs) 4 | title: 'toolchain' 5 | labels: ['bug'] 6 | assignees: ['@cjdb'] 7 | body: 8 | - type: markdown 9 | attributes: 10 | value: | 11 | Thank you for taking the time out to file a bug report! To help us triage this as quickly as 12 | possible, please familiarise yourself with our [bug reporting documentation](../../docs/user/reporting_bugs.rst). 13 | 14 | ## Bug details 15 | 16 | - type: textarea 17 | id: description 18 | attributes: 19 | label: Bug description 20 | description: 21 | Please provide a clear description of your issue. If you got a compile-time error or warning, 22 | or a runtime error, please include it in your description. 23 | validations: 24 | required: true 25 | 26 | - type: textarea 27 | id: expected 28 | attributes: 29 | label: Expected result 30 | description: What do you expect to happen? 31 | validations: 32 | required: true 33 | 34 | - type: textarea 35 | id: repro 36 | attributes: 37 | label: Minimal reproduction 38 | description: Please provide the smallest amount of code possible to reproduce your issue. 39 | validations: 40 | required: true 41 | 42 | - type: markdown 43 | attributes: 44 | value: '## Toolchain information' 45 | 46 | - type: dropdown 47 | id: compiler 48 | attributes: 49 | label: Which compiler are you experiencing this on? 50 | multiple: false 51 | options: 52 | - Clang 53 | - GCC 54 | - MSVC 55 | - Other 56 | validations: 57 | required: true 58 | 59 | - type: textarea 60 | id: compiler_version 61 | attributes: 62 | label: What version of the compiler are you using? 63 | placeholder: | 64 | $ clang --version 65 | clang version 16.0.0 66 | Target: x86_64-unknown-linux-gnu 67 | Thread model: posix 68 | InstalledDir: /usr/bin 69 | validations: 70 | required: true 71 | 72 | - type: input 73 | id: build_flags 74 | attributes: 75 | label: Build options 76 | description: 77 | Please paste the complete compiler and linker options. You can get this by passing `-###` to 78 | the compiler alongside the rest of your options. 79 | validations: 80 | required: true 81 | 82 | - type: input 83 | id: os 84 | attributes: 85 | label: Operating system 86 | description: Which operating system are you using? 87 | placeholder: Ubuntu 24.04 88 | validations: 89 | required: true 90 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | description: Suggest an idea for the project 4 | title: '' 5 | labels: ['enhancement'] 6 | assignees: [] 7 | body: 8 | - type: markdown 9 | attributes: 10 | value: | 11 | ## Feature request 12 | 13 | - type: textarea 14 | id: description 15 | attributes: 16 | label: Is your feature request related to a problem? Please describe 17 | description: 18 | A clear and concise description of the problem (e.g. I'm always frustrated when...) 19 | validations: 20 | required: true 21 | 22 | - type: textarea 23 | id: proposed_solution 24 | attributes: 25 | label: Describe the solution you'd like 26 | description: A clear and concise description of what you would like to happen. 27 | validations: 28 | required: true 29 | 30 | - type: textarea 31 | id: alternatives 32 | attributes: 33 | label: Describe any alternatives that you've considered 34 | validations: 35 | required: true 36 | -------------------------------------------------------------------------------- /.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | Issues #123, #456, #789 9 | Fixes #1011, #1213 10 | 11 | ## Tests 12 | 13 | 14 | 15 | ## Benchmarks 16 | 17 | 18 | 19 | ## Other checks 20 | 21 | - [ ] Adds or updates relevant unit tests 22 | - [ ] Relevant fuzz tests were added 23 | - [ ] Documentation has been updated 24 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "vcpkg"] 2 | path = vcpkg 3 | url = https://github.com/Microsoft/vcpkg.git 4 | -------------------------------------------------------------------------------- /.readthedocs.yml: -------------------------------------------------------------------------------- 1 | # .readthedocs.yaml 2 | # Read the Docs configuration file 3 | # See https://docs.readthedocs.io/en/stable/config-file/v2.html for details 4 | 5 | # Required 6 | version: 2 7 | 8 | # Set the OS, Python version and other tools you might need 9 | build: 10 | os: ubuntu-24.04 11 | tools: 12 | python: "3.12" 13 | 14 | # Build documentation in the "docs/" directory with Sphinx 15 | sphinx: 16 | configuration: docs/conf.py 17 | 18 | python: 19 | install: 20 | - requirements: docs/requirements.txt 21 | -------------------------------------------------------------------------------- /args.py: -------------------------------------------------------------------------------- 1 | # Copyright Christopher Di Bella 2 | # Licensed under the Apache License v2.0 with LLVM Exceptions. 3 | # See /LICENCE for licence information. 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | import argparse 6 | import sys 7 | 8 | 9 | def parse_args(): 10 | parser = argparse.ArgumentParser(prog=sys.argv[0], 11 | description='Generates a new C++ project') 12 | parser.add_argument( 13 | 'path', 14 | help='A path to the project directory. Created if absent.', 15 | ) 16 | parser.add_argument( 17 | '--author', 18 | required=True, 19 | help='The entity who owns the copyright.', 20 | ) 21 | parser.add_argument( 22 | '--remote', 23 | type=str, 24 | help='A remote that the repo can be uploaded to by default', 25 | default='') 26 | parser.add_argument( 27 | '--package-manager', 28 | type=str, 29 | choices=['none', 'vcpkg'], 30 | help='Specifies the package manager to use', 31 | default='none', 32 | ) 33 | parser.add_argument( 34 | '--package-manager-remote', 35 | type=str, 36 | help='A remote that the package manager can be acquired from', 37 | default='', 38 | ) 39 | 40 | return parser.parse_args() 41 | -------------------------------------------------------------------------------- /docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM ubuntu:noble 2 | 3 | RUN apt-get update 4 | RUN apt-get dist-upgrade -y 5 | RUN apt-get update 6 | RUN apt-get install -y software-properties-common 7 | RUN add-apt-repository universe 8 | RUN apt-get update 9 | RUN apt-get install -y wget lsb-release 10 | RUN wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add - 11 | RUN apt-get remove -y '*clang*' '*llvm*' 12 | RUN apt-get autoremove -y 13 | RUN apt-get install -y \ 14 | build-essential \ 15 | bzip2 \ 16 | curl \ 17 | gcc-14 \ 18 | g++-14 \ 19 | libssl-dev \ 20 | libz3-dev \ 21 | ninja-build \ 22 | pkg-config \ 23 | python-is-python3 \ 24 | python3 \ 25 | python3-git \ 26 | python3-myst-parser \ 27 | python3-pip \ 28 | python3-psutil \ 29 | python3-sphinx \ 30 | tar \ 31 | unzip \ 32 | wget \ 33 | zip 34 | ENV LLVM_VERSION=19 35 | RUN apt-add-repository "deb http://apt.llvm.org/noble/ llvm-toolchain-noble main" 36 | RUN apt-get update 37 | RUN apt-get install -y \ 38 | libllvm${LLVM_VERSION} \ 39 | llvm-${LLVM_VERSION} \ 40 | llvm-${LLVM_VERSION}-dev \ 41 | llvm-${LLVM_VERSION}-runtime \ 42 | clang-${LLVM_VERSION} \ 43 | clang-tools-${LLVM_VERSION} \ 44 | libclang-common-${LLVM_VERSION}-dev \ 45 | libclang-${LLVM_VERSION}-dev \ 46 | libclang1-${LLVM_VERSION} \ 47 | clang-format-${LLVM_VERSION} \ 48 | python3-clang-${LLVM_VERSION} \ 49 | clang-tidy-${LLVM_VERSION} \ 50 | libclang-rt-${LLVM_VERSION}-dev \ 51 | libfuzzer-${LLVM_VERSION}-dev \ 52 | lld-${LLVM_VERSION} \ 53 | libc++-${LLVM_VERSION}-dev \ 54 | libc++abi-${LLVM_VERSION}-dev \ 55 | libunwind-${LLVM_VERSION}-dev \ 56 | libllvmlibc-${LLVM_VERSION}-dev 57 | RUN git clone https://github.com/Kitware/CMake.git --depth=1 && \ 58 | cd CMake && \ 59 | ./bootstrap --parallel=$(nproc) --generator=Ninja --no-debugger && \ 60 | ninja && \ 61 | ninja install && \ 62 | cd .. && \ 63 | rm -rf CMake 64 | WORKDIR / 65 | RUN update-alternatives --install /usr/bin/clang clang /usr/bin/clang-${LLVM_VERSION} 100 66 | RUN update-alternatives --install /usr/bin/clang++ clang++ /usr/bin/clang++-${LLVM_VERSION} 100 67 | RUN update-alternatives --install /usr/bin/clang-format clang-format /usr/bin/clang-format-${LLVM_VERSION} 100 68 | RUN update-alternatives --install /usr/bin/clang-tidy clang-tidy /usr/bin/clang-tidy-${LLVM_VERSION} 100 69 | RUN update-alternatives --install /usr/bin/llvm-ar llvm-ar /usr/bin/llvm-ar-${LLVM_VERSION} 100 70 | RUN update-alternatives --install /usr/bin/llvm-rc llvm-rc /usr/bin/llvm-rc-${LLVM_VERSION} 100 71 | RUN update-alternatives --install /usr/bin/llvm-ranlib llvm-ranlib /usr/bin/llvm-ranlib-${LLVM_VERSION} 100 72 | RUN update-alternatives --install /usr/bin/FileCheck FileCheck /usr/bin/FileCheck-${LLVM_VERSION} 100 73 | RUN update-alternatives --install /usr/bin/lit lit /usr/lib/llvm-${LLVM_VERSION}/build/utils/lit/lit.py 100 74 | RUN update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-14 100 75 | RUN update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-14 100 76 | RUN update-alternatives --install /usr/bin/cc cc /usr/bin/gcc-14 100 77 | RUN update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++-14 100 78 | -------------------------------------------------------------------------------- /docs/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ../CODE_OF_CONDUCT.md -------------------------------------------------------------------------------- /docs/LICENCE.md: -------------------------------------------------------------------------------- 1 | ../LICENCE -------------------------------------------------------------------------------- /docs/_templates/layout.html: -------------------------------------------------------------------------------- 1 | {% extends '!layout.html' %} 2 | 3 | {% block footer %} 4 | 5 |

This work is licensed under CC BY-SA 4.0

6 |
7 | {% endblock %} 8 | -------------------------------------------------------------------------------- /docs/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # For the full list of built-in configuration values, see the documentation: 4 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 5 | 6 | # -- Project information ----------------------------------------------------- 7 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information 8 | 9 | project = 'new_cxx_project' 10 | author = 'Christopher Di Bella' 11 | 12 | # -- General configuration --------------------------------------------------- 13 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration 14 | 15 | extensions = [ 16 | 'myst_parser', 17 | 'sphinx.ext.autosectionlabel', 18 | 'sphinx.ext.extlinks', 19 | 'sphinx.ext.mathjax', 20 | 'sphinx.ext.todo', 21 | 'sphinx.ext.viewcode', 22 | ] 23 | 24 | templates_path = ['_templates'] 25 | exclude_patterns = [] 26 | 27 | # -- Options for HTML output ------------------------------------------------- 28 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output 29 | 30 | html_theme = 'sphinx_book_theme' 31 | html_theme_options = { 32 | 'repository_url': 'https://github.com/cjdb/new_cxx_project', 33 | 'use_repository_button': True, 34 | } 35 | html_static_path = ['_static'] 36 | html_show_copyright = False 37 | 38 | myst_enable_extensions = [ 39 | 'dollarmath', 40 | 'amsmath', 41 | 'deflist', 42 | 'fieldlist', 43 | 'html_admonition', 44 | 'html_image', 45 | 'colon_fence', 46 | 'smartquotes', 47 | 'replacements', 48 | 'strikethrough', 49 | 'substitution', 50 | 'tasklist', 51 | 'attrs_inline', 52 | 'attrs_block', 53 | ] 54 | -------------------------------------------------------------------------------- /docs/index.md: -------------------------------------------------------------------------------- 1 | ../README.md -------------------------------------------------------------------------------- /docs/requirements.in: -------------------------------------------------------------------------------- 1 | GitPython 2 | sphinx 3 | myst-parser 4 | psutil 5 | sphinx_book_theme 6 | -------------------------------------------------------------------------------- /docs/requirements.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is autogenerated by pip-compile with Python 3.12 3 | # by the following command: 4 | # 5 | # pip-compile requirements.in 6 | # 7 | accessible-pygments==0.0.5 8 | # via pydata-sphinx-theme 9 | alabaster==0.7.16 10 | # via sphinx 11 | babel==2.15.0 12 | # via 13 | # pydata-sphinx-theme 14 | # sphinx 15 | beautifulsoup4==4.12.3 16 | # via pydata-sphinx-theme 17 | certifi==2024.7.4 18 | # via requests 19 | charset-normalizer==3.3.2 20 | # via requests 21 | docutils==0.21.2 22 | # via 23 | # myst-parser 24 | # pydata-sphinx-theme 25 | # sphinx 26 | gitdb==4.0.11 27 | # via gitpython 28 | gitpython==3.1.43 29 | # via -r requirements.in 30 | idna==3.7 31 | # via requests 32 | imagesize==1.4.1 33 | # via sphinx 34 | jinja2==3.1.4 35 | # via 36 | # myst-parser 37 | # sphinx 38 | markdown-it-py==3.0.0 39 | # via 40 | # mdit-py-plugins 41 | # myst-parser 42 | markupsafe==2.1.5 43 | # via jinja2 44 | mdit-py-plugins==0.4.1 45 | # via myst-parser 46 | mdurl==0.1.2 47 | # via markdown-it-py 48 | myst-parser==3.0.1 49 | # via -r requirements.in 50 | packaging==24.1 51 | # via 52 | # pydata-sphinx-theme 53 | # sphinx 54 | psutil==6.0.0 55 | # via -r requirements.in 56 | pydata-sphinx-theme==0.15.4 57 | # via sphinx-book-theme 58 | pygments==2.18.0 59 | # via 60 | # accessible-pygments 61 | # pydata-sphinx-theme 62 | # sphinx 63 | pyyaml==6.0.1 64 | # via myst-parser 65 | requests==2.32.3 66 | # via sphinx 67 | smmap==5.0.1 68 | # via gitdb 69 | snowballstemmer==2.2.0 70 | # via sphinx 71 | soupsieve==2.5 72 | # via beautifulsoup4 73 | sphinx==7.4.7 74 | # via 75 | # -r requirements.in 76 | # myst-parser 77 | # pydata-sphinx-theme 78 | # sphinx-book-theme 79 | sphinx-book-theme==1.1.3 80 | # via -r requirements.in 81 | sphinxcontrib-applehelp==2.0.0 82 | # via sphinx 83 | sphinxcontrib-devhelp==2.0.0 84 | # via sphinx 85 | sphinxcontrib-htmlhelp==2.1.0 86 | # via sphinx 87 | sphinxcontrib-jsmath==1.0.1 88 | # via sphinx 89 | sphinxcontrib-qthelp==2.0.0 90 | # via sphinx 91 | sphinxcontrib-serializinghtml==2.0.0 92 | # via sphinx 93 | typing-extensions==4.12.2 94 | # via pydata-sphinx-theme 95 | urllib3==2.2.2 96 | # via requests 97 | -------------------------------------------------------------------------------- /docs/source/generated_files/vcpkg.rst: -------------------------------------------------------------------------------- 1 | .. 2 | Copyright (c) 2024 Christopher Di Bella 3 | Licensed under Creative Commons Attribution-ShareAlike 4.0 International 4 | See /LICENCE for licence information. 5 | SPDX-License-Identifier: CC BY-SA 4.0 6 | 7 | *********** 8 | Using vcpkg 9 | *********** 10 | 11 | .. note:: 12 | 13 | This documentation is the same documentation that would be generated for your project when using 14 | new_cxx_project. The term :code:`${project_name}` will be replaced with your project's designated 15 | name. 16 | 17 | ${project_name} uses `vcpkg `_ for package management. We use the 18 | `manifest mode `_. 19 | 20 | Adding packages 21 | ================ 22 | 23 | To add a dependency, add it to the top-level ``vcpkg.json``, and then add the corresponding CMake 24 | ``find_package`` (or equivalent) rule to ``config/cmake/add_packages.cmake``. 25 | 26 | Setting up the toolchain with vcpkg 27 | =================================== 28 | 29 | This project aims to build its dependencies with the same compile-time options as its own targets, 30 | where possible (Titus Winters' keynote, `'C++ Past vs. Future' `_, 31 | summarises why we adopt this philosophy). ${project_name} generates a vcpkg toolchain file when you 32 | configure the project, so you shouldn't follow the vcpkg instructions for setting things up. Instead, 33 | just configure the project using the options documented in :doc:`cmake`. You can optionally set 34 | :code:`-DVCPKG_INSTALL_OPTIONS`, which will be passed to vcpkg. 35 | 36 | .. code-block:: 37 | :caption: An example showing how vcpkg can be used. The ``-DVCPKG_INSTALL_OPTIONS='--clean-after-build'`` 38 | option is optional, and tells vcpkg to clean its build cache after all packages are installed. 39 | 40 | $ cmake -S. -Bbuild -GNinja \ 41 | -DCMAKE_BUILD_TYPE=Debug \ 42 | -DTOOLCHAIN_FILE='/path/to/project/config/cmake/toolchains/x86_64-unknown-linux-llvm.cmake' \ 43 | -DVCPKG_INSTALL_OPTIONS='--clean-after-build' \ 44 | 45 | -------------------------------------------------------------------------------- /new_cxx_project.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | # Copyright (c) Christopher Di Bella. 3 | # SPDX-License-Identifier: Apache-2.0 with LLVM Exception 4 | # 5 | import sys 6 | from pathlib import Path 7 | from args import parse_args 8 | from new_project.generate_project import generate 9 | import new_project.diagnostics as diagnostics 10 | 11 | 12 | def main(): 13 | args = parse_args() 14 | generate(path=Path(args.path), 15 | author=args.author, 16 | remote=args.remote, 17 | package_manager=args.package_manager, 18 | package_manager_remote=args.package_manager_remote) 19 | sys.exit(int(diagnostics.total_errors != 0)) 20 | 21 | 22 | if __name__ == "__main__": 23 | main() 24 | -------------------------------------------------------------------------------- /new_project/diagnostics.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Christopher Di Bella. 2 | # SPDX-License-Identifier: Apache-2.0 with LLVM Exception 3 | # 4 | import sys 5 | import pygments 6 | 7 | total_errors = 0 8 | 9 | 10 | def report_error(message: str, fatal: bool = False): 11 | print(f'error: {message}', file=sys.stderr) 12 | if fatal: 13 | sys.exit(1) 14 | ++total_errors 15 | 16 | 17 | def report_note(message: str): 18 | print(f'note: {message}') 19 | -------------------------------------------------------------------------------- /new_project/import_templates.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) Christopher Di Bella. 2 | # SPDX-License-Identifier: Apache-2.0 with LLVM Exception 3 | # 4 | import os 5 | import re 6 | from pathlib import Path 7 | from string import Template 8 | from typing import Dict 9 | 10 | template_dir = f'{Path(__file__).resolve().parent}/../templates' 11 | 12 | 13 | def substitute(replace: Dict[str, str], 14 | template: str, 15 | prefix: str, 16 | rename: str = None) -> str: 17 | with open(f'{template_dir}/{template}') as f: 18 | data = Template(f.read()) 19 | 20 | suffix = template if not rename else os.path.join( 21 | os.path.dirname(template), rename) 22 | path = f'{prefix}/{suffix}' 23 | with open(path, 'w') as f: 24 | f.write(re.sub(r'^\s+$', '', data.substitute(replace))) 25 | return path 26 | -------------------------------------------------------------------------------- /templates/.clang-tidy: -------------------------------------------------------------------------------- 1 | Checks: 'abseil-*, 2 | boost-*, 3 | bugprone-*, 4 | -bugprone-exception-escape, 5 | cert-*, 6 | -cert-dcl21-cpp, 7 | -cert-msc32-c, 8 | -cert-msc51-cpp, 9 | clang-analyzer-*, 10 | clang-diagnostic-*, 11 | cppcoreguildelines-*, 12 | google-*, 13 | -google-runtime-int, 14 | -google-runtime-references, 15 | misc-*, 16 | -misc-no-recursion, 17 | -misc-non-private-member-variables-in-classes, 18 | modernize-*, 19 | -modernize-use-trailing-return-type, 20 | performance-*, 21 | portability-*, 22 | -portability-simd-intrinsics, 23 | readability-*, 24 | -readability-function-size, 25 | -readability-function-cognitive-complexity, 26 | -readability-named-parameter, 27 | -readability-qualified-auto, 28 | -readability-identifier-length' 29 | WarningsAsErrors: '*' 30 | 31 | CheckOptions: 32 | - key: bugprone-dangling-handle.HandleClasses 33 | value: 'std::basic_string_view;std::span;std::ranges::subrange;std::ranges::all_view;std::ranges::common_view;std::ranges::keys_view;std::ranges::values_view' 34 | - key: bugprone-exception-escape.FunctionsThatShouldNotThrow 35 | value: 'iter_move,iter_swap' 36 | - key: readability-simplify-boolean-expr.ChainedConditionalReturn 37 | value: '1' 38 | - key: readability-simplify-boolean-expr.ChainedConditionalAssignment 39 | value: '1' 40 | - key: readability-simplify-subscript-expr.Types 41 | value: 'std::array;std::basic_string;std::basic_string_view;std::span;std::vector' 42 | 43 | # For the full list, see https://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-naming.html. 44 | - key: readability-identifier-naming.ClassCase 45 | value: "lower_case" 46 | - key: readability-identifier-naming.ClassMemberSuffix 47 | value: "_" 48 | - key: readability-identifier-naming.ConceptCase 49 | value: "lower_case" 50 | - key: readability-identifier-naming.ConstantCase 51 | value: "lower_case" 52 | - key: readability-identifier-naming.ConstantMemberCase 53 | value: "lower_case" 54 | - key: readability-identifier-naming.ConstexprVariableCase 55 | value: "lower_case" 56 | - key: readability-identifier-naming.EnumCase 57 | value: "lower_case" 58 | - key: readability-identifier-naming.EnumConstantCase 59 | value: "lower_case" 60 | - key: readability-identifier-naming.FunctionCase 61 | value: "lower_case" 62 | - key: readability-identifier-naming.GlobalCase 63 | value: "lower_case" 64 | - key: readability-identifier-naming.MacroDefinitionCase 65 | value: "UPPER_CASE" 66 | - key: readability-identifier-naming.MacroDefinitionPrefix 67 | value: "${PROJECT_NAME}_" 68 | - key: readability-identifier-naming.MemberCase 69 | value: "lower_case" 70 | - key: readability-identifier-naming.MethodCase 71 | value: "lower_case" 72 | - key: readability-identifier-naming.NamespaceCase 73 | value: "lower_case" 74 | - key: readability-identifier-naming.ParameterCase 75 | value: "lower_case" 76 | - key: readability-identifier-naming.PrivateMemberSuffix 77 | value: "_" 78 | - key: readability-identifier-naming.PrivateMethodCase 79 | value: "lower_case" 80 | - key: readability-identifier-naming.PublicMemberCase 81 | value: "lower_case" 82 | - key: readability-identifier-naming.PublicMethodCase 83 | value: "lower_case" 84 | - key: readability-identifier-naming.TypeAliasCase 85 | value: "lower_case" 86 | - key: readability-identifier-naming.VariableCase 87 | value: "lower_case" 88 | -------------------------------------------------------------------------------- /templates/.clangd: -------------------------------------------------------------------------------- 1 | CompileFlags: 2 | Remove: 3 | - -fmodules 4 | CompilationDatabase: ./build 5 | Diagnostics: 6 | MissingIncludes: Strict 7 | Index: 8 | Background: Build 9 | StandardLibrary: Yes 10 | -------------------------------------------------------------------------------- /templates/.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | description: Create a report to help us improve 4 | title: 'bug report' 5 | labels: ['bug'] 6 | assignees: [] 7 | body: 8 | - type: markdown 9 | attributes: 10 | value: | 11 | Thank you for taking the time out to file a bug report! To help us triage this as quickly as 12 | possible, please familiarise yourself with our [bug reporting documentation](../../docs/user/reporting_bugs.rst). 13 | 14 | ## Bug details 15 | 16 | - type: textarea 17 | id: description 18 | attributes: 19 | label: Bug description 20 | description: 21 | Please provide a clear description of your issue. If you got a compile-time error or warning, 22 | or a runtime error, please include it in your description. 23 | validations: 24 | required: true 25 | 26 | - type: textarea 27 | id: expected 28 | attributes: 29 | label: Expected result 30 | description: What do you expect to happen? 31 | validations: 32 | required: true 33 | 34 | - type: textarea 35 | id: repro 36 | attributes: 37 | label: Minimal reproduction 38 | description: Please provide the smallest amount of code possible to reproduce your issue. 39 | validations: 40 | required: true 41 | 42 | - type: markdown 43 | attributes: 44 | value: '## Toolchain information' 45 | 46 | - type: dropdown 47 | id: compiler 48 | attributes: 49 | label: Which compiler are you experiencing this on? 50 | multiple: false 51 | options: 52 | - Clang 53 | - GCC 54 | - MSVC 55 | - Other 56 | validations: 57 | required: true 58 | 59 | - type: textarea 60 | id: compiler_version 61 | attributes: 62 | label: What version of the compiler are you using? 63 | placeholder: | 64 | $ clang --version 65 | clang version 16.0.0 66 | Target: x86_64-unknown-linux-gnu 67 | Thread model: posix 68 | InstalledDir: /usr/bin 69 | validations: 70 | required: true 71 | 72 | - type: input 73 | id: build_flags 74 | attributes: 75 | label: Build options 76 | description: 77 | Please paste the complete compiler and linker options. You can get this by passing `-###` to 78 | the compiler alongside the rest of your options. 79 | validations: 80 | required: true 81 | 82 | - type: input 83 | id: os 84 | attributes: 85 | label: Operating system 86 | description: Which operating system are you using? 87 | placeholder: Ubuntu 20.04 88 | validations: 89 | required: true 90 | -------------------------------------------------------------------------------- /templates/.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | -------------------------------------------------------------------------------- /templates/.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | description: Suggest an idea for the project 4 | title: 'feature request' 5 | labels: ['enhancement'] 6 | assignees: [] 7 | body: 8 | - type: markdown 9 | attributes: 10 | value: | 11 | ## Feature request 12 | 13 | - type: textarea 14 | id: description 15 | attributes: 16 | label: Is your feature request related to a problem? Please describe 17 | description: 18 | A clear and concise description of the problem (e.g. I'm always frustrated when...) 19 | validations: 20 | required: true 21 | 22 | - type: textarea 23 | id: proposed_solution 24 | attributes: 25 | label: Describe the solution you'd like 26 | description: A clear and concise description of what you would like to happen. 27 | validations: 28 | required: true 29 | 30 | - type: textarea 31 | id: alternatives 32 | attributes: 33 | label: Describe any alternatives that you've considered 34 | validations: 35 | required: true 36 | -------------------------------------------------------------------------------- /templates/.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | Issues #123, #456, #789 9 | Fixes #1011, #1213 10 | 11 | ## Tests 12 | 13 | 14 | 15 | ## Benchmarks 16 | 17 | 18 | 19 | ## Other checks 20 | 21 | - [ ] Adds or updates relevant unit tests 22 | - [ ] Relevant fuzz tests were added 23 | - [ ] Documentation has been updated 24 | -------------------------------------------------------------------------------- /templates/.github/workflows/basic_ci.yml: -------------------------------------------------------------------------------- 1 | name: Basic CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | name: $${{ matrix.os }}-$${{ matrix.build_type }}-$${{ matrix.toolchain }} 8 | runs-on: $${{ matrix.os }} 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | os: [ubuntu-24.04] 13 | build_type: 14 | - Debug 15 | - Release 16 | - RelWithDebInfo 17 | toolchain: 18 | - x86_64-unknown-linux-llvm.cmake 19 | - x86_64-unknown-linux-gnu.cmake 20 | steps: 21 | - name: Install tools 22 | id: install-tools 23 | run: | 24 | sudo apt-get update 25 | sudo apt-get full-upgrade -y 26 | sudo apt-get autoremove -y 27 | sudo apt-get remove -y clang-* llvm-* 28 | sudo bash -c "$$(wget -O - https://apt.llvm.org/llvm.sh)" 29 | sudo apt-get install -y gcc g++ mold cmake 30 | 31 | - name: Checkout 32 | uses: actions/checkout@v4 33 | with: 34 | repository: ${repository} 35 | ref: main 36 | submodules: recursive 37 | 38 | - name: Format changes 39 | id: clang-format 40 | run: git clang-format 41 | --style=file 42 | --extensions c,cc,cpp,cxx,h,hh,hpp,hxx 43 | --diff origin/main HEAD 44 | 45 | - name: Configure project 46 | id: configure-project 47 | run: 48 | cmake -S. -Bbuild -GNinja 49 | -DCMAKE_BUILD_TYPE=$${{ matrix.build_type }} 50 | -DCMAKE_TOOLCHAIN_FILE=$${{ matrix.toolchain }} 51 | 52 | - name: Bulid project 53 | id: build-project 54 | run: ninja -C build -v 55 | 56 | - name: Run tests 57 | id: run-tests 58 | run: ctest -j$$(nproc) --output-on-failure --test-dir build 59 | -------------------------------------------------------------------------------- /templates/.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 | 34 | # Directories 35 | build*/* 36 | vcpkg/* 37 | docs/build 38 | .vscode/ipch/* 39 | .clangd/* 40 | .cache/* 41 | -------------------------------------------------------------------------------- /templates/.vscode/cmake-kits.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "LLVM Toolchain (x86_64)", 4 | "toolchainFile": "${workspaceFolder}/config/cmake/toolchains/x86_64-unknown-linux-llvm.cmake", 5 | "preferredGenerator": { 6 | "name": "Ninja" 7 | }, 8 | "cmakeSettings": {} 9 | }, 10 | { 11 | "name": "GNU Toolchain (x86_64)", 12 | "toolchainFile": "${workspaceFolder}/config/cmake/toolchains/x86_64-unknown-linux-gnu.cmake", 13 | "preferredGenerator": { 14 | "name": "Ninja" 15 | }, 16 | "cmakeSettings": {} 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /templates/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "lldb", 9 | "request": "launch", 10 | "name": "Launch LLDB", 11 | "program": "${command:cmake.launchTargetPath}", 12 | "args": [], 13 | "cwd": "${workspaceFolder}", 14 | "env": { 15 | "ASAN_OPTIONS": "detect_leaks=0" 16 | } 17 | }, 18 | { 19 | "type": "gdb", 20 | "request": "launch", 21 | "name": "Launch GDB", 22 | "target": "${command:cmake.launchTargetPath}", 23 | "arguments": "", 24 | "cwd": "${workspaceFolder}", 25 | "env": { 26 | "ASAN_OPTIONS": "detect_leaks=0" 27 | } 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /templates/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Christopher Di Bella 2 | # Licensed under the Apache License v2.0 with LLVM Exceptions. 3 | # See /LICENCE for licence information. 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | cmake_minimum_required(VERSION 3.28 FATAL_ERROR) 6 | 7 | project("${project_name}" C CXX) 8 | 9 | set(CMAKE_CXX_STANDARD 23) 10 | set(CMAKE_CXX_EXTENSIONS Yes) 11 | set(CMAKE_CXX_STANDARD_REQUIRED Yes) 12 | set(CMAKE_EXPORT_COMPILE_COMMANDS Yes) 13 | 14 | message(STATUS "Building with C++$${CMAKE_CXX_STANDARD} (extensions enabled)") 15 | ${include_package_manager} 16 | include("$${PROJECT_SOURCE_DIR}/config/cmake/project_options.cmake") 17 | include("$${PROJECT_SOURCE_DIR}/config/cmake/detail/add_targets.cmake") 18 | include("$${PROJECT_SOURCE_DIR}/config/cmake/import_packages.cmake") 19 | enable_testing() 20 | include(CTest) 21 | 22 | add_subdirectory(source) 23 | add_subdirectory(docs) 24 | 25 | # This file is deliberately included after everything else, since installation targets depend on at 26 | # least one target requesting to be installed first. 27 | include("$${PROJECT_SOURCE_DIR}/config/cmake/install_targets.cmake") 28 | -------------------------------------------------------------------------------- /templates/README.md: -------------------------------------------------------------------------------- 1 | 7 | # ${project_name} 8 | 9 | ```{toctree} 10 | :maxdepth: 1 11 | 12 | LICENCE 13 | CODE_OF_CONDUCT.md 14 | ${build_systems}${package_managers} 15 | ``` 16 | 17 | ## Indices and tables 18 | 19 | * {ref}`genindex` 20 | * {ref}`search` 21 | -------------------------------------------------------------------------------- /templates/config/cmake/detail/default_options.cmake: -------------------------------------------------------------------------------- 1 | # Copyright Christopher Di Bella 2 | # Licensed under the Apache License v2.0 with LLVM Exceptions. 3 | # See /LICENCE for licence information. 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | # This file was autogenerated by new_cxx_project.py. Do not modify this file, as add_targets.cmake 7 | # heavily depends on it. 8 | 9 | function(validate_option value option valid_values) 10 | list(FIND "$${valid_values}" "$${value}" found) 11 | 12 | if(found EQUAL -1) 13 | message(FATAL_ERROR "invalid value '$${value}' for $${option} (valid values are [$${$${valid_values}}])") 14 | endif() 15 | endfunction() 16 | 17 | if (NOT CMAKE_CONFIGURATION_TYPES) 18 | set(CMAKE_CONFIGURATION_TYPES Debug RelWithDebInfo MinSizeRel Release) 19 | endif() 20 | 21 | if(CMAKE_BUILD_TYPE) 22 | list(FIND CMAKE_CONFIGURATION_TYPES "$${CMAKE_BUILD_TYPE}" valid_build_type) 23 | if(valid_build_type EQUAL -1) 24 | message(FATAL_ERROR "$${CMAKE_BUILD_TYPE} is not a valid value") 25 | endif() 26 | else() 27 | message(FATAL_ERROR "CMAKE_BUILD_TYPE must be set") 28 | endif() 29 | message(STATUS "Build type: $${CMAKE_BUILD_TYPE}") 30 | 31 | set( 32 | # Variable 33 | ${PROJECT_NAME}_BUILD_DOCS 34 | # Default value 35 | Yes 36 | CACHE STRING 37 | "Toggles whether the documentation is built. Requires both Sphinx and MyST to be installed first." 38 | ) 39 | -------------------------------------------------------------------------------- /templates/config/cmake/detail/vcpkg.cmake: -------------------------------------------------------------------------------- 1 | # Copyright Christopher Di Bella 2 | # Licensed under the Apache License v2.0 with LLVM Exceptions. 3 | # See /LICENCE for licence information. 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | execute_process( 6 | COMMAND "$${CMAKE_CXX_COMPILER}" -dumpmachine 7 | COMMAND tr -d '\n' 8 | OUTPUT_VARIABLE _${PROJECT_NAME}_TARGET_TRIPLE 9 | ) 10 | 11 | if(_${PROJECT_NAME}_TARGET_TRIPLE MATCHES "^x86_64") 12 | set(_${PROJECT_NAME}_TARGET_ARCHITECTURE "x64") 13 | elseif(_${PROJECT_NAME}_TARGET_TRIPLE MATCHES "^x86") 14 | set(_${PROJECT_NAME}_TARGET_ARCHITECTURE "x86") 15 | elseif(_${PROJECT_NAME}_TARGET_TRIPLE MATCHES "^arm64") 16 | set(_${PROJECT_NAME}_TARGET_ARCHITECTURE "arm64") 17 | elseif(_${PROJECT_NAME}_TARGET_TRIPLE MATCHES "^arm") 18 | set(_${PROJECT_NAME}_TARGET_ARCHITECTURE "arm") 19 | elseif(_${PROJECT_NAME}_TARGET_TRIPLE MATCHES "^aarch64") 20 | set(_${PROJECT_NAME}_TARGET_ARCHITECTURE "aarch64") 21 | elseif(_${PROJECT_NAME}_TARGET_TRIPLE MATCHES "^loongarch32") 22 | set(_${PROJECT_NAME}_TARGET_ARCHITECTURE "loongarch32") 23 | elseif(_${PROJECT_NAME}_TARGET_TRIPLE MATCHES "^loongarch64") 24 | set(_${PROJECT_NAME}_TARGET_ARCHITECTURE "loongarch64") 25 | elseif(_${PROJECT_NAME}_TARGET_TRIPLE MATCHES "^riscv32") 26 | set(_${PROJECT_NAME}_TARGET_ARCHITECTURE "riscv32") 27 | elseif(_${PROJECT_NAME}_TARGET_TRIPLE MATCHES "^riscv64") 28 | set(_${PROJECT_NAME}_TARGET_ARCHITECTURE "riscv64") 29 | elseif(_${PROJECT_NAME}_TARGET_TRIPLE MATCHES "^s390x") 30 | set(_${PROJECT_NAME}_TARGET_ARCHITECTURE "s390x") 31 | elseif(_${PROJECT_NAME}_TARGET_TRIPLE MATCHES "^mips64") 32 | set(_${PROJECT_NAME}_TARGET_ARCHITECTURE "mips64") 33 | elseif(_${PROJECT_NAME}_TARGET_TRIPLE MATCHES "^ppc64le") 34 | set(_${PROJECT_NAME}_TARGET_ARCHITECTURE "ppc64le") 35 | elseif(_${PROJECT_NAME}_TARGET_TRIPLE MATCHES "^wasm32") 36 | set(_${PROJECT_NAME}_TARGET_ARCHITECTURE "wasm32") 37 | else() 38 | message(FATAL_ERROR "Can't generate vcpkg toolchain file because $${_${PROJECT_NAME}_TARGET_TRIPLE} doesn't have a known architecture mapping") 39 | endif() 40 | 41 | set(${PROJECT_NAME}_CRT_LINKAGE static) 42 | set(${PROJECT_NAME}_LIBRARY_LINKAGE static) 43 | 44 | configure_file( 45 | "$${CMAKE_CURRENT_LIST_DIR}/vcpkg_toolchain_file.cmake.in" 46 | "$${CMAKE_BINARY_DIR}/vcpkg_toolchain_file.cmake" 47 | @ONLY 48 | ) 49 | set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "$${CMAKE_BINARY_DIR}/vcpkg_toolchain_file.cmake") 50 | include("$${PROJECT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake") 51 | -------------------------------------------------------------------------------- /templates/config/cmake/detail/vcpkg_toolchain_file.cmake.in: -------------------------------------------------------------------------------- 1 | set(CMAKE_BUILD_TYPE @CMAKE_BUILD_TYPE@) 2 | set(CMAKE_SYSTEM_NAME @CMAKE_SYSTEM_NAME@) 3 | set(CMAKE_SYSTEM_PROCESSOR @CMAKE_SYSTEM_PROCESSOR@) 4 | 5 | set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@") 6 | set(CMAKE_C_COMPILER_AR "@CMAKE_C_COMPILER_AR@") 7 | set(CMAKE_C_COMPILER_RANLIB "@CMAKE_C_COMPILER_RANLIB@") 8 | set(CMAKE_C_COMPILER_TARGET @CMAKE_C_COMPILER_TARGET@) 9 | 10 | set(CMAKE_CXX_COMPILER "@CMAKE_CXX_COMPILER@") 11 | set(CMAKE_CXX_COMPILER_AR "@CMAKE_CXX_COMPILER_AR@") 12 | set(CMAKE_CXX_COMPILER_RANLIB "@CMAKE_CXX_COMPILER_RANLIB@") 13 | set(CMAKE_CXX_COMPILER_TARGET @CMAKE_CXX_COMPILER_TARGET@) 14 | 15 | set(CMAKE_RC_COMPILER "@CMAKE_RC_COMPILER@") 16 | set(CMAKE_RC_COMPILER_AR "@CMAKE_AR@") 17 | set(CMAKE_RC_COMPILER_RANLIB "@CMAKE_RANLIB@") 18 | 19 | set(CMAKE_LINKER_TYPE @CMAKE_LINKER_TYPE@) 20 | 21 | string(JOIN " " CMAKE_C_FLAGS_INIT @CMAKE_CXX_FLAGS_INIT@ -w -Wno-error) 22 | string(JOIN " " CMAKE_C_FLAGS_DEBUG_INIT @CMAKE_CXX_FLAGS_DEBUG_INIT@ -w -Wno-error) 23 | string(JOIN " " CMAKE_C_FLAGS_RELEASE_INIT @CMAKE_CXX_FLAGS_RELEASE_INIT@ -w -Wno-error) 24 | string(JOIN " " CMAKE_C_FLAGS_RELWITHDEBINFO_INIT @CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT@ -w -Wno-error) 25 | string(JOIN " " CMAKE_C_FLAGS_MINSIZEREL_INIT @CMAKE_CXX_FLAGS_MINSIZEREL_INIT@ -w -Wno-error) 26 | 27 | string(JOIN " " CMAKE_CXX_FLAGS_INIT @CMAKE_CXX_FLAGS_INIT@ -w -Wno-error) 28 | string(JOIN " " CMAKE_CXX_FLAGS_DEBUG_INIT @CMAKE_CXX_FLAGS_DEBUG_INIT@ -w -Wno-error) 29 | string(JOIN " " CMAKE_CXX_FLAGS_RELEASE_INIT @CMAKE_CXX_FLAGS_RELEASE_INIT@ -w -Wno-error) 30 | string(JOIN " " CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT @CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT@ -w -Wno-error) 31 | string(JOIN " " CMAKE_CXX_FLAGS_MINSIZEREL_INIT @CMAKE_CXX_FLAGS_MINSIZEREL_INIT@ -w -Wno-error) 32 | 33 | string(JOIN " " CMAKE_EXE_LINKER_FLAGS_INIT @CMAKE_EXE_LINKER_FLAGS_INIT@) 34 | string(JOIN " " CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT @CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT@) 35 | string(JOIN " " CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT @CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT@) 36 | string(JOIN " " CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT @CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT@) 37 | string(JOIN " " CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT @CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT@) 38 | 39 | set(VCPKG_TARGET_ARCHITECTURE "@${PROJECT_NAME}_TARGET_ARCHITECTURE@") 40 | set(VCPKG_CRT_LINKAGE "@${PROJECT_NAME}_CRT_LINKAGE@") 41 | set(VCPKG_LIBRARY_LINKAGE "@${PROJECT_NAME}_LIBRARY_LINKAGE@") 42 | 43 | set(VCPKG_CMAKE_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@") 44 | 45 | set(VCPKG_INSTALL_OPTIONS @VCPKG_INSTALL_OPTIONS@) 46 | set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "$${CMAKE_CURRENT_LIST_FILE}") 47 | set(VCPKG_TARGET_TRIPLET vcpkg_toolchain_file) 48 | set(VCPKG_OVERLAY_TRIPLETS "@CMAKE_BINARY_DIR@") 49 | -------------------------------------------------------------------------------- /templates/config/cmake/import_packages.cmake: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_MODULE_PATH "$${CMAKE_CURRENT_LIST_DIR}/packages") 2 | find_package(Sphinx REQUIRED) 3 | list(POP_BACK CMAKE_MODULE_PATH CMAKE_MODULE_PATH) 4 | -------------------------------------------------------------------------------- /templates/config/cmake/install_targets.cmake: -------------------------------------------------------------------------------- 1 | include(CMakePackageConfigHelpers) 2 | 3 | # Here's an example installation target that you can potentially use as-is. We leave it commented 4 | # out until you have something to install; CMake produces a fatal error when the installation target 5 | # doesn't have anything to install. 6 | # 7 | # install( 8 | # EXPORT ${project_name}-install 9 | # FILE ${project_name}-config.cmake 10 | # NAMESPACE ${project_name}:: 11 | # DESTINATION lib/cmake/${project_name} 12 | # ) 13 | 14 | message( 15 | AUTHOR_WARNING "no installation targets have been declared (please modify $${CMAKE_CURRENT_SOURCE_DIR}/config/cmake/install_targets.cmake to rectify this)" 16 | ) 17 | -------------------------------------------------------------------------------- /templates/config/cmake/packages/FindSphinx.cmake: -------------------------------------------------------------------------------- 1 | # Copyright VORtech 2 | # Copyright Christopher Di Bella 3 | # Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | # See /LICENCE for licence information. 5 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | include(FindPackageHandleStandardArgs) 7 | include(GNUInstallDirs) 8 | 9 | if(NOT ${PROJECT_NAME}_BUILD_DOCS) 10 | return() 11 | endif() 12 | 13 | if(NOT Python3_ROOT_DIR) 14 | set(Python3_ROOT_DIR "$$ENV{HOME}/.config/new_cxx_project/") 15 | endif() 16 | find_package(Python3 COMPONENTS Interpreter REQUIRED) 17 | 18 | if(Python3_FOUND) 19 | get_filename_component(_Python3_DIR "$${Python3_EXECUTABLE}" DIRECTORY) 20 | set( 21 | _Python3_PATHS 22 | "$${_Python3_DIR}/.." 23 | "$${_Python3_DIR}/../bin" 24 | "$${_Python3_DIR}/../Scripts" 25 | ) 26 | endif() 27 | 28 | find_program( 29 | SPHINX_EXECUTABLE 30 | NAMES sphinx-build sphinx-build.exe 31 | HINTS $${_Python3_PATHS} 32 | ) 33 | mark_as_advanced(SPHINX_EXECUTABLE) 34 | 35 | find_package_handle_standard_args(Sphinx DEFAULT_MSG SPHINX_EXECUTABLE) 36 | 37 | if(NOT Sphinx_FOUND) 38 | return() 39 | endif() 40 | 41 | set(_SPHINX_SCRIPT_DIR "$${CMAKE_CURRENT_LIST_DIR}") 42 | 43 | if(NOT EXISTS "$${PROJECT_SOURCE_DIR}/docs/_static") 44 | file(MAKE_DIRECTORY "$${PROJECT_SOURCE_DIR}/docs/_static") 45 | endif() 46 | 47 | function(sphinx_documentation TARGET_NAME) 48 | cmake_parse_arguments( 49 | sphinx_args 50 | "" 51 | "TARGET;CONF_FILE" 52 | "SOURCES;TEMPLATES;STATIC" 53 | $${ARGN} 54 | ) 55 | 56 | set(SPHINX_DEPENDS "$${sphinx_args_CONF_FILE}" "$${sphinx_args_SOURCES}" "$${sphinx_args_TEMPLATES}" "$${sphinx_args_STATIC}") 57 | 58 | add_custom_command( 59 | OUTPUT "$${CMAKE_CURRENT_BINARY_DIR}/html.stamp" 60 | COMMAND "$${SPHINX_EXECUTABLE}" -q -j auto -b html "$${CMAKE_CURRENT_LIST_DIR}" "$${CMAKE_CURRENT_BINARY_DIR}" 61 | COMMAND "$${CMAKE_COMMAND}" -E touch "$${CMAKE_CURRENT_BINARY_DIR}/html.stamp" 62 | DEPENDS "$${SPHINX_DEPENDS}" 63 | ) 64 | set(TARGET_DEPENDS "$${CMAKE_CURRENT_BINARY_DIR}/html.stamp") 65 | 66 | add_custom_target( 67 | $${TARGET_NAME} ALL 68 | DEPENDS $${TARGET_DEPENDS} 69 | ) 70 | 71 | install( 72 | DIRECTORY "$${CMAKE_CURRENT_BINARY_DIR}/" 73 | TYPE DOC 74 | PATTERN ".buildinfo" EXCLUDE 75 | PATTERN ".doctrees" EXCLUDE 76 | PATTERN "_sources" EXCLUDE 77 | PATTERN "objects.inv" EXCLUDE 78 | PATTERN "CMakeFiles" EXCLUDE 79 | PATTERN "html.stamp" EXCLUDE 80 | REGEX ".*[.]cmake$$" EXCLUDE 81 | ) 82 | endfunction() 83 | -------------------------------------------------------------------------------- /templates/config/cmake/project_options.cmake: -------------------------------------------------------------------------------- 1 | include("$${PROJECT_SOURCE_DIR}/config/cmake/detail/default_options.cmake") 2 | 3 | # Add your project options here. 4 | -------------------------------------------------------------------------------- /templates/config/cmake/toolchains/toolchain_base.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME ${system_name}) 2 | set(CMAKE_SYSTEM_PROCESSOR ${target}) 3 | 4 | set(CMAKE_C_COMPILER "${prefix}/bin/${cc}") 5 | set(CMAKE_C_COMPILER_AR "${prefix}/bin/${ar}") 6 | set(CMAKE_C_COMPILER_RANLIB "${prefix}/bin/${ranlib}") 7 | set(CMAKE_C_COMPILER_TARGET ${triple}) 8 | 9 | set(CMAKE_CXX_COMPILER "${prefix}/bin/${cxx}") 10 | set(CMAKE_CXX_COMPILER_AR "${prefix}/bin/${ar}") 11 | set(CMAKE_CXX_COMPILER_RANLIB "${prefix}/bin/${ranlib}") 12 | set(CMAKE_CXX_COMPILER_TARGET ${triple}) 13 | 14 | set(CMAKE_RC_COMPILER "${prefix}/bin/${rc}") 15 | set(CMAKE_RC_COMPILER_AR "${prefix}/bin/${ar}") 16 | set(CMAKE_RC_COMPILER_RANLIB "${prefix}/bin/${ranlib}") 17 | 18 | set(CMAKE_LINKER_TYPE ${linker}) 19 | 20 | string( 21 | JOIN " " CMAKE_CXX_FLAGS_INIT 22 | -fdiagnostics-color=always 23 | -fstack-protector-strong 24 | -fvisibility=hidden 25 | -Werror 26 | -pedantic 27 | -Wall 28 | -Wattributes 29 | -Wcast-align 30 | -Wconversion 31 | -Wdouble-promotion 32 | -Wextra 33 | -Wformat=2 34 | -Wnon-virtual-dtor 35 | -Wnull-dereference 36 | -Wodr 37 | -Wold-style-cast 38 | -Woverloaded-virtual 39 | -Wshadow 40 | -Wsign-conversion 41 | -Wsign-promo 42 | -Wunused 43 | -Wno-ignored-attributes 44 | -Wno-unused-command-line-argument${stdlib}${hardening} 45 | ) 46 | string( 47 | JOIN " " CMAKE_EXE_LINKER_FLAGS_INIT${compiler_rt}${libunwind} 48 | ) 49 | 50 | string( 51 | JOIN " " CMAKE_CXX_FLAGS_DEBUG_INIT 52 | -fsanitize=address${undefined} 53 | ) 54 | string( 55 | JOIN " " CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT 56 | -fsanitize=address${undefined} 57 | ) 58 | 59 | string( 60 | JOIN " " CMAKE_CXX_FLAGS_RELEASE_INIT 61 | ${lto}${cfi} 62 | ) 63 | string( 64 | JOIN " " CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT 65 | ${lto}${cfi} 66 | ) 67 | 68 | string( 69 | JOIN " " CMAKE_CXX_FLAGS_MINSIZEREL_INIT 70 | ${lto}${cfi} 71 | ) 72 | string( 73 | JOIN " " CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT 74 | ${lto}${cfi} 75 | ) 76 | 77 | string( 78 | JOIN " " CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT 79 | -fsanitize=address${undefined} 80 | ) 81 | string( 82 | JOIN " " CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT 83 | -fsanitize=address${undefined} 84 | ) 85 | -------------------------------------------------------------------------------- /templates/docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(NOT ${PROJECT_NAME}_BUILD_DOCS) 2 | return() 3 | endif() 4 | 5 | sphinx_documentation( 6 | TARGET docs 7 | CONF_FILE "conf.py" 8 | SOURCES 9 | "index.md" 10 | "LICENCE.md" 11 | "CODE_OF_CONDUCT.md"${build_systems}${package_managers} 12 | TEMPLATES 13 | "_templates/layout.html" 14 | ) 15 | -------------------------------------------------------------------------------- /templates/docs/_templates/layout.html: -------------------------------------------------------------------------------- 1 | {% extends '!layout.html' %} 2 | 3 | {% block footer %} 4 | 5 |

This work is licensed under CC BY-SA 4.0

6 |
7 | {% endblock %} 8 | -------------------------------------------------------------------------------- /templates/docs/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # For the full list of built-in configuration values, see the documentation: 4 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 5 | 6 | # -- Project information ----------------------------------------------------- 7 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information 8 | 9 | project = '${project_name}' 10 | author = '${author}' 11 | 12 | # -- General configuration --------------------------------------------------- 13 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration 14 | 15 | extensions = [ 16 | 'myst_parser', 17 | 'sphinx.ext.autosectionlabel', 18 | 'sphinx.ext.extlinks', 19 | 'sphinx.ext.mathjax', 20 | 'sphinx.ext.todo', 21 | 'sphinx.ext.viewcode', 22 | ] 23 | 24 | templates_path = ['_templates'] 25 | exclude_patterns = [] 26 | 27 | # -- Options for HTML output ------------------------------------------------- 28 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output 29 | 30 | html_theme = 'pyramid' 31 | # html_theme_options = { 32 | # 'repository_url': '', 33 | # 'use_repository_button': True, 34 | # } 35 | html_static_path = ['_static'] 36 | html_show_copyright = False 37 | 38 | myst_enable_extensions = [ 39 | 'dollarmath', 40 | 'amsmath', 41 | 'deflist', 42 | 'fieldlist', 43 | 'html_admonition', 44 | 'html_image', 45 | 'colon_fence', 46 | 'smartquotes', 47 | 'replacements', 48 | 'strikethrough', 49 | 'substitution', 50 | 'tasklist', 51 | 'attrs_inline', 52 | 'attrs_block', 53 | ] 54 | -------------------------------------------------------------------------------- /templates/docs/requirements.in: -------------------------------------------------------------------------------- 1 | sphinx 2 | myst-parser 3 | psutil 4 | -------------------------------------------------------------------------------- /templates/docs/requirements.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is autogenerated by pip-compile with Python 3.12 3 | # by the following command: 4 | # 5 | # pip-compile requirements.in 6 | # 7 | alabaster==0.7.16 8 | # via sphinx 9 | babel==2.15.0 10 | # via sphinx 11 | certifi==2024.7.4 12 | # via requests 13 | charset-normalizer==3.3.2 14 | # via requests 15 | docutils==0.21.2 16 | # via 17 | # myst-parser 18 | # sphinx 19 | idna==3.7 20 | # via requests 21 | imagesize==1.4.1 22 | # via sphinx 23 | jinja2==3.1.4 24 | # via 25 | # myst-parser 26 | # sphinx 27 | markdown-it-py==3.0.0 28 | # via 29 | # mdit-py-plugins 30 | # myst-parser 31 | markupsafe==2.1.5 32 | # via jinja2 33 | mdit-py-plugins==0.4.1 34 | # via myst-parser 35 | mdurl==0.1.2 36 | # via markdown-it-py 37 | myst-parser==3.0.1 38 | # via -r requirements.in 39 | packaging==24.1 40 | # via sphinx 41 | psutil==6.0.0 42 | # via -r requirements.in 43 | pygments==2.18.0 44 | # via sphinx 45 | pyyaml==6.0.1 46 | # via myst-parser 47 | requests==2.32.3 48 | # via sphinx 49 | snowballstemmer==2.2.0 50 | # via sphinx 51 | sphinx==7.4.7 52 | # via 53 | # -r requirements.in 54 | # myst-parser 55 | sphinxcontrib-applehelp==2.0.0 56 | # via sphinx 57 | sphinxcontrib-devhelp==2.0.0 58 | # via sphinx 59 | sphinxcontrib-htmlhelp==2.1.0 60 | # via sphinx 61 | sphinxcontrib-jsmath==1.0.1 62 | # via sphinx 63 | sphinxcontrib-qthelp==2.0.0 64 | # via sphinx 65 | sphinxcontrib-serializinghtml==2.0.0 66 | # via sphinx 67 | urllib3==2.2.2 68 | # via requests 69 | -------------------------------------------------------------------------------- /templates/docs/source/project/vcpkg.rst: -------------------------------------------------------------------------------- 1 | .. 2 | Copyright (c) 2024 Christopher Di Bella 3 | Licensed under Creative Commons Attribution-ShareAlike 4.0 International 4 | See /LICENCE for licence information. 5 | SPDX-License-Identifier: CC BY-SA 4.0 6 | 7 | *********** 8 | Using vcpkg 9 | *********** 10 | 11 | ${project_name} uses `vcpkg `_ for package management. We use the 12 | `manifest mode `_. 13 | 14 | Adding packages 15 | ================ 16 | 17 | To add a dependency, add it to the top-level ``vcpkg.json``, and then add the corresponding CMake 18 | ``find_package`` (or equivalent) rule to ``config/cmake/add_packages.cmake``. 19 | 20 | Setting up the toolchain with vcpkg 21 | =================================== 22 | 23 | This project aims to build its dependencies with the same compile-time options as its own targets, 24 | where possible (Titus Winters' keynote, `'C++ Past vs. Future' `_, 25 | summarises why we adopt this philosophy). ${project_name} generates a vcpkg toolchain file when you 26 | configure the project, so you shouldn't follow the vcpkg instructions for setting things up. Instead, 27 | just configure the project using the options documented in :doc:`cmake`. You can optionally set 28 | :code:`-DVCPKG_INSTALL_OPTIONS`, which will be passed to vcpkg. 29 | 30 | .. code-block:: 31 | :caption: An example showing how vcpkg can be used. The ``-DVCPKG_INSTALL_OPTIONS='--clean-after-build'`` 32 | option is optional, and tells vcpkg to clean its build cache after all packages are installed. 33 | 34 | $$ cmake -S. -Bbuild -GNinja \ 35 | -DCMAKE_BUILD_TYPE=Debug \ 36 | -DTOOLCHAIN_FILE='/path/to/project/config/cmake/toolchains/x86_64-unknown-linux-llvm.cmake' \ 37 | -DVCPKG_INSTALL_OPTIONS='--clean-after-build' \ 38 | 39 | -------------------------------------------------------------------------------- /templates/source/CMakeLists.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cjdb/new_cxx_project/ad44b6de11129084765ebf9632366dc2e8597da7/templates/source/CMakeLists.txt -------------------------------------------------------------------------------- /templates/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "${project_name}", 3 | "version-string": "", 4 | "homepage": "", 5 | "description": "", 6 | "dependencies": [] 7 | } 8 | -------------------------------------------------------------------------------- /test/default-options/asan-only-changes/source/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(asan) 2 | -------------------------------------------------------------------------------- /test/default-options/asan-only-changes/source/asan/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET greeter_object_with_asan 3 | LIBRARY_TYPE OBJECT 4 | HEADERS 5 | greeter.hpp 6 | SOURCES 7 | greeter.cpp 8 | ) 9 | cxx_test( 10 | TARGET test_greeter_object_with_asan 11 | HEADERS 12 | greeter.hpp 13 | SOURCES 14 | test_greeter.cpp 15 | DEPENDS_ON 16 | check 17 | greeter_object_with_asan 18 | ) 19 | cxx_executable( 20 | TARGET hello_object_with_asan 21 | HEADERS 22 | greeter.hpp 23 | SOURCES 24 | hello.cpp 25 | DEPENDS_ON 26 | greeter_object_with_asan 27 | ) 28 | -------------------------------------------------------------------------------- /test/default-options/asan-only-changes/source/asan/greeter.cpp: -------------------------------------------------------------------------------- 1 | #pragma GCC diagnostic push 2 | #pragma GCC diagnostic ignored "-Warray-bounds" 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | std::string* greet(std::string_view const greeting, std::string_view const name) 9 | { 10 | auto result = new std::string(); 11 | *result = std::format("{}, {}!", greeting, name); 12 | return result; 13 | } 14 | -------------------------------------------------------------------------------- /test/default-options/asan-only-changes/source/asan/greeter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef GREETER_HPP 2 | #define GREETER_HPP 3 | 4 | #include 5 | 6 | std::string* greet(std::string_view greeting, std::string_view name); 7 | 8 | #endif // GREETER_HPP 9 | -------------------------------------------------------------------------------- /test/default-options/asan-only-changes/source/asan/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::println("{}", *greet("Hello", "world")); 7 | } 8 | -------------------------------------------------------------------------------- /test/default-options/asan-only-changes/source/asan/test_greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | auto message = greet("Hello", "world"); 7 | ++message; 8 | CHECK(*message == "Hello, world!"); 9 | } 10 | -------------------------------------------------------------------------------- /test/default-options/changes/config/cmake/import_packages.cmake: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/packages") 2 | find_package(Sphinx REQUIRED) 3 | list(POP_BACK CMAKE_MODULE_PATH CMAKE_MODULE_PATH) 4 | 5 | find_package(Catch2 CONFIG REQUIRED) 6 | -------------------------------------------------------------------------------- /test/default-options/changes/config/cmake/install_targets.cmake: -------------------------------------------------------------------------------- 1 | include(CMakePackageConfigHelpers) 2 | 3 | # Here's an example installation target that you can potentially use as-is. We leave it commented 4 | # out until you have something to install; CMake produces a fatal error when the installation target 5 | # doesn't have anything to install. 6 | # 7 | install( 8 | EXPORT install-targets 9 | FILE project_name-config.cmake 10 | NAMESPACE project_name:: 11 | DESTINATION lib/cmake/project_name 12 | ) 13 | -------------------------------------------------------------------------------- /test/default-options/changes/source/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET check 3 | LIBRARY_TYPE HEADER_ONLY 4 | HEADER_INTERFACE 5 | check.hpp 6 | ) 7 | 8 | add_subdirectory(header_only_library) 9 | add_subdirectory(object_library) 10 | add_subdirectory(plugin_library) 11 | add_subdirectory(shared_library) 12 | add_subdirectory(static_library) 13 | add_subdirectory(multi_file) 14 | add_subdirectory(define) 15 | add_subdirectory(compile_options) 16 | add_subdirectory(link_options) 17 | add_subdirectory(module_interface) 18 | -------------------------------------------------------------------------------- /test/default-options/changes/source/check.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TEST_ASSERT_HPP 2 | #define TEST_ASSERT_HPP 3 | 4 | #include 5 | 6 | #define CHECK(...) \ 7 | if (not (__VA_ARGS__)) { \ 8 | std::println(stderr, "error: " #__VA_ARGS__ " evaluated to false"); \ 9 | } 10 | 11 | #endif // TEST_ASSERT_HPP 12 | -------------------------------------------------------------------------------- /test/default-options/changes/source/compile_options/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET greeter_compile_options 3 | LIBRARY_TYPE STATIC 4 | HEADER_INTERFACE 5 | greeter.hpp 6 | SOURCES 7 | greeter.cpp 8 | COMPILE_OPTIONS 9 | -fno-inline 10 | ) 11 | cxx_test( 12 | TARGET test_greeter_compile_options 13 | HEADERS 14 | greeter.hpp 15 | SOURCES 16 | test_greeter.cpp 17 | DEPENDS_ON 18 | check 19 | greeter_compile_options 20 | COMPILE_OPTIONS 21 | -fno-inline 22 | ) 23 | cxx_executable( 24 | TARGET hello_compile_options 25 | HEADERS 26 | greeter.hpp 27 | SOURCES 28 | hello.cpp 29 | DEPENDS_ON 30 | greeter_compile_options 31 | COMPILE_OPTIONS 32 | -fno-inline 33 | ) 34 | -------------------------------------------------------------------------------- /test/default-options/changes/source/compile_options/greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | std::string greet(std::string_view const greeting, std::string_view const name) 7 | { 8 | return std::format("{}, {}!", greeting, name); 9 | } 10 | -------------------------------------------------------------------------------- /test/default-options/changes/source/compile_options/greeter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef GREETER_HPP 2 | #define GREETER_HPP 3 | 4 | #include 5 | #include 6 | 7 | std::string greet(std::string_view greeting, std::string_view name); 8 | 9 | #endif // GREETER_HPP 10 | -------------------------------------------------------------------------------- /test/default-options/changes/source/compile_options/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main(int, char**, char**) 6 | { 7 | std::println("{}", greet("Hello", "world")); 8 | } 9 | -------------------------------------------------------------------------------- /test/default-options/changes/source/compile_options/test_greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | CHECK(greet("Hello", "world") == "Hello, world!"); 8 | } 9 | -------------------------------------------------------------------------------- /test/default-options/changes/source/define/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET greeter_with_macro 3 | LIBRARY_TYPE STATIC 4 | HEADER_INTERFACE 5 | greeter.hpp 6 | SOURCES 7 | greeter.cpp 8 | DEFINE 9 | RETURN_TYPE 10 | PARAMETER_TYPE=std::string_view 11 | ) 12 | cxx_test( 13 | TARGET test_greeter_with_macro 14 | SOURCES 15 | test_greeter.cpp 16 | DEPENDS_ON 17 | check 18 | greeter_with_macro 19 | DEFINE 20 | RETURN_TYPE 21 | PARAMETER_TYPE=std::string_view 22 | ) 23 | cxx_executable( 24 | TARGET hello_with_macro 25 | SOURCES 26 | hello.cpp 27 | DEPENDS_ON 28 | greeter_with_macro 29 | DEFINE 30 | RETURN_TYPE 31 | PARAMETER_TYPE=std::string_view 32 | ) 33 | -------------------------------------------------------------------------------- /test/default-options/changes/source/define/greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | greet_result_t greet(PARAMETER_TYPE const greeting, PARAMETER_TYPE const name) 7 | { 8 | return std::format("{}, {}!", greeting, name); 9 | } 10 | -------------------------------------------------------------------------------- /test/default-options/changes/source/define/greeter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef GREETER_HPP 2 | #define GREETER_HPP 3 | 4 | #include 5 | #include 6 | 7 | #if defined(RETURN_TYPE) 8 | using greet_result_t = std::string; 9 | #endif 10 | 11 | greet_result_t greet(PARAMETER_TYPE greeting, PARAMETER_TYPE name); 12 | 13 | #endif // GREETER_HPP 14 | -------------------------------------------------------------------------------- /test/default-options/changes/source/define/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::println("{}", greet("Hello", "world")); 7 | } 8 | -------------------------------------------------------------------------------- /test/default-options/changes/source/define/test_greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | CHECK(greet("Hello", "world") == "Hello, world!"); 7 | } 8 | -------------------------------------------------------------------------------- /test/default-options/changes/source/header_only_library/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET greeter_header_only 3 | LIBRARY_TYPE HEADER_ONLY 4 | HEADER_INTERFACE 5 | greeter.hpp 6 | INSTALL_WITH install-targets 7 | INSTALL_PREFIX_INCLUDE header_only 8 | ) 9 | 10 | cxx_library( 11 | TARGET fanciful_header_only 12 | LIBRARY_TYPE HEADER_ONLY 13 | HEADER_INTERFACE 14 | fanciful.hpp 15 | DEPENDS_ON_INTERFACE 16 | greeter_header_only 17 | ) 18 | 19 | cxx_executable( 20 | TARGET hello_header_only 21 | SOURCES 22 | hello.cpp 23 | DEPENDS_ON 24 | fanciful_header_only 25 | INSTALL_WITH install-targets 26 | ) 27 | 28 | cxx_test( 29 | TARGET test_greeter_header_only 30 | SOURCES 31 | test_greeter.cpp 32 | DEPENDS_ON 33 | check 34 | fanciful_header_only 35 | ) 36 | -------------------------------------------------------------------------------- /test/default-options/changes/source/header_only_library/fanciful.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | inline std::string make_fancy(std::string_view const message) 5 | { 6 | return std::format("fancy {}", message); 7 | } 8 | -------------------------------------------------------------------------------- /test/default-options/changes/source/header_only_library/greeter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef GREETER_HPP 2 | #define GREETER_HPP 3 | 4 | #include 5 | #include 6 | 7 | inline std::string greet(std::string_view const greeting, std::string_view const name) 8 | { 9 | return std::format("{}, {}!", greeting, name); 10 | } 11 | 12 | #endif // GREETER_HPP 13 | -------------------------------------------------------------------------------- /test/default-options/changes/source/header_only_library/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | std::println("{}", make_fancy(greet("Hello", "world"))); 8 | } 9 | -------------------------------------------------------------------------------- /test/default-options/changes/source/header_only_library/test_greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | CHECK(make_fancy(greet("Hello", "world")) == "fancy Hello, world!"); 8 | } 9 | -------------------------------------------------------------------------------- /test/default-options/changes/source/link_options/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET greeter_link_options 3 | LIBRARY_TYPE SHARED 4 | HEADER_INTERFACE 5 | greeter.hpp 6 | SOURCES 7 | greeter.cpp 8 | LINK_OPTIONS 9 | -z nodlopen 10 | ) 11 | cxx_test( 12 | TARGET test_greeter_link_options 13 | HEADERS 14 | greeter.hpp 15 | SOURCES 16 | test_greeter.cpp 17 | DEPENDS_ON 18 | check 19 | greeter_link_options 20 | LINK_OPTIONS 21 | -pie 22 | ) 23 | cxx_executable( 24 | TARGET hello_link_options 25 | HEADERS 26 | greeter.hpp 27 | SOURCES 28 | hello.cpp 29 | DEPENDS_ON 30 | greeter_link_options 31 | LINK_OPTIONS 32 | -pie 33 | ) 34 | -------------------------------------------------------------------------------- /test/default-options/changes/source/link_options/greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | [[gnu::visibility("default")]] std::string greet(std::string_view greeting, std::string_view name) 7 | { 8 | return std::format("{}, {}!", greeting, name); 9 | } 10 | -------------------------------------------------------------------------------- /test/default-options/changes/source/link_options/greeter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef GREETER_HPP 2 | #define GREETER_HPP 3 | 4 | #include 5 | #include 6 | 7 | std::string greet(std::string_view greeting, std::string_view name); 8 | 9 | #endif // GREETER_HPP 10 | -------------------------------------------------------------------------------- /test/default-options/changes/source/link_options/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::println("{}", greet("Hello", "world")); 7 | } 8 | -------------------------------------------------------------------------------- /test/default-options/changes/source/link_options/test_greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | CHECK(greet("Hello", "world") == "Hello, world!"); 7 | } 8 | -------------------------------------------------------------------------------- /test/default-options/changes/source/module_interface/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET greeter_module 3 | LIBRARY_TYPE STATIC 4 | MODULE_INTERFACE 5 | greeter_module.cpp 6 | SOURCES 7 | greeter.cpp 8 | ) 9 | -------------------------------------------------------------------------------- /test/default-options/changes/source/module_interface/greeter.cpp: -------------------------------------------------------------------------------- 1 | module; 2 | #include 3 | #include 4 | #include 5 | 6 | module greeter; 7 | 8 | std::string greet(std::string_view const greeting, std::string_view const name) 9 | { 10 | return std::format("{}, {}!", greeting, name); 11 | } 12 | -------------------------------------------------------------------------------- /test/default-options/changes/source/module_interface/greeter_module.cpp: -------------------------------------------------------------------------------- 1 | module; 2 | #include 3 | 4 | export module greeter; 5 | 6 | std::string greet(std::string_view greeting, std::string_view name); 7 | -------------------------------------------------------------------------------- /test/default-options/changes/source/multi_file/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET greeter_multi_file1 3 | LIBRARY_TYPE STATIC 4 | HEADER_INTERFACE 5 | greeter.hpp 6 | HEADERS 7 | greeter_impl.hpp 8 | SOURCES 9 | greeter.cpp 10 | greeter_impl.cpp 11 | ) 12 | cxx_library( 13 | TARGET greeter_multi_file2 14 | LIBRARY_TYPE STATIC 15 | HEADERS 16 | greeter.hpp 17 | greeter_impl.hpp 18 | SOURCES 19 | greeter.cpp 20 | greeter_impl.cpp 21 | ) 22 | cxx_library( 23 | TARGET greeter_multi_file3 24 | LIBRARY_TYPE STATIC 25 | HEADER_INTERFACE 26 | greeter.hpp 27 | greeter_impl.hpp 28 | SOURCES 29 | greeter.cpp 30 | greeter_impl.cpp 31 | ) 32 | cxx_test( 33 | TARGET test_greeter_multi_file 34 | HEADERS 35 | check.hpp 36 | greeter.hpp 37 | greeter_impl.hpp 38 | SOURCES 39 | test_greeter.cpp 40 | greeter.cpp 41 | greeter_impl.cpp 42 | ) 43 | cxx_test( 44 | TARGET hello_multi_file 45 | HEADERS 46 | greeter.hpp 47 | greeter_impl.hpp 48 | SOURCES 49 | greeter.cpp 50 | hello.cpp 51 | greeter_impl.cpp 52 | ) 53 | -------------------------------------------------------------------------------- /test/default-options/changes/source/multi_file/check.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TEST_ASSERT_HPP 2 | #define TEST_ASSERT_HPP 3 | 4 | #include 5 | 6 | #define CHECK(...) \ 7 | if (not (__VA_ARGS__)) { \ 8 | std::println(stderr, "error: " #__VA_ARGS__ " evaluated to false"); \ 9 | } 10 | 11 | #endif // TEST_ASSERT_HPP 12 | -------------------------------------------------------------------------------- /test/default-options/changes/source/multi_file/greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | std::string greet(std::string_view const greeting, std::string_view const name) 4 | { 5 | return greet_impl(greeting, name); 6 | } 7 | -------------------------------------------------------------------------------- /test/default-options/changes/source/multi_file/greeter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef GREETER_HPP 2 | #define GREETER_HPP 3 | 4 | #include 5 | 6 | std::string greet(std::string_view greeting, std::string_view name); 7 | 8 | #endif // GREETER_HPP 9 | -------------------------------------------------------------------------------- /test/default-options/changes/source/multi_file/greeter_impl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | std::string greet_impl(std::string_view const greeting, std::string_view const name) 6 | { 7 | return std::format("{}, {}!", greeting, name); 8 | } 9 | -------------------------------------------------------------------------------- /test/default-options/changes/source/multi_file/greeter_impl.hpp: -------------------------------------------------------------------------------- 1 | #ifndef GREETER_IMPL_HPP 2 | #define GREETER_IMPL_HPP 3 | 4 | #include 5 | 6 | std::string greet_impl(std::string_view const greeting, std::string_view const name); 7 | 8 | #endif // GREETER_IMPL_HPP 9 | -------------------------------------------------------------------------------- /test/default-options/changes/source/multi_file/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::println("{}", greet("Hello", "world")); 7 | } 8 | -------------------------------------------------------------------------------- /test/default-options/changes/source/multi_file/test_greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | CHECK(greet("Hello", "world") == "Hello, world!"); 7 | } 8 | -------------------------------------------------------------------------------- /test/default-options/changes/source/object_library/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET greeter_object 3 | LIBRARY_TYPE OBJECT 4 | HEADERS 5 | greeter.hpp 6 | SOURCES 7 | greeter.cpp 8 | ) 9 | cxx_test( 10 | TARGET test_greeter_object 11 | HEADERS 12 | greeter.hpp 13 | SOURCES 14 | test_greeter.cpp 15 | DEPENDS_ON 16 | Catch2::Catch2 17 | Catch2::Catch2WithMain 18 | greeter_object 19 | ) 20 | cxx_executable( 21 | TARGET hello_object 22 | HEADERS 23 | greeter.hpp 24 | SOURCES 25 | hello.cpp 26 | DEPENDS_ON 27 | greeter_object 28 | ) 29 | -------------------------------------------------------------------------------- /test/default-options/changes/source/object_library/greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | std::string greet(std::string_view const greeting, std::string_view const name) 6 | { 7 | return std::format("{}, {}!", greeting, name); 8 | } 9 | -------------------------------------------------------------------------------- /test/default-options/changes/source/object_library/greeter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef GREETER_HPP 2 | #define GREETER_HPP 3 | 4 | #include 5 | 6 | std::string greet(std::string_view greeting, std::string_view name); 7 | 8 | #endif // GREETER_HPP 9 | -------------------------------------------------------------------------------- /test/default-options/changes/source/object_library/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::println("{}", greet("Hello", "world")); 7 | } 8 | -------------------------------------------------------------------------------- /test/default-options/changes/source/object_library/test_greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | TEST_CASE("hello, world!") 5 | { 6 | CHECK(greet("Hello", "world") == "Hello, world!"); 7 | } 8 | -------------------------------------------------------------------------------- /test/default-options/changes/source/plugin_library/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET plugin_handler 3 | LIBRARY_TYPE HEADER_ONLY 4 | HEADER_INTERFACE 5 | plugin_handler.hpp 6 | DEPENDS_ON_INTERFACE 7 | check 8 | ) 9 | cxx_library( 10 | TARGET greeter_plugin 11 | LIBRARY_TYPE PLUGIN 12 | HEADER_INTERFACE 13 | greeter.hpp 14 | SOURCES 15 | greeter.cpp 16 | COMPILE_OPTIONS 17 | -Wno-pragmas 18 | INSTALL_WITH install-targets 19 | INSTALL_PREFIX_INCLUDE plugin 20 | ) 21 | cxx_test( 22 | TARGET test_greeter_with_plugin 23 | HEADERS 24 | greeter.hpp 25 | SOURCES 26 | test_greeter.cpp 27 | DEPENDS_ON 28 | plugin_handler 29 | COMPILE_OPTIONS 30 | -Wno-pragmas 31 | ) 32 | cxx_executable( 33 | TARGET hello_with_plugin 34 | HEADERS 35 | greeter.hpp 36 | SOURCES 37 | hello.cpp 38 | DEPENDS_ON 39 | plugin_handler 40 | COMPILE_OPTIONS 41 | -Wno-pragmas 42 | INSTALL_WITH install-targets 43 | ) 44 | -------------------------------------------------------------------------------- /test/default-options/changes/source/plugin_library/greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | #pragma GCC diagnostic push 6 | #pragma GCC diagnostic ignored "-Wreturn-type-c-linkage" 7 | 8 | extern "C" [[gnu::visibility("default")]] std::string greet(std::string_view const greeting, std::string_view const name) 9 | { 10 | return std::format("{}, {}!", greeting, name); 11 | } 12 | 13 | #pragma GCC diagnostic pop 14 | -------------------------------------------------------------------------------- /test/default-options/changes/source/plugin_library/greeter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef GREETER_HPP 2 | #define GREETER_HPP 3 | 4 | #include 5 | 6 | #pragma GCC diagnostic push 7 | #pragma GCC diagnostic ignored "-Wreturn-type-c-linkage" 8 | 9 | extern "C" std::string greet(std::string_view greeting, std::string_view name); 10 | 11 | #pragma GCC diagnostic pop 12 | 13 | #endif // GREETER_HPP 14 | -------------------------------------------------------------------------------- /test/default-options/changes/source/plugin_library/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | #include 6 | #include 7 | 8 | int main(int, char* argv[]) 9 | { 10 | auto const binary_path = std::string_view(argv[0]); 11 | auto const lib_path = std::format("{}/../lib/libgreeter_plugin.so", binary_path.substr(0, binary_path.rfind('/'))); 12 | auto greeter = dynamic_library(lib_path); 13 | auto greet = greeter.template load_function("greet"); 14 | std::println("{}", greet("Hello", "world")); 15 | } 16 | -------------------------------------------------------------------------------- /test/default-options/changes/source/plugin_library/plugin_handler.hpp: -------------------------------------------------------------------------------- 1 | #ifndef PLUGIN_HANDLER 2 | #define PLUGIN_HANDLER 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | class dynamic_library { 12 | public: 13 | dynamic_library(std::string_view const name) 14 | : library_(dlopen(name.data(), RTLD_LAZY), dlclose) 15 | { 16 | CHECK(library_ != nullptr); 17 | } 18 | 19 | template 20 | class dynamic_function { 21 | public: 22 | explicit dynamic_function(T* const function) 23 | : function_(function) 24 | {} 25 | 26 | template 27 | decltype(auto) operator()(Args&&... args) 28 | { 29 | return std::invoke(function_, std::forward(args)...); 30 | } 31 | private: 32 | T* function_; 33 | }; 34 | 35 | template 36 | dynamic_function load_function(std::string_view const name) 37 | { 38 | auto function = reinterpret_cast(dlsym(library_.get(), name.data())); 39 | CHECK(function != nullptr); 40 | return dynamic_function(function); 41 | } 42 | private: 43 | std::unique_ptr library_; 44 | }; 45 | 46 | #endif // PLUGIN_HANDLER 47 | -------------------------------------------------------------------------------- /test/default-options/changes/source/plugin_library/test_greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | int main() 7 | { 8 | auto greeter = dynamic_library("./libgreeter_plugin.so"); 9 | auto greet = greeter.template load_function("greet"); 10 | CHECK(greet("Hello", "world") == "Hello, world!"); 11 | } 12 | -------------------------------------------------------------------------------- /test/default-options/changes/source/shared_library/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET greeter_shared 3 | LIBRARY_TYPE SHARED 4 | HEADER_INTERFACE 5 | greeter.hpp 6 | SOURCES 7 | greeter.cpp 8 | INSTALL_WITH install-targets 9 | INSTALL_PREFIX_INCLUDE shared 10 | INSTALL_PERMISSIONS OWNER_READ OWNER_WRITE 11 | ) 12 | cxx_library( 13 | TARGET fanciful_shared 14 | LIBRARY_TYPE SHARED 15 | HEADER_INTERFACE 16 | fanciful.hpp 17 | SOURCES 18 | fanciful.cpp 19 | DEPENDS_ON_INTERFACE 20 | greeter_shared 21 | INSTALL_WITH install-targets 22 | INSTALL_PREFIX_INCLUDE shared 23 | ) 24 | cxx_test( 25 | TARGET test_greeter_shared 26 | SOURCES 27 | test_greeter.cpp 28 | DEPENDS_ON 29 | check 30 | fanciful_shared 31 | ) 32 | cxx_executable( 33 | TARGET hello_shared 34 | SOURCES 35 | hello.cpp 36 | DEPENDS_ON 37 | fanciful_shared 38 | INSTALL_WITH install-targets 39 | ) 40 | -------------------------------------------------------------------------------- /test/default-options/changes/source/shared_library/fanciful.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | [[gnu::visibility("default")]] std::string make_fancy(std::string_view const message) 6 | { 7 | return std::format("fancy {}", message); 8 | } 9 | -------------------------------------------------------------------------------- /test/default-options/changes/source/shared_library/fanciful.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | std::string make_fancy(std::string_view const message); 5 | -------------------------------------------------------------------------------- /test/default-options/changes/source/shared_library/greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | [[gnu::visibility("default")]] std::string greet(std::string_view const greeting, std::string_view const name) 6 | { 7 | return std::format("{}, {}!", greeting, name); 8 | } 9 | -------------------------------------------------------------------------------- /test/default-options/changes/source/shared_library/greeter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef GREETER_HPP 2 | #define GREETER_HPP 3 | 4 | #include 5 | 6 | std::string greet(std::string_view greeting, std::string_view name); 7 | 8 | #endif // GREETER_HPP 9 | -------------------------------------------------------------------------------- /test/default-options/changes/source/shared_library/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | std::println("{}", make_fancy(greet("Hello", "world"))); 8 | } 9 | -------------------------------------------------------------------------------- /test/default-options/changes/source/shared_library/test_greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | CHECK(make_fancy(greet("Hello", "world")) == "fancy Hello, world!"); 8 | } 9 | -------------------------------------------------------------------------------- /test/default-options/changes/source/static_library/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET greeter_static 3 | LIBRARY_TYPE STATIC 4 | HEADER_INTERFACE 5 | greeter.hpp 6 | SOURCES 7 | greeter.cpp 8 | INSTALL_WITH install-targets 9 | INSTALL_PREFIX_INCLUDE static-inc 10 | INSTALL_PREFIX_LIBRARY static 11 | ) 12 | cxx_library( 13 | TARGET fanciful_static 14 | LIBRARY_TYPE STATIC 15 | HEADER_INTERFACE 16 | fanciful.hpp 17 | SOURCES 18 | fanciful.cpp 19 | DEPENDS_ON_INTERFACE 20 | greeter_static 21 | ) 22 | cxx_test( 23 | TARGET test_greeter_static 24 | SOURCES 25 | test_greeter.cpp 26 | DEPENDS_ON 27 | check 28 | fanciful_static 29 | ) 30 | cxx_executable( 31 | TARGET hello_static 32 | SOURCES 33 | hello.cpp 34 | DEPENDS_ON 35 | fanciful_static 36 | INSTALL_WITH install-target 37 | INSTALL_PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_EXECUTE WORLD_READ 38 | ) 39 | -------------------------------------------------------------------------------- /test/default-options/changes/source/static_library/fanciful.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | std::string make_fancy(std::string_view const message) 6 | { 7 | return std::format("fancy {}", message); 8 | } 9 | -------------------------------------------------------------------------------- /test/default-options/changes/source/static_library/fanciful.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | std::string make_fancy(std::string_view const message); 5 | -------------------------------------------------------------------------------- /test/default-options/changes/source/static_library/greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | std::string greet(std::string_view const greeting, std::string_view const name) 6 | { 7 | return std::format("{}, {}!", greeting, name); 8 | } 9 | -------------------------------------------------------------------------------- /test/default-options/changes/source/static_library/greeter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef GREETER_HPP 2 | #define GREETER_HPP 3 | 4 | #include 5 | 6 | std::string greet(std::string_view greeting, std::string_view name); 7 | 8 | #endif // GREETER_HPP 9 | -------------------------------------------------------------------------------- /test/default-options/changes/source/static_library/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | std::println("{}", make_fancy(greet("Hello", "world"))); 8 | } 9 | -------------------------------------------------------------------------------- /test/default-options/changes/source/static_library/test_greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | CHECK(make_fancy(greet("Hello", "world")) == "fancy Hello, world!"); 8 | } 9 | -------------------------------------------------------------------------------- /test/default-options/changes/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "check-vcpkg", 3 | "version-string": "", 4 | "homepage": "", 5 | "description": "", 6 | "dependencies": [ 7 | "catch2" 8 | ] 9 | } 10 | -------------------------------------------------------------------------------- /test/default-options/expected-output/.clang-tidy: -------------------------------------------------------------------------------- 1 | Checks: 'abseil-*, 2 | boost-*, 3 | bugprone-*, 4 | -bugprone-exception-escape, 5 | cert-*, 6 | -cert-dcl21-cpp, 7 | -cert-msc32-c, 8 | -cert-msc51-cpp, 9 | clang-analyzer-*, 10 | clang-diagnostic-*, 11 | cppcoreguildelines-*, 12 | google-*, 13 | -google-runtime-int, 14 | -google-runtime-references, 15 | misc-*, 16 | -misc-no-recursion, 17 | -misc-non-private-member-variables-in-classes, 18 | modernize-*, 19 | -modernize-use-trailing-return-type, 20 | performance-*, 21 | portability-*, 22 | -portability-simd-intrinsics, 23 | readability-*, 24 | -readability-function-size, 25 | -readability-function-cognitive-complexity, 26 | -readability-named-parameter, 27 | -readability-qualified-auto, 28 | -readability-identifier-length' 29 | WarningsAsErrors: '*' 30 | 31 | CheckOptions: 32 | - key: bugprone-dangling-handle.HandleClasses 33 | value: 'std::basic_string_view;std::span;std::ranges::subrange;std::ranges::all_view;std::ranges::common_view;std::ranges::keys_view;std::ranges::values_view' 34 | - key: bugprone-exception-escape.FunctionsThatShouldNotThrow 35 | value: 'iter_move,iter_swap' 36 | - key: readability-simplify-boolean-expr.ChainedConditionalReturn 37 | value: '1' 38 | - key: readability-simplify-boolean-expr.ChainedConditionalAssignment 39 | value: '1' 40 | - key: readability-simplify-subscript-expr.Types 41 | value: 'std::array;std::basic_string;std::basic_string_view;std::span;std::vector' 42 | 43 | # For the full list, see https://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-naming.html. 44 | - key: readability-identifier-naming.ClassCase 45 | value: "lower_case" 46 | - key: readability-identifier-naming.ClassMemberSuffix 47 | value: "_" 48 | - key: readability-identifier-naming.ConceptCase 49 | value: "lower_case" 50 | - key: readability-identifier-naming.ConstantCase 51 | value: "lower_case" 52 | - key: readability-identifier-naming.ConstantMemberCase 53 | value: "lower_case" 54 | - key: readability-identifier-naming.ConstexprVariableCase 55 | value: "lower_case" 56 | - key: readability-identifier-naming.EnumCase 57 | value: "lower_case" 58 | - key: readability-identifier-naming.EnumConstantCase 59 | value: "lower_case" 60 | - key: readability-identifier-naming.FunctionCase 61 | value: "lower_case" 62 | - key: readability-identifier-naming.GlobalCase 63 | value: "lower_case" 64 | - key: readability-identifier-naming.MacroDefinitionCase 65 | value: "UPPER_CASE" 66 | - key: readability-identifier-naming.MacroDefinitionPrefix 67 | value: "DEFAULT_OPTIONS_" 68 | - key: readability-identifier-naming.MemberCase 69 | value: "lower_case" 70 | - key: readability-identifier-naming.MethodCase 71 | value: "lower_case" 72 | - key: readability-identifier-naming.NamespaceCase 73 | value: "lower_case" 74 | - key: readability-identifier-naming.ParameterCase 75 | value: "lower_case" 76 | - key: readability-identifier-naming.PrivateMemberSuffix 77 | value: "_" 78 | - key: readability-identifier-naming.PrivateMethodCase 79 | value: "lower_case" 80 | - key: readability-identifier-naming.PublicMemberCase 81 | value: "lower_case" 82 | - key: readability-identifier-naming.PublicMethodCase 83 | value: "lower_case" 84 | - key: readability-identifier-naming.TypeAliasCase 85 | value: "lower_case" 86 | - key: readability-identifier-naming.VariableCase 87 | value: "lower_case" 88 | -------------------------------------------------------------------------------- /test/default-options/expected-output/.clangd: -------------------------------------------------------------------------------- 1 | CompileFlags: 2 | Remove: 3 | - -fmodules 4 | CompilationDatabase: ./build 5 | Diagnostics: 6 | MissingIncludes: Strict 7 | Index: 8 | Background: Build 9 | StandardLibrary: Yes 10 | -------------------------------------------------------------------------------- /test/default-options/expected-output/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.28 FATAL_ERROR) 2 | 3 | project("DEFAULT_OPTIONS" C CXX) 4 | 5 | set(CMAKE_CXX_STANDARD 23) 6 | set(CMAKE_CXX_EXTENSIONS Yes) 7 | set(CMAKE_CXX_STANDARD_REQUIRED Yes) 8 | set(CMAKE_EXPORT_COMPILE_COMMANDS Yes) 9 | 10 | if(CMAKE_CXX_EXTENSIONS) 11 | message(STATUS "Building with C++${CMAKE_CXX_STANDARD} (extensions enabled)") 12 | else() 13 | message(STATUS "Building with C++${CMAKE_CXX_STANDARD} (extensions disabled)") 14 | endif() 15 | 16 | include("${PROJECT_SOURCE_DIR}/config/cmake/project_options.cmake") 17 | include("${PROJECT_SOURCE_DIR}/config/cmake/detail/add_targets.cmake") 18 | enable_testing() 19 | include(CTest) 20 | 21 | add_subdirectory(source) 22 | add_subdirectory(docs) 23 | 24 | # This file is deliberately included after everything else, since installation targets depend on at 25 | # least one target requesting to be installed first. 26 | include("${PROJECT_SOURCE_DIR}/config/cmake/install_targets.cmake") 27 | -------------------------------------------------------------------------------- /test/default-options/expected-output/README.md: -------------------------------------------------------------------------------- 1 | # default_options 2 | 3 | Welcome to default_options! 4 | 5 | * [Licence](LICENCE) 6 | * [Code of conduct](CODE_OF_CONDUCT.md) 7 | -------------------------------------------------------------------------------- /test/default-options/expected-output/config/cmake/detail/default_options.cmake: -------------------------------------------------------------------------------- 1 | # This file was autogenerated by new_cxx_project.py. Do not modify this file, as add_targets.cmake 2 | # heavily depends on it. 3 | 4 | function(validate_option value option valid_values) 5 | list(FIND "${valid_values}" "${value}" found) 6 | 7 | if(found EQUAL -1) 8 | message(FATAL_ERROR "invalid value '${value}' for ${option} (valid values are [${${valid_values}}])") 9 | endif() 10 | endfunction() 11 | 12 | if (NOT CMAKE_CONFIGURATION_TYPES) 13 | set(CMAKE_CONFIGURATION_TYPES Debug RelWithDebInfo MinSizeRel Release) 14 | endif() 15 | 16 | if(CMAKE_BUILD_TYPE) 17 | list(FIND CMAKE_CONFIGURATION_TYPES "${CMAKE_BUILD_TYPE}" valid_build_type) 18 | if(valid_build_type EQUAL -1) 19 | message(FATAL_ERROR "${CMAKE_BUILD_TYPE} is not a valid value") 20 | endif() 21 | else() 22 | message(FATAL_ERROR "CMAKE_BUILD_TYPE must be set") 23 | endif() 24 | message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") 25 | 26 | set( 27 | # Variable 28 | DEFAULT_OPTIONS_BUILD_DOCS 29 | # Default value 30 | Yes 31 | CACHE STRING 32 | "Toggles whether the documentation is built. Requires both Sphinx and MyST to be installed first." 33 | ) 34 | -------------------------------------------------------------------------------- /test/default-options/expected-output/config/cmake/install_targets.cmake: -------------------------------------------------------------------------------- 1 | include(CMakePackageConfigHelpers) 2 | 3 | # Here's an example installation target that you can potentially use as-is. We leave it commented 4 | # out until you have something to install; CMake produces a fatal error when the installation target 5 | # doesn't have anything to install. 6 | # 7 | # install( 8 | # EXPORT default_options-installation-target 9 | # FILE default_options-config.cmake 10 | # NAMESPACE default_options:: 11 | # DESTINATION lib/cmake/default_options 12 | # CXX_MODULES_DIRECTORY lib/modules/default_options 13 | # ) 14 | 15 | message( 16 | AUTHOR_WARNING "no installation targets have been declared (please modify ${CMAKE_CURRENT_SOURCE_DIR}/config/cmake/install_targets.cmake to rectify this)" 17 | ) 18 | -------------------------------------------------------------------------------- /test/default-options/expected-output/config/cmake/project_options.cmake: -------------------------------------------------------------------------------- 1 | include("${PROJECT_SOURCE_DIR}/config/cmake/detail/default_options.cmake") 2 | 3 | # Add your project options here. 4 | -------------------------------------------------------------------------------- /test/default-options/expected-output/config/cmake/toolchains/x86_64-unknown-linux-gnu.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR x86_64) 3 | 4 | set(CMAKE_C_COMPILER "/usr/bin/gcc") 5 | set(CMAKE_C_COMPILER_AR "/usr/bin/ar") 6 | set(CMAKE_C_COMPILER_RANLIB "/usr/bin/ranlib") 7 | set(CMAKE_C_COMPILER_TARGET x86_64-unknown-linux-gnu) 8 | 9 | set(CMAKE_CXX_COMPILER "/usr/bin/g++") 10 | set(CMAKE_CXX_COMPILER_AR "/usr/bin/ar") 11 | set(CMAKE_CXX_COMPILER_RANLIB "/usr/bin/ranlib") 12 | set(CMAKE_CXX_COMPILER_TARGET x86_64-unknown-linux-gnu) 13 | 14 | set(CMAKE_RC_COMPILER "/usr/bin/rc") 15 | set(CMAKE_RC_COMPILER_AR "/usr/bin/ar") 16 | set(CMAKE_RC_COMPILER_RANLIB "/usr/bin/ranlib") 17 | 18 | set(CMAKE_LINKER_TYPE GOLD) 19 | 20 | string( 21 | JOIN " " CMAKE_CXX_FLAGS_INIT 22 | -fdiagnostics-color=always 23 | -fstack-protector-strong 24 | -fvisibility=hidden 25 | -Werror 26 | -pedantic 27 | -Wall 28 | -Wattributes 29 | -Wcast-align 30 | -Wconversion 31 | -Wdouble-promotion 32 | -Wextra 33 | -Wformat=2 34 | -Wnon-virtual-dtor 35 | -Wnull-dereference 36 | -Wodr 37 | -Wold-style-cast 38 | -Woverloaded-virtual 39 | -Wshadow 40 | -Wsign-conversion 41 | -Wsign-promo 42 | -Wunused 43 | -Wno-ignored-attributes 44 | -Wno-cxx-attribute-extension 45 | -Wno-gnu-include-next 46 | -Wno-private-header 47 | -Wno-unused-command-line-argument 48 | -D_GLIBCXX_ASSERTIONS 49 | ) 50 | 51 | string( 52 | JOIN " " CMAKE_EXE_LINKER_FLAGS_INIT 53 | ) 54 | -------------------------------------------------------------------------------- /test/default-options/expected-output/config/cmake/toolchains/x86_64-unknown-linux-llvm.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR x86_64) 3 | 4 | set(CMAKE_C_COMPILER "/usr/bin/clang") 5 | set(CMAKE_C_COMPILER_AR "/usr/bin/llvm-ar") 6 | set(CMAKE_C_COMPILER_RANLIB "/usr/bin/llvm-ranlib") 7 | set(CMAKE_C_COMPILER_TARGET x86_64-unknown-linux-gnu) 8 | 9 | set(CMAKE_CXX_COMPILER "/usr/bin/clang++") 10 | set(CMAKE_CXX_COMPILER_AR "/usr/bin/llvm-ar") 11 | set(CMAKE_CXX_COMPILER_RANLIB "/usr/bin/llvm-ranlib") 12 | set(CMAKE_CXX_COMPILER_TARGET x86_64-unknown-linux-gnu) 13 | 14 | set(CMAKE_RC_COMPILER "/usr/bin/llvm-rc") 15 | set(CMAKE_RC_COMPILER_AR "/usr/bin/llvm-ar") 16 | set(CMAKE_RC_COMPILER_RANLIB "/usr/bin/llvm-ranlib") 17 | 18 | set(CMAKE_LINKER_TYPE LLD) 19 | 20 | string( 21 | JOIN " " CMAKE_CXX_FLAGS_INIT 22 | -fdiagnostics-color=always 23 | -fstack-protector-strong 24 | -fvisibility=hidden 25 | -Werror 26 | -pedantic 27 | -Wall 28 | -Wattributes 29 | -Wcast-align 30 | -Wconversion 31 | -Wdouble-promotion 32 | -Wextra 33 | -Wformat=2 34 | -Wnon-virtual-dtor 35 | -Wnull-dereference 36 | -Wodr 37 | -Wold-style-cast 38 | -Woverloaded-virtual 39 | -Wshadow 40 | -Wsign-conversion 41 | -Wsign-promo 42 | -Wunused 43 | -Wno-ignored-attributes 44 | -Wno-cxx-attribute-extension 45 | -Wno-gnu-include-next 46 | -Wno-private-header 47 | -Wno-unused-command-line-argument 48 | -stdlib=libc++ 49 | -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST 50 | ) 51 | 52 | string( 53 | JOIN " " CMAKE_EXE_LINKER_FLAGS_INIT 54 | -rtlib=compiler-rt 55 | -unwindlib=libunwind 56 | ) 57 | -------------------------------------------------------------------------------- /test/default-options/expected-output/docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(NOT DEFAULT_OPTIONS_BUILD_DOCS) 2 | return() 3 | endif() 4 | -------------------------------------------------------------------------------- /test/default-options/expected-output/source/CMakeLists.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cjdb/new_cxx_project/ad44b6de11129084765ebf9632366dc2e8597da7/test/default-options/expected-output/source/CMakeLists.txt -------------------------------------------------------------------------------- /test/default-options/tests/default_options/expected-cmake.out: -------------------------------------------------------------------------------- 1 | CHECK-CMAKE: -- The C compiler identification is {{(GNU|Clang) ([0-9.]+)}} 2 | CHECK-CMAKE-NEXT: -- The CXX compiler identification is {{(GNU|Clang) ([0-9.]+)}} 3 | CHECK-CMAKE-NEXT: -- Detecting C compiler ABI info 4 | CHECK-CMAKE-NEXT: -- Detecting C compiler ABI info - done 5 | CHECK-CMAKE-NEXT: -- Check for working C compiler: {{.*}} 6 | CHECK-CMAKE-NEXT: -- Detecting C compile features 7 | CHECK-CMAKE-NEXT: -- Detecting C compile features - done 8 | CHECK-CMAKE-NEXT: -- Detecting CXX compiler ABI info 9 | CHECK-CMAKE-NEXT: -- Detecting CXX compiler ABI info - done 10 | CHECK-CMAKE-NEXT: -- Check for working CXX compiler: {{.*}} 11 | CHECK-CMAKE-NEXT: -- Detecting CXX compile features 12 | CHECK-CMAKE-NEXT: -- Detecting CXX compile features - done 13 | CHECK-CMAKE-NEXT: -- Building with C++23 (extensions enabled) 14 | CHECK-CMAKE-NEXT: -- Bootstrapping vcpkg before install 15 | CHECK-CMAKE-NEXT: -- Bootstrapping vcpkg before install - done 16 | CHECK-CMAKE-NEXT: -- Running vcpkg install 17 | CHECK-CMAKE-NEXT: Detecting compiler hash for triplet x64-linux... 18 | CHECK-CMAKE-NEXT: Compiler found: /usr/bin/c++ 19 | CHECK-CMAKE-NEXT: Detecting compiler hash for triplet vcpkg_toolchain_file... 20 | CHECK-CMAKE-NEXT: Compiler found: /usr/bin/c++ 21 | CHECK-CMAKE-NEXT: The following packages will be built and installed: 22 | CHECK-CMAKE-NEXT: catch2:vcpkg_toolchain_file@{{.*}} 23 | CHECK-CMAKE-NEXT: * vcpkg-cmake:x64-linux@{{.*}} 24 | CHECK-CMAKE-NEXT: * vcpkg-cmake-config:x64-linux@{{.*}} 25 | CHECK-CMAKE: {{.+/default_options/Output}}/[[BUILD_TYPE]].test.tmp/build/vcpkg_toolchain_file.cmake: info: loaded overlay triplet from here 26 | CHECK-CMAKE: -- Running vcpkg install - done 27 | CHECK-CMAKE-NEXT: -- Build type: [[BUILD_TYPE]] 28 | CHECK-CMAKE-NEXT: -- Found Python3: {{.+/python[0-9.]*}} (found version "{{[0-9.]+}}") found components: Interpreter 29 | CHECK-CMAKE-NEXT: -- Found Sphinx: {{.+/sphinx-build}} 30 | CHECK-CMAKE-NEXT: -- Configuring done ({{[0-9.]+s}}) 31 | CHECK-CMAKE-NEXT: -- Generating done ({{[0-9.]+s}}) 32 | CHECK-CMAKE-NEXT: -- Build files have been written to: {{.+/build}} 33 | -------------------------------------------------------------------------------- /test/default-options/tests/default_options/expected-ctest.out: -------------------------------------------------------------------------------- 1 | CHECK-CTEST: Internal ctest changing into directory: {{.+/build}} 2 | CHECK-CTEST-NEXT: Test project {{.+/build}} 3 | CHECK-CTEST-NEXT: Start 1: test.test_greeter_header_only 4 | CHECK-CTEST-NEXT: 1/10 Test #1: test.test_greeter_header_only ....... Passed {{[0-9.]+}} sec 5 | CHECK-CTEST-NEXT: Start 2: test.test_greeter_object 6 | CHECK-CTEST-NEXT: 2/10 Test #2: test.test_greeter_object ............ Passed {{[0-9.]+}} sec 7 | CHECK-CTEST-NEXT: Start 3: test.test_greeter_with_plugin 8 | CHECK-CTEST-NEXT: 3/10 Test #3: test.test_greeter_with_plugin ....... Passed {{[0-9.]+}} sec 9 | CHECK-CTEST-NEXT: Start 4: test.test_greeter_shared 10 | CHECK-CTEST-NEXT: 4/10 Test #4: test.test_greeter_shared ............ Passed {{[0-9.]+}} sec 11 | CHECK-CTEST-NEXT: Start 5: test.test_greeter_static 12 | CHECK-CTEST-NEXT: 5/10 Test #5: test.test_greeter_static ............ Passed {{[0-9.]+}} sec 13 | CHECK-CTEST-NEXT: Start 6: test.test_greeter_multi_file 14 | CHECK-CTEST-NEXT: 6/10 Test #6: test.test_greeter_multi_file ........ Passed {{[0-9.]+}} sec 15 | CHECK-CTEST-NEXT: Start 7: test.hello_multi_file 16 | CHECK-CTEST-NEXT: 7/10 Test #7: test.hello_multi_file ............... Passed {{[0-9.]+}} sec 17 | CHECK-CTEST-NEXT: Start 8: test.test_greeter_with_macro 18 | CHECK-CTEST-NEXT: 8/10 Test #8: test.test_greeter_with_macro ........ Passed {{[0-9.]+}} sec 19 | CHECK-CTEST-NEXT: Start 9: test.test_greeter_compile_options 20 | CHECK-CTEST-NEXT: 9/10 Test #9: test.test_greeter_compile_options ... Passed {{[0-9.]+}} sec 21 | CHECK-CTEST-NEXT: Start 10: test.test_greeter_link_options 22 | CHECK-CTEST-NEXT: 10/10 Test #10: test.test_greeter_link_options ...... Passed {{[0-9.]+}} sec 23 | CHECK-CTEST-EMPTY: 24 | CHECK-CTEST-NEXT: 100% tests passed, 0 tests failed out of 10 25 | -------------------------------------------------------------------------------- /test/default-options/tests/default_options/expected-stdout.out: -------------------------------------------------------------------------------- 1 | CHECK: Hello, world! 2 | CHECK-FANCY: fancy Hello, world! 3 | -------------------------------------------------------------------------------- /test/default-options/tests/gnu/expected-cmake.out: -------------------------------------------------------------------------------- 1 | CHECK-CMAKE: -- The C compiler identification is GNU {{[0-9.]+}} 2 | CHECK-CMAKE-NEXT: -- The CXX compiler identification is GNU {{[0-9.]+}} 3 | CHECK-CMAKE-NEXT: -- Detecting C compiler ABI info 4 | CHECK-CMAKE-NEXT: -- Detecting C compiler ABI info - done 5 | CHECK-CMAKE-NEXT: -- Check for working C compiler: /usr/bin/gcc - skipped 6 | CHECK-CMAKE-NEXT: -- Detecting C compile features 7 | CHECK-CMAKE-NEXT: -- Detecting C compile features - done 8 | CHECK-CMAKE-NEXT: -- Detecting CXX compiler ABI info 9 | CHECK-CMAKE-NEXT: -- Detecting CXX compiler ABI info - done 10 | CHECK-CMAKE-NEXT: -- Check for working CXX compiler: /usr/bin/g++ - skipped 11 | CHECK-CMAKE-NEXT: -- Detecting CXX compile features 12 | CHECK-CMAKE-NEXT: -- Detecting CXX compile features - done 13 | CHECK-CMAKE-NEXT: -- Building with C++23 (extensions enabled) 14 | CHECK-CMAKE-NEXT: -- Bootstrapping vcpkg before install 15 | CHECK-CMAKE-NEXT: -- Bootstrapping vcpkg before install - done 16 | CHECK-CMAKE-NEXT: -- Running vcpkg install 17 | CHECK-CMAKE-NEXT: Detecting compiler hash for triplet x64-linux... 18 | CHECK-CMAKE-NEXT: Compiler found: /usr/bin/c++ 19 | CHECK-CMAKE-NEXT: Detecting compiler hash for triplet vcpkg_toolchain_file... 20 | CHECK-CMAKE-NEXT: Compiler found: /usr/bin/g++ 21 | CHECK-CMAKE-NEXT: The following packages will be built and installed: 22 | CHECK-CMAKE-NEXT: catch2:vcpkg_toolchain_file@{{.*}} 23 | CHECK-CMAKE-NEXT: * vcpkg-cmake:x64-linux@{{.*}} 24 | CHECK-CMAKE-NEXT: * vcpkg-cmake-config:x64-linux@{{.*}} 25 | CHECK-CMAKE: {{.+/gnu/Output}}/[[BUILD_TYPE]].test.tmp/build/vcpkg_toolchain_file.cmake: info: loaded overlay triplet from here 26 | CHECK-CMAKE: -- Running vcpkg install - done 27 | CHECK-CMAKE-NEXT: -- Build type: [[BUILD_TYPE]] 28 | CHECK-CMAKE-NEXT: -- Found Python3: {{.+/python[0-9.]*}} (found version "{{[0-9.]+}}") found components: Interpreter 29 | CHECK-CMAKE-NEXT: -- Found Sphinx: {{.+/sphinx-build}} 30 | CHECK-CMAKE-NEXT: -- Configuring done ({{[0-9.]+s}}) 31 | CHECK-CMAKE-NEXT: -- Generating done ({{[0-9.]+s}}) 32 | CHECK-CMAKE-NEXT: -- Build files have been written to: {{.+/build}} 33 | -------------------------------------------------------------------------------- /test/default-options/tests/gnu/expected-ctest.out: -------------------------------------------------------------------------------- 1 | CHECK-CTEST: Internal ctest changing into directory: {{.+/build}} 2 | CHECK-CTEST-NEXT: Test project {{.+/build}} 3 | CHECK-CTEST-NEXT: Start 1: test.test_greeter_header_only 4 | CHECK-CTEST-NEXT: 1/11 Test #1: test.test_greeter_header_only ........ Passed {{[0-9.]+}} sec 5 | CHECK-CTEST-NEXT: Start 2: test.test_greeter_object 6 | CHECK-CTEST-NEXT: 2/11 Test #2: test.test_greeter_object ............. Passed {{[0-9.]+}} sec 7 | CHECK-CTEST-NEXT: Start 3: test.test_greeter_with_plugin 8 | CHECK-CTEST-NEXT: 3/11 Test #3: test.test_greeter_with_plugin ........ Passed {{[0-9.]+}} sec 9 | CHECK-CTEST-NEXT: Start 4: test.test_greeter_shared 10 | CHECK-CTEST-NEXT: 4/11 Test #4: test.test_greeter_shared ............. Passed {{[0-9.]+}} sec 11 | CHECK-CTEST-NEXT: Start 5: test.test_greeter_static 12 | CHECK-CTEST-NEXT: 5/11 Test #5: test.test_greeter_static ............. Passed {{[0-9.]+}} sec 13 | CHECK-CTEST-NEXT: Start 6: test.test_greeter_multi_file 14 | CHECK-CTEST-NEXT: 6/11 Test #6: test.test_greeter_multi_file ......... Passed {{[0-9.]+}} sec 15 | CHECK-CTEST-NEXT: Start 7: test.hello_multi_file 16 | CHECK-CTEST-NEXT: 7/11 Test #7: test.hello_multi_file ................ Passed {{[0-9.]+}} sec 17 | CHECK-CTEST-NEXT: Start 8: test.test_greeter_with_macro 18 | CHECK-CTEST-NEXT: 8/11 Test #8: test.test_greeter_with_macro ......... Passed {{[0-9.]+}} sec 19 | CHECK-CTEST-NEXT: Start 9: test.test_greeter_compile_options 20 | CHECK-CTEST-NEXT: 9/11 Test #9: test.test_greeter_compile_options .... Passed {{[0-9.]+}} sec 21 | CHECK-CTEST-NEXT: Start 10: test.test_greeter_link_options 22 | CHECK-CTEST-NEXT: 10/11 Test #10: test.test_greeter_link_options ....... Passed {{[0-9.]+}} sec 23 | CHECK-CTEST-NEXT: Start 11: test.test_greeter_object_with_asan 24 | CHECK-CTEST-ASAN-NEXT: 11/11 Test #11: test.test_greeter_object_with_asan ...***Failed {{[0-9.]+}} sec 25 | CHECK-CTEST-NOASAN-NEXT: 11/11 Test #11: test.test_greeter_object_with_asan ... Passed {{[0-9.]+}} sec 26 | CHECK-CTEST-ASAN-NEXT: ================================================================= 27 | CHECK-CTEST-ASAN-NEXT: ERROR: AddressSanitizer: heap-buffer-overflow on address 28 | CHECK-CTEST-ASAN: SUMMARY: AddressSanitizer: heap-buffer-overflow 29 | CHECK-CTEST-ASAN: ABORTING 30 | CHECK-CTEST-ASAN: 91% tests passed, 1 tests failed out of 11 31 | CHECK-CTEST-NOASAN: 100% tests passed, 0 tests failed out of 11 32 | CHECK-CTEST-ASAN: The following tests FAILED: 33 | CHECK-CTEST-ASAN: 11 - test.test_greeter_object_with_asan 34 | CHCEK-CTEST-ASAN: Errors while running CTest 35 | -------------------------------------------------------------------------------- /test/default-options/tests/gnu/expected-permissions.out: -------------------------------------------------------------------------------- 1 | CHECK: -rwxr-xr-x 1 {{.*/install}}/bin/hello_header_only 2 | CHECK-NEXT: -rwxr-xr-x 1 {{.*/install}}/bin/hello_shared 3 | CHECK-NEXT: -rwx--xr-- 1 {{.*/install}}/bin/hello_static 4 | CHECK-NEXT: -rwxr-xr-x 1 {{.*/install}}/bin/hello_with_plugin 5 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/include/header_only/greeter.hpp 6 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/include/plugin/greeter.hpp 7 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/include/shared/fanciful.hpp 8 | CHECK-NEXT: -rw------- 1 {{.*/install}}/include/shared/greeter.hpp 9 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/include/static-inc/greeter.hpp 10 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/lib/cmake/project_name/project_name-config-[[build_type]].cmake 11 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/lib/cmake/project_name/project_name-config.cmake 12 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/lib/libfanciful_shared.so 13 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/lib/libgreeter_plugin.so 14 | CHECK-NEXT: -rw------- 1 {{.*/install}}/lib/libgreeter_shared.so 15 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/lib/static/libgreeter_static.a 16 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/CODE_OF_CONDUCT.html 17 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/LICENCE.html 18 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/basic.css 19 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/dialog-note.png 20 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/dialog-seealso.png 21 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/dialog-todo.png 22 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/dialog-topic.png 23 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/dialog-warning.png 24 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/doctools.js 25 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/documentation_options.js 26 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/epub.css 27 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/file.png 28 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/footerbg.png 29 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/headerbg.png 30 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/ie6.css 31 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/language_data.js 32 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/middlebg.png 33 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/minus.png 34 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/plus.png 35 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/pygments.css 36 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/pyramid.css 37 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/searchtools.js 38 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/sphinx_highlight.js 39 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/_static/transparent.gif 40 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/genindex.html 41 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/index.html 42 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/search.html 43 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/searchindex.js 44 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/source/project/cmake.html 45 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/gnu_toolchain/source/project/vcpkg.html 46 | -------------------------------------------------------------------------------- /test/default-options/tests/gnu/expected-stdout.out: -------------------------------------------------------------------------------- 1 | CHECK: Hello, world! 2 | CHECK-FANCY: fancy Hello, world! 3 | -------------------------------------------------------------------------------- /test/default-options/tests/llvm/expected-cmake.out: -------------------------------------------------------------------------------- 1 | CHECK-CMAKE: -- The C compiler identification is Clang {{[0-9.]+}} 2 | CHECK-CMAKE-NEXT: -- The CXX compiler identification is Clang {{[0-9.]+}} 3 | CHECK-CMAKE-NEXT: -- Detecting C compiler ABI info 4 | CHECK-CMAKE-NEXT: -- Detecting C compiler ABI info - done 5 | CHECK-CMAKE-NEXT: -- Check for working C compiler: /usr/bin/clang - skipped 6 | CHECK-CMAKE-NEXT: -- Detecting C compile features 7 | CHECK-CMAKE-NEXT: -- Detecting C compile features - done 8 | CHECK-CMAKE-NEXT: -- Detecting CXX compiler ABI info 9 | CHECK-CMAKE-NEXT: -- Detecting CXX compiler ABI info - done 10 | CHECK-CMAKE-NEXT: -- Check for working CXX compiler: /usr/bin/clang++ - skipped 11 | CHECK-CMAKE-NEXT: -- Detecting CXX compile features 12 | CHECK-CMAKE-NEXT: -- Detecting CXX compile features - done 13 | CHECK-CMAKE-NEXT: -- Building with C++23 (extensions enabled) 14 | CHECK-CMAKE-NEXT: -- Bootstrapping vcpkg before install 15 | CHECK-CMAKE-NEXT: -- Bootstrapping vcpkg before install - done 16 | CHECK-CMAKE-NEXT: -- Running vcpkg install 17 | CHECK-CMAKE-NEXT: Detecting compiler hash for triplet x64-linux... 18 | CHECK-CMAKE-NEXT: Compiler found: /usr/bin/c++ 19 | CHECK-CMAKE-NEXT: Detecting compiler hash for triplet vcpkg_toolchain_file... 20 | CHECK-CMAKE-NEXT: Compiler found: /usr/bin/clang++ 21 | CHECK-CMAKE-NEXT: The following packages will be built and installed: 22 | CHECK-CMAKE-NEXT: catch2:vcpkg_toolchain_file@{{.*}} 23 | CHECK-CMAKE-NEXT: * vcpkg-cmake:x64-linux@{{.*}} 24 | CHECK-CMAKE-NEXT: * vcpkg-cmake-config:x64-linux@{{.*}} 25 | CHECK-CMAKE: {{.+/llvm/Output}}/[[BUILD_TYPE]].test.tmp/build/vcpkg_toolchain_file.cmake: info: loaded overlay triplet from here 26 | CHECK-CMAKE: -- Running vcpkg install - done 27 | CHECK-CMAKE-NEXT: -- Build type: [[BUILD_TYPE]] 28 | CHECK-CMAKE-NEXT: -- Found Python3: {{.+/python[0-9.]*}} (found version "{{[0-9.]+}}") found components: Interpreter 29 | CHECK-CMAKE-NEXT: -- Found Sphinx: {{.+/sphinx-build}} 30 | CHECK-CMAKE-NEXT: -- Configuring done ({{[0-9.]+s}}) 31 | CHECK-CMAKE-NEXT: -- Generating done ({{[0-9.]+s}}) 32 | CHECK-CMAKE-NEXT: -- Build files have been written to: {{.+/build}} 33 | -------------------------------------------------------------------------------- /test/default-options/tests/llvm/expected-ctest.out: -------------------------------------------------------------------------------- 1 | CHECK-CTEST: Internal ctest changing into directory: {{.+/build}} 2 | CHECK-CTEST-NEXT: Test project {{.+/build}} 3 | CHECK-CTEST-NEXT: Start 1: test.test_greeter_header_only 4 | CHECK-CTEST-NEXT: 1/12 Test #1: test.test_greeter_header_only ......... Passed {{[0-9.]+}} sec 5 | CHECK-CTEST-NEXT: Start 2: test.test_greeter_object 6 | CHECK-CTEST-NEXT: 2/12 Test #2: test.test_greeter_object .............. Passed {{[0-9.]+}} sec 7 | CHECK-CTEST-NEXT: Start 3: test.test_greeter_with_plugin 8 | CHECK-CTEST-NEXT: 3/12 Test #3: test.test_greeter_with_plugin ......... Passed {{[0-9.]+}} sec 9 | CHECK-CTEST-NEXT: Start 4: test.test_greeter_shared 10 | CHECK-CTEST-NEXT: 4/12 Test #4: test.test_greeter_shared .............. Passed {{[0-9.]+}} sec 11 | CHECK-CTEST-NEXT: Start 5: test.test_greeter_static 12 | CHECK-CTEST-NEXT: 5/12 Test #5: test.test_greeter_static .............. Passed {{[0-9.]+}} sec 13 | CHECK-CTEST-NEXT: Start 6: test.test_greeter_multi_file 14 | CHECK-CTEST-NEXT: 6/12 Test #6: test.test_greeter_multi_file .......... Passed {{[0-9.]+}} sec 15 | CHECK-CTEST-NEXT: Start 7: test.hello_multi_file 16 | CHECK-CTEST-NEXT: 7/12 Test #7: test.hello_multi_file ................. Passed {{[0-9.]+}} sec 17 | CHECK-CTEST-NEXT: Start 8: test.test_greeter_with_macro 18 | CHECK-CTEST-NEXT: 8/12 Test #8: test.test_greeter_with_macro .......... Passed {{[0-9.]+}} sec 19 | CHECK-CTEST-NEXT: Start 9: test.test_greeter_compile_options 20 | CHECK-CTEST-NEXT: 9/12 Test #9: test.test_greeter_compile_options ..... Passed {{[0-9.]+}} sec 21 | CHECK-CTEST-NEXT: Start 10: test.test_greeter_link_options 22 | CHECK-CTEST-NEXT: 10/12 Test #10: test.test_greeter_link_options ........ Passed {{[0-9.]+}} sec 23 | CHECK-CTEST-NEXT: Start 11: test.test_greeter_object_with_asan 24 | CHECK-CTEST-SAN-NEXT: 11/12 Test #11: test.test_greeter_object_with_asan ....***Failed {{[0-9.]+}} sec 25 | CHECK-CTEST-NOSAN-NEXT: 11/12 Test #11: test.test_greeter_object_with_asan .... Passed {{[0-9.]+}} sec 26 | CHECK-CTEST-SAN-NEXT: ================================================================= 27 | CHECK-CTEST-SAN-NEXT: ERROR: AddressSanitizer: heap-buffer-overflow on address 28 | CHECK-CTEST-SAN: SUMMARY: AddressSanitizer: heap-buffer-overflow 29 | CHECK-CTEST-SAN: ABORTING 30 | CHECK-CTEST: Start 12: test.test_greeter_object_with_ubsan 31 | CHECK-CTEST-SAN-NEXT: 12/12 Test #12: test.test_greeter_object_with_ubsan ...***Failed {{[0-9.]+}} sec 32 | CHECK-CTEST-SAN-NEXT: {{.+/llvm_toolchain/source/ubsan/greeter.cpp}}:{{[0-9]+}}:{{[0-9]+}}: runtime error: signed integer overflow: 2147483647 + 5 cannot be represented in type 'int' 33 | CHECK-CTEST-SAN-NEXT: SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior {{.+/llvm_toolchain/source/ubsan/greeter.cpp}}:{{[0-9]+}}:{{[0-9]+}} 34 | CHECK-CTEST-NOSAN-NEXT: 12/12 Test #12: test.test_greeter_object_with_ubsan ...Subprocess aborted***Exception: {{[0-9.]+}} sec 35 | CHECK-CTEST-NOSAN-NEXT: ubsan: add-overflow by {{0x[0-9a-f]+}} 36 | CHECK-CTEST-SAN: 83% tests passed, 2 tests failed out of 12 37 | CHECK-CTEST-NOSAN: 92% tests passed, 1 tests failed out of 12 38 | CHECK-CTEST: The following tests FAILED: 39 | CHECK-CTEST-SAN: 11 - test.test_greeter_object_with_asan 40 | CHECK-CTEST: 12 - test.test_greeter_object_with_ubsan 41 | CHCEK-CTEST: Errors while running CTest 42 | -------------------------------------------------------------------------------- /test/default-options/tests/llvm/expected-permissions.out: -------------------------------------------------------------------------------- 1 | CHECK: -rwxr-xr-x 1 {{.*/install}}/bin/hello_header_only 2 | CHECK-NEXT: -rwxr-xr-x 1 {{.*/install}}/bin/hello_shared 3 | CHECK-NEXT: -rwx--xr-- 1 {{.*/install}}/bin/hello_static 4 | CHECK-NEXT: -rwxr-xr-x 1 {{.*/install}}/bin/hello_with_plugin 5 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/include/header_only/greeter.hpp 6 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/include/plugin/greeter.hpp 7 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/include/shared/fanciful.hpp 8 | CHECK-NEXT: -rw------- 1 {{.*/install}}/include/shared/greeter.hpp 9 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/include/static-inc/greeter.hpp 10 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/lib/cmake/project_name/project_name-config-[[build_type]].cmake 11 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/lib/cmake/project_name/project_name-config.cmake 12 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/lib/libfanciful_shared.so 13 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/lib/libgreeter_plugin.so 14 | CHECK-NEXT: -rw------- 1 {{.*/install}}/lib/libgreeter_shared.so 15 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/lib/static/libgreeter_static.a 16 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/CODE_OF_CONDUCT.html 17 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/LICENCE.html 18 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/basic.css 19 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/dialog-note.png 20 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/dialog-seealso.png 21 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/dialog-todo.png 22 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/dialog-topic.png 23 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/dialog-warning.png 24 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/doctools.js 25 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/documentation_options.js 26 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/epub.css 27 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/file.png 28 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/footerbg.png 29 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/headerbg.png 30 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/ie6.css 31 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/language_data.js 32 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/middlebg.png 33 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/minus.png 34 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/plus.png 35 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/pygments.css 36 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/pyramid.css 37 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/searchtools.js 38 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/sphinx_highlight.js 39 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/_static/transparent.gif 40 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/genindex.html 41 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/index.html 42 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/search.html 43 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/searchindex.js 44 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/source/project/cmake.html 45 | CHECK-NEXT: -rw-r--r-- 1 {{.*/install}}/share/doc/llvm_toolchain/source/project/vcpkg.html 46 | -------------------------------------------------------------------------------- /test/default-options/tests/llvm/expected-stdout.out: -------------------------------------------------------------------------------- 1 | CHECK: Hello, world! 2 | CHECK-FANCY: fancy Hello, world! 3 | -------------------------------------------------------------------------------- /test/default-options/ubsan-only-changes/source/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_subdirectory(ubsan) 2 | -------------------------------------------------------------------------------- /test/default-options/ubsan-only-changes/source/ubsan/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET greeter_object_with_ubsan 3 | LIBRARY_TYPE OBJECT 4 | HEADERS 5 | greeter.hpp 6 | SOURCES 7 | greeter.cpp 8 | ) 9 | cxx_test( 10 | TARGET test_greeter_object_with_ubsan 11 | HEADERS 12 | greeter.hpp 13 | SOURCES 14 | test_greeter.cpp 15 | DEPENDS_ON 16 | check 17 | greeter_object_with_ubsan 18 | ) 19 | cxx_executable( 20 | TARGET hello_object_with_ubsan 21 | HEADERS 22 | greeter.hpp 23 | SOURCES 24 | hello.cpp 25 | DEPENDS_ON 26 | greeter_object_with_ubsan 27 | ) 28 | -------------------------------------------------------------------------------- /test/default-options/ubsan-only-changes/source/ubsan/greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | std::string greet(std::string_view const greeting, std::string_view const name) 7 | { 8 | auto k = 0x7f'ff'ff'ff; 9 | k += static_cast(name.size()); 10 | return std::format("{}, {}!", greeting, name.substr(0, static_cast(k))); 11 | } 12 | -------------------------------------------------------------------------------- /test/default-options/ubsan-only-changes/source/ubsan/greeter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef GREETER_HPP 2 | #define GREETER_HPP 3 | 4 | #include 5 | 6 | std::string greet(std::string_view greeting, std::string_view name); 7 | 8 | #endif // GREETER_HPP 9 | -------------------------------------------------------------------------------- /test/default-options/ubsan-only-changes/source/ubsan/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::println("{}", greet("Hello", "world")); 7 | } 8 | -------------------------------------------------------------------------------- /test/default-options/ubsan-only-changes/source/ubsan/test_greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | CHECK(greet("Hello", "world") == "Hello, world!"); 7 | } 8 | -------------------------------------------------------------------------------- /test/diagnostics/COMPILE_OPTIONS-do-not-propagate/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET greeting 3 | LIBRARY_TYPE STATIC 4 | HEADER_INTERFACE 5 | greeter.hpp 6 | SOURCES 7 | greeter.cpp 8 | COMPILE_OPTIONS 9 | -DRETURN_TYPE 10 | ) 11 | cxx_executable( 12 | TARGET hello 13 | SOURCES 14 | hello.cpp 15 | DEPENDS_ON 16 | greeting 17 | ) 18 | -------------------------------------------------------------------------------- /test/diagnostics/COMPILE_OPTIONS-do-not-propagate/greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | greet_result_t greet(std::string_view const greeting, std::string_view const name) 7 | { 8 | return std::format("{}, {}!", greeting, name); 9 | } 10 | -------------------------------------------------------------------------------- /test/diagnostics/COMPILE_OPTIONS-do-not-propagate/greeter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef GREETER_HPP 2 | #define GREETER_HPP 3 | 4 | #include 5 | 6 | #if defined(RETURN_TYPE) 7 | using greet_result_t = std::string; 8 | #endif 9 | 10 | greet_result_t greet(std::string_view greeting, std::string_view name); 11 | 12 | #endif // GREETER_HPP 13 | -------------------------------------------------------------------------------- /test/diagnostics/COMPILE_OPTIONS-do-not-propagate/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::println("{}", greet("Hello", "world")); 7 | } 8 | -------------------------------------------------------------------------------- /test/diagnostics/COMPILE_OPTIONS-do-not-propagate/test.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t 2 | RUN: %new-project %t/expected_error --author='new_cxx_project Test Suite' --package-manager=none 3 | RUN: cp %S/CMakeLists.txt %t/expected_error/source/CMakeLists.txt 4 | RUN: cp %S/*pp %t/expected_error/source/. 5 | RUN: cmake -S %t/expected_error -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug -DEXPECTED_ERROR_BUILD_DOCS=No 6 | RUN: ninja -j1 -C %t/build >%t/actual_error 2>&1 || %expect-error 7 | RUN: %{replace_path} %t/actual_error | FileCheck %s 8 | 9 | CHECK: ninja: Entering directory `/build/test/diagnostics/COMPILE_OPTIONS-do-not-propagate/Output/test.test.tmp/build' 10 | CHECK-NEXT: [1/8] Scanning /build/test/diagnostics/COMPILE_OPTIONS-do-not-propagate/Output/test.test.tmp/expected_error/source/greeter.cpp for CXX dependencies 11 | CHECK-NEXT: [2/8] Generating CXX dyndep file source/CMakeFiles/greeting.dir/CXX.dd 12 | CHECK-NEXT: [3/8] Building CXX object source/CMakeFiles/greeting.dir/greeter.cpp.o 13 | CHECK-NEXT: [4/8] Linking CXX static library source/libgreeting.a 14 | CHECK-NEXT: [5/8] Scanning /build/test/diagnostics/COMPILE_OPTIONS-do-not-propagate/Output/test.test.tmp/expected_error/source/hello.cpp for CXX dependencies 15 | CHECK-NEXT: [6/8] Generating CXX dyndep file source/CMakeFiles/hello.dir/CXX.dd 16 | CHECK-NEXT: [7/8] Building CXX object source/CMakeFiles/hello.dir/hello.cpp.o 17 | CHECK-NEXT: FAILED: source/CMakeFiles/hello.dir/hello.cpp.o 18 | CHECK-NEXT: /usr/bin/c++ -I/build/test/diagnostics/COMPILE_OPTIONS-do-not-propagate/Output/test.test.tmp/expected_error/source -g -std=gnu++23 -MD -MT source/CMakeFiles/hello.dir/hello.cpp.o -MF source/CMakeFiles/hello.dir/hello.cpp.o.d -fmodules-ts -fmodule-mapper=source/CMakeFiles/hello.dir/hello.cpp.o.modmap -MD -fdeps-format=p1689r5 -x c++ -o source/CMakeFiles/hello.dir/hello.cpp.o -c /build/test/diagnostics/COMPILE_OPTIONS-do-not-propagate/Output/test.test.tmp/expected_error/source/hello.cpp 19 | CHECK-NEXT: In file included from /build/test/diagnostics/COMPILE_OPTIONS-do-not-propagate/Output/test.test.tmp/expected_error/source/hello.cpp:{{[0-9]+}}: 20 | CHECK-NEXT: /build/test/diagnostics/COMPILE_OPTIONS-do-not-propagate/Output/test.test.tmp/expected_error/source/greeter.hpp:{{[0-9]+}}:{{[0-9]+}}: error: 'greet_result_t' does not name a type 21 | CHECK-NEXT: {{[0-9]+}} | greet_result_t greet(std::string_view greeting, std::string_view name); 22 | CHECK-NEXT: | ^~~~~~~~~~~~~~ 23 | CHECK-NEXT: /build/test/diagnostics/COMPILE_OPTIONS-do-not-propagate/Output/test.test.tmp/expected_error/source/hello.cpp: In function 'int main()': 24 | CHECK-NEXT: /build/test/diagnostics/COMPILE_OPTIONS-do-not-propagate/Output/test.test.tmp/expected_error/source/hello.cpp:{{[0-9]+}}:{{[0-9]+}}: error: 'greet' was not declared in this scope 25 | CHECK-NEXT: {{[0-9]+}} | std::println("{}", greet("Hello", "world")); 26 | CHECK-NEXT: | ^~~~~ 27 | CHECK-NEXT: ninja: build stopped: subcommand failed. 28 | -------------------------------------------------------------------------------- /test/diagnostics/DEFINE-does-not-propagate/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET greeting 3 | LIBRARY_TYPE STATIC 4 | HEADER_INTERFACE 5 | greeter.hpp 6 | SOURCES 7 | greeter.cpp 8 | DEFINE 9 | RETURN_TYPE 10 | ) 11 | cxx_executable( 12 | TARGET hello 13 | SOURCES 14 | hello.cpp 15 | DEPENDS_ON 16 | greeting 17 | ) 18 | -------------------------------------------------------------------------------- /test/diagnostics/DEFINE-does-not-propagate/greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | greet_result_t greet(std::string_view const greeting, std::string_view const name) 7 | { 8 | return std::format("{}, {}!", greeting, name); 9 | } 10 | -------------------------------------------------------------------------------- /test/diagnostics/DEFINE-does-not-propagate/greeter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef GREETER_HPP 2 | #define GREETER_HPP 3 | 4 | #include 5 | 6 | #if defined(RETURN_TYPE) 7 | using greet_result_t = std::string; 8 | #endif 9 | 10 | greet_result_t greet(std::string_view greeting, std::string_view name); 11 | 12 | #endif // GREETER_HPP 13 | -------------------------------------------------------------------------------- /test/diagnostics/DEFINE-does-not-propagate/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::println("{}", greet("Hello", "world")); 7 | } 8 | -------------------------------------------------------------------------------- /test/diagnostics/DEFINE-does-not-propagate/test.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t 2 | RUN: %new-project %t/expected_error --author='new_cxx_project Test Suite' --package-manager=none 3 | RUN: cp %S/CMakeLists.txt %t/expected_error/source/CMakeLists.txt 4 | RUN: cp %S/*pp %t/expected_error/source/. 5 | RUN: cmake -S %t/expected_error -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug -DEXPECTED_ERROR_BUILD_DOCS=No 6 | RUN: ninja -j1 -C %t/build >%t/actual_error 2>&1 || %expect-error 7 | RUN: %{replace_path} %t/actual_error | FileCheck %s 8 | 9 | CHECK: ninja: Entering directory `/build/test/diagnostics/DEFINE-does-not-propagate/Output/test.test.tmp/build' 10 | CHECK-NEXT: [1/8] Scanning /build/test/diagnostics/DEFINE-does-not-propagate/Output/test.test.tmp/expected_error/source/greeter.cpp for CXX dependencies 11 | CHECK-NEXT: [2/8] Generating CXX dyndep file source/CMakeFiles/greeting.dir/CXX.dd 12 | CHECK-NEXT: [3/8] Building CXX object source/CMakeFiles/greeting.dir/greeter.cpp.o 13 | CHECK-NEXT: [4/8] Linking CXX static library source/libgreeting.a 14 | CHECK-NEXT: [5/8] Scanning /build/test/diagnostics/DEFINE-does-not-propagate/Output/test.test.tmp/expected_error/source/hello.cpp for CXX dependencies 15 | CHECK-NEXT: [6/8] Generating CXX dyndep file source/CMakeFiles/hello.dir/CXX.dd 16 | CHECK-NEXT: [7/8] Building CXX object source/CMakeFiles/hello.dir/hello.cpp.o 17 | CHECK-NEXT: FAILED: source/CMakeFiles/hello.dir/hello.cpp.o 18 | CHECK-NEXT: /usr/bin/c++ -I/build/test/diagnostics/DEFINE-does-not-propagate/Output/test.test.tmp/expected_error/source -g -std=gnu++23 -MD -MT source/CMakeFiles/hello.dir/hello.cpp.o -MF source/CMakeFiles/hello.dir/hello.cpp.o.d -fmodules-ts -fmodule-mapper=source/CMakeFiles/hello.dir/hello.cpp.o.modmap -MD -fdeps-format=p1689r5 -x c++ -o source/CMakeFiles/hello.dir/hello.cpp.o -c /build/test/diagnostics/DEFINE-does-not-propagate/Output/test.test.tmp/expected_error/source/hello.cpp 19 | CHECK-NEXT: In file included from /build/test/diagnostics/DEFINE-does-not-propagate/Output/test.test.tmp/expected_error/source/hello.cpp:{{[0-9]+}}: 20 | CHECK-NEXT: /build/test/diagnostics/DEFINE-does-not-propagate/Output/test.test.tmp/expected_error/source/greeter.hpp:{{[0-9]+}}:{{[0-9]+}}: error: 'greet_result_t' does not name a type 21 | CHECK-NEXT: {{[0-9]+}} | greet_result_t greet(std::string_view greeting, std::string_view name); 22 | CHECK-NEXT: | ^~~~~~~~~~~~~~ 23 | CHECK-NEXT: /build/test/diagnostics/DEFINE-does-not-propagate/Output/test.test.tmp/expected_error/source/hello.cpp: In function 'int main()': 24 | CHECK-NEXT: /build/test/diagnostics/DEFINE-does-not-propagate/Output/test.test.tmp/expected_error/source/hello.cpp:{{[0-9]+}}:{{[0-9]+}}: error: 'greet' was not declared in this scope 25 | CHECK-NEXT: {{[0-9]+}} | std::println("{}", greet("Hello", "world")); 26 | CHECK-NEXT: | ^~~~~ 27 | CHECK-NEXT: ninja: build stopped: subcommand failed. 28 | -------------------------------------------------------------------------------- /test/diagnostics/DEPENDS_ON-does-not-propagate/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET make_fancy 3 | LIBRARY_TYPE SHARED 4 | HEADER_INTERFACE 5 | make_fancy.hpp 6 | SOURCES 7 | make_fancy.cpp 8 | DEPENDS_ON 9 | -s 10 | ) 11 | cxx_library( 12 | TARGET greeting 13 | LIBRARY_TYPE STATIC 14 | HEADER_INTERFACE 15 | greeter.hpp 16 | SOURCES 17 | greeter.cpp 18 | DEPENDS_ON 19 | make_fancy 20 | ) 21 | cxx_executable( 22 | TARGET hello 23 | SOURCES 24 | hello.cpp 25 | DEPENDS_ON 26 | greeting 27 | ) 28 | -------------------------------------------------------------------------------- /test/diagnostics/DEPENDS_ON-does-not-propagate/greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | std::string greet(std::string_view const greeting, std::string_view const name) 7 | { 8 | return std::format("{}, {}!", greeting, name); 9 | } 10 | -------------------------------------------------------------------------------- /test/diagnostics/DEPENDS_ON-does-not-propagate/greeter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef GREETER_HPP 2 | #define GREETER_HPP 3 | 4 | #include 5 | #include 6 | 7 | std::string greet(std::string_view greeting, std::string_view name); 8 | 9 | #endif // GREETER_HPP 10 | -------------------------------------------------------------------------------- /test/diagnostics/DEPENDS_ON-does-not-propagate/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | int main() 6 | { 7 | std::println("{}", make_fancy(greet("Hello", "world"))); 8 | } 9 | -------------------------------------------------------------------------------- /test/diagnostics/DEPENDS_ON-does-not-propagate/make_fancy.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | std::string make_fancy(std::string_view message) 5 | { 6 | return std::format("fancy {}", message); 7 | } 8 | -------------------------------------------------------------------------------- /test/diagnostics/DEPENDS_ON-does-not-propagate/make_fancy.hpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | std::string make_fancy(std::string_view message); 5 | -------------------------------------------------------------------------------- /test/diagnostics/LINK_OPTIONS-do-not-propagate/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET greeter 3 | LIBRARY_TYPE OBJECT 4 | HEADERS 5 | greeter.hpp 6 | SOURCES 7 | greeter.cpp 8 | COMPILE_OPTIONS 9 | -fPIC 10 | ) 11 | cxx_library( 12 | TARGET greeter_impl 13 | LIBRARY_TYPE OBJECT 14 | HEADERS 15 | greeter.hpp 16 | SOURCES 17 | greeter_impl.cpp 18 | COMPILE_OPTIONS 19 | -fPIC 20 | ) 21 | cxx_library( 22 | TARGET greeting 23 | LIBRARY_TYPE SHARED 24 | HEADER_INTERFACE 25 | greeter.hpp 26 | COMPILE_OPTIONS 27 | -fPIC 28 | DEPENDS_ON 29 | greeter 30 | greeter_impl 31 | LINK_OPTIONS 32 | --no-demangle 33 | ) 34 | cxx_executable( 35 | TARGET hello 36 | SOURCES 37 | hello.cpp 38 | DEPENDS_ON 39 | greeting 40 | ) 41 | -------------------------------------------------------------------------------- /test/diagnostics/LINK_OPTIONS-do-not-propagate/greeter.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | std::string greet_impl(std::string_view, std::string_view); 6 | 7 | std::string greet(std::string_view const greeting, std::string_view const name) 8 | { 9 | return greet_impl(greeting, name); 10 | } 11 | -------------------------------------------------------------------------------- /test/diagnostics/LINK_OPTIONS-do-not-propagate/greeter.hpp: -------------------------------------------------------------------------------- 1 | #ifndef GREETER_HPP 2 | #define GREETER_HPP 3 | 4 | #include 5 | #include 6 | 7 | std::string greet(std::string_view greeting, std::string_view name); 8 | 9 | #endif // GREETER_HPP 10 | -------------------------------------------------------------------------------- /test/diagnostics/LINK_OPTIONS-do-not-propagate/greeter_impl.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include 5 | 6 | std::string greet_impl(std::string_view const greeting, std::string_view const name) 7 | { 8 | return std::format("{}, {}!", greeting, name); 9 | } 10 | -------------------------------------------------------------------------------- /test/diagnostics/LINK_OPTIONS-do-not-propagate/hello.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | int main() 5 | { 6 | std::println("{}", greet("Hello", "world")); 7 | } 8 | -------------------------------------------------------------------------------- /test/diagnostics/MODULE_INTERFACE-cannot-be-installed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET module_interface_tries_to_install 3 | LIBRARY_TYPE STATIC 4 | MODULE_INTERFACE hello.cpp 5 | INSTALL_WITH a 6 | ) 7 | -------------------------------------------------------------------------------- /test/diagnostics/MODULE_INTERFACE-cannot-be-installed/test.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t 2 | RUN: %new-project %t/expected_error --author='new_cxx_project Test Suite' --package-manager=none 3 | RUN: cp %S/CMakeLists.txt %t/expected_error/source/CMakeLists.txt 4 | RUN: cmake -S %t/expected_error -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 5 | RUN: FileCheck --input-file=%t/actual_error %s 6 | 7 | CHECK: CMake Error at config/cmake/detail/add_targets.cmake:{{[0-9]+}} (message): 8 | CHECK-NEXT: cxx_library 'module_interface_tries_to_install' tries to install a module 9 | CHECK-NEXT: interface, but tooling isn't mature enough to support installing them yet 10 | CHECK-NEXT: Call Stack (most recent call first): 11 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (add_scoped_options) 12 | CHECK-NEXT: source/CMakeLists.txt:1 (cxx_library) 13 | CHECK: -- Configuring incomplete, errors occurred! 14 | -------------------------------------------------------------------------------- /test/diagnostics/bad_github_remote.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t 2 | RUN: %new-project %t/bad_remote --author='new_cxx_project Test Suite' --remote=https://github.com/missing/dot_git >%t.actual_error 2>&1 || %expect-error 3 | RUN: FileCheck --input-file=%t.actual_error -DREMOTE=https://github.com/missing/dot_git %s 4 | 5 | RUN: %rm %t 6 | RUN: %new-project %t/bad_remote --author='new_cxx_project Test Suite' --remote=git://github.com/missing/dot_git >%t.actual_error 2>&1 || %expect-error 7 | RUN: FileCheck --input-file=%t.actual_error -DREMOTE=git://github.com/missing/dot_git %s 8 | 9 | RUN: %rm %t 10 | RUN: %new-project %t/bad_remote --author='new_cxx_project Test Suite' --remote=git@github.com:missing/dot_git >%t.actual_error 2>&1 || %expect-error 11 | RUN: FileCheck --input-file=%t.actual_error -DREMOTE=git@github.com:missing/dot_git %s 12 | 13 | RUN: %rm %t 14 | RUN: %new-project %t/bad_remote --author='new_cxx_project Test Suite' --remote=http://github.com/is/http.git >%t.actual_error 2>&1 || %expect-error 15 | RUN: FileCheck --input-file=%t.actual_error -DREMOTE=http://github.com/is/http.git %s 16 | 17 | RUN: %rm %t 18 | RUN: %new-project %t/bad_remote --author='new_cxx_project Test Suite' --remote=you@github.com:user_not/git.git >%t.actual_error 2>&1 || %expect-error 19 | RUN: FileCheck --input-file=%t.actual_error -DREMOTE=you@github.com:user_not/git.git %s 20 | 21 | RUN: %rm %t 22 | RUN: %new-project %t/bad_remote --author='new_cxx_project Test Suite' --remote=git@github.com/slash/not_colon.git >%t.actual_error 2>&1 || %expect-error 23 | RUN: FileCheck --input-file=%t.actual_error -DREMOTE=git@github.com/slash/not_colon.git %s 24 | 25 | RUN: %rm %t 26 | RUN: %new-project %t/bad_remote --author='new_cxx_project Test Suite' --remote=https://github.com/no_user.git >%t.actual_error 2>&1 || %expect-error 27 | RUN: FileCheck --input-file=%t.actual_error -DREMOTE=https://github.com/no_user.git %s 28 | 29 | RUN: %rm %t 30 | RUN: %new-project %t/bad_remote --author='new_cxx_project Test Suite' --remote=git://github.com/no_user.git >%t.actual_error 2>&1 || %expect-error 31 | RUN: FileCheck --input-file=%t.actual_error -DREMOTE=git://github.com/no_user.git %s 32 | 33 | RUN: %rm %t 34 | RUN: %new-project %t/bad_remote --author='new_cxx_project Test Suite' --remote=git@github.com:no_user.git >%t.actual_error 2>&1 || %expect-error 35 | RUN: FileCheck --input-file=%t.actual_error -DREMOTE=git@github.com:no_user.git %s 36 | 37 | RUN: %rm %t 38 | RUN: %new-project %t/bad_remote --author='new_cxx_project Test Suite' --remote=https://github.com/no_repo >%t.actual_error 2>&1 || %expect-error 39 | RUN: FileCheck --input-file=%t.actual_error -DREMOTE=https://github.com/no_repo %s 40 | 41 | RUN: %rm %t 42 | RUN: %new-project %t/bad_remote --author='new_cxx_project Test Suite' --remote=git://github.com/no_repo >%t.actual_error 2>&1 || %expect-error 43 | RUN: FileCheck --input-file=%t.actual_error -DREMOTE=git://github.com/no_repo %s 44 | 45 | RUN: %rm %t 46 | RUN: %new-project %t/bad_remote --author='new_cxx_project Test Suite' --remote=git@github.com:no_repo >%t.actual_error 2>&1 || %expect-error 47 | RUN: FileCheck --input-file=%t.actual_error -DREMOTE=git@github.com:no_repo %s 48 | 49 | CHECK: error: remote '[[REMOTE]]' contains 'github.com', but it looks incorrect 50 | CHECK-NEXT: note: valid remotes include: 51 | CHECK-NEXT: * 'https://github.com/user/repo.git' 52 | CHECK-NEXT: * 'git://github.com/user/repo.git' 53 | CHECK-NEXT: * 'git@github.com:user/repo.git' 54 | -------------------------------------------------------------------------------- /test/diagnostics/build-type-not-set.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t 2 | RUN: %new-project %t/build_type_not_set --author='new_cxx_project Test Suite' --package-manager=none 3 | RUN: cmake -S %t/build_type_not_set -B %t/build -GNinja >%t/actual_error 2>&1 || %expect-error 4 | RUN: FileCheck --input-file=%t/actual_error %s 5 | 6 | CHECK: CMake Error at config/cmake/detail/default_options.cmake:{{[0-9]+}} (message): 7 | CHECK: CMAKE_BUILD_TYPE must be set 8 | CHECK: Call Stack (most recent call first): 9 | CHECK: config/cmake/project_options.cmake:{{[0-9]+}} (include) 10 | CHECK: CMakeLists.txt:{{[0-9]+}} (include) 11 | -------------------------------------------------------------------------------- /test/diagnostics/cxx_test-specifies-INSTALL_WITH/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_test( 2 | TARGET test_tries_to_install 3 | SOURCES hello.hpp 4 | INSTALL_WITH a 5 | ) 6 | -------------------------------------------------------------------------------- /test/diagnostics/cxx_test-specifies-INSTALL_WITH/test.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t 2 | RUN: %new-project %t/expected_error --author='new_cxx_project Test Suite' --package-manager=none 3 | RUN: cp %S/CMakeLists.txt %t/expected_error/source/CMakeLists.txt 4 | RUN: cmake -S %t/expected_error -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 5 | RUN: FileCheck --input-file=%t/actual_error %s 6 | 7 | CHECK: CMake Error at config/cmake/detail/add_targets.cmake:{{[0-9]+}} (message): 8 | CHECK-NEXT: cxx_test 'test_tries_to_install' specifies 'INSTALL_WITH', but tests can't 9 | CHECK-NEXT: be installed 10 | CHECK-NEXT: Call Stack (most recent call first): 11 | CHECK-NEXT: source/CMakeLists.txt:1 (cxx_test) 12 | CHECK: -- Configuring incomplete, errors occurred! 13 | -------------------------------------------------------------------------------- /test/diagnostics/invalid_name.test: -------------------------------------------------------------------------------- 1 | RUN: %rm valid_name 2 | RUN: %new-project valid_name --author='invalid_name.test' --package-manager=none 3 | RUN: %rm valid_name2 4 | RUN: %new-project valid_name2 --author='invalid_name.test' --package-manager=none 5 | RUN: %rm valid_3name 6 | RUN: %new-project valid_3name --author='invalid_name.test' --package-manager=none 7 | RUN: %rm valid4-name 8 | RUN: %new-project valid4-name --author='invalid_name.test' --package-manager=none 9 | RUN: %rm valid-name5 10 | RUN: %new-project valid-name5 --author='invalid_name.test' --package-manager=none 11 | RUN: %rm val1d-name 12 | RUN: %new-project val1d-name --author='invalid_name.test' --package-manager=none 13 | 14 | RUN: %new-project 'invalid&name' --author='invalid_name.test' >%t 2>&1 || %expect-error 15 | RUN: FileCheck %s --input-file=%t -DNAME='invalid&name' 16 | 17 | RUN: %new-project '1nvalid_name' --author='invalid_name.test' >%t 2>&1 || %expect-error 18 | RUN: FileCheck %s --input-file=%t -DNAME='1nvalid_name' 19 | 20 | CHECK: error: '[[NAME]]' cannot be used as a project name because it is not a valid C++ identifier 21 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/HEADER_ONLY-specifes-COMPILE_OPTIONS/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET header_only 3 | LIBRARY_TYPE HEADER_ONLY 4 | HEADER_INTERFACE world.hpp 5 | COMPILE_OPTIONS -Wall 6 | ) 7 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/HEADER_ONLY-specifes-COMPILE_OPTIONS/test.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t 2 | RUN: %new-project %t/expected_error --author='new_cxx_project Test Suite' --package-manager=none 3 | RUN: cp %S/CMakeLists.txt %t/expected_error/source/CMakeLists.txt 4 | RUN: cmake -S %t/expected_error -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 5 | RUN: FileCheck --input-file=%t/actual_error %s 6 | 7 | CHECK: CMake Error at config/cmake/detail/add_targets.cmake:{{[0-9]+}} (message): 8 | CHECK-NEXT: cxx_library 'header_only' specifies 'COMPILE_OPTIONS', which is 9 | CHECK-NEXT: incompatible with its library type, 'HEADER_ONLY' 10 | CHECK-NEXT: Call Stack (most recent call first): 11 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (library_type_error) 12 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (check_library_type) 13 | CHECK-NEXT: source/CMakeLists.txt:1 (cxx_library) 14 | CHECK: -- Configuring incomplete, errors occurred! 15 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/HEADER_ONLY-specifes-LINK_OPTIONS/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET header_only 3 | LIBRARY_TYPE HEADER_ONLY 4 | HEADER_INTERFACE world.hpp 5 | LINK_OPTIONS -s 6 | ) 7 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/HEADER_ONLY-specifes-LINK_OPTIONS/test.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t 2 | RUN: %new-project %t/expected_error --author='new_cxx_project Test Suite' --package-manager=none 3 | RUN: cp %S/CMakeLists.txt %t/expected_error/source/CMakeLists.txt 4 | RUN: cmake -S %t/expected_error -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 5 | RUN: FileCheck --input-file=%t/actual_error %s 6 | 7 | CHECK: CMake Error at config/cmake/detail/add_targets.cmake:{{[0-9]+}} (message): 8 | CHECK-NEXT: cxx_library 'header_only' specifies 'LINK_OPTIONS', which is incompatible 9 | CHECK-NEXT: with its library type, 'HEADER_ONLY' 10 | CHECK-NEXT: Call Stack (most recent call first): 11 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (library_type_error) 12 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (check_library_type) 13 | CHECK-NEXT: source/CMakeLists.txt:1 (cxx_library) 14 | CHECK: -- Configuring incomplete, errors occurred! 15 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/HEADER_ONLY-specifies-DEPENDS_ON/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET header_only 3 | LIBRARY_TYPE HEADER_ONLY 4 | HEADER_INTERFACE hello.hpp 5 | DEPENDS_ON something 6 | ) 7 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/HEADER_ONLY-specifies-DEPENDS_ON/test.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t 2 | RUN: %new-project %t/expected_error --author='new_cxx_project Test Suite' --package-manager=none 3 | RUN: cp %S/CMakeLists.txt %t/expected_error/source/CMakeLists.txt 4 | RUN: cmake -S %t/expected_error -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 5 | RUN: FileCheck --input-file=%t/actual_error %s 6 | 7 | CHECK: CMake Error at config/cmake/detail/add_targets.cmake:{{[0-9]+}} (message): 8 | CHECK-NEXT: cxx_library 'header_only' specifies 'DEPENDS_ON', which is incompatible 9 | CHECK-NEXT: with its library type, 'HEADER_ONLY' 10 | CHECK-EMPTY: 11 | CHECK-NEXT: did you mean 'DEPENDS_ON_INTERFACE'? 12 | CHECK-NEXT: Call Stack (most recent call first): 13 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (library_type_error) 14 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (check_library_type) 15 | CHECK-NEXT: source/CMakeLists.txt:1 (cxx_library) 16 | CHECK: -- Configuring incomplete, errors occurred! 17 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/HEADER_ONLY-specifies-HEADERS/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET header_only_with_HEADERS 3 | LIBRARY_TYPE HEADER_ONLY 4 | HEADERS hello.hpp 5 | HEADER_INTERFACE world.hpp 6 | ) 7 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/HEADER_ONLY-specifies-HEADERS/test.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t 2 | RUN: %new-project %t/expected_error --author='new_cxx_project Test Suite' --package-manager=none 3 | RUN: cp %S/CMakeLists.txt %t/expected_error/source/CMakeLists.txt 4 | RUN: cmake -S %t/expected_error -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 5 | RUN: FileCheck --input-file=%t/actual_error %s 6 | 7 | CHECK: CMake Error at config/cmake/detail/add_targets.cmake:{{[0-9]+}} (message): 8 | CHECK-NEXT: cxx_library 'header_only_with_HEADERS' specifies 'HEADERS', which is 9 | CHECK-NEXT: incompatible with its library type, 'HEADER_ONLY' 10 | CHECK-EMPTY: 11 | CHECK-NEXT: did you mean 'HEADER_INTERFACE'? 12 | CHECK-NEXT: Call Stack (most recent call first): 13 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (library_type_error) 14 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (check_library_type) 15 | CHECK-NEXT: source/CMakeLists.txt:1 (cxx_library) 16 | CHECK: -- Configuring incomplete, errors occurred! 17 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/HEADER_ONLY-specifies-MODULE_INTERFACE/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET header_only_with_module_interface 3 | LIBRARY_TYPE HEADER_ONLY 4 | MODULE_INTERFACE hello.hpp 5 | ) 6 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/HEADER_ONLY-specifies-MODULE_INTERFACE/test.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t 2 | RUN: %new-project %t/expected_error --author='new_cxx_project Test Suite' --package-manager=none 3 | RUN: cp %S/CMakeLists.txt %t/expected_error/source/CMakeLists.txt 4 | RUN: cmake -S %t/expected_error -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 5 | RUN: FileCheck --input-file=%t/actual_error %s 6 | 7 | CHECK: CMake Error at config/cmake/detail/add_targets.cmake:{{[0-9]+}} (message): 8 | CHECK-NEXT: cxx_library 'header_only_with_module_interface' specifies 9 | CHECK-NEXT: 'MODULE_INTERFACE', which is incompatible with its library type, 10 | CHECK-NEXT: 'HEADER_ONLY' 11 | CHECK-EMPTY: 12 | CHECK-NEXT: did you mean 'HEADER_INTERFACE'? 13 | CHECK-NEXT: Call Stack (most recent call first): 14 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (library_type_error) 15 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (check_library_type) 16 | CHECK-NEXT: source/CMakeLists.txt:1 (cxx_library) 17 | CHECK: -- Configuring incomplete, errors occurred! 18 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/HEADER_ONLY-specifies-SOURCES/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET header_only 3 | LIBRARY_TYPE HEADER_ONLY 4 | SOURCES hello.cpp 5 | ) 6 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/HEADER_ONLY-specifies-SOURCES/test.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t 2 | RUN: %new-project %t/expected_error --author='new_cxx_project Test Suite' --package-manager=none 3 | RUN: cp %S/CMakeLists.txt %t/expected_error/source/CMakeLists.txt 4 | RUN: cmake -S %t/expected_error -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 5 | RUN: FileCheck --input-file=%t/actual_error %s 6 | 7 | CHECK: CMake Error at config/cmake/detail/add_targets.cmake:{{[0-9]+}} (message): 8 | CHECK-NEXT: cxx_library 'header_only' specifies 'SOURCES', which is incompatible with 9 | CHECK-NEXT: its library type, 'HEADER_ONLY' 10 | CHECK-EMPTY: 11 | CHECK-NEXT: did you mean 'HEADER_INTERFACE'? 12 | CHECK-NEXT: Call Stack (most recent call first): 13 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (library_type_error) 14 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (check_library_type) 15 | CHECK-NEXT: source/CMakeLists.txt:1 (cxx_library) 16 | CHECK: -- Configuring incomplete, errors occurred! 17 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/LIBRARY_TYPE-missing/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET no_library_type 3 | SOURCES hello.cpp 4 | ) 5 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/LIBRARY_TYPE-missing/test.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t 2 | RUN: %new-project %t/expected_error --author='new_cxx_project Test Suite' --package-manager=none 3 | RUN: cp %S/CMakeLists.txt %t/expected_error/source/CMakeLists.txt 4 | RUN: cmake -S %t/expected_error -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 5 | RUN: FileCheck --input-file=%t/actual_error %s 6 | 7 | CHECK: CMake Error at config/cmake/detail/add_targets.cmake:{{[0-9]+}} (message): 8 | CHECK-NEXT: cxx_library 'no_library_type' does not specify a LIBRARY_TYPE 9 | CHECK-NEXT: Call Stack (most recent call first): 10 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (check_library_type) 11 | CHECK-NEXT: source/CMakeLists.txt:1 (cxx_library) 12 | CHECK: -- Configuring incomplete, errors occurred! 13 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/LIBRARY_TYPE-unknown/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET bad_library_type 3 | LIBRARY_TYPE object 4 | SOURCES hello.cpp 5 | ) 6 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/LIBRARY_TYPE-unknown/test.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t 2 | RUN: %new-project %t/expected_error --author='new_cxx_project Test Suite' --package-manager=none 3 | RUN: cp %S/CMakeLists.txt %t/expected_error/source/CMakeLists.txt 4 | RUN: cmake -S %t/expected_error -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 5 | RUN: FileCheck --input-file=%t/actual_error %s 6 | 7 | CHECK: CMake Error at config/cmake/detail/add_targets.cmake:{{[0-9]+}} (message): 8 | CHECK-NEXT: cxx_library 'bad_library_type' uses unknown library type 'object' 9 | CHECK-NEXT: Call Stack (most recent call first): 10 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (check_library_type) 11 | CHECK-NEXT: source/CMakeLists.txt:1 (cxx_library) 12 | CHECK: -- Configuring incomplete, errors occurred! 13 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/OBJECT-specifes-LINK_OPTIONS/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET object 3 | LIBRARY_TYPE OBJECT 4 | SOURCES world.hpp 5 | LINK_OPTIONS -s 6 | ) 7 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/OBJECT-specifes-LINK_OPTIONS/test.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t 2 | RUN: %new-project %t/expected_error --author='new_cxx_project Test Suite' --package-manager=none 3 | RUN: cp %S/CMakeLists.txt %t/expected_error/source/CMakeLists.txt 4 | RUN: cmake -S %t/expected_error -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 5 | RUN: FileCheck --input-file=%t/actual_error %s 6 | 7 | CHECK: CMake Error at config/cmake/detail/add_targets.cmake:{{[0-9]+}} (message): 8 | CHECK-NEXT: cxx_library 'object' specifies 'LINK_OPTIONS', which is incompatible with 9 | CHECK-NEXT: its library type, 'OBJECT' 10 | CHECK-NEXT: Call Stack (most recent call first): 11 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (library_type_error) 12 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (check_library_type) 13 | CHECK-NEXT: source/CMakeLists.txt:1 (cxx_library) 14 | CHECK: -- Configuring incomplete, errors occurred! 15 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/OBJECT-specifies-DEPENDS_ON_INTERFACE/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET object 3 | LIBRARY_TYPE OBJECT 4 | SOURCES hello.cpp 5 | DEPENDS_ON_INTERFACE greeter 6 | ) 7 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/OBJECT-specifies-DEPENDS_ON_INTERFACE/test.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t 2 | RUN: %new-project %t/expected_error --author='new_cxx_project Test Suite' --package-manager=none 3 | RUN: cp %S/CMakeLists.txt %t/expected_error/source/CMakeLists.txt 4 | RUN: cmake -S %t/expected_error -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 5 | RUN: FileCheck --input-file=%t/actual_error %s 6 | 7 | CHECK: CMake Error at config/cmake/detail/add_targets.cmake:{{[0-9]+}} (message): 8 | CHECK-NEXT: cxx_library 'object' specifies 'DEPENDS_ON_INTERFACE', which is 9 | CHECK-NEXT: incompatible with its library type, 'OBJECT' 10 | CHECK-EMPTY: 11 | CHECK-NEXT: did you mean 'DEPENDS_ON'? 12 | CHECK-NEXT: Call Stack (most recent call first): 13 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (library_type_error) 14 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (check_library_type) 15 | CHECK-NEXT: source/CMakeLists.txt:1 (cxx_library) 16 | CHECK: -- Configuring incomplete, errors occurred! 17 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/OBJECT-specifies-HEADER_INTERFACE/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET object_with_header_interface 3 | LIBRARY_TYPE OBJECT 4 | HEADER_INTERFACE hello.hpp 5 | SOURCES hello.cpp 6 | ) 7 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/OBJECT-specifies-HEADER_INTERFACE/test.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t 2 | RUN: %new-project %t/expected_error --author='new_cxx_project Test Suite' --package-manager=none 3 | RUN: cp %S/CMakeLists.txt %t/expected_error/source/CMakeLists.txt 4 | RUN: cmake -S %t/expected_error -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 5 | RUN: FileCheck --input-file=%t/actual_error %s 6 | 7 | CHECK: CMake Error at config/cmake/detail/add_targets.cmake:{{[0-9]+}} (message): 8 | CHECK-NEXT: cxx_library 'object_with_header_interface' specifies 'HEADER_INTERFACE', 9 | CHECK-NEXT: which is incompatible with its library type, 'OBJECT' 10 | CHECK-EMPTY: 11 | CHECK-NEXT: did you mean 'HEADERS'? 12 | CHECK-NEXT: Call Stack (most recent call first): 13 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (library_type_error) 14 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (check_library_type) 15 | CHECK-NEXT: source/CMakeLists.txt:1 (cxx_library) 16 | CHECK: -- Configuring incomplete, errors occurred! 17 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/OBJECT-specifies-INSTALL_WITH/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET object_tries_to_install 3 | LIBRARY_TYPE OBJECT 4 | SOURCES hello.hpp 5 | INSTALL_WITH a 6 | ) 7 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/OBJECT-specifies-INSTALL_WITH/test.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t 2 | RUN: %new-project %t/expected_error --author='new_cxx_project Test Suite' --package-manager=none 3 | RUN: cp %S/CMakeLists.txt %t/expected_error/source/CMakeLists.txt 4 | RUN: cmake -S %t/expected_error -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 5 | RUN: FileCheck --input-file=%t/actual_error %s 6 | 7 | CHECK: CMake Error at config/cmake/detail/add_targets.cmake:{{[0-9]+}} (message): 8 | CHECK-NEXT: cxx_library 'object_tries_to_install' specifies 'INSTALL_WITH', which is 9 | CHECK-NEXT: incompatible with its library type, 'OBJECT' 10 | CHECK-NEXT: Call Stack (most recent call first): 11 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (library_type_error) 12 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (check_library_type) 13 | CHECK-NEXT: source/CMakeLists.txt:1 (cxx_library) 14 | CHECK: -- Configuring incomplete, errors occurred! 15 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/OBJECT-specifies-MODULE_INTERFACE/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cxx_library( 2 | TARGET object_with_module_interface 3 | LIBRARY_TYPE OBJECT 4 | MODULE_INTERFACE hello.hpp 5 | ) 6 | -------------------------------------------------------------------------------- /test/diagnostics/library-type-errors/OBJECT-specifies-MODULE_INTERFACE/test.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t 2 | RUN: %new-project %t/expected_error --author='new_cxx_project Test Suite' --package-manager=none 3 | RUN: cp %S/CMakeLists.txt %t/expected_error/source/CMakeLists.txt 4 | RUN: cmake -S %t/expected_error -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 5 | RUN: FileCheck --input-file=%t/actual_error %s 6 | 7 | CHECK: CMake Error at config/cmake/detail/add_targets.cmake:{{[0-9]+}} (message): 8 | CHECK-NEXT: cxx_library 'object_with_module_interface' specifies 'MODULE_INTERFACE', 9 | CHECK-NEXT: which is incompatible with its library type, 'OBJECT' 10 | CHECK-EMPTY: 11 | CHECK-NEXT: did you mean 'SOURCES'? 12 | CHECK-NEXT: Call Stack (most recent call first): 13 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (library_type_error) 14 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (check_library_type) 15 | CHECK-NEXT: source/CMakeLists.txt:1 (cxx_library) 16 | CHECK: -- Configuring incomplete, errors occurred! 17 | -------------------------------------------------------------------------------- /test/diagnostics/no_args.test: -------------------------------------------------------------------------------- 1 | RUN: %new-project >%t 2>&1 || %expect-error 2 | RUN: FileCheck --input-file=%t %s 3 | 4 | CHECK: usage: {{.*/new_cxx_project.py}} 5 | CHECK: [-h] --author AUTHOR [--remote REMOTE] [--package-manager {none,vcpkg}] 6 | CHECK: [--package-manager-remote PACKAGE_MANAGER_REMOTE] 7 | CHECK: path 8 | CHECK: {{.*/new_cxx_project.py}}: error: the following arguments are required: path, --author 9 | -------------------------------------------------------------------------------- /test/diagnostics/preexisting_repo.test: -------------------------------------------------------------------------------- 1 | RUN: %rm preexisting_repo 2 | RUN: %new-project preexisting_repo --author='preexisting_repo.test' --package-manager=none 3 | RUN: %new-project preexisting_repo --author='preexisting_repo.test' --package-manager=none >%t 2>&1 || %expect-error 4 | RUN: FileCheck %s --input-file=%t 5 | 6 | CHECK: error: 'preexisting_repo' already exists, aborting to avoid overwriting its contents... 7 | -------------------------------------------------------------------------------- /test/diagnostics/source-not-set.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t/source_not_set 2 | RUN: %new-project %t/source_not_set --author='new_cxx_project Test Suite' --package-manager=none 3 | 4 | RUN: echo 'cxx_executable(TARGET hello)' > %t/source_not_set/source/CMakeLists.txt 5 | RUN: cmake -S %t/source_not_set -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 6 | RUN: FileCheck --input-file=%t/actual_error %s --check-prefixes=CHECK,CHECK-EXE -Dbuild_rule=cxx_executable 7 | 8 | RUN: echo 'cxx_library(TARGET hello)' > %t/source_not_set/source/CMakeLists.txt 9 | RUN: cmake -S %t/source_not_set -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 10 | RUN: FileCheck --input-file=%t/actual_error %s --check-prefixes=CHECK,CHECK-LIB -Dbuild_rule=cxx_library 11 | 12 | RUN: echo 'cxx_test(TARGET hello)' > %t/source_not_set/source/CMakeLists.txt 13 | RUN: cmake -S %t/source_not_set -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 14 | RUN: FileCheck --input-file=%t/actual_error %s --check-prefixes=CHECK,CHECK-EXE -Dbuild_rule=cxx_test 15 | 16 | CHECK: CMake Error at config/cmake/detail/add_targets.cmake:{{[0-9]+}} (message): 17 | CHECK-EXE-NEXT: build rule '[[build_rule]]' requires 'SOURCES ...' as a parameter 18 | CHECK-LIB-NEXT: build rule 'cxx_library' requires at least one of 'SOURCES ...', 19 | CHECK-LIB-NEXT: 'HEADER_INTERFACE ...', or 'MODULE_INTERFACE ...' as a 20 | CHECK-LIB-NEXT: parameter 21 | CHECK-NEXT: Call Stack (most recent call first): 22 | CHECK-EXE-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (cxx_executable_impl) 23 | CHECK-NEXT: source/CMakeLists.txt:1 ([[build_rule]]) 24 | CHECK-EMPTY: 25 | CHECK-EMPTY: 26 | CHECK-NEXT: -- Configuring incomplete, errors occurred! 27 | -------------------------------------------------------------------------------- /test/diagnostics/target-not-set.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t/target_not_set 2 | RUN: %new-project %t/target_not_set --author='new_cxx_project Test Suite' --package-manager=none 3 | 4 | RUN: echo 'cxx_executable(SOURCES hello.cpp)' > %t/target_not_set/source/CMakeLists.txt 5 | RUN: cmake -S %t/target_not_set -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 6 | RUN: FileCheck --input-file=%t/actual_error %s --check-prefixes=CHECK,CHECK-EXE -Dbuild_rule=cxx_executable 7 | 8 | RUN: echo 'cxx_library(SOURCES hello.cpp)' > %t/target_not_set/source/CMakeLists.txt 9 | RUN: cmake -S %t/target_not_set -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 10 | RUN: FileCheck --input-file=%t/actual_error %s -Dbuild_rule=cxx_library 11 | 12 | RUN: echo 'cxx_test(SOURCES hello.cpp)' > %t/target_not_set/source/CMakeLists.txt 13 | RUN: cmake -S %t/target_not_set -B %t/build -GNinja -DCMAKE_BUILD_TYPE=Debug >%t/actual_error 2>&1 || %expect-error 14 | RUN: FileCheck --input-file=%t/actual_error %s --check-prefixes=CHECK,CHECK-EXE -Dbuild_rule=cxx_test 15 | 16 | CHECK: CMake Error at config/cmake/detail/add_targets.cmake:{{[0-9]+}} (message): 17 | CHECK-NEXT: build rule '[[build_rule]]' requires 'TARGET ' as a parameter 18 | CHECK-NEXT: Call Stack (most recent call first): 19 | CHECK-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (ADD_TARGETS_EXTRACT_ARGS) 20 | CHECK-EXE-NEXT: config/cmake/detail/add_targets.cmake:{{[0-9]+}} (cxx_executable_impl) 21 | CHECK-NEXT: source/CMakeLists.txt:1 ([[build_rule]]) 22 | CHECK-EMPTY: 23 | CHECK-EMPTY: 24 | CHECK-NEXT: -- Configuring incomplete, errors occurred! 25 | -------------------------------------------------------------------------------- /test/files/.github/ISSUE_TEMPLATE/bug_report.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | description: Create a report to help us improve 4 | title: 'bug report' 5 | labels: ['bug'] 6 | assignees: [] 7 | body: 8 | - type: markdown 9 | attributes: 10 | value: | 11 | Thank you for taking the time out to file a bug report! To help us triage this as quickly as 12 | possible, please familiarise yourself with our [bug reporting documentation](../../docs/user/reporting_bugs.rst). 13 | 14 | ## Bug details 15 | 16 | - type: textarea 17 | id: description 18 | attributes: 19 | label: Bug description 20 | description: 21 | Please provide a clear description of your issue. If you got a compile-time error or warning, 22 | or a runtime error, please include it in your description. 23 | validations: 24 | required: true 25 | 26 | - type: textarea 27 | id: expected 28 | attributes: 29 | label: Expected result 30 | description: What do you expect to happen? 31 | validations: 32 | required: true 33 | 34 | - type: textarea 35 | id: repro 36 | attributes: 37 | label: Minimal reproduction 38 | description: Please provide the smallest amount of code possible to reproduce your issue. 39 | validations: 40 | required: true 41 | 42 | - type: markdown 43 | attributes: 44 | value: '## Toolchain information' 45 | 46 | - type: dropdown 47 | id: compiler 48 | attributes: 49 | label: Which compiler are you experiencing this on? 50 | multiple: false 51 | options: 52 | - Clang 53 | - GCC 54 | - MSVC 55 | - Other 56 | validations: 57 | required: true 58 | 59 | - type: textarea 60 | id: compiler_version 61 | attributes: 62 | label: What version of the compiler are you using? 63 | placeholder: | 64 | $ clang --version 65 | clang version 16.0.0 66 | Target: x86_64-unknown-linux-gnu 67 | Thread model: posix 68 | InstalledDir: /usr/bin 69 | validations: 70 | required: true 71 | 72 | - type: input 73 | id: build_flags 74 | attributes: 75 | label: Build options 76 | description: 77 | Please paste the complete compiler and linker options. You can get this by passing `-###` to 78 | the compiler alongside the rest of your options. 79 | validations: 80 | required: true 81 | 82 | - type: input 83 | id: os 84 | attributes: 85 | label: Operating system 86 | description: Which operating system are you using? 87 | placeholder: Ubuntu 20.04 88 | validations: 89 | required: true 90 | -------------------------------------------------------------------------------- /test/files/.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | -------------------------------------------------------------------------------- /test/files/.github/ISSUE_TEMPLATE/feature_request.yml: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | description: Suggest an idea for the project 4 | title: 'feature request' 5 | labels: ['enhancement'] 6 | assignees: [] 7 | body: 8 | - type: markdown 9 | attributes: 10 | value: | 11 | ## Feature request 12 | 13 | - type: textarea 14 | id: description 15 | attributes: 16 | label: Is your feature request related to a problem? Please describe 17 | description: 18 | A clear and concise description of the problem (e.g. I'm always frustrated when...) 19 | validations: 20 | required: true 21 | 22 | - type: textarea 23 | id: proposed_solution 24 | attributes: 25 | label: Describe the solution you'd like 26 | description: A clear and concise description of what you would like to happen. 27 | validations: 28 | required: true 29 | 30 | - type: textarea 31 | id: alternatives 32 | attributes: 33 | label: Describe any alternatives that you've considered 34 | validations: 35 | required: true 36 | -------------------------------------------------------------------------------- /test/files/.github/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 6 | 7 | 8 | Issues #123, #456, #789 9 | Fixes #1011, #1213 10 | 11 | ## Tests 12 | 13 | 14 | 15 | ## Benchmarks 16 | 17 | 18 | 19 | ## Other checks 20 | 21 | - [ ] Adds or updates relevant unit tests 22 | - [ ] Relevant fuzz tests were added 23 | - [ ] Documentation has been updated 24 | -------------------------------------------------------------------------------- /test/files/.github/workflows/basic_ci.yml: -------------------------------------------------------------------------------- 1 | name: Basic CI 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | build: 7 | name: ${{ matrix.os }}-${{ matrix.build_type }}-${{ matrix.toolchain }} 8 | runs-on: ${{ matrix.os }} 9 | strategy: 10 | fail-fast: false 11 | matrix: 12 | os: [ubuntu-24.04] 13 | build_type: 14 | - Debug 15 | - Release 16 | - RelWithDebInfo 17 | toolchain: 18 | - x86_64-unknown-linux-llvm.cmake 19 | - x86_64-unknown-linux-gnu.cmake 20 | steps: 21 | - name: Install tools 22 | id: install-tools 23 | run: | 24 | sudo apt-get update 25 | sudo apt-get full-upgrade -y 26 | sudo apt-get autoremove -y 27 | sudo apt-get remove -y clang-* llvm-* 28 | sudo bash -c "$(wget -O - https://apt.llvm.org/llvm.sh)" 29 | sudo apt-get install -y gcc g++ mold cmake 30 | 31 | - name: Checkout 32 | uses: actions/checkout@v4 33 | with: 34 | repository: copied_okay/yeah.git 35 | ref: main 36 | submodules: recursive 37 | 38 | - name: Format changes 39 | id: clang-format 40 | run: git clang-format 41 | --style=file 42 | --extensions c,cc,cpp,cxx,h,hh,hpp,hxx 43 | --diff origin/main HEAD 44 | 45 | - name: Configure project 46 | id: configure-project 47 | run: 48 | cmake -S. -Bbuild -GNinja 49 | -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} 50 | -DCMAKE_TOOLCHAIN_FILE=${{ matrix.toolchain }} 51 | 52 | - name: Bulid project 53 | id: build-project 54 | run: ninja -C build -v 55 | 56 | - name: Run tests 57 | id: run-tests 58 | run: ctest -j$(nproc) --output-on-failure --test-dir build 59 | -------------------------------------------------------------------------------- /test/files/copied-okay.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t/expected 2 | RUN: mkdir -p %t 3 | RUN: cp -r %S/expected %t/expected 4 | 5 | RUN: %rm %t/copied_okay 6 | RUN: %new-project %t/copied_okay --author='copied_okay' 7 | RUN: pushd %t/copied_okay 8 | RUN: rm -r .git 9 | RUN: popd 10 | RUN: diff -r --unified %S/expected %t/copied_okay 11 | 12 | RUN: %rm %t/copied_okay 13 | RUN: %new-project %t/copied_okay --author='copied_okay' --package-manager=none 14 | RUN: pushd %t/copied_okay 15 | RUN: rm -r .git 16 | RUN: popd 17 | RUN: diff -r --unified %S/expected %t/copied_okay 18 | 19 | RUN: %rm %t/copied_okay %t/expected 20 | RUN: cp -r %S/expected %t/expected 21 | RUN: cp -r %S/vcpkg-changes/* %S/vcpkg-changes/.gitmodules %t/expected/. 22 | RUN: %new-project %t/copied_okay --author='copied_okay' --package-manager=vcpkg 23 | RUN: pushd %t/copied_okay 24 | RUN: rm -r .git vcpkg 25 | RUN: popd 26 | RUN: diff -r --unified %t/expected %t/copied_okay 27 | 28 | RUN: %rm %t/expected 29 | RUN: cp -r %S/expected %t/expected 30 | RUN: cp -r %S/.github %t/expected/.github 31 | 32 | RUN: %rm %t/copied_okay 33 | RUN: %new-project %t/copied_okay --author='copied_okay' --remote=https://github.com/copied_okay/yeah.git 34 | RUN: pushd %t/copied_okay 35 | RUN: rm -r .git 36 | RUN: popd 37 | RUN: diff -r --unified %t/expected %t/copied_okay 38 | 39 | RUN: %rm %t/copied_okay 40 | RUN: %new-project %t/copied_okay --author='copied_okay' --remote=git://github.com/copied_okay/yeah.git 41 | RUN: pushd %t/copied_okay 42 | RUN: rm -r .git 43 | RUN: popd 44 | RUN: diff -r --unified %t/expected %t/copied_okay 45 | 46 | RUN: %rm %t/copied_okay 47 | RUN: %new-project %t/copied_okay --author='copied_okay' --remote=git@github.com:copied_okay/yeah.git 48 | RUN: pushd %t/copied_okay 49 | RUN: rm -r .git 50 | RUN: popd 51 | RUN: diff -r --unified %t/expected %t/copied_okay 52 | -------------------------------------------------------------------------------- /test/files/expected/.clang-tidy: -------------------------------------------------------------------------------- 1 | Checks: 'abseil-*, 2 | boost-*, 3 | bugprone-*, 4 | -bugprone-exception-escape, 5 | cert-*, 6 | -cert-dcl21-cpp, 7 | -cert-msc32-c, 8 | -cert-msc51-cpp, 9 | clang-analyzer-*, 10 | clang-diagnostic-*, 11 | cppcoreguildelines-*, 12 | google-*, 13 | -google-runtime-int, 14 | -google-runtime-references, 15 | misc-*, 16 | -misc-no-recursion, 17 | -misc-non-private-member-variables-in-classes, 18 | modernize-*, 19 | -modernize-use-trailing-return-type, 20 | performance-*, 21 | portability-*, 22 | -portability-simd-intrinsics, 23 | readability-*, 24 | -readability-function-size, 25 | -readability-function-cognitive-complexity, 26 | -readability-named-parameter, 27 | -readability-qualified-auto, 28 | -readability-identifier-length' 29 | WarningsAsErrors: '*' 30 | 31 | CheckOptions: 32 | - key: bugprone-dangling-handle.HandleClasses 33 | value: 'std::basic_string_view;std::span;std::ranges::subrange;std::ranges::all_view;std::ranges::common_view;std::ranges::keys_view;std::ranges::values_view' 34 | - key: bugprone-exception-escape.FunctionsThatShouldNotThrow 35 | value: 'iter_move,iter_swap' 36 | - key: readability-simplify-boolean-expr.ChainedConditionalReturn 37 | value: '1' 38 | - key: readability-simplify-boolean-expr.ChainedConditionalAssignment 39 | value: '1' 40 | - key: readability-simplify-subscript-expr.Types 41 | value: 'std::array;std::basic_string;std::basic_string_view;std::span;std::vector' 42 | 43 | # For the full list, see https://clang.llvm.org/extra/clang-tidy/checks/readability/identifier-naming.html. 44 | - key: readability-identifier-naming.ClassCase 45 | value: "lower_case" 46 | - key: readability-identifier-naming.ClassMemberSuffix 47 | value: "_" 48 | - key: readability-identifier-naming.ConceptCase 49 | value: "lower_case" 50 | - key: readability-identifier-naming.ConstantCase 51 | value: "lower_case" 52 | - key: readability-identifier-naming.ConstantMemberCase 53 | value: "lower_case" 54 | - key: readability-identifier-naming.ConstexprVariableCase 55 | value: "lower_case" 56 | - key: readability-identifier-naming.EnumCase 57 | value: "lower_case" 58 | - key: readability-identifier-naming.EnumConstantCase 59 | value: "lower_case" 60 | - key: readability-identifier-naming.FunctionCase 61 | value: "lower_case" 62 | - key: readability-identifier-naming.GlobalCase 63 | value: "lower_case" 64 | - key: readability-identifier-naming.MacroDefinitionCase 65 | value: "UPPER_CASE" 66 | - key: readability-identifier-naming.MacroDefinitionPrefix 67 | value: "COPIED_OKAY_" 68 | - key: readability-identifier-naming.MemberCase 69 | value: "lower_case" 70 | - key: readability-identifier-naming.MethodCase 71 | value: "lower_case" 72 | - key: readability-identifier-naming.NamespaceCase 73 | value: "lower_case" 74 | - key: readability-identifier-naming.ParameterCase 75 | value: "lower_case" 76 | - key: readability-identifier-naming.PrivateMemberSuffix 77 | value: "_" 78 | - key: readability-identifier-naming.PrivateMethodCase 79 | value: "lower_case" 80 | - key: readability-identifier-naming.PublicMemberCase 81 | value: "lower_case" 82 | - key: readability-identifier-naming.PublicMethodCase 83 | value: "lower_case" 84 | - key: readability-identifier-naming.TypeAliasCase 85 | value: "lower_case" 86 | - key: readability-identifier-naming.VariableCase 87 | value: "lower_case" 88 | -------------------------------------------------------------------------------- /test/files/expected/.clangd: -------------------------------------------------------------------------------- 1 | CompileFlags: 2 | Remove: 3 | - -fmodules 4 | CompilationDatabase: ./build 5 | Diagnostics: 6 | MissingIncludes: Strict 7 | Index: 8 | Background: Build 9 | StandardLibrary: Yes 10 | -------------------------------------------------------------------------------- /test/files/expected/.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 | 34 | # Directories 35 | build*/* 36 | vcpkg/* 37 | docs/build 38 | .vscode/ipch/* 39 | .clangd/* 40 | .cache/* 41 | -------------------------------------------------------------------------------- /test/files/expected/.vscode/cmake-kits.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "name": "LLVM Toolchain (x86_64)", 4 | "toolchainFile": "${workspaceFolder}/config/cmake/toolchains/x86_64-unknown-linux-llvm.cmake", 5 | "preferredGenerator": { 6 | "name": "Ninja" 7 | }, 8 | "cmakeSettings": {} 9 | }, 10 | { 11 | "name": "GNU Toolchain (x86_64)", 12 | "toolchainFile": "${workspaceFolder}/config/cmake/toolchains/x86_64-unknown-linux-gnu.cmake", 13 | "preferredGenerator": { 14 | "name": "Ninja" 15 | }, 16 | "cmakeSettings": {} 17 | } 18 | ] 19 | -------------------------------------------------------------------------------- /test/files/expected/.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | // Use IntelliSense to learn about possible attributes. 3 | // Hover to view descriptions of existing attributes. 4 | // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 5 | "version": "0.2.0", 6 | "configurations": [ 7 | { 8 | "type": "lldb", 9 | "request": "launch", 10 | "name": "Launch LLDB", 11 | "program": "${command:cmake.launchTargetPath}", 12 | "args": [], 13 | "cwd": "${workspaceFolder}", 14 | "env": { 15 | "ASAN_OPTIONS": "detect_leaks=0" 16 | } 17 | }, 18 | { 19 | "type": "gdb", 20 | "request": "launch", 21 | "name": "Launch GDB", 22 | "target": "${command:cmake.launchTargetPath}", 23 | "arguments": "", 24 | "cwd": "${workspaceFolder}", 25 | "env": { 26 | "ASAN_OPTIONS": "detect_leaks=0" 27 | } 28 | } 29 | ] 30 | } 31 | -------------------------------------------------------------------------------- /test/files/expected/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Christopher Di Bella 2 | # Licensed under the Apache License v2.0 with LLVM Exceptions. 3 | # See /LICENCE for licence information. 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | cmake_minimum_required(VERSION 3.28 FATAL_ERROR) 6 | 7 | project("copied_okay" C CXX) 8 | 9 | set(CMAKE_CXX_STANDARD 23) 10 | set(CMAKE_CXX_EXTENSIONS Yes) 11 | set(CMAKE_CXX_STANDARD_REQUIRED Yes) 12 | set(CMAKE_EXPORT_COMPILE_COMMANDS Yes) 13 | 14 | message(STATUS "Building with C++${CMAKE_CXX_STANDARD} (extensions enabled)") 15 | 16 | include("${PROJECT_SOURCE_DIR}/config/cmake/project_options.cmake") 17 | include("${PROJECT_SOURCE_DIR}/config/cmake/detail/add_targets.cmake") 18 | include("${PROJECT_SOURCE_DIR}/config/cmake/import_packages.cmake") 19 | enable_testing() 20 | include(CTest) 21 | 22 | add_subdirectory(source) 23 | add_subdirectory(docs) 24 | 25 | # This file is deliberately included after everything else, since installation targets depend on at 26 | # least one target requesting to be installed first. 27 | include("${PROJECT_SOURCE_DIR}/config/cmake/install_targets.cmake") 28 | -------------------------------------------------------------------------------- /test/files/expected/README.md: -------------------------------------------------------------------------------- 1 | 7 | # copied_okay 8 | 9 | ```{toctree} 10 | :maxdepth: 1 11 | 12 | LICENCE 13 | CODE_OF_CONDUCT.md 14 | source/project/cmake 15 | source/project/vcpkg 16 | ``` 17 | 18 | ## Indices and tables 19 | 20 | * {ref}`genindex` 21 | * {ref}`search` 22 | -------------------------------------------------------------------------------- /test/files/expected/config/cmake/detail/default_options.cmake: -------------------------------------------------------------------------------- 1 | # Copyright Christopher Di Bella 2 | # Licensed under the Apache License v2.0 with LLVM Exceptions. 3 | # See /LICENCE for licence information. 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | 6 | # This file was autogenerated by new_cxx_project.py. Do not modify this file, as add_targets.cmake 7 | # heavily depends on it. 8 | 9 | function(validate_option value option valid_values) 10 | list(FIND "${valid_values}" "${value}" found) 11 | 12 | if(found EQUAL -1) 13 | message(FATAL_ERROR "invalid value '${value}' for ${option} (valid values are [${${valid_values}}])") 14 | endif() 15 | endfunction() 16 | 17 | if (NOT CMAKE_CONFIGURATION_TYPES) 18 | set(CMAKE_CONFIGURATION_TYPES Debug RelWithDebInfo MinSizeRel Release) 19 | endif() 20 | 21 | if(CMAKE_BUILD_TYPE) 22 | list(FIND CMAKE_CONFIGURATION_TYPES "${CMAKE_BUILD_TYPE}" valid_build_type) 23 | if(valid_build_type EQUAL -1) 24 | message(FATAL_ERROR "${CMAKE_BUILD_TYPE} is not a valid value") 25 | endif() 26 | else() 27 | message(FATAL_ERROR "CMAKE_BUILD_TYPE must be set") 28 | endif() 29 | message(STATUS "Build type: ${CMAKE_BUILD_TYPE}") 30 | 31 | set( 32 | # Variable 33 | COPIED_OKAY_BUILD_DOCS 34 | # Default value 35 | Yes 36 | CACHE STRING 37 | "Toggles whether the documentation is built. Requires both Sphinx and MyST to be installed first." 38 | ) 39 | -------------------------------------------------------------------------------- /test/files/expected/config/cmake/import_packages.cmake: -------------------------------------------------------------------------------- 1 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/packages") 2 | find_package(Sphinx REQUIRED) 3 | list(POP_BACK CMAKE_MODULE_PATH CMAKE_MODULE_PATH) 4 | -------------------------------------------------------------------------------- /test/files/expected/config/cmake/install_targets.cmake: -------------------------------------------------------------------------------- 1 | include(CMakePackageConfigHelpers) 2 | 3 | # Here's an example installation target that you can potentially use as-is. We leave it commented 4 | # out until you have something to install; CMake produces a fatal error when the installation target 5 | # doesn't have anything to install. 6 | # 7 | # install( 8 | # EXPORT copied_okay-install 9 | # FILE copied_okay-config.cmake 10 | # NAMESPACE copied_okay:: 11 | # DESTINATION lib/cmake/copied_okay 12 | # ) 13 | 14 | message( 15 | AUTHOR_WARNING "no installation targets have been declared (please modify ${CMAKE_CURRENT_SOURCE_DIR}/config/cmake/install_targets.cmake to rectify this)" 16 | ) 17 | -------------------------------------------------------------------------------- /test/files/expected/config/cmake/packages/FindSphinx.cmake: -------------------------------------------------------------------------------- 1 | # Copyright VORtech 2 | # Copyright Christopher Di Bella 3 | # Licensed under the Apache License v2.0 with LLVM Exceptions. 4 | # See /LICENCE for licence information. 5 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 6 | include(FindPackageHandleStandardArgs) 7 | include(GNUInstallDirs) 8 | 9 | if(NOT COPIED_OKAY_BUILD_DOCS) 10 | return() 11 | endif() 12 | 13 | if(NOT Python3_ROOT_DIR) 14 | set(Python3_ROOT_DIR "$ENV{HOME}/.config/new_cxx_project/") 15 | endif() 16 | find_package(Python3 COMPONENTS Interpreter REQUIRED) 17 | 18 | if(Python3_FOUND) 19 | get_filename_component(_Python3_DIR "${Python3_EXECUTABLE}" DIRECTORY) 20 | set( 21 | _Python3_PATHS 22 | "${_Python3_DIR}/.." 23 | "${_Python3_DIR}/../bin" 24 | "${_Python3_DIR}/../Scripts" 25 | ) 26 | endif() 27 | 28 | find_program( 29 | SPHINX_EXECUTABLE 30 | NAMES sphinx-build sphinx-build.exe 31 | HINTS ${_Python3_PATHS} 32 | ) 33 | mark_as_advanced(SPHINX_EXECUTABLE) 34 | 35 | find_package_handle_standard_args(Sphinx DEFAULT_MSG SPHINX_EXECUTABLE) 36 | 37 | if(NOT Sphinx_FOUND) 38 | return() 39 | endif() 40 | 41 | set(_SPHINX_SCRIPT_DIR "${CMAKE_CURRENT_LIST_DIR}") 42 | 43 | if(NOT EXISTS "${PROJECT_SOURCE_DIR}/docs/_static") 44 | file(MAKE_DIRECTORY "${PROJECT_SOURCE_DIR}/docs/_static") 45 | endif() 46 | 47 | function(sphinx_documentation TARGET_NAME) 48 | cmake_parse_arguments( 49 | sphinx_args 50 | "" 51 | "TARGET;CONF_FILE" 52 | "SOURCES;TEMPLATES;STATIC" 53 | ${ARGN} 54 | ) 55 | 56 | set(SPHINX_DEPENDS "${sphinx_args_CONF_FILE}" "${sphinx_args_SOURCES}" "${sphinx_args_TEMPLATES}" "${sphinx_args_STATIC}") 57 | 58 | add_custom_command( 59 | OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/html.stamp" 60 | COMMAND "${SPHINX_EXECUTABLE}" -q -j auto -b html "${CMAKE_CURRENT_LIST_DIR}" "${CMAKE_CURRENT_BINARY_DIR}" 61 | COMMAND "${CMAKE_COMMAND}" -E touch "${CMAKE_CURRENT_BINARY_DIR}/html.stamp" 62 | DEPENDS "${SPHINX_DEPENDS}" 63 | ) 64 | set(TARGET_DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/html.stamp") 65 | 66 | add_custom_target( 67 | ${TARGET_NAME} ALL 68 | DEPENDS ${TARGET_DEPENDS} 69 | ) 70 | 71 | install( 72 | DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/" 73 | TYPE DOC 74 | PATTERN ".buildinfo" EXCLUDE 75 | PATTERN ".doctrees" EXCLUDE 76 | PATTERN "_sources" EXCLUDE 77 | PATTERN "objects.inv" EXCLUDE 78 | PATTERN "CMakeFiles" EXCLUDE 79 | PATTERN "html.stamp" EXCLUDE 80 | REGEX ".*[.]cmake$" EXCLUDE 81 | ) 82 | endfunction() 83 | -------------------------------------------------------------------------------- /test/files/expected/config/cmake/project_options.cmake: -------------------------------------------------------------------------------- 1 | include("${PROJECT_SOURCE_DIR}/config/cmake/detail/default_options.cmake") 2 | 3 | # Add your project options here. 4 | -------------------------------------------------------------------------------- /test/files/expected/config/cmake/toolchains/x86_64-unknown-linux-gnu.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR x86_64) 3 | 4 | set(CMAKE_C_COMPILER "/usr/bin/gcc") 5 | set(CMAKE_C_COMPILER_AR "/usr/bin/ar") 6 | set(CMAKE_C_COMPILER_RANLIB "/usr/bin/ranlib") 7 | set(CMAKE_C_COMPILER_TARGET x86_64-unknown-linux-gnu) 8 | 9 | set(CMAKE_CXX_COMPILER "/usr/bin/g++") 10 | set(CMAKE_CXX_COMPILER_AR "/usr/bin/ar") 11 | set(CMAKE_CXX_COMPILER_RANLIB "/usr/bin/ranlib") 12 | set(CMAKE_CXX_COMPILER_TARGET x86_64-unknown-linux-gnu) 13 | 14 | set(CMAKE_RC_COMPILER "/usr/bin/rc") 15 | set(CMAKE_RC_COMPILER_AR "/usr/bin/ar") 16 | set(CMAKE_RC_COMPILER_RANLIB "/usr/bin/ranlib") 17 | 18 | set(CMAKE_LINKER_TYPE GOLD) 19 | 20 | string( 21 | JOIN " " CMAKE_CXX_FLAGS_INIT 22 | -fdiagnostics-color=always 23 | -fstack-protector-strong 24 | -fvisibility=hidden 25 | -Werror 26 | -pedantic 27 | -Wall 28 | -Wattributes 29 | -Wcast-align 30 | -Wconversion 31 | -Wdouble-promotion 32 | -Wextra 33 | -Wformat=2 34 | -Wnon-virtual-dtor 35 | -Wnull-dereference 36 | -Wodr 37 | -Wold-style-cast 38 | -Woverloaded-virtual 39 | -Wshadow 40 | -Wsign-conversion 41 | -Wsign-promo 42 | -Wunused 43 | -Wno-ignored-attributes 44 | -Wno-unused-command-line-argument 45 | -D_GLIBCXX_ASSERTIONS 46 | ) 47 | string( 48 | JOIN " " CMAKE_EXE_LINKER_FLAGS_INIT 49 | ) 50 | 51 | string( 52 | JOIN " " CMAKE_CXX_FLAGS_DEBUG_INIT 53 | -fsanitize=address 54 | ) 55 | string( 56 | JOIN " " CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT 57 | -fsanitize=address 58 | ) 59 | 60 | string( 61 | JOIN " " CMAKE_CXX_FLAGS_RELEASE_INIT 62 | -flto=auto 63 | ) 64 | string( 65 | JOIN " " CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT 66 | -flto=auto 67 | ) 68 | 69 | string( 70 | JOIN " " CMAKE_CXX_FLAGS_MINSIZEREL_INIT 71 | -flto=auto 72 | ) 73 | string( 74 | JOIN " " CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT 75 | -flto=auto 76 | ) 77 | 78 | string( 79 | JOIN " " CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT 80 | -fsanitize=address 81 | ) 82 | string( 83 | JOIN " " CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT 84 | -fsanitize=address 85 | ) 86 | -------------------------------------------------------------------------------- /test/files/expected/config/cmake/toolchains/x86_64-unknown-linux-llvm.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR x86_64) 3 | 4 | set(CMAKE_C_COMPILER "/usr/bin/clang") 5 | set(CMAKE_C_COMPILER_AR "/usr/bin/llvm-ar") 6 | set(CMAKE_C_COMPILER_RANLIB "/usr/bin/llvm-ranlib") 7 | set(CMAKE_C_COMPILER_TARGET x86_64-unknown-linux-gnu) 8 | 9 | set(CMAKE_CXX_COMPILER "/usr/bin/clang++") 10 | set(CMAKE_CXX_COMPILER_AR "/usr/bin/llvm-ar") 11 | set(CMAKE_CXX_COMPILER_RANLIB "/usr/bin/llvm-ranlib") 12 | set(CMAKE_CXX_COMPILER_TARGET x86_64-unknown-linux-gnu) 13 | 14 | set(CMAKE_RC_COMPILER "/usr/bin/llvm-rc") 15 | set(CMAKE_RC_COMPILER_AR "/usr/bin/llvm-ar") 16 | set(CMAKE_RC_COMPILER_RANLIB "/usr/bin/llvm-ranlib") 17 | 18 | set(CMAKE_LINKER_TYPE LLD) 19 | 20 | string( 21 | JOIN " " CMAKE_CXX_FLAGS_INIT 22 | -fdiagnostics-color=always 23 | -fstack-protector-strong 24 | -fvisibility=hidden 25 | -Werror 26 | -pedantic 27 | -Wall 28 | -Wattributes 29 | -Wcast-align 30 | -Wconversion 31 | -Wdouble-promotion 32 | -Wextra 33 | -Wformat=2 34 | -Wnon-virtual-dtor 35 | -Wnull-dereference 36 | -Wodr 37 | -Wold-style-cast 38 | -Woverloaded-virtual 39 | -Wshadow 40 | -Wsign-conversion 41 | -Wsign-promo 42 | -Wunused 43 | -Wno-ignored-attributes 44 | -Wno-unused-command-line-argument 45 | -stdlib=libc++ 46 | -D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_FAST 47 | ) 48 | string( 49 | JOIN " " CMAKE_EXE_LINKER_FLAGS_INIT 50 | -rtlib=compiler-rt 51 | -unwindlib=libunwind 52 | ) 53 | 54 | string( 55 | JOIN " " CMAKE_CXX_FLAGS_DEBUG_INIT 56 | -fsanitize=address,undefined -fno-sanitize-recover=all 57 | ) 58 | string( 59 | JOIN " " CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT 60 | -fsanitize=address,undefined -fno-sanitize-recover=all 61 | ) 62 | 63 | string( 64 | JOIN " " CMAKE_CXX_FLAGS_RELEASE_INIT 65 | -flto=thin 66 | -fsanitize=undefined -fno-sanitize-recover=all -fsanitize-minimal-runtime 67 | ) 68 | string( 69 | JOIN " " CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT 70 | -flto=thin 71 | -fsanitize=undefined -fno-sanitize-recover=all -fsanitize-minimal-runtime 72 | ) 73 | 74 | string( 75 | JOIN " " CMAKE_CXX_FLAGS_MINSIZEREL_INIT 76 | -flto=thin 77 | -fsanitize=undefined -fno-sanitize-recover=all -fsanitize-minimal-runtime 78 | ) 79 | string( 80 | JOIN " " CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT 81 | -flto=thin 82 | -fsanitize=undefined -fno-sanitize-recover=all -fsanitize-minimal-runtime 83 | ) 84 | 85 | string( 86 | JOIN " " CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT 87 | -fsanitize=address,undefined -fno-sanitize-recover=all 88 | ) 89 | string( 90 | JOIN " " CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT 91 | -fsanitize=address,undefined -fno-sanitize-recover=all 92 | ) 93 | -------------------------------------------------------------------------------- /test/files/expected/docs/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(NOT COPIED_OKAY_BUILD_DOCS) 2 | return() 3 | endif() 4 | 5 | sphinx_documentation( 6 | TARGET docs 7 | CONF_FILE "conf.py" 8 | SOURCES 9 | "index.md" 10 | "LICENCE.md" 11 | "CODE_OF_CONDUCT.md" 12 | source/project/cmake.rst 13 | source/project/vcpkg.rst 14 | TEMPLATES 15 | "_templates/layout.html" 16 | ) 17 | -------------------------------------------------------------------------------- /test/files/expected/docs/CODE_OF_CONDUCT.md: -------------------------------------------------------------------------------- 1 | ../CODE_OF_CONDUCT.md -------------------------------------------------------------------------------- /test/files/expected/docs/LICENCE.md: -------------------------------------------------------------------------------- 1 | ../LICENCE -------------------------------------------------------------------------------- /test/files/expected/docs/_templates/layout.html: -------------------------------------------------------------------------------- 1 | {% extends '!layout.html' %} 2 | 3 | {% block footer %} 4 | 5 |

This work is licensed under CC BY-SA 4.0

6 |
7 | {% endblock %} 8 | -------------------------------------------------------------------------------- /test/files/expected/docs/conf.py: -------------------------------------------------------------------------------- 1 | # Configuration file for the Sphinx documentation builder. 2 | # 3 | # For the full list of built-in configuration values, see the documentation: 4 | # https://www.sphinx-doc.org/en/master/usage/configuration.html 5 | 6 | # -- Project information ----------------------------------------------------- 7 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#project-information 8 | 9 | project = 'copied_okay' 10 | author = 'copied_okay' 11 | 12 | # -- General configuration --------------------------------------------------- 13 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#general-configuration 14 | 15 | extensions = [ 16 | 'myst_parser', 17 | 'sphinx.ext.autosectionlabel', 18 | 'sphinx.ext.extlinks', 19 | 'sphinx.ext.mathjax', 20 | 'sphinx.ext.todo', 21 | 'sphinx.ext.viewcode', 22 | ] 23 | 24 | templates_path = ['_templates'] 25 | exclude_patterns = [] 26 | 27 | # -- Options for HTML output ------------------------------------------------- 28 | # https://www.sphinx-doc.org/en/master/usage/configuration.html#options-for-html-output 29 | 30 | html_theme = 'pyramid' 31 | # html_theme_options = { 32 | # 'repository_url': '', 33 | # 'use_repository_button': True, 34 | # } 35 | html_static_path = ['_static'] 36 | html_show_copyright = False 37 | 38 | myst_enable_extensions = [ 39 | 'dollarmath', 40 | 'amsmath', 41 | 'deflist', 42 | 'fieldlist', 43 | 'html_admonition', 44 | 'html_image', 45 | 'colon_fence', 46 | 'smartquotes', 47 | 'replacements', 48 | 'strikethrough', 49 | 'substitution', 50 | 'tasklist', 51 | 'attrs_inline', 52 | 'attrs_block', 53 | ] 54 | -------------------------------------------------------------------------------- /test/files/expected/docs/index.md: -------------------------------------------------------------------------------- 1 | ../README.md -------------------------------------------------------------------------------- /test/files/expected/docs/requirements.in: -------------------------------------------------------------------------------- 1 | sphinx 2 | myst-parser 3 | psutil 4 | -------------------------------------------------------------------------------- /test/files/expected/docs/requirements.txt: -------------------------------------------------------------------------------- 1 | # 2 | # This file is autogenerated by pip-compile with Python 3.12 3 | # by the following command: 4 | # 5 | # pip-compile requirements.in 6 | # 7 | alabaster==0.7.16 8 | # via sphinx 9 | babel==2.15.0 10 | # via sphinx 11 | certifi==2024.7.4 12 | # via requests 13 | charset-normalizer==3.3.2 14 | # via requests 15 | docutils==0.21.2 16 | # via 17 | # myst-parser 18 | # sphinx 19 | idna==3.7 20 | # via requests 21 | imagesize==1.4.1 22 | # via sphinx 23 | jinja2==3.1.4 24 | # via 25 | # myst-parser 26 | # sphinx 27 | markdown-it-py==3.0.0 28 | # via 29 | # mdit-py-plugins 30 | # myst-parser 31 | markupsafe==2.1.5 32 | # via jinja2 33 | mdit-py-plugins==0.4.1 34 | # via myst-parser 35 | mdurl==0.1.2 36 | # via markdown-it-py 37 | myst-parser==3.0.1 38 | # via -r requirements.in 39 | packaging==24.1 40 | # via sphinx 41 | psutil==6.0.0 42 | # via -r requirements.in 43 | pygments==2.18.0 44 | # via sphinx 45 | pyyaml==6.0.1 46 | # via myst-parser 47 | requests==2.32.3 48 | # via sphinx 49 | snowballstemmer==2.2.0 50 | # via sphinx 51 | sphinx==7.4.7 52 | # via 53 | # -r requirements.in 54 | # myst-parser 55 | sphinxcontrib-applehelp==2.0.0 56 | # via sphinx 57 | sphinxcontrib-devhelp==2.0.0 58 | # via sphinx 59 | sphinxcontrib-htmlhelp==2.1.0 60 | # via sphinx 61 | sphinxcontrib-jsmath==1.0.1 62 | # via sphinx 63 | sphinxcontrib-qthelp==2.0.0 64 | # via sphinx 65 | sphinxcontrib-serializinghtml==2.0.0 66 | # via sphinx 67 | urllib3==2.2.2 68 | # via requests 69 | -------------------------------------------------------------------------------- /test/files/expected/source/CMakeLists.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cjdb/new_cxx_project/ad44b6de11129084765ebf9632366dc2e8597da7/test/files/expected/source/CMakeLists.txt -------------------------------------------------------------------------------- /test/files/git-remote.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t/git-file 2 | RUN: %new-project %t/git-file --author='git' --remote=file:///tmp/dir.git 3 | RUN: pushd %t/git-file 4 | RUN: git remote -v | FileCheck %s --check-prefix=CHECK-REMOTE -DREMOTE=file:///tmp/dir.git 5 | RUN: popd 6 | 7 | RUN: %rm %t/git-https 8 | RUN: %new-project %t/git-https --author='git' --remote=https://host.xyz/cjdb/new_cxx_project.git 9 | RUN: pushd %t/git-https 10 | RUN: git remote -v | FileCheck %s --check-prefix=CHECK-REMOTE -DREMOTE=https://host.xyz/cjdb/new_cxx_project.git 11 | RUN: popd 12 | 13 | RUN: %rm %t/git-git 14 | RUN: %new-project %t/git-git --author='git' --remote=git://host.xyz/cjdb/new_cxx_project.git 15 | RUN: pushd %t/git-git 16 | RUN: git remote -v | FileCheck %s --check-prefix=CHECK-REMOTE -DREMOTE=git://host.xyz/cjdb/new_cxx_project.git 17 | RUN: popd 18 | 19 | RUN: %rm %t/git-ssh 20 | RUN: %new-project %t/git-ssh --author='git' --remote=git@host.xyz:cjdb/new_cxx_project.git 21 | RUN: pushd %t/git-ssh 22 | RUN: git remote -v | FileCheck %s --check-prefix=CHECK-REMOTE -DREMOTE=git@host.xyz:cjdb/new_cxx_project.git 23 | RUN: popd 24 | 25 | CHECK-REMOTE: origin [[REMOTE]] (fetch) 26 | CHECK-REMOTE: origin [[REMOTE]] (push) 27 | -------------------------------------------------------------------------------- /test/files/git-status.test: -------------------------------------------------------------------------------- 1 | RUN: %rm %t/git 2 | RUN: %new-project %t/git --author='git' 3 | RUN: pushd %t/git 4 | RUN: git status --porcelain --ignored | FileCheck %s --allow-empty 5 | RUN: git remote -v | FileCheck %s --allow-empty 6 | RUN: popd 7 | 8 | CHECK-NOT: {{.+}} 9 | -------------------------------------------------------------------------------- /test/files/vcpkg-changes/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "vcpkg"] 2 | url = https://github.com/Microsoft/vcpkg.git 3 | path = vcpkg 4 | -------------------------------------------------------------------------------- /test/files/vcpkg-changes/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Copyright Christopher Di Bella 2 | # Licensed under the Apache License v2.0 with LLVM Exceptions. 3 | # See /LICENCE for licence information. 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | cmake_minimum_required(VERSION 3.28 FATAL_ERROR) 6 | 7 | project("copied_okay" C CXX) 8 | 9 | set(CMAKE_CXX_STANDARD 23) 10 | set(CMAKE_CXX_EXTENSIONS Yes) 11 | set(CMAKE_CXX_STANDARD_REQUIRED Yes) 12 | set(CMAKE_EXPORT_COMPILE_COMMANDS Yes) 13 | 14 | message(STATUS "Building with C++${CMAKE_CXX_STANDARD} (extensions enabled)") 15 | 16 | include("${PROJECT_SOURCE_DIR}/config/cmake/detail/vcpkg.cmake") 17 | include("${PROJECT_SOURCE_DIR}/config/cmake/project_options.cmake") 18 | include("${PROJECT_SOURCE_DIR}/config/cmake/detail/add_targets.cmake") 19 | include("${PROJECT_SOURCE_DIR}/config/cmake/import_packages.cmake") 20 | enable_testing() 21 | include(CTest) 22 | 23 | add_subdirectory(source) 24 | add_subdirectory(docs) 25 | 26 | # This file is deliberately included after everything else, since installation targets depend on at 27 | # least one target requesting to be installed first. 28 | include("${PROJECT_SOURCE_DIR}/config/cmake/install_targets.cmake") 29 | -------------------------------------------------------------------------------- /test/files/vcpkg-changes/config/cmake/detail/vcpkg.cmake: -------------------------------------------------------------------------------- 1 | # Copyright Christopher Di Bella 2 | # Licensed under the Apache License v2.0 with LLVM Exceptions. 3 | # See /LICENCE for licence information. 4 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 5 | execute_process( 6 | COMMAND "${CMAKE_CXX_COMPILER}" -dumpmachine 7 | COMMAND tr -d '\n' 8 | OUTPUT_VARIABLE _COPIED_OKAY_TARGET_TRIPLE 9 | ) 10 | 11 | if(_COPIED_OKAY_TARGET_TRIPLE MATCHES "^x86_64") 12 | set(_COPIED_OKAY_TARGET_ARCHITECTURE "x64") 13 | elseif(_COPIED_OKAY_TARGET_TRIPLE MATCHES "^x86") 14 | set(_COPIED_OKAY_TARGET_ARCHITECTURE "x86") 15 | elseif(_COPIED_OKAY_TARGET_TRIPLE MATCHES "^arm64") 16 | set(_COPIED_OKAY_TARGET_ARCHITECTURE "arm64") 17 | elseif(_COPIED_OKAY_TARGET_TRIPLE MATCHES "^arm") 18 | set(_COPIED_OKAY_TARGET_ARCHITECTURE "arm") 19 | elseif(_COPIED_OKAY_TARGET_TRIPLE MATCHES "^aarch64") 20 | set(_COPIED_OKAY_TARGET_ARCHITECTURE "aarch64") 21 | elseif(_COPIED_OKAY_TARGET_TRIPLE MATCHES "^loongarch32") 22 | set(_COPIED_OKAY_TARGET_ARCHITECTURE "loongarch32") 23 | elseif(_COPIED_OKAY_TARGET_TRIPLE MATCHES "^loongarch64") 24 | set(_COPIED_OKAY_TARGET_ARCHITECTURE "loongarch64") 25 | elseif(_COPIED_OKAY_TARGET_TRIPLE MATCHES "^riscv32") 26 | set(_COPIED_OKAY_TARGET_ARCHITECTURE "riscv32") 27 | elseif(_COPIED_OKAY_TARGET_TRIPLE MATCHES "^riscv64") 28 | set(_COPIED_OKAY_TARGET_ARCHITECTURE "riscv64") 29 | elseif(_COPIED_OKAY_TARGET_TRIPLE MATCHES "^s390x") 30 | set(_COPIED_OKAY_TARGET_ARCHITECTURE "s390x") 31 | elseif(_COPIED_OKAY_TARGET_TRIPLE MATCHES "^mips64") 32 | set(_COPIED_OKAY_TARGET_ARCHITECTURE "mips64") 33 | elseif(_COPIED_OKAY_TARGET_TRIPLE MATCHES "^ppc64le") 34 | set(_COPIED_OKAY_TARGET_ARCHITECTURE "ppc64le") 35 | elseif(_COPIED_OKAY_TARGET_TRIPLE MATCHES "^wasm32") 36 | set(_COPIED_OKAY_TARGET_ARCHITECTURE "wasm32") 37 | else() 38 | message(FATAL_ERROR "Can't generate vcpkg toolchain file because ${_COPIED_OKAY_TARGET_TRIPLE} doesn't have a known architecture mapping") 39 | endif() 40 | 41 | set(COPIED_OKAY_CRT_LINKAGE static) 42 | set(COPIED_OKAY_LIBRARY_LINKAGE static) 43 | 44 | configure_file( 45 | "${CMAKE_CURRENT_LIST_DIR}/vcpkg_toolchain_file.cmake.in" 46 | "${CMAKE_BINARY_DIR}/vcpkg_toolchain_file.cmake" 47 | @ONLY 48 | ) 49 | set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_BINARY_DIR}/vcpkg_toolchain_file.cmake") 50 | include("${PROJECT_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake") 51 | -------------------------------------------------------------------------------- /test/files/vcpkg-changes/config/cmake/detail/vcpkg_toolchain_file.cmake.in: -------------------------------------------------------------------------------- 1 | set(CMAKE_BUILD_TYPE @CMAKE_BUILD_TYPE@) 2 | set(CMAKE_SYSTEM_NAME @CMAKE_SYSTEM_NAME@) 3 | set(CMAKE_SYSTEM_PROCESSOR @CMAKE_SYSTEM_PROCESSOR@) 4 | 5 | set(CMAKE_C_COMPILER "@CMAKE_C_COMPILER@") 6 | set(CMAKE_C_COMPILER_AR "@CMAKE_C_COMPILER_AR@") 7 | set(CMAKE_C_COMPILER_RANLIB "@CMAKE_C_COMPILER_RANLIB@") 8 | set(CMAKE_C_COMPILER_TARGET @CMAKE_C_COMPILER_TARGET@) 9 | 10 | set(CMAKE_CXX_COMPILER "@CMAKE_CXX_COMPILER@") 11 | set(CMAKE_CXX_COMPILER_AR "@CMAKE_CXX_COMPILER_AR@") 12 | set(CMAKE_CXX_COMPILER_RANLIB "@CMAKE_CXX_COMPILER_RANLIB@") 13 | set(CMAKE_CXX_COMPILER_TARGET @CMAKE_CXX_COMPILER_TARGET@) 14 | 15 | set(CMAKE_RC_COMPILER "@CMAKE_RC_COMPILER@") 16 | set(CMAKE_RC_COMPILER_AR "@CMAKE_AR@") 17 | set(CMAKE_RC_COMPILER_RANLIB "@CMAKE_RANLIB@") 18 | 19 | set(CMAKE_LINKER_TYPE @CMAKE_LINKER_TYPE@) 20 | 21 | string(JOIN " " CMAKE_C_FLAGS_INIT @CMAKE_CXX_FLAGS_INIT@ -w -Wno-error) 22 | string(JOIN " " CMAKE_C_FLAGS_DEBUG_INIT @CMAKE_CXX_FLAGS_DEBUG_INIT@ -w -Wno-error) 23 | string(JOIN " " CMAKE_C_FLAGS_RELEASE_INIT @CMAKE_CXX_FLAGS_RELEASE_INIT@ -w -Wno-error) 24 | string(JOIN " " CMAKE_C_FLAGS_RELWITHDEBINFO_INIT @CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT@ -w -Wno-error) 25 | string(JOIN " " CMAKE_C_FLAGS_MINSIZEREL_INIT @CMAKE_CXX_FLAGS_MINSIZEREL_INIT@ -w -Wno-error) 26 | 27 | string(JOIN " " CMAKE_CXX_FLAGS_INIT @CMAKE_CXX_FLAGS_INIT@ -w -Wno-error) 28 | string(JOIN " " CMAKE_CXX_FLAGS_DEBUG_INIT @CMAKE_CXX_FLAGS_DEBUG_INIT@ -w -Wno-error) 29 | string(JOIN " " CMAKE_CXX_FLAGS_RELEASE_INIT @CMAKE_CXX_FLAGS_RELEASE_INIT@ -w -Wno-error) 30 | string(JOIN " " CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT @CMAKE_CXX_FLAGS_RELWITHDEBINFO_INIT@ -w -Wno-error) 31 | string(JOIN " " CMAKE_CXX_FLAGS_MINSIZEREL_INIT @CMAKE_CXX_FLAGS_MINSIZEREL_INIT@ -w -Wno-error) 32 | 33 | string(JOIN " " CMAKE_EXE_LINKER_FLAGS_INIT @CMAKE_EXE_LINKER_FLAGS_INIT@) 34 | string(JOIN " " CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT @CMAKE_EXE_LINKER_FLAGS_DEBUG_INIT@) 35 | string(JOIN " " CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT @CMAKE_EXE_LINKER_FLAGS_RELEASE_INIT@) 36 | string(JOIN " " CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT @CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO_INIT@) 37 | string(JOIN " " CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT @CMAKE_EXE_LINKER_FLAGS_MINSIZEREL_INIT@) 38 | 39 | set(VCPKG_TARGET_ARCHITECTURE "@COPIED_OKAY_TARGET_ARCHITECTURE@") 40 | set(VCPKG_CRT_LINKAGE "@COPIED_OKAY_CRT_LINKAGE@") 41 | set(VCPKG_LIBRARY_LINKAGE "@COPIED_OKAY_LIBRARY_LINKAGE@") 42 | 43 | set(VCPKG_CMAKE_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@") 44 | 45 | set(VCPKG_INSTALL_OPTIONS @VCPKG_INSTALL_OPTIONS@) 46 | set(VCPKG_CHAINLOAD_TOOLCHAIN_FILE "${CMAKE_CURRENT_LIST_FILE}") 47 | set(VCPKG_TARGET_TRIPLET vcpkg_toolchain_file) 48 | set(VCPKG_OVERLAY_TRIPLETS "@CMAKE_BINARY_DIR@") 49 | -------------------------------------------------------------------------------- /test/files/vcpkg-changes/docs/source/project/vcpkg.rst: -------------------------------------------------------------------------------- 1 | .. 2 | Copyright (c) 2024 Christopher Di Bella 3 | Licensed under Creative Commons Attribution-ShareAlike 4.0 International 4 | See /LICENCE for licence information. 5 | SPDX-License-Identifier: CC BY-SA 4.0 6 | 7 | *********** 8 | Using vcpkg 9 | *********** 10 | 11 | copied_okay uses `vcpkg `_ for package management. We use the 12 | `manifest mode `_. 13 | 14 | Adding packages 15 | ================ 16 | 17 | To add a dependency, add it to the top-level ``vcpkg.json``, and then add the corresponding CMake 18 | ``find_package`` (or equivalent) rule to ``config/cmake/add_packages.cmake``. 19 | 20 | Setting up the toolchain with vcpkg 21 | =================================== 22 | 23 | This project aims to build its dependencies with the same compile-time options as its own targets, 24 | where possible (Titus Winters' keynote, `'C++ Past vs. Future' `_, 25 | summarises why we adopt this philosophy). copied_okay generates a vcpkg toolchain file when you 26 | configure the project, so you shouldn't follow the vcpkg instructions for setting things up. Instead, 27 | just configure the project using the options documented in :doc:`cmake`. You can optionally set 28 | :code:`-DVCPKG_INSTALL_OPTIONS`, which will be passed to vcpkg. 29 | 30 | .. code-block:: 31 | :caption: An example showing how vcpkg can be used. The ``-DVCPKG_INSTALL_OPTIONS='--clean-after-build'`` 32 | option is optional, and tells vcpkg to clean its build cache after all packages are installed. 33 | 34 | $ cmake -S. -Bbuild -GNinja \ 35 | -DCMAKE_BUILD_TYPE=Debug \ 36 | -DTOOLCHAIN_FILE='/path/to/project/config/cmake/toolchains/x86_64-unknown-linux-llvm.cmake' \ 37 | -DVCPKG_INSTALL_OPTIONS='--clean-after-build' \ 38 | 39 | -------------------------------------------------------------------------------- /test/files/vcpkg-changes/vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "copied-okay", 3 | "version-string": "", 4 | "homepage": "", 5 | "description": "", 6 | "dependencies": [] 7 | } 8 | -------------------------------------------------------------------------------- /test/lit.cfg.py: -------------------------------------------------------------------------------- 1 | # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 2 | # See https://llvm.org/LICENSE.txt for license information. 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | import lit.formats 5 | import lit.util 6 | import os 7 | import platform 8 | import re 9 | import subprocess 10 | import sys 11 | import tempfile 12 | from pathlib import Path 13 | 14 | from lit.llvm import llvm_config 15 | from lit.llvm.subst import ToolSubst, FindTool 16 | 17 | # Configuration file for the 'lit' test runner. 18 | 19 | # name: the name of this test suite 20 | config.name = 'new_cxx_project' 21 | 22 | # testFormat: The test format used to use to interpret tests. 23 | # 24 | # For now we require '&&' between commands, until they get globally killed and 25 | # the test runner updated. 26 | config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) 27 | 28 | # suffixes: A list of file extensions to treat as test files. 29 | config.suffixes = ['.test'] 30 | 31 | # excludes: A list of directories to exclude from the testsuite. The 'Inputs' 32 | # subdirectories contain auxiliary inputs for various tests in their parent 33 | # directories. 34 | config.excludes = [] 35 | 36 | # test_source_root: The root path where tests are located. 37 | config.test_source_root = os.path.dirname(__file__) 38 | 39 | # test_exec_root: The root path where tests should be run. 40 | config.test_exec_root = os.path.join(config.clang_obj_root, 'test') 41 | 42 | llvm_config.use_default_substitutions() 43 | llvm_config.use_clang() 44 | 45 | config.environment["PATH"] = ( 46 | f"{os.path.expanduser('~')}/.config/new_cxx_project/bin:{config.environment['PATH']}" 47 | ) 48 | config.substitutions.append(('%PATH%', config.environment['PATH'])) 49 | 50 | homedir = tempfile.TemporaryDirectory() 51 | config.environment['HOME'] = homedir.name 52 | 53 | config.environment['TRUE_HOME'] = os.path.expanduser('~') 54 | 55 | tool_dirs = [] 56 | tools = [] 57 | -------------------------------------------------------------------------------- /test/lit.rm.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python3 2 | import shutil 3 | import sys 4 | 5 | 6 | def main(): 7 | for i in sys.argv[1:]: 8 | shutil.rmtree(i, True) 9 | 10 | 11 | if __name__ == "__main__": 12 | main() 13 | -------------------------------------------------------------------------------- /test/lit.site.cfg.py.in: -------------------------------------------------------------------------------- 1 | # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 2 | # See https://llvm.org/LICENSE.txt for license information. 3 | # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 4 | @LIT_SITE_CFG_IN_HEADER@ 5 | 6 | import sys 7 | 8 | config.llvm_src_root = path(r"@LLVM_SOURCE_DIR@") 9 | config.llvm_obj_root = path(r"@LLVM_BINARY_DIR@") 10 | config.llvm_tools_dir = path(r"@LLVM_TOOLS_DIR@") 11 | config.llvm_libs_dir = path(r"@LLVM_LIBS_DIR@") 12 | config.llvm_shlib_dir = path(r"@SHLIBDIR@") 13 | config.llvm_plugin_ext = "@LLVM_PLUGIN_EXT@" 14 | config.lit_tools_dir = path(r"@LLVM_LIT_TOOLS_DIR@") 15 | config.errc_messages = "@LLVM_LIT_ERRC_MESSAGES@" 16 | config.clang_lit_site_cfg = __file__ 17 | config.clang_obj_root = path(r"@CLANG_BINARY_DIR@") 18 | config.clang_src_dir = path(r"@PROJECT_SOURCE_DIR@") 19 | config.clang_tools_dir = path(r"@CLANG_TOOLS_DIR@") 20 | config.clang_lib_dir = path(r"@CMAKE_LIBRARY_OUTPUT_DIRECTORY@") 21 | config.host_triple = "x86_64-unknown-linux-gnu" 22 | config.target_triple = "x86_64-unknown-linux-gnu" 23 | config.host_cc = "@CMAKE_C_COMPILER@" 24 | config.host_cxx = "@CMAKE_CXX_COMPILER@" 25 | config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@" 26 | config.have_zlib = 1 27 | config.clang_arcmt = 0 28 | config.clang_default_pie_on_linux = 1 29 | config.clang_default_cxx_stdlib = "" 30 | config.clang_staticanalyzer = 0 31 | config.clang_staticanalyzer_z3 = 0 32 | config.clang_examples = 0 33 | config.enable_shared = 0 34 | config.enable_backtrace = 1 35 | config.enable_experimental_new_pass_manager = 1 36 | config.enable_threads = 1 37 | config.host_arch = "@HOST_ARCH@" 38 | config.python_executable = "@Python_EXECUTABLE@" 39 | config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', "@USE_Z3_SOLVER@") 40 | config.has_plugins = False 41 | config.clang_vendor_uti = "@CLANG_VENDOR_UTI@" 42 | config.llvm_external_lit = path(r"@LLVM_EXTERNAL_LIT@") 43 | 44 | # Support substitution of the tools and libs dirs with user parameters. This is 45 | # used when we can't determine the tool dir at configuration time. 46 | try: 47 | config.clang_tools_dir = config.clang_tools_dir % lit_config.params 48 | config.llvm_tools_dir = config.llvm_tools_dir % lit_config.params 49 | config.llvm_shlib_dir = config.llvm_shlib_dir % lit_config.params 50 | config.llvm_libs_dir = config.llvm_libs_dir % lit_config.params 51 | except KeyError: 52 | e = sys.exc_info()[1] 53 | key, = e.args 54 | lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key)) 55 | 56 | import lit.llvm 57 | lit.llvm.initialize(lit_config, config) 58 | 59 | config.substitutions.append( 60 | ('%rm', 'python @CMAKE_SOURCE_DIR@/test/lit.rm.py')) 61 | config.substitutions.append( 62 | ('%new-project', '@PROJECT_SOURCE_DIR@/new_cxx_project.py')) 63 | config.substitutions.append(('%expect-error', 'if [[ $? == 0 ]]; then exit 1; fi')) 64 | escaped_directory = '@PROJECT_SOURCE_DIR@'.replace('/', '\\/') 65 | config.substitutions.append( 66 | ('%{replace_path}', f'''awk '!/^#.*$/' | awk '{{ gsub(/{escaped_directory}/, ""); print; }}\'''')) 67 | 68 | 69 | # Let the main config do the real work. 70 | lit_config.load_config( 71 | config, os.path.join(config.clang_src_dir, "test/lit.cfg.py")) 72 | --------------------------------------------------------------------------------