diff --git a/.github/workflows/linux-clang-build.yml b/.github/workflows/linux-clang-build.yml index 2a913bc1d..6caeeaaad 100644 --- a/.github/workflows/linux-clang-build.yml +++ b/.github/workflows/linux-clang-build.yml @@ -7,9 +7,6 @@ on: workflow_dispatch: pull_request: -env: - BUILD_TYPE: Debug - jobs: build: runs-on: ubuntu-24.04 @@ -20,33 +17,25 @@ jobs: with: submodules: recursive - - name: Install apt-get dependencies - run: | - sudo apt -qq update \ - && sudo apt install -y --no-install-recommends --no-install-suggests ninja-build - - - name: Initialize submodules - run: git submodule update --init --recursive + - name: Install Ninja + uses: seanmiddleditch/gha-setup-ninja@master - name: Configure CMake run: | - cmake -S ${{github.workspace}} -B ${{github.workspace}}/build \ - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ + cmake -S ${{github.workspace}} --preset=unixlike-clang-debug \ -DCMAKE_C_COMPILER=/usr/bin/clang-18 \ -DCMAKE_CXX_COMPILER=/usr/bin/clang++-18 \ -DCODE_COVERAGE:BOOL=ON \ - -DBUILD_TESTING:BOOL=ON \ - -GNinja + -DBUILD_TESTING:BOOL=ON - name: Build - run: cmake --build ${{github.workspace}}/build + run: cmake --build --preset=unixlike-clang-debug - name: Test - working-directory: ${{github.workspace}}/build/tests - run: ctest --output-on-failure + run: ctest --preset=unixlike-clang-debug - name: Generate code coverage - working-directory: ${{github.workspace}}/build + working-directory: ${{github.workspace}}/build/unixlike-clang-debug run: | ninja faker-ccov-all \ && llvm-cov-18 show `cat ccov/binaries.list` -instr-profile=ccov/all-merged.profdata > coverage.txt diff --git a/.github/workflows/linux-gcc-12.yml b/.github/workflows/linux-gcc-12.yml deleted file mode 100644 index 57061eeea..000000000 --- a/.github/workflows/linux-gcc-12.yml +++ /dev/null @@ -1,46 +0,0 @@ -name: gcc-12 - -on: - push: - branches: - - 'main' - workflow_dispatch: - pull_request: - -env: - BUILD_TYPE: Debug - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - submodules: recursive - - - name: Install apt-get dependencies - run: | - sudo add-apt-repository ppa:ubuntu-toolchain-r/test - sudo apt-get update - sudo apt-get install -y g++-12 ninja-build build-essential - - - name: Initialize submodules - run: git submodule update --init --recursive - - - name: Configure CMake - run: | - cmake -B ${{github.workspace}}/build \ - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ - -DCMAKE_C_COMPILER=gcc-12 \ - -DCMAKE_CXX_COMPILER=g++-12 \ - -DBUILD_TESTING:BOOL=ON \ - -GNinja - - - name: Build - run: cmake --build ${{github.workspace}}/build - - - name: Test - working-directory: ${{github.workspace}}/build/tests - run: ctest --output-on-failure diff --git a/.github/workflows/linux-gxx-build.yml b/.github/workflows/linux-gxx-build.yml index c50c37ffb..e67fd544d 100644 --- a/.github/workflows/linux-gxx-build.yml +++ b/.github/workflows/linux-gxx-build.yml @@ -7,21 +7,33 @@ on: workflow_dispatch: pull_request: -env: - BUILD_TYPE: Debug - jobs: build: - runs-on: ubuntu-latest - + name: ci-ubuntu-24.04-gcc-${{ matrix.gcc_version }} + runs-on: ubuntu-24.04 + strategy: + matrix: + gcc_version: + - 12 + - 13 steps: - name: Checkout uses: actions/checkout@v3 with: submodules: recursive - - name: Build docker image - run: docker build -t test . + - name: Install Ninja + uses: seanmiddleditch/gha-setup-ninja@master + + - name: Configure CMake + run: | + cmake -S . --preset=unixlike-gcc-debug \ + -DCMAKE_C_COMPILER=gcc-${{ matrix.gcc_version }} \ + -DCMAKE_CXX_COMPILER=g++-${{ matrix.gcc_version }} \ + -DBUILD_TESTING:BOOL=ON + + - name: Build + run: cmake --build --preset=unixlike-gcc-debug - - name: Run docker container - run: docker run test + - name: Test + run: ctest --preset=unixlike-gcc-debug diff --git a/.github/workflows/macos-clang-build.yml b/.github/workflows/macos-clang-build.yml index cf385276b..fbf647667 100644 --- a/.github/workflows/macos-clang-build.yml +++ b/.github/workflows/macos-clang-build.yml @@ -7,8 +7,6 @@ on: workflow_dispatch: pull_request: -env: - BUILD_TYPE: Debug jobs: build: @@ -23,15 +21,17 @@ jobs: with: submodules: recursive + - name: Install Ninja + uses: seanmiddleditch/gha-setup-ninja@master + - name: Configure CMake run: | - cmake -B ${{github.workspace}}/build \ - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ + cmake -S . --preset=unixlike-clang-debug \ -DBUILD_TESTING:BOOL=ON \ -DCMAKE_CXX_COMPILER=clang++ - name: Build - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} + run: cmake --build --preset=unixlike-clang-debug - - working-directory: build/tests - run: ./faker-cxx-UT + - name: Test + run: ctest --preset=unixlike-clang-debug diff --git a/.github/workflows/windows-msvc-build.yml b/.github/workflows/windows-msvc-build.yml index 5a066b614..c6709fb83 100644 --- a/.github/workflows/windows-msvc-build.yml +++ b/.github/workflows/windows-msvc-build.yml @@ -7,9 +7,6 @@ on: workflow_dispatch: pull_request: -env: - BUILD_TYPE: Debug - jobs: build: runs-on: windows-latest @@ -20,13 +17,18 @@ jobs: with: submodules: recursive - - run: cmake -E make_directory build + - name: Install Ninja + uses: seanmiddleditch/gha-setup-ninja@master + + - name: Configure cl.exe in PATH + uses: ilammy/msvc-dev-cmd@v1 - - working-directory: build/ - run: cmake .. -G "Visual Studio 17 2022" -DBUILD_TESTING:BOOL=ON + - name: Configure CMake + run: | + cmake -S . --preset=windows-msvc-debug -DBUILD_TESTING:BOOL=ON - - working-directory: build/ - run: cmake --build . --config ${{env.BUILD_TYPE}} + - name: Build + run: cmake --build --preset=windows-msvc-debug - - working-directory: build/tests - run: ctest -C ${{env.BUILD_TYPE}} --output-on-failure + - name: Test + run: ctest --preset=windows-msvc-debug diff --git a/CMakePresets.json b/CMakePresets.json new file mode 100644 index 000000000..4c391361c --- /dev/null +++ b/CMakePresets.json @@ -0,0 +1,214 @@ +{ + "version": 6, + "cmakeMinimumRequired": { + "major": 3, + "minor": 23, + "patch": 0 + }, + "configurePresets": [ + { + "name": "conf-common", + "description": "General settings that apply to all configurations", + "hidden": true, + "generator": "Ninja", + "binaryDir": "${sourceDir}/build/${presetName}", + "installDir": "${sourceDir}/install/${presetName}", + "cacheVariables": { + "USE_SYSTEM_DEPENDENCIES": "FALSE" + } + }, + { + "name": "conf-windows-common", + "description": "Windows settings for MSBuild toolchain that apply to msvc and clang", + "hidden": true, + "inherits": "conf-common", + "condition": { + "type": "equals", + "lhs": "${hostSystemName}", + "rhs": "Windows" + }, + "architecture": { + "value": "x64", + "strategy": "external" + }, + "toolset": { + "value": "host=x64", + "strategy": "external" + } + }, + { + "name": "conf-unixlike-common", + "description": "Unix-like OS settings for gcc and clang toolchains", + "hidden": true, + "inherits": "conf-common", + "condition": { + "type": "inList", + "string": "${hostSystemName}", + "list": [ + "Linux", + "Darwin" + ] + } + }, + { + "name": "windows-msvc-debug", + "displayName": "msvc Debug ", + "description": "Target Windows with the msvc compiler, debug build type", + "inherits": "conf-windows-common", + "cacheVariables": { + "CMAKE_C_COMPILER": "cl.exe", + "CMAKE_CXX_COMPILER": "cl.exe", + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "windows-msvc-release", + "displayName": "msvc Release", + "description": "Target Windows with the msvc compiler, release build type", + "inherits": "conf-windows-common", + "cacheVariables": { + "CMAKE_C_COMPILER": "cl.exe", + "CMAKE_CXX_COMPILER": "cl.exe", + "CMAKE_BUILD_TYPE": "RelWithDebInfo" + } + }, + { + "name": "unixlike-gcc-debug", + "displayName": "gcc Debug", + "description": "Target Unix-like OS with the gcc compiler, debug build type", + "inherits": "conf-unixlike-common", + "cacheVariables": { + "CMAKE_C_COMPILER": "gcc", + "CMAKE_CXX_COMPILER": "g++", + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "unixlike-gcc-release", + "displayName": "gcc Release", + "description": "Target Unix-like OS with the gcc compiler, release build type", + "inherits": "conf-unixlike-common", + "cacheVariables": { + "CMAKE_C_COMPILER": "gcc", + "CMAKE_CXX_COMPILER": "g++", + "CMAKE_BUILD_TYPE": "Release" + } + }, + { + "name": "unixlike-clang-debug", + "displayName": "clang Debug", + "description": "Target Unix-like OS with the clang compiler, debug build type", + "inherits": "conf-unixlike-common", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++", + "CMAKE_BUILD_TYPE": "Debug" + } + }, + { + "name": "unixlike-clang-release", + "displayName": "clang Release", + "description": "Target Unix-like OS with the clang compiler, release build type", + "inherits": "conf-unixlike-common", + "cacheVariables": { + "CMAKE_C_COMPILER": "clang", + "CMAKE_CXX_COMPILER": "clang++", + "CMAKE_BUILD_TYPE": "RelWithDebInfo" + } + } + ], + "buildPresets": [ + { + "name": "unixlike-gcc-release", + "displayName": "Library Release Build", + "configurePreset": "unixlike-gcc-release", + "configuration": "Release" + }, + { + "name": "unixlike-gcc-debug", + "displayName": "Library Debug Build", + "configurePreset": "unixlike-gcc-debug", + "configuration": "Debug" + }, + { + "name": "unixlike-clang-release", + "displayName": "Library Release Build", + "configurePreset": "unixlike-clang-release", + "configuration": "Release" + }, + { + "name": "unixlike-clang-debug", + "displayName": "Library Debug Build", + "configurePreset": "unixlike-clang-debug", + "configuration": "Debug" + }, + { + "name": "windows-msvc-release", + "displayName": "Library Release Build", + "configurePreset": "windows-msvc-release", + "configuration": "Release" + }, + { + "name": "windows-msvc-debug", + "displayName": "Library Debug Build", + "configurePreset": "windows-msvc-debug", + "configuration": "Debug" + } + ], + "testPresets": [ + { + "name": "test-common", + "description": "Test CMake settings that apply to all configurations", + "hidden": true, + "output": { + "outputOnFailure": true + }, + "execution": { + "noTestsAction": "error", + "stopOnFailure": true + } + }, + { + "name": "windows-msvc-debug", + "displayName": "Strict", + "description": "Enable output and stop on failure", + "inherits": "test-common", + "configurePreset": "windows-msvc-debug" + }, + { + "name": "windows-msvc-release", + "displayName": "Strict", + "description": "Enable output and stop on failure", + "inherits": "test-common", + "configurePreset": "windows-msvc-release" + }, + { + "name": "unixlike-gcc-debug", + "displayName": "Strict", + "description": "Enable output and stop on failure", + "inherits": "test-common", + "configurePreset": "unixlike-gcc-debug" + }, + { + "name": "unixlike-gcc-release", + "displayName": "Strict", + "description": "Enable output and stop on failure", + "inherits": "test-common", + "configurePreset": "unixlike-gcc-release" + }, + { + "name": "unixlike-clang-debug", + "displayName": "Strict", + "description": "Enable output and stop on failure", + "inherits": "test-common", + "configurePreset": "unixlike-clang-debug" + }, + { + "name": "unixlike-clang-release", + "displayName": "Strict", + "description": "Enable output and stop on failure", + "inherits": "test-common", + "configurePreset": "unixlike-clang-release" + } + ] +} \ No newline at end of file