From efd3eec9b4562d97f0cd413d0ba1ff5fee4dd02d Mon Sep 17 00:00:00 2001 From: Alonso Schaich Date: Sun, 18 Feb 2024 18:16:45 +0000 Subject: [PATCH] Use CMakePresets.json (#6) Fixes #5 --- .github/workflows/cmake.yml | 14 +- CMakeLists.txt | 2 +- CMakePresets.json | 524 ++++++++++++++++++++++++++++++++++++ README.md | 9 +- build.ps1 | 10 - run.ps1 | 7 - 6 files changed, 539 insertions(+), 27 deletions(-) create mode 100644 CMakePresets.json delete mode 100644 build.ps1 delete mode 100644 run.ps1 diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml index 79d2811..70747cb 100644 --- a/.github/workflows/cmake.yml +++ b/.github/workflows/cmake.yml @@ -6,10 +6,6 @@ on: pull_request: branches: [ "master" ] -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: Release - jobs: build: # The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac. @@ -28,13 +24,15 @@ jobs: # # See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type # run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} + - name: Configure + working-directory: ${{github.workspace}} + run: cmake --preset ci-x64-windows-vs2022-release + - name: Build working-directory: ${{github.workspace}} - shell: pwsh - run: ./build.ps1 + run: cmake --build --preset ci-x64-windows-vs2022-release - name: Test working-directory: ${{github.workspace}} - shell: pwsh - run: ./run.ps1 + run: ctest --preset ci-x64-windows-vs2022-release diff --git a/CMakeLists.txt b/CMakeLists.txt index cd5452e..a2157f0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.24) +cmake_minimum_required(VERSION 3.25) project(VcpkgSQLiteIntegrationDemo CXX) enable_testing() diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 0000000..9e1c786 --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,524 @@ +{ + "version": 6, + "cmakeMinimumRequired": { + "major": 3, + "minor": 25, + "patch": 0 + }, + "configurePresets": [ + { + "name": "clangd", + "description": "EXPORT_COMPILE_COMMANDS is required for clangd to be able to provide autocompletion in vscode.", + "cacheVariables": { + "CMAKE_EXPORT_COMPILE_COMMANDS": "ON" + }, + "hidden": true + }, + { + "name": "vcpkg", + "description": "enable vcpkg submodule", + "cacheVariables": { + "VCPKG_INSTALL_OPTIONS": "--debug;--allow-unsupported", + "VCPKG_VERBOSE": "ON", + "VCPKG_APPLOCAL_DEPS": "OFF" + }, + "toolchainFile": "${sourceDir}/vcpkg/scripts/buildsystems/vcpkg.cmake", + "hidden": true + }, + { + "name": "debug", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Debug" + }, + "hidden": true + }, + { + "name": "release", + "cacheVariables": { + "CMAKE_BUILD_TYPE": "Release" + }, + "hidden": true + }, + { + "name": "make", + "generator": "Unix Makefiles", + "hidden": true + }, + { + "name": "ninja", + "generator": "Ninja", + "hidden": true + }, + { + "name": "ninjamulti", + "generator": "Ninja Multi-Config", + "hidden": true + }, + { + "name": "vs2022", + "generator": "Visual Studio 17 2022", + "hidden": true + }, + { + "name": "x64-freebsd", + "cacheVariables": { + "VCPKG_TARGET_TRIPLET": "x64-freebsd" + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "FreeBSD" + }, + "hidden": true + }, + { + "name": "x64-openbsd", + "cacheVariables": { + "VCPKG_TARGET_TRIPLET": "x64-openbsd" + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "OpenBSD" + }, + "hidden": true + }, + { + "name": "x64-linux", + "cacheVariables": { + "VCPKG_TARGET_TRIPLET": "x64-linux" + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Linux" + }, + "hidden": true + }, + { + "name": "x64-windows", + "architecture": "x64", + "cacheVariables": { + "VCPKG_TARGET_TRIPLET": "x64-windows" + }, + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + }, + "hidden": true + }, + { + "name": "base", + "binaryDir": "${sourceDir}/build", + "cacheVariables": { + }, + "inherits": ["vcpkg"], + "hidden": true + }, + { + "name": "llvm-base", + "description": "no version suffix", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++", + "LLVM_COV_COMMAND": "llvm-cov", + "LLVM_PROFDATA_COMMAND": "llvm-profdata" + }, + "hidden": true + }, + { + "name": "llvm-14", + "description": "dash character used in version suffix", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang-14", + "CMAKE_CXX_COMPILER": "clang++-14", + "LLVM_COV_COMMAND": "llvm-cov-14", + "LLVM_PROFDATA_COMMAND": "llvm-profdata-14" + }, + "hidden": true + }, + { + "name": "llvm-15", + "description": "dash character used in version suffix", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang-15", + "CMAKE_CXX_COMPILER": "clang++-15", + "LLVM_COV_COMMAND": "llvm-cov-15", + "LLVM_PROFDATA_COMMAND": "llvm-profdata-15" + }, + "hidden": true + }, + { + "name": "llvm-16", + "description": "dash character used in version suffix", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang-16", + "CMAKE_CXX_COMPILER": "clang++-16", + "LLVM_COV_COMMAND": "llvm-cov-16", + "LLVM_PROFDATA_COMMAND": "llvm-profdata-16" + }, + "hidden": true + }, + { + "name": "llvm-17", + "description": "dash character used in version suffix", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang-17", + "CMAKE_CXX_COMPILER": "clang++-17", + "LLVM_COV_COMMAND": "llvm-cov-17", + "LLVM_PROFDATA_COMMAND": "llvm-profdata-17" + }, + "hidden": true + }, + { + "name": "llvm17", + "description": "version suffix", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang17", + "CMAKE_CXX_COMPILER": "clang++17", + "LLVM_COV_COMMAND": "llvm-cov17", + "LLVM_PROFDATA_COMMAND": "llvm-profdata17" + }, + "hidden": true + }, + { + "name": "llvm-cl", + "description": "llvm version integrated into visual studio", + "toolset": "ClangCL", + "hidden": true + }, + { + "name": "ci-base", + "inherits": ["base"], + "cacheVariables": { + }, + "hidden": true + }, + { + "name": "coverage", + "cacheVariables": { + "COVERAGE_REPORT": "On" + }, + "hidden": true + }, + + { + "name": "gh-ubuntu22.04-llvm14-debug", + "inherits": [ "ci-base", "make", "x64-linux", "llvm-14", "debug", "coverage" ] + }, + { + "name": "gh-ubuntu22.04-llvm14-release", + "inherits": [ "ci-base", "make", "x64-linux", "llvm-14", "release" ] + }, + { + "name": "gh-ubuntu22.04-llvm15-debug", + "inherits": [ "ci-base", "make", "x64-linux", "llvm-15", "debug", "coverage" ] + }, + { + "name": "gh-ubuntu22.04-llvm15-release", + "inherits": [ "ci-base", "make", "x64-linux", "llvm-15", "release" ] + }, + { + "name": "ci-x64-linux-debug", + "inherits": [ "ci-base", "make", "x64-linux", "debug", "coverage" ] + }, + { + "name": "ci-x64-linux-release", + "inherits": [ "ci-base", "make", "x64-linux", "release" ] + }, + { + "name": "ci-x64-freebsd-debug", + "inherits": [ "ci-base", "make", "x64-freebsd", "debug" ] + }, + { + "name": "ci-x64-freebsd-release", + "inherits": [ "ci-base", "make", "x64-freebsd", "release" ] + }, + { + "name": "ci-x64-openbsd-debug", + "inherits": [ "ci-base", "make", "x64-openbsd", "debug" ] + }, + { + "name": "ci-x64-openbsd-release", + "inherits": [ "ci-base", "make", "x64-openbsd", "release" ] + }, + { + "name": "ci-x64-windows-vs2022-debug", + "inherits": [ "ci-base", "vs2022", "x64-windows", "debug" ] + }, + { + "name": "ci-x64-windows-vs2022-release", + "inherits": [ "ci-base", "vs2022", "x64-windows", "release" ] + }, + { + "name": "ci-x64-windows-vs2022-llvm-debug", + "inherits": [ "ci-base", "vs2022", "x64-windows", "llvm-cl", "debug" ] + }, + { + "name": "ci-x64-windows-vs2022-llvm-release", + "inherits": [ "ci-base", "vs2022", "x64-windows", "llvm-cl", "release" ] + } + ], + "buildPresets": [ + { + "name": "freebsd", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "FreeBSD" + }, + "hidden": true + }, + { + "name": "openbsd", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "OpenBSD" + }, + "hidden": true + }, + { + "name": "linux", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Linux" + }, + "hidden": true + }, + { + "name": "windows", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + }, + "hidden": true + }, + { + "name": "debug", + "configurePreset": "debug", + "configuration": "Debug", + "hidden": true + }, + { + "name": "release", + "configurePreset": "release", + "configuration": "Release", + "hidden": true + }, + { + "name": "gh-ubuntu22.04-llvm14-debug", + "configurePreset": "gh-ubuntu22.04-llvm14-debug", + "configuration": "Debug", + "inherits": [ "linux" ] + }, + { + "name": "gh-ubuntu22.04-llvm14-release", + "configurePreset": "gh-ubuntu22.04-llvm14-release", + "configuration": "Release", + "inherits": [ "linux" ] + }, + { + "name": "gh-ubuntu22.04-llvm15-debug", + "configurePreset": "gh-ubuntu22.04-llvm15-debug", + "configuration": "Debug", + "inherits": [ "linux" ] + }, + { + "name": "gh-ubuntu22.04-llvm15-release", + "configurePreset": "gh-ubuntu22.04-llvm15-release", + "configuration": "Release", + "inherits": [ "linux" ] + }, + { + "name": "ci-x64-freebsd-debug", + "configurePreset": "ci-x64-freebsd-debug", + "configuration": "Debug", + "inherits": [ "freebsd" ] + }, + { + "name": "ci-x64-freebsd-release", + "configurePreset": "ci-x64-freebsd-release", + "configuration": "Release", + "inherits": [ "freebsd" ] + }, + { + "name": "ci-x64-openbsd-debug", + "configurePreset": "ci-x64-openbsd-debug", + "configuration": "Debug", + "inherits": [ "openbsd" ] + }, + { + "name": "ci-x64-openbsd-release", + "configurePreset": "ci-x64-openbsd-release", + "configuration": "Release", + "inherits": [ "openbsd" ] + }, + { + "name": "ci-x64-linux-debug", + "configurePreset": "ci-x64-linux-debug", + "configuration": "Debug", + "inherits": [ "linux" ] + }, + { + "name": "ci-x64-linux-release", + "configurePreset": "ci-x64-linux-release", + "configuration": "Release", + "inherits": [ "linux" ] + }, + { + "name": "ci-x64-windows-vs2022-debug", + "configurePreset": "ci-x64-windows-vs2022-debug", + "configuration": "Debug", + "inherits": [ "windows" ] + }, + { + "name": "ci-x64-windows-vs2022-release", + "configurePreset": "ci-x64-windows-vs2022-release", + "configuration": "Release", + "inherits": [ "windows" ] + }, + { + "name": "ci-x64-windows-vs2022-llvm-debug", + "configurePreset": "ci-x64-windows-vs2022-llvm-debug", + "configuration": "Debug", + "inherits": [ "windows" ] + }, + { + "name": "ci-x64-windows-vs2022-llvm-release", + "configurePreset": "ci-x64-windows-vs2022-llvm-release", + "configuration": "Release", + "inherits": [ "windows" ] + } + ], + "testPresets": [ + { + "name": "debug", + "configurePreset": "debug", + "configuration": "Debug", + "hidden": true + }, + { + "name": "release", + "configurePreset": "release", + "configuration": "Release", + "hidden": true + }, + { + "name": "ci", + "output": { + "verbosity": "extra" + }, + "hidden": true + }, + { + "name": "freebsd", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "FreeBSD" + }, + "hidden": true + }, + { + "name": "openbsd", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "OpenBSD" + }, + "hidden": true + }, + { + "name": "linux", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Linux" + }, + "hidden": true + }, + { + "name": "windows", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + }, + "hidden": true + }, + { + "name": "gh-ubuntu22.04-llvm14-debug", + "configurePreset": "gh-ubuntu22.04-llvm14-debug", + "inherits": [ "ci", "linux", "debug" ] + }, + { + "name": "gh-ubuntu22.04-llvm14-release", + "configurePreset": "gh-ubuntu22.04-llvm14-release", + "inherits": [ "ci", "linux", "release" ] + }, + { + "name": "gh-ubuntu22.04-llvm15-debug", + "configurePreset": "gh-ubuntu22.04-llvm15-debug", + "inherits": [ "ci", "linux", "debug" ] + }, + { + "name": "gh-ubuntu22.04-llvm15-release", + "configurePreset": "gh-ubuntu22.04-llvm15-release", + "inherits": [ "ci", "linux", "release" ] + }, + { + "name": "ci-x64-freebsd-debug", + "configurePreset": "ci-x64-freebsd-debug", + "inherits": [ "ci", "freebsd", "debug" ] + }, + { + "name": "ci-x64-freebsd-release", + "configurePreset": "ci-x64-freebsd-release", + "inherits": [ "ci", "freebsd", "release" ] + }, + { + "name": "ci-x64-openbsd-debug", + "configurePreset": "ci-x64-openbsd-debug", + "inherits": [ "ci", "openbsd", "debug" ] + }, + { + "name": "ci-x64-openbsd-release", + "configurePreset": "ci-x64-openbsd-release", + "inherits": [ "ci", "openbsd", "release" ] + }, + { + "name": "ci-x64-linux-debug", + "configurePreset": "ci-x64-linux-debug", + "inherits": [ "ci", "linux", "debug" ] + }, + { + "name": "ci-x64-linux-release", + "configurePreset": "ci-x64-linux-release", + "inherits": [ "ci", "linux", "release" ] + }, + { + "name": "ci-x64-windows-vs2022-debug", + "configurePreset": "ci-x64-windows-vs2022-debug", + "inherits": [ "ci", "windows", "debug" ] + }, + { + "name": "ci-x64-windows-vs2022-release", + "configurePreset": "ci-x64-windows-vs2022-release", + "inherits": [ "ci", "windows", "release" ] + }, + { + "name": "ci-x64-windows-vs2022-llvm-debug", + "configurePreset": "ci-x64-windows-vs2022-llvm-debug", + "inherits": [ "ci", "windows", "debug" ] + }, + { + "name": "ci-x64-windows-vs2022-llvm-release", + "configurePreset": "ci-x64-windows-vs2022-llvm-release", + "inherits": [ "ci", "windows", "release" ] + } + ] +} diff --git a/README.md b/README.md index 18b20c3..d791a06 100644 --- a/README.md +++ b/README.md @@ -1 +1,8 @@ -Run `build.ps1` to build and `run.ps1` to execute the demo. If the invoking session is not in the checkout directory, the `GITHUB_WORKSPACE` environment variable needs to point to the checkout path. +Run `cmake --list-presets` to display a set of supported presets, and then use + +``` +cmake --preset ${preset} +cmake --build --preset ${preset} +ctest --preset ${preset} +``` +in order to build and and execute the demo application. diff --git a/build.ps1 b/build.ps1 deleted file mode 100644 index 4c6027f..0000000 --- a/build.ps1 +++ /dev/null @@ -1,10 +0,0 @@ -if (${env:GITHUB_WORKSPACE} -eq ${null}) { - ${env:GITHUB_WORKSPACE}=${pwd} -} - -cmake -E make_directory ${env:GITHUB_WORKSPACE}/build - -pushd ${env:GITHUB_WORKSPACE}/build - cmake -DCMAKE_TOOLCHAIN_FILE="${env:GITHUB_WORKSPACE}/vcpkg/scripts/buildsystems/vcpkg.cmake" .. - cmake --build . --config Release -- "-v:n" -popd \ No newline at end of file diff --git a/run.ps1 b/run.ps1 deleted file mode 100644 index f794bb2..0000000 --- a/run.ps1 +++ /dev/null @@ -1,7 +0,0 @@ -if (${env:GITHUB_WORKSPACE} -eq ${null}) { - ${env:GITHUB_WORKSPACE}=${pwd} -} - -pushd ${env:GITHUB_WORKSPACE}/build - ctest --build-config Release --extra-verbose -popd