From b57e85aee52b6ebb103dc13d0410c5ae3d8cb9d1 Mon Sep 17 00:00:00 2001 From: Ranieri Althoff <1993083+ranisalt@users.noreply.github.com> Date: Wed, 3 May 2023 19:31:37 -0700 Subject: [PATCH] Cleanup GitHub workflows using CMake presets (#4435) --- .github/workflows/build-ubuntu.yml | 11 ++++++-- .github/workflows/build-vcpkg.yml | 34 ++++------------------ .github/workflows/release-vcpkg.yml | 6 ++-- .github/workflows/test.yml | 8 +++--- CMakeLists.txt | 2 -- CMakePresets.json | 44 +++++++++++------------------ 6 files changed, 39 insertions(+), 66 deletions(-) diff --git a/.github/workflows/build-ubuntu.yml b/.github/workflows/build-ubuntu.yml index 653e87963c..8b72eef219 100644 --- a/.github/workflows/build-ubuntu.yml +++ b/.github/workflows/build-ubuntu.yml @@ -21,7 +21,13 @@ on: jobs: build-ubuntu: + name: ubuntu-${{ matrix.buildtype }}-luajit=${{ matrix.luajit }} runs-on: ubuntu-latest + strategy: + matrix: + buildtype: [Debug, Release] + luajit: [on, off] + steps: - uses: actions/checkout@v3 @@ -39,8 +45,9 @@ jobs: - name: Build with cmake uses: lukka/run-cmake@v10 with: - buildPreset: ninja - configurePreset: ninja + buildPreset: default + buildPresetAdditionalArgs: "['--config ${{ matrix.buildtype }}']" + configurePreset: default - name: Upload artifact binary uses: actions/upload-artifact@v3 diff --git a/.github/workflows/build-vcpkg.yml b/.github/workflows/build-vcpkg.yml index 243c0b697e..bf0fdb6852 100644 --- a/.github/workflows/build-vcpkg.yml +++ b/.github/workflows/build-vcpkg.yml @@ -23,31 +23,13 @@ on: jobs: build-vcpkg: - name: ${{ matrix.name }}-${{ matrix.buildtype }}-luajit=${{ matrix.luajit }} + name: ${{ matrix.os }}-${{ matrix.buildtype }}-luajit=${{ matrix.luajit }} runs-on: ${{ matrix.os }}-latest strategy: matrix: - name: [ubuntu, ubuntu-clang, macos-clang, windows-msvc] + os: [ubuntu, macos, windows] buildtype: [Debug, Release] luajit: [on, off] - include: - - name: ubuntu - os: ubuntu - - name: ubuntu-clang - os: ubuntu - - name: macos-clang - os: macos - - name: windows-msvc - os: windows - exclude: - - name: ubuntu-clang - buildtype: Release - - name: ubuntu-clang - luajit: off - - name: macos-clang - luajit: off - - name: windows-msvc - luajit: off steps: - uses: actions/checkout@v3 @@ -60,12 +42,6 @@ jobs: if: ${{ matrix.luajit }} == "on" run: echo "VCPKG_FEATURE_FLAGS=luajit" >> $GITHUB_ENV - - name: Set clang as compiler - if: ${{ endsWith(matrix.name, 'clang') }} - run: | - echo "CC=clang" >> $GITHUB_ENV - echo "CXX=clang++" >> $GITHUB_ENV - - name: Run vcpkg uses: lukka/run-vcpkg@v11 with: @@ -74,8 +50,10 @@ jobs: - name: Build with CMake uses: lukka/run-cmake@v10 with: - buildPreset: ninja-vcpkg - configurePreset: ninja-vcpkg + buildPreset: vcpkg + buildPresetAdditionalArgs: "['--config ${{ matrix.buildtype }}', '--clean-first']" + configurePreset: vcpkg + configurePresetAdditionalArgs: "['-G Ninja']" - name: Upload artifact binary uses: actions/upload-artifact@v3 diff --git a/.github/workflows/release-vcpkg.yml b/.github/workflows/release-vcpkg.yml index f1ec1cc690..f1e62197d6 100644 --- a/.github/workflows/release-vcpkg.yml +++ b/.github/workflows/release-vcpkg.yml @@ -31,8 +31,10 @@ jobs: - name: Build with CMake uses: lukka/run-cmake@v10 with: - buildPreset: ninja-vcpkg - configurePreset: ninja-vcpkg + buildPreset: vcpkg + buildPresetAdditionalArgs: "['--config Release', '--clean-first']" + configurePreset: vcpkg + configurePresetAdditionalArgs: "['-G Ninja']" - name: Prepare datapack contents run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 18ec958710..2166968218 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -27,7 +27,7 @@ jobs: - name: Build with CMake uses: lukka/run-cmake@v10 with: - buildPreset: ninja - configurePreset: ninja - configurePresetAdditionalArgs: "['-DENABLE_TESTING=ON']" - testPreset: ninja + buildPreset: default + configurePreset: default + configurePresetAdditionalArgs: "['-G Ninja', '-DENABLE_TESTING=ON']" + testPreset: default diff --git a/CMakeLists.txt b/CMakeLists.txt index 095d8d4eea..65c3755dbd 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,8 +19,6 @@ if (NOT WIN32) add_compile_options(-Wall -Werror -pipe -fvisibility=hidden) endif () -set(CMAKE_CXX_FLAGS_PERFORMANCE "${CMAKE_CXX_FLAGS_RELEASE} -march=native") - if (CMAKE_COMPILER_IS_GNUCXX) add_compile_options(-fno-strict-aliasing) endif () diff --git a/CMakePresets.json b/CMakePresets.json index a3d4cb8057..e81829f11d 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,50 +1,38 @@ { - "version": 2, - "cmakeMinimumRequired": { - "major": 3, - "minor": 20, - "patch": 2 - }, + "version": 3, "configurePresets": [ { - "name": "ninja", - "displayName": "Ninja", + "name": "default", "description": "Generate Ninja project files", - "binaryDir": "${sourceDir}/build", - "generator": "Ninja" + "binaryDir": "${sourceDir}/build" }, { - "name": "ninja-vcpkg", - "displayName": "Ninja", + "name": "vcpkg", + "inherits": [ + "default" + ], "description": "Configure with vcpkg toolchain and generate Ninja project files", - "binaryDir": "${sourceDir}/build", - "generator": "Ninja", - "cacheVariables": { - "CMAKE_TOOLCHAIN_FILE": { - "type": "FILEPATH", - "value": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" - } - } + "toolchainFile": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" } ], "buildPresets": [ { - "name": "ninja", - "configurePreset": "ninja" + "name": "default", + "configurePreset": "default" }, { - "name": "ninja-vcpkg", - "configurePreset": "ninja-vcpkg" + "name": "vcpkg", + "configurePreset": "vcpkg" } ], "testPresets": [ { - "name": "ninja", - "configurePreset": "ninja" + "name": "default", + "configurePreset": "default" }, { - "name": "ninja-vcpkg", - "configurePreset": "ninja-vcpkg" + "name": "vcpkg", + "configurePreset": "vcpkg" } ] }