CMake presets. (#744)

* CI: use single build action
* CMake: use imported targets
* CI: do not build boost for linux
* CMake: add FORCE_BUNDLED_MINIZIP option
* linux: use external minizip and fuzzylite
* CMake: add presets
* .gitignore: ignore cmake build dirs
* github: use cmake presets
This commit is contained in:
Konstantin authored and GitHub committed 2022-05-26 08:55:20 +03:00
1 parent a8265c7052
commit 8fc14369a4
27 files changed
+1413 -688

No files matched your search

+41 -39
View File
@@ -8,7 +8,7 @@ on:
pull_request:
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
BUILD_TYPE: RelWithDebInfo
jobs:
build:
@@ -17,22 +17,18 @@ jobs:
include:
- platform: linux
os: ubuntu-20.04
cc: clang-10
cxx: clang++-10
test: 0
cmake_args: -G Ninja
preset: linux-clang-release
- platform: linux
os: ubuntu-20.04
cc: gcc-9
cxx: g++-9
test: 0
cmake_args: -G Ninja
preset: linux-gcc-release
- platform: mac
os: macos-latest
test: 0
pack: 1
extension: dmg
cmake_args: -G Ninja
preset: macos-ninja-release
- platform: mxe
os: ubuntu-20.04
mxe: i686-w64-mingw32.shared
@@ -46,15 +42,14 @@ jobs:
test: 0
pack: 1
extension: exe
cmake_args: -G "Visual Studio 17 2022" -A x64 '-DCMAKE_TOOLCHAIN_FILE=vcpkg/scripts/buildsystems/vcpkg.cmake'
preset: windows-msvc-release
runs-on: ${{ matrix.os }}
defaults:
run:
shell: bash
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
submodules: recursive
@@ -63,7 +58,7 @@ jobs:
env:
MXE_TARGET: ${{ matrix.mxe }}
VCMI_BUILD_PLATFORM: x64
- name: Git branch name
id: git-branch-name
uses: EthanSK/git-branch-name-action@v1
@@ -77,10 +72,13 @@ jobs:
PULL_REQUEST: ${{ github.event.pull_request.number }}
- name: Configure CMake
if: "${{ matrix.preset == '' }}"
run: |
mkdir '${{github.workspace}}/build'
cd '${{github.workspace}}/build'
cmake ${{matrix.cmake_args}} .. -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
mkdir -p '${{github.workspace}}/out/build/${{matrix.preset}}'
cd '${{github.workspace}}/out/build/${{matrix.preset}}'
cmake \
../.. -GNinja \
${{matrix.cmake_args}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
-DENABLE_TEST=${{matrix.test}} \
-DPACKAGE_NAME_SUFFIX:STRING="$VCMI_PACKAGE_NAME_SUFFIX" \
-DPACKAGE_FILE_NAME:STRING="$VCMI_PACKAGE_FILE_NAME"
@@ -88,54 +86,58 @@ jobs:
CC: ${{ matrix.cc }}
CXX: ${{ matrix.cxx }}
- name: CMake Preset
if: "${{ matrix.preset != '' }}"
run: |
cmake --preset ${{ matrix.preset }}
- name: Build
if: ${{ matrix.platform != 'msvc' }}
if: "${{ matrix.preset == '' }}"
run: |
cd '${{github.workspace}}/build'
ninja
- name: Build MSVC
if: ${{ matrix.platform == 'msvc' }}
cmake --build '${{github.workspace}}/out/build/${{matrix.preset}}'
- name: Build Preset
if: "${{ matrix.preset != '' }}"
run: |
cd '${{github.workspace}}/build'
cmake --build . --config ${{env.BUILD_TYPE}}
cmake --build --preset ${{matrix.preset}}
- name: Test
if: ${{ matrix.test == 1 }}
if: ${{ matrix.test == 1 && matrix.preset != ''}}
run: |
cd '${{github.workspace}}/build'
ctest -C Release -V
ctest --preset ${{matrix.preset}}
- name: Pack
id: cpack
if: ${{ matrix.pack == 1 }}
run: |
cd '${{github.workspace}}/build'
cd '${{github.workspace}}/out/build/${{matrix.preset}}'
CPACK_PATH=`which -a cpack | grep -m1 -v -i chocolatey`
"$CPACK_PATH" -C Release ${{ matrix.cpack_args }}
"$CPACK_PATH" -C ${{env.BUILD_TYPE}} ${{ matrix.cpack_args }}
rm -rf _CPack_Packages
- name: Additional logs
if: ${{ failure() && steps.cpack.outcome == 'failure' && matrix.platform == 'mxe' }}
run: |
cat '${{github.workspace}}/build/_CPack_Packages/win32/NSIS/project.nsi'
cat '${{github.workspace}}/build/_CPack_Packages/win32/NSIS/NSISOutput.log'
cat '${{github.workspace}}/out/build/${{matrix.preset}}/_CPack_Packages/win32/NSIS/project.nsi'
cat '${{github.workspace}}/out/build/${{matrix.preset}}/_CPack_Packages/win32/NSIS/NSISOutput.log'
- name: Artifacts
if: ${{ matrix.pack == 1 }}
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v3
with:
name: ${{ env.VCMI_PACKAGE_FILE_NAME }} - ${{ matrix.platform }}
path: ${{github.workspace}}/build/${{ env.VCMI_PACKAGE_FILE_NAME }}.${{ matrix.extension }}
path: |
${{github.workspace}}/**/${{ env.VCMI_PACKAGE_FILE_NAME }}.${{ matrix.extension }}
- name: Upload build
if: ${{ matrix.pack == 1 && github.ref == 'refs/heads/develop' && matrix.platform != 'msvc' }}
run: |
cd '${{github.workspace}}/build'
cd '${{github.workspace}}/out/build/${{matrix.preset}}'
source '${{github.workspace}}/CI/upload_package.sh'
env:
DEPLOY_RSA: ${{ secrets.DEPLOY_RSA }}
PACKAGE_EXTENSION: ${{ matrix.extension }}
- uses: act10ns/slack@v1
with:
status: ${{ job.status }}
@@ -143,7 +145,7 @@ jobs:
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: always()
- name: Trigger Android
uses: peter-evans/repository-dispatch@v1
if: ${{ github.ref == 'refs/heads/develop' && matrix.platform == 'mxe' }}