Skip to content

Refactor build system to use cmake to fetch dependencies #87

Refactor build system to use cmake to fetch dependencies

Refactor build system to use cmake to fetch dependencies #87

Workflow file for this run

---
name: Build and Test
on:
workflow_dispatch:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Format
run: find src include test -iregex '.*\.\(c\|h\|cpp\|hpp\|cc\|hh\|cxx\|hxx\)$' | xargs clang-format -n -Werror
build-linux:
runs-on: ubuntu-latest
env:
CMAKE_GENERATOR: Ninja
CMAKE_BUILD_TYPE: Debug
BUILD_DIR: build-linux64-debug
BUILD_LIBS_DIR: build-linux64-libs-debug
steps:
- uses: actions/checkout@v3
- name: Install compiler tools
run: |
sudo apt-get -y update
sudo apt-get -y install cmake ninja-build
- name: Build without getlibs
run: |
export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc)
cmake -S . -B $BUILD_DIR -DUBSAN=ON
cmake --build $BUILD_DIR --config $CMAKE_BUILD_TYPE
(cd $BUILD_DIR && ctest -C $CMAKE_BUILD_TYPE --output-on-failure)
- name: Get dependencies
run: |
CMAKE_BUILD_TYPE=Release ./getlibs.sh linux64
- name: Build with getlibs
run: |
export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc)
cmake -S . -B $BUILD_LIBS_DIR -DCMAKE_PREFIX_PATH="$PWD/libs-linux64" -DUBSAN=ON -DFIND_FATAL=ON
cmake --build $BUILD_LIBS_DIR --config $CMAKE_BUILD_TYPE
(cd $BUILD_LIBS_DIR && ctest -C $CMAKE_BUILD_TYPE --output-on-failure)
build-win:
runs-on: ubuntu-latest
env:
WINARCH: win64
CMAKE_GENERATOR: Ninja
CMAKE_BUILD_TYPE: Debug
CMAKE_TOOLCHAIN_FILE: ${{ github.workspace }}/toolchains/mingw.cmake
BUILD_DIR: build-win64-debug
BUILD_LIBS_DIR: build-win64-libs-debug
steps:
- uses: actions/checkout@v3
- name: Install cross-compiler tools
run: |
sudo apt-get -y update
sudo apt-get -y install cmake ninja-build g++-mingw-w64-x86-64 mingw-w64-x86-64-dev mingw-w64-tools wine wine-binfmt
sudo update-alternatives --set x86_64-w64-mingw32-gcc /usr/bin/x86_64-w64-mingw32-gcc-posix
sudo update-alternatives --set x86_64-w64-mingw32-g++ /usr/bin/x86_64-w64-mingw32-g++-posix
- name: Build without getlibs
run: |
export WINEPATH=$("$PWD/mingw-winepath.sh")
export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc)
cmake -S . -B $BUILD_DIR
cmake --build $BUILD_DIR --config $CMAKE_BUILD_TYPE
(cd $BUILD_DIR && ctest -C $CMAKE_BUILD_TYPE --output-on-failure)
- name: Get dependencies
run: |
CMAKE_BUILD_TYPE=Release CMAKE_TOOLCHAIN_FILE="$PWD/toolchains/mingw.cmake" ./getlibs.sh win64
- name: Build with getlibs
run: |
export WINEPATH=$("$PWD/mingw-winepath.sh")
export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc)
cmake -S . -B $BUILD_LIBS_DIR -DCMAKE_PREFIX_PATH="$PWD/libs-win64" -DFIND_FATAL=ON
cmake --build $BUILD_LIBS_DIR --config $CMAKE_BUILD_TYPE
(cd $BUILD_LIBS_DIR && ctest -C $CMAKE_BUILD_TYPE --output-on-failure)
build-macos:
runs-on: macos-latest
env:
CMAKE_GENERATOR: Ninja
CMAKE_BUILD_TYPE: Debug
BUILD_DIR: build-macos64-debug
BUILD_LIBS_DIR: build-macos64-libs-debug
steps:
- uses: actions/checkout@v3
- name: Install Ninja
run: |
brew install ninja
- name: Build without getlibs
run: |
export CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.ncpu)
cmake -S . -B $BUILD_DIR
cmake --build $BUILD_DIR --config $CMAKE_BUILD_TYPE
(cd $BUILD_DIR && ctest -C $CMAKE_BUILD_TYPE --output-on-failure)
- name: Get dependencies
run: |
CMAKE_BUILD_TYPE=Release ./getlibs.sh macos64
- name: Build with getlibs
run: |
export CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.ncpu)
cmake -S . -B $BUILD_LIBS_DIR -DCMAKE_PREFIX_PATH="$PWD/libs-macos64" -DFIND_FATAL=ON
cmake --build $BUILD_LIBS_DIR --config $CMAKE_BUILD_TYPE
(cd $BUILD_LIBS_DIR && ctest -C $CMAKE_BUILD_TYPE --output-on-failure)