diff --git a/.github/workflows/cmake-linux.yml b/.github/workflows/cmake-linux.yml new file mode 100644 index 0000000..8d74118 --- /dev/null +++ b/.github/workflows/cmake-linux.yml @@ -0,0 +1,57 @@ +name: Linux Build (GCC & Clang) + +on: + push: + branches: [ "**" ] + pull_request: + branches: [ "master" ] + +jobs: + build-linux: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + compiler: [gcc, clang] + build_type: [Release] + shared: [ON, OFF] + include: + - compiler: gcc + c: gcc + cxx: g++ + - compiler: clang + c: clang + cxx: clang++ + + steps: + - name: Checkout repository with submodules + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Install compilers + run: | + sudo apt-get update + if [[ "${{ matrix.compiler }}" == "clang" ]]; then + sudo apt-get install -y clang + else + sudo apt-get install -y build-essential + fi + + - name: Configure CMake (Linux) + run: > + cmake -B build + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + -DCMAKE_C_COMPILER=${{ matrix.c }} + -DCMAKE_CXX_COMPILER=${{ matrix.cxx }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DPYRO_COMMON_BUILD_TESTS=ON + -DPYRO_COMMON_SHARED_LIBRARY=${{ matrix.shared }} + -S . + + - name: Build (Linux) + run: cmake --build build --config ${{ matrix.build_type }} --parallel 4 + + - name: Run tests + working-directory: build + run: ctest --build-config ${{ matrix.build_type }} diff --git a/.github/workflows/cmake-macos.yml b/.github/workflows/cmake-macos.yml new file mode 100644 index 0000000..ce21eca --- /dev/null +++ b/.github/workflows/cmake-macos.yml @@ -0,0 +1,40 @@ +name: macOS Build (AppleClang x86 & ARM) + +on: + push: + branches: [ "**" ] + pull_request: + branches: [ "master" ] + +jobs: + build-macos: + runs-on: macos-latest + strategy: + fail-fast: false + matrix: + arch: [x86_64, arm64] + build_type: [Release] + shared: [ON, OFF] + + steps: + - name: Checkout repository with submodules + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Configure CMake (macOS) + run: > + cmake -B build + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + -DCMAKE_OSX_ARCHITECTURES=${{ matrix.arch }} + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DPYRO_COMMON_BUILD_TESTS=ON + -DPYRO_COMMON_SHARED_LIBRARY=${{ matrix.shared }} + -S . + + - name: Build (macOS) + run: cmake --build build --config ${{ matrix.build_type }} --parallel 4 + + - name: Run tests + working-directory: build + run: ctest --build-config ${{ matrix.build_type }} diff --git a/.github/workflows/cmake-multi-platform.yml b/.github/workflows/cmake-multi-platform.yml deleted file mode 100644 index 40d82e8..0000000 --- a/.github/workflows/cmake-multi-platform.yml +++ /dev/null @@ -1,112 +0,0 @@ -# This starter workflow is for a CMake project running on multiple platforms. -# There is a different starter workflow if you just want a single platform. -# See: https://github.com/actions/starter-workflows/blob/main/ci/cmake-single-platform.yml -name: CMake on multiple platforms - -on: - push: - branches: [ "**" ] - pull_request: - branches: [ "master" ] - -jobs: - build: - runs-on: ${{ matrix.os }} - - strategy: - # Set fail-fast to false to ensure that feedback is delivered for all matrix combinations. Consider changing this to true when your workflow is stable. - fail-fast: false - - # Set up a matrix to run the following 3 configurations: - # 1. - # 2. - # 3. - # - # To add more build types (Release, Debug, RelWithDebInfo, etc.) customize the build_type list. - matrix: - os: [ubuntu-latest, windows-latest] - build_type: [Release] - c_compiler: [gcc, clang, cl] - include: - - os: windows-latest - c_compiler: cl - cpp_compiler: cl - - os: ubuntu-latest - c_compiler: gcc - cpp_compiler: g++ - - os: ubuntu-latest - c_compiler: clang - cpp_compiler: clang++ - exclude: - - os: windows-latest - c_compiler: gcc - - os: windows-latest - c_compiler: clang - - os: ubuntu-latest - c_compiler: cl - - steps: - - name: Set reusable strings - # Turn repeated input strings (such as the build output directory) into - # step outputs. These step outputs can be used throughout the workflow - # file. - id: strings - shell: bash - run: | - echo "build-output-dir=${{ github.workspace }}/build" >> "$GITHUB_OUTPUT" - - name: Checkout repository with submodules - uses: actions/checkout@v4 - with: - submodules: recursive - - # - name: Get Ninja - # uses: seanmiddleditch/gha-setup-ninja@master - - # - name: ccache - # uses: hendrikmuhs/ccache-action@v1.2.11 - # with: - # key: ${{ matrix.os }}-${{ matrix.cpp_compiler }} - - - name: Configure CMake - run: > - cmake -B ${{ steps.strings.outputs.build-output-dir }} - -DCMAKE_POLICY_VERSION_MINIMUM=3.5 - -DCMAKE_CXX_COMPILER=${{ matrix.cpp_compiler }} - -DCMAKE_C_COMPILER=${{ matrix.c_compiler }} - -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} - -DPYRO_COMMON_BUILD_TESTS=ON - -S ${{ github.workspace }} - # -G "Ninja Multi-Config" - # -DCMAKE_C_COMPILER_LAUNCHER=ccache - # -DCMAKE_CXX_COMPILER_LAUNCHER=ccache - - - name: Build - # Build your program with the given configuration. Note that --config is - # needed because the default Windows generator is a multi-config - # generator (Visual Studio generator). - run: cmake --build ${{ steps.strings.outputs.build-output-dir }} --config ${{ matrix.build_type }} --parallel 4 - - - name: Test - working-directory: ${{ steps.strings.outputs.build-output-dir }} - # Execute tests defined by the CMake configuration. Note that - # --build-config is needed because the default Windows generator is a - # multi-config generator (Visual Studio generator). - # See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more - # detail - run: ctest --build-config ${{ matrix.build_type }} - - build-macos: - if: github.ref == 'refs/heads/master' - runs-on: macos-latest - name: build (macos-arm-latest, Release, AppleClang) - steps: - - name: Checkout repository with submodules - uses: actions/checkout@v4 - with: - submodules: recursive - - - name: Configure CMake - run: cmake -S . -B build -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release -DPYRO_COMMON_BUILD_TESTS=ON - - - name: Build - run: cmake --build build --config Release --parallel 4 diff --git a/.github/workflows/cmake-windows-msvc.yml b/.github/workflows/cmake-windows-msvc.yml new file mode 100644 index 0000000..4efee18 --- /dev/null +++ b/.github/workflows/cmake-windows-msvc.yml @@ -0,0 +1,40 @@ +name: Windows Build (MSVC) + +on: + push: + branches: [ "**" ] + pull_request: + branches: [ "master" ] + +jobs: + build-windows: + runs-on: windows-latest + strategy: + fail-fast: false + matrix: + build_type: [Release] + shared: [ON, OFF] + + steps: + - name: Checkout repository with submodules + uses: actions/checkout@v4 + with: + submodules: recursive + + - name: Configure CMake (MSVC) + run: > + cmake -B build + -DCMAKE_POLICY_VERSION_MINIMUM=3.5 + -DCMAKE_C_COMPILER=cl + -DCMAKE_CXX_COMPILER=cl + -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} + -DPYRO_COMMON_BUILD_TESTS=ON + -DPYRO_COMMON_SHARED_LIBRARY=${{ matrix.shared }} + -S . + + - name: Build (MSVC) + run: cmake --build build --config ${{ matrix.build_type }} --parallel 4 + + - name: Run tests + working-directory: build + run: ctest --build-config ${{ matrix.build_type }} diff --git a/README.md b/README.md index 0ceb4f8..a7fa374 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,8 @@ -[![CMake on multiple platforms](https://github.com/PyroshockStudios/PyroCommon/actions/workflows/cmake-multi-platform.yml/badge.svg)](https://github.com/PyroshockStudios/PyroCommon/actions/workflows/cmake-multi-platform.yml) - ## PyroshockStudios Common Utilities (PyroshockStudios © 2025) +[![Windows MSVC](https://github.com/PyroshockStudios/PyroCommon/actions/workflows/cmake-windows-msvc.yml/badge.svg)](https://github.com/PyroshockStudios/PyroCommon/actions/workflows/cmake-windows-msvc.yml) +[![Linux GCC & Clang](https://github.com/PyroshockStudios/PyroCommon/actions/workflows/cmake-linux.yml/badge.svg)](https://github.com/PyroshockStudios/PyroCommon/actions/workflows/cmake-linux.yml) +[![macOS ARM/x86](https://github.com/PyroshockStudios/PyroCommon/actions/workflows/cmake-macos.yml/badge.svg)](https://github.com/PyroshockStudios/PyroCommon/actions/workflows/cmake-macos.yml) + + ### This repository contains many shared files used in PyroshockStudios projects