diff --git a/.copier-answers.yml b/.copier-answers.yml index 8058ae1..e69ac83 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,4 +1,4 @@ -_commit: v1.6.14 +_commit: v1.6.21 _src_path: https://github.com/serious-scaffold/ss-cpp author_email: msclock@126.com author_name: l.feng @@ -15,6 +15,7 @@ header_target: '' organization_name: msclock project_description: Practice based on cppfront project_name: Practice on cppfront +repo_host: github.com repo_name: cppfront-practice repo_namespace: msclock repo_platform: github diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index e4fc4bf..d7fda5f 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -33,24 +33,24 @@ jobs: ref: ${{ github.head_ref }} - name: Cache - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 with: path: | ~/vcpkg ~/.cache/pip ~/.cache/vcpkg - key: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }} - restore-keys: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }} + key: x64-linux-gcc-14-${{ hashFiles('vcpkg.json') }} + restore-keys: x64-linux-gcc-14-${{ hashFiles('vcpkg.json') }} - uses: aminya/setup-cpp@v1 with: - compiler: gcc-13 + compiler: gcc-14 cmake: true ninja: true ccache: true doxygen: true - - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5 + - uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5 with: python-version: 3.x diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 948ebd7..457c6d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: with: fetch-depth: 0 - - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5 + - uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5 with: python-version: 3.11 @@ -36,12 +36,11 @@ jobs: check-on-linux: runs-on: ubuntu-24.04 needs: [pre-commit] - timeout-minutes: 15 + strategy: - fail-fast: false matrix: triplet: [x64-linux] - compiler: [gcc-13, llvm-17] + compiler: [gcc-14, llvm-18] std: [20] build_type: [Debug, RelWithDebInfo] @@ -53,7 +52,7 @@ jobs: fetch-depth: 0 - name: Cache - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 with: path: | ~/vcpkg @@ -115,12 +114,10 @@ jobs: if: false runs-on: macos-14 needs: [pre-commit] - timeout-minutes: 30 strategy: - fail-fast: false matrix: triplet: [arm64-osx] - compiler: [gcc@13, llvm@17] + compiler: [gcc@14, llvm@18] std: [23] build_type: [Debug, RelWithDebInfo] @@ -132,7 +129,7 @@ jobs: fetch-depth: 0 - name: Cache - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 with: path: | ~/vcpkg @@ -142,7 +139,7 @@ jobs: - name: Install compilers and tools run: | - brew install ${{ matrix.compiler }} ninja ccache + brew install ${{ matrix.compiler }} cmake ninja ccache lcov - name: Prepare PATH for compilers run: echo "PATH=/usr/local/opt/${{ matrix.compiler }}/bin:$PATH" >> $GITHUB_ENV @@ -162,13 +159,6 @@ jobs: gcov_version=${compiler##*@} echo "GCOV=$(which gcov-$gcov_version)" >> $GITHUB_ENV - - name: Prepare for lcov - if: contains(matrix.compiler, 'gcc') - run: | - curl -o /tmp/lcov.rb https://raw.githubusercontent.com/Homebrew/homebrew-core/e92d2ae54954ebf485b484d8522104700b144fee/Formula/lcov.rb - HOMEBREW_NO_AUTO_UPDATE=1 brew install --formula /tmp/lcov.rb - brew pin lcov - - name: Configure CMake run: > cmake -S . --preset=default @@ -201,12 +191,11 @@ jobs: check-on-windows: runs-on: windows-2022 needs: [pre-commit] - timeout-minutes: 15 + strategy: - fail-fast: false matrix: triplet: [x64-windows] - compiler: [msvc-2022, llvm-17] + compiler: [msvc-2022, llvm-18] std: [20] build_type: [Debug, RelWithDebInfo] @@ -218,7 +207,7 @@ jobs: fetch-depth: 0 - name: Cache - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 with: path: | ~/vcpkg @@ -267,9 +256,8 @@ jobs: check-mingw: runs-on: windows-2022 needs: [pre-commit] - timeout-minutes: 15 + strategy: - fail-fast: false matrix: triplet: [x64-mingw-dynamic] compiler: [mingw] @@ -284,7 +272,7 @@ jobs: fetch-depth: 0 - name: Cache - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 with: path: | ~/vcpkg @@ -301,13 +289,13 @@ jobs: ninja: true ccache: true - - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5 + - uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5 with: python-version: 3.x - name: Prepare for gcovr run: | - pip install gcovr==7.2 + pip install gcovr==8.3 - name: Configure CMake run: > @@ -337,9 +325,8 @@ jobs: check-sanitizers: runs-on: ubuntu-24.04 needs: [pre-commit] - timeout-minutes: 15 + strategy: - fail-fast: false matrix: sanitizer: - address,undefined @@ -353,17 +340,17 @@ jobs: fetch-depth: 0 - name: Cache - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 with: path: | ~/vcpkg ~/.cache/vcpkg - key: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }} - restore-keys: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }} + key: x64-linux-gcc-14-${{ hashFiles('vcpkg.json') }} + restore-keys: x64-linux-gcc-14-${{ hashFiles('vcpkg.json') }} - uses: aminya/setup-cpp@v1 with: - compiler: gcc-13 + compiler: gcc-14 cmake: true ninja: true ccache: true @@ -387,9 +374,8 @@ jobs: check-valgrind: runs-on: ubuntu-24.04 needs: [pre-commit] - timeout-minutes: 15 + strategy: - fail-fast: false matrix: build_type: [Debug, RelWithDebInfo] @@ -401,17 +387,17 @@ jobs: fetch-depth: 0 - name: Cache - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 with: path: | ~/vcpkg ~/.cache/vcpkg - key: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }} - restore-keys: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }} + key: x64-linux-gcc-14-${{ hashFiles('vcpkg.json') }} + restore-keys: x64-linux-gcc-14-${{ hashFiles('vcpkg.json') }} - uses: aminya/setup-cpp@v1 with: - compiler: gcc-13 + compiler: gcc-14 cmake: true ninja: true ccache: true @@ -447,7 +433,7 @@ jobs: - name: Upload test results if: failure() - uses: actions/upload-artifact@6f51ac03b9356f520e9adb1b1b7802705f340c2b # v4 + uses: actions/upload-artifact@4cec3d8aa04e39d1a68397de0c4cd6fb9dce8ec1 # v4 with: name: valgrind-results path: out/valgrind-results.tar.gz @@ -455,7 +441,6 @@ jobs: clang-tidy: runs-on: ubuntu-24.04 needs: [pre-commit] - timeout-minutes: 15 steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 @@ -463,28 +448,28 @@ jobs: fetch-depth: 0 - name: Cache - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 with: path: | ~/vcpkg ~/.cache/vcpkg - key: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }} - restore-keys: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }} + key: x64-linux-gcc-14-${{ hashFiles('vcpkg.json') }} + restore-keys: x64-linux-gcc-14-${{ hashFiles('vcpkg.json') }} - uses: aminya/setup-cpp@v1 with: - compiler: gcc-13 + compiler: gcc-14 cmake: true ninja: true ccache: true - - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5 + - uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5 with: python-version: 3.x - name: Install latest clang-tidy run: | - pip install clang-tidy==19.1.0 + pip install clang-tidy==19.1.0.1 - name: Configure CMake run: > @@ -504,7 +489,6 @@ jobs: cppcheck: runs-on: ubuntu-24.04 needs: [pre-commit] - timeout-minutes: 15 steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 @@ -512,28 +496,28 @@ jobs: fetch-depth: 0 - name: Cache - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 with: path: | ~/vcpkg ~/.cache/vcpkg - key: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }} - restore-keys: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }} + key: x64-linux-gcc-14-${{ hashFiles('vcpkg.json') }} + restore-keys: x64-linux-gcc-14-${{ hashFiles('vcpkg.json') }} - uses: aminya/setup-cpp@v1 with: - compiler: gcc-13 + compiler: gcc-14 cmake: true ninja: true ccache: true - - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5 + - uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5 with: python-version: 3.x - name: Install latest cppcheck run: | - pip install cppcheck==1.4.6 + pip install cppcheck==1.4.7 - name: Configure CMake run: > @@ -553,7 +537,6 @@ jobs: check-docs: runs-on: ubuntu-24.04 needs: [pre-commit] - timeout-minutes: 15 steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 @@ -561,25 +544,25 @@ jobs: fetch-depth: 0 - name: Cache - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 with: path: | ~/vcpkg ~/.cache/pip ~/.cache/vcpkg - key: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }} - restore-keys: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }} + key: x64-linux-gcc-14-${{ hashFiles('vcpkg.json') }} + restore-keys: x64-linux-gcc-14-${{ hashFiles('vcpkg.json') }} - uses: aminya/setup-cpp@v1 with: - compiler: gcc-13 + compiler: gcc-14 cmake: true ninja: true ccache: true doxygen: true graphviz: true - - uses: actions/setup-python@0b93645e9fea7318ecaed2b359559ac225c90a2b # v5 + - uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5 with: python-version: 3.x @@ -599,7 +582,6 @@ jobs: codecov: runs-on: ubuntu-24.04 needs: [pre-commit] - timeout-minutes: 15 steps: - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4 @@ -607,17 +589,17 @@ jobs: fetch-depth: 0 - name: Cache - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 with: path: | ~/vcpkg ~/.cache/vcpkg - key: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }} - restore-keys: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }} + key: x64-linux-gcc-14-${{ hashFiles('vcpkg.json') }} + restore-keys: x64-linux-gcc-14-${{ hashFiles('vcpkg.json') }} - uses: aminya/setup-cpp@v1 with: - compiler: gcc-13 + compiler: gcc-14 cmake: true ninja: true ccache: true @@ -625,7 +607,7 @@ jobs: - name: Prepare for lcov run: | sudo apt-get update; sudo apt-get install lcov -y - gcc_compiler=gcc-13 + gcc_compiler=gcc-14 gcov_version=${gcc_compiler##*-} sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-$gcov_version 100 @@ -646,12 +628,12 @@ jobs: run: cmake --build --preset=default --target ccov-all - name: Upload coverage report - uses: codecov/codecov-action@b9fd7d16f6d7d1b5d2bec1a2887e65ceed900238 # v4.6.0 + uses: codecov/codecov-action@13ce06bfc6bbe3ecf90edbbf1bc32fe5978ca1d3 # v5.3.1 with: token: ${{ secrets.CODECOV_TOKEN }} fail_ci_if_error: true disable_search: true - file: ./out/build/default/code_coverage/coverage.info + files: ./out/build/default/code_coverage/coverage.info verbose: true diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index c7f1ece..81833ba 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -50,23 +50,23 @@ jobs: fetch-depth: 0 - name: Initialize CodeQL - uses: github/codeql-action/init@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6 + uses: github/codeql-action/init@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10 with: languages: ${{ matrix.language }} config-file: ./.github/codeql-config.yml - name: Cache - uses: actions/cache@1bd1e32a3bdc45362d1e726936510720a7c30a57 # v4 + uses: actions/cache@d4323d4df104b026a6aa633fdb11d772146be0bf # v4 with: path: | ~/vcpkg ~/.cache/vcpkg - key: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }} - restore-keys: x64-linux-gcc-13-${{ hashFiles('vcpkg.json') }} + key: x64-linux-gcc-14-${{ hashFiles('vcpkg.json') }} + restore-keys: x64-linux-gcc-14-${{ hashFiles('vcpkg.json') }} - uses: aminya/setup-cpp@v1 with: - compiler: gcc-13 + compiler: gcc-14 cmake: true ninja: true ccache: true @@ -87,4 +87,4 @@ jobs: run: cmake --build --preset=default --target all - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@aa578102511db1f4524ed59b8cc2bae4f6e88195 # v3.27.6 + uses: github/codeql-action/analyze@b56ba49b26e50535fa1e7f7db0f4f7b4bf65d80d # v3.28.10 diff --git a/.github/workflows/renovate.yml b/.github/workflows/renovate.yml index 7aa95ff..2ee5477 100644 --- a/.github/workflows/renovate.yml +++ b/.github/workflows/renovate.yml @@ -2,8 +2,8 @@ name: Renovate on: schedule: - # Match renovate schedule:earlyMondays and schedule:automergeMonthly - - cron: '*/15 0-3 * * *' + # Match renovate schedule and automergeSchedule + - cron: '*/15 0-3 1-7 * *' workflow_dispatch: jobs: @@ -19,7 +19,7 @@ jobs: RENOVATE_PLATFORM: github RENOVATE_REPOSITORIES: '["${{ github.repository }}"]' RENOVATE_REPOSITORY_CACHE: enabled - image: ghcr.io/renovatebot/renovate:39.42.4@sha256:c5d718e312cdacc0746e37f13c215ff498be28c51e50efd24c070ae29f5b636a + image: ghcr.io/renovatebot/renovate:39.158.1@sha256:6e67b965456bfa064287d23e1f2009082940e78eb928bafa0820d4f85b14a63d options: --user root runs-on: ubuntu-24.04 steps: @@ -28,7 +28,7 @@ jobs: - name: Generate a token with GitHub App if App ID exists id: generate-token if: vars.BOT_APP_ID - uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1 + uses: actions/create-github-app-token@21cfef2b496dd8ef5b904c159339626a10ad380e # v1 with: app-id: ${{ vars.BOT_APP_ID }} private-key: ${{ secrets.BOT_PRIVATE_KEY }} diff --git a/.github/workflows/semantic-release.yml b/.github/workflows/semantic-release.yml index f6aabca..49217bf 100644 --- a/.github/workflows/semantic-release.yml +++ b/.github/workflows/semantic-release.yml @@ -24,7 +24,7 @@ jobs: - name: Generate a bot token with BOT_APP_ID id: bot_token if: vars.BOT_APP_ID && env.BOT_PRIVATE_KEY != null - uses: actions/create-github-app-token@c1a285145b9d317df6ced56c09f525b5c2b6f755 # v1 + uses: actions/create-github-app-token@21cfef2b496dd8ef5b904c159339626a10ad380e # v1 env: BOT_PRIVATE_KEY: ${{ secrets.BOT_PRIVATE_KEY }} with: @@ -46,7 +46,7 @@ jobs: token: ${{ steps.bot_token.outputs.token || secrets.PAT || secrets.GITHUB_TOKEN }} - name: Setup Node.js - uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4 + uses: actions/setup-node@1d0ff469b7ec7b3cb9d8673fde0c81c44821de2a # v4 with: node-version: lts/* diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 02bd456..369c12a 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -66,7 +66,7 @@ repos: # Check for spelling - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.1 hooks: - id: codespell args: @@ -82,20 +82,20 @@ repos: # Clang format the codebase automatically - repo: https://github.com/pre-commit/mirrors-clang-format - rev: v19.1.4 + rev: v19.1.7 hooks: - id: clang-format types_or: [c++, c, cuda] # Check for markdown - repo: https://github.com/igorshubovych/markdownlint-cli - rev: v0.43.0 + rev: v0.44.0 hooks: - id: markdownlint-fix # Check for renovate config - repo: https://github.com/renovatebot/pre-commit-hooks - rev: 39.57.4 + rev: 39.158.1 hooks: - id: renovate-config-validator stages: [manual] diff --git a/.renovaterc.json b/.renovaterc.json index 7b09471..d508bf5 100644 --- a/.renovaterc.json +++ b/.renovaterc.json @@ -15,9 +15,11 @@ "addLabels": [ "auto-approval" ], - "extends": [ - "schedule:earlyMondays", - "schedule:automergeMonthly" + "schedule": [ + "* 0-3 1-7 * *" + ], + "automergeSchedule": [ + "* 0-3 1-7 * *" ], "matchUpdateTypes": [ "minor", diff --git a/.vscode/launch.json b/.vscode/launch.json index bad5311..a946e52 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -4,6 +4,17 @@ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 "version": "0.2.0", "configurations": [ + { + "name": "(Windows) Launch", + "type": "cppvsdbg", + "request": "launch", + "program": "${command:cmake.launchTargetPath}", + "args": [], + "stopAtEntry": false, + "cwd": "${command:cmake.launchTargetDirectory}", + "environment": [], + "console": "integratedTerminal" + }, { "name": "(gdb) Launch", "type": "cppdbg", @@ -11,7 +22,7 @@ "program": "${command:cmake.launchTargetPath}", "args": [], "stopAtEntry": false, - "cwd": "${fileDirname}", + "cwd": "${command:cmake.launchTargetDirectory}", "environment": [], "externalConsole": false, "MIMode": "gdb", diff --git a/.vscode/settings.json b/.vscode/settings.json index 09407be..5145e83 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,12 +1,7 @@ { + "cmake.configureOnEdit": false, + "cmake.options.statusBarVisibility": "icon", "cmake.useCMakePresets": "always", - "cmake.options.statusBarVisibility": "compact", - "files.exclude": { - "**/.clangd/**": true - }, - "files.watcherExclude": { - "**/.clangd/**": true - }, "files.associations": { "*.cpp2": "cpp", "*.h2": "cpp", diff --git a/CMakeLists.txt b/CMakeLists.txt index 81cda35..46fcceb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,28 +8,11 @@ project( HOMEPAGE_URL "https://github.com/msclock/cppfront-practice" DESCRIPTION "Practice based on cppfront") -set(CMAKE_CXX_STANDARD - 23 - CACHE STRING "C++ standard") -set(CMAKE_CXX_STANDARD_REQUIRED - ON - CACHE BOOL "C++ standard required") -set(CMAKE_CXX_EXTENSIONS - OFF - CACHE BOOL "C++ extensions") - -# Source includes from vcpkg -include_directories(${VCPKG_INSTALLED_DIR}/${VCPKG_TARGET_TRIPLET}/include) - -# From https://github.com/msclock/cmake-registry. +# Project default module find_package(cmake-modules REQUIRED) include(cmake-modules/ProjectDefault) - -# Project custom modules -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") -include(ConfigureWarningsAndHardening) include(ConfigureVersion) -include(ConfigureDocs) include(ConfigureCoverage) +include(ConfigureDocs) add_subdirectory(src) diff --git a/Makefile b/Makefile index e3ccf32..ad74e06 100644 --- a/Makefile +++ b/Makefile @@ -25,8 +25,8 @@ clean: # Install standalone tools prerequisites: - pipx install --force pre-commit==4.0.1 - pipx install --force watchfiles==1.0.0 + pipx install --force pre-commit==4.1.0 + pipx install --force watchfiles==1.0.4 ######################################################################################## # Lint diff --git a/cmake/ConfigureWarningsAndHardening.cmake b/cmake/ProjectOptions.cmake similarity index 81% rename from cmake/ConfigureWarningsAndHardening.cmake rename to cmake/ProjectOptions.cmake index 298cb6a..9dc10ff 100644 --- a/cmake/ConfigureWarningsAndHardening.cmake +++ b/cmake/ProjectOptions.cmake @@ -1,26 +1,27 @@ #[[ -This file configures the following things: - - dynamic tools: sanitizers, valgrind. - - static tools: clang-tidy, cppcheck. - - compiler flags - - hardening options - +ProjectOptions.cmake - Defines project-specific options for CMake. ]] -include_guard(GLOBAL) +set(CMAKE_CXX_STANDARD + 20 + CACHE STRING "C++ standard") +set(CMAKE_CXX_STANDARD_REQUIRED + ON + CACHE BOOL "C++ standard required") +set(CMAKE_CXX_EXTENSIONS + OFF + CACHE BOOL "C++ extensions") # ############################################################################## -# Sanitizer +# Sanitizer - cmake-modules/build/Sanitizer.cmake # ############################################################################## set(USE_SANITIZER OFF CACHE BOOL "Enable sanitizer") -include(cmake-modules/build/Sanitizer) - # ############################################################################## -# Valgrind +# Valgrind - cmake-modules/test/Valgrind.cmake # ############################################################################## set(USE_VALGRIND @@ -37,20 +38,16 @@ set(USE_VALGRIND_OPTIONS # Valgrind is unacceptably slow. CACHE STRING "valgrind options.") -include(cmake-modules/test/Valgrind) - # ############################################################################## -# Clang-Tidy +# Clang-Tidy - cmake-modules/build/ClangTidy.cmake # ############################################################################## set(USE_CLANGTIDY OFF CACHE BOOL "Enable Clang-Tidy") -include(cmake-modules/build/ClangTidy) - # ############################################################################## -# Cppcheck +# Cppcheck - cmake-modules/build/Cppcheck.cmake # ############################################################################## set(USE_CPPCHECK @@ -61,16 +58,8 @@ set(USE_CPPCHECK_SUPPRESSION_FILE CACHE STRING "Customize the path to the Cppcheck suppressions file of the project") -include(cmake-modules/build/Cppcheck) - # ############################################################################## -# CompilerFlags -# ############################################################################## - -include(cmake-modules/build/CompilerFlags) - -# ############################################################################## -# Hardening +# Hardening - cmake-modules/build/Hardening.cmake # ############################################################################## # Comment `-Wl,-z,nodlopen` for dlopen call @@ -105,9 +94,8 @@ if(NOT MSVC) set(USE_HARDENING_LINKS -fstack-protector-strong # Enable stack protector - "-fsanitize=undefined -fsanitize-minimal-runtime" # Enable minimal runtime - # undefined behavior sanitizer -Wl,-z,nodlopen # Restrict dlopen(3) calls - # to shared objects + "-fsanitize=undefined -fsanitize-minimal-runtime" + # -Wl,-z,nodlopen # Restrict dlopen(3) calls to shared objects -Wl,-z,noexecstack # Enable data execution prevention by marking stack # memory as non-executable -Wl,-z,relro # Mark relocation table entries resolved at load-time as @@ -116,5 +104,3 @@ if(NOT MSVC) # read-only. It impacts startup performance CACHE STRING "Additional hardening linking flags for GCC/Clang") endif() - -include(cmake-modules/build/Hardening) diff --git a/cmake/presets/base.json b/cmake/presets/base.json index f1b7667..f41a688 100644 --- a/cmake/presets/base.json +++ b/cmake/presets/base.json @@ -5,63 +5,68 @@ "toolchains/vcpkg.json" ], "configurePresets": [ + { + "name": "base-common", + "hidden":true, + "binaryDir":"${sourceDir}/out/build/${presetName}", + "installDir":"${sourceDir}/out/install/${presetName}", + "cacheVariables":{ + "CMAKE_COMPILE_WARNING_AS_ERROR":false, + "CMAKE_EXPORT_COMPILE_COMMANDS":true, + "CMAKE_VERBOSE_MAKEFILE":"FALSE" + } + }, { "name": "base", "hidden": true, "inherits": [ + "base-common", "ninja", "vcpkg" ], - "binaryDir": "${sourceDir}/out/build/${presetName}", - "installDir": "${sourceDir}/out/install/${presetName}", "cacheVariables": { - "CMAKE_EXPORT_COMPILE_COMMANDS": true, - "CMAKE_COMPILE_WARNING_AS_ERROR": false, - "CMAKE_BUILD_TYPE": "Debug", - "CMAKE_VERBOSE_MAKEFILE": "FALSE" + "CMAKE_BUILD_TYPE": "Debug" } }, { "name": "base-config", "hidden": true, "inherits": [ + "base-common", "ninja-config", "vcpkg" - ], - "binaryDir": "${sourceDir}/out/build/${presetName}", - "installDir": "${sourceDir}/out/install/${presetName}", - "cacheVariables": { - "CMAKE_EXPORT_COMPILE_COMMANDS": true, - "CMAKE_COMPILE_WARNING_AS_ERROR": false, - "CMAKE_VERBOSE_MAKEFILE": "FALSE" - } + ] } ], "buildPresets": [ { "name": "base", "hidden": true, - "inherits": "ninja", "configurePreset": "base" }, + { + "name": "base-config-debug", + "hidden": true, + "configurePreset": "base-config", + "configuration": "Debug" + }, { "name": "base-config-relwithdebinfo", "hidden": true, - "inherits": "ninja-config-relwithdebinfo", - "configurePreset": "base-config" + "configurePreset": "base-config", + "configuration": "RelWithDebInfo" }, { - "name": "base-config-debug", + "name": "base-config-release", "hidden": true, - "inherits": "ninja-config-debug", - "configurePreset": "base-config" + "configurePreset": "base-config", + "configuration": "Release" } ], "testPresets": [ { "name": "base", "hidden": true, - "inherits": "ninja", "configurePreset": "base", "output": { "outputOnFailure": true @@ -74,28 +79,29 @@ { "name": "base-config-relwithdebinfo", "hidden": true, - "inherits": "ninja-config-relwithdebinfo", + "inherits": [ + "base" + ], "configurePreset": "base-config", - "output": { - "outputOnFailure": true - }, - "execution": { - "noTestsAction": "error", - "stopOnFailure": true - } + "configuration": "RelWithDebInfo" }, { "name": "base-config-debug", "hidden": true, - "inherits": "ninja-config-debug", + "inherits": [ + "base" + ], "configurePreset": "base-config", - "output": { - "outputOnFailure": true - }, - "execution": { - "noTestsAction": "error", - "stopOnFailure": true - } + "configuration": "Debug" + }, + { + "name": "base-config-release", + "hidden": true, + "inherits": [ + "base" + ], + "configurePreset": "base-config", + "configuration": "Release" } ] } diff --git a/cmake/presets/default.json b/cmake/presets/default.json index 7423711..0db1eb6 100644 --- a/cmake/presets/default.json +++ b/cmake/presets/default.json @@ -32,6 +32,11 @@ "name": "default-config-debug", "inherits": "base-config-debug", "configurePreset": "default-config" + }, + { + "name": "default-config-release", + "inherits": "base-config-release", + "configurePreset": "default-config" } ], "testPresets": [ @@ -49,6 +54,11 @@ "name": "default-config-debug", "inherits": "base-config-debug", "configurePreset": "default-config" + }, + { + "name": "default-config-release", + "inherits": "base-config-release", + "configurePreset": "default-config" } ] } diff --git a/cmake/presets/generators/ninja.json b/cmake/presets/generators/ninja.json index 424407d..2280f4e 100644 --- a/cmake/presets/generators/ninja.json +++ b/cmake/presets/generators/ninja.json @@ -11,43 +11,5 @@ "hidden": true, "generator": "Ninja Multi-Config" } - ], - "buildPresets": [ - { - "name": "ninja", - "hidden": true, - "configurePreset": "ninja" - }, - { - "name": "ninja-config-relwithdebinfo", - "hidden": true, - "configurePreset": "ninja-config", - "configuration": "RelWithDebInfo" - }, - { - "name": "ninja-config-debug", - "hidden": true, - "configurePreset": "ninja-config", - "configuration": "Debug" - } - ], - "testPresets": [ - { - "name": "ninja", - "hidden": true, - "configurePreset": "ninja" - }, - { - "name": "ninja-config-relwithdebinfo", - "hidden": true, - "configurePreset": "ninja-config", - "configuration": "RelWithDebInfo" - }, - { - "name": "ninja-config-debug", - "hidden": true, - "configurePreset": "ninja-config", - "configuration": "Debug" - } ] } diff --git a/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake b/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake index c697a0c..5546f78 100644 --- a/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake +++ b/cmake/vcpkg/bootstrap/vcpkg_bootstrap.cmake @@ -188,6 +188,10 @@ function(_vcpkg_bootstrap) "${arg_UNPARSED_ARGUMENTS}") endif() + if(NOT DEFINED arg_REPO) + set(arg_REPO https://github.com/microsoft/vcpkg.git) + endif() + find_package(Git QUIET REQUIRED) if(DEFINED CACHE{_VCPKG_ROOT}) diff --git a/cmake/vcpkg/bootstrap/vcpkg_load_triplet.cmake b/cmake/vcpkg/bootstrap/vcpkg_load_triplet.cmake index 6ceb2f0..95722b1 100644 --- a/cmake/vcpkg/bootstrap/vcpkg_load_triplet.cmake +++ b/cmake/vcpkg/bootstrap/vcpkg_load_triplet.cmake @@ -207,19 +207,22 @@ macro(_vcpkg_load_triplet) set(_community_triplet "triplets/community/${VCPKG_TARGET_TRIPLET}.cmake") if(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${_triplet}") - include("${CMAKE_CURRENT_LIST_DIR}/${_triplet}") + set(_load_triplet "${CMAKE_CURRENT_LIST_DIR}/${_triplet}") elseif(EXISTS "${_VCPKG_ROOT}/${_triplet}") - include("${_VCPKG_ROOT}/${_triplet}") - elseif(EXISTS "${CMAKE_CURRENT_LIST_DIR}/${_community_triplet}") - include("${CMAKE_CURRENT_LIST_DIR}/${_community_triplet}") + set(_load_triplet "${_VCPKG_ROOT}/${_triplet}") elseif(EXISTS "${_VCPKG_ROOT}/${_community_triplet}") - include("${_VCPKG_ROOT}/${_community_triplet}") + set(_load_triplet "${_VCPKG_ROOT}/${_community_triplet}") else() message( FATAL_ERROR "Triplet ${VCPKG_TARGET_TRIPLET} not found at ${CMAKE_CURRENT_LIST_DIR}/${_triplet} or ${_VCPKG_ROOT}/${_triplet}" ) endif() + + message(STATUS "Loading triplet: ${_load_triplet}") + include(${_load_triplet}) + unset(_triplet) unset(_community_triplet) + unset(_load_triplet) endmacro(_vcpkg_load_triplet) diff --git a/cmake/vcpkg/vcpkg.toolchain.cmake b/cmake/vcpkg/vcpkg.toolchain.cmake index 1a15984..e268ec0 100644 --- a/cmake/vcpkg/vcpkg.toolchain.cmake +++ b/cmake/vcpkg/vcpkg.toolchain.cmake @@ -27,5 +27,4 @@ set(VCPKG_VERBOSE file(READ ${CMAKE_SOURCE_DIR}/vcpkg.json _vcpkg_json) string(JSON _builtin_baseline GET ${_vcpkg_json} builtin-baseline) -vcpkg_configure(CACHE_DIR_NAME cppfront-practice REPO - https://github.com/microsoft/vcpkg.git REF ${_builtin_baseline}) +vcpkg_configure(CACHE_DIR_NAME cppfront-practice REF ${_builtin_baseline}) diff --git a/vcpkg.json b/vcpkg.json index f1bc784..fad07c5 100644 --- a/vcpkg.json +++ b/vcpkg.json @@ -2,7 +2,7 @@ "$schema": "https://raw.githubusercontent.com/microsoft/vcpkg-tool/main/docs/vcpkg.schema.json", "name": "cppfront-practice", "description": "Practice based on cppfront", - "builtin-baseline": "55dec59d05cd1731a06a832302e80f6105a3d482", + "builtin-baseline": "efb1e7436979a30c4d3e5ab2375fd8e2e461d541", "homepage": "https://github.com/msclock/cppfront-practice", "dependencies": [ "cppfront", @@ -23,7 +23,7 @@ }, { "name": "cmake-modules", - "version": "1.6.8" + "version": "1.6.14" }, { "name": "robotology-cmake-ycm", @@ -45,7 +45,7 @@ "registries": [ { "kind": "git", - "baseline": "9d739d71af31a73a6000fb1e64b7cca54a962439", + "baseline": "1d0d4631798175f9863f730609711bd695154600", "repository": "https://github.com/msclock/cmake-registry", "packages": [ "cmake-modules",