Skip to content

Add support for MacOS with ARM CPUs (CMake + GitHub Action) #20

Add support for MacOS with ARM CPUs (CMake + GitHub Action)

Add support for MacOS with ARM CPUs (CMake + GitHub Action) #20

name: Build and Test macOS 14 (M1)
# Builds FANS for macOS 14 on M1 CPU and runs the tests.
on:
push:
branches:
- main
- develop
pull_request:
workflow_dispatch:
concurrency:
group: ${{ github.event_name }}-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{github.event_name == 'pull_request'}}
jobs:
build:
name: macOS 14 (M1)
runs-on: macos-14
env:
FANS_BUILD_DIR: build
strategy:
fail-fast: false
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install FANS dependencies
run: brew install libomp hdf5 openmpi eigen fftw
- name: Generate build directory
run: mkdir -p ${{ env.FANS_BUILD_DIR }}
- name: Configure
working-directory: ${{ env.FANS_BUILD_DIR }}
run: |
cmake --version
cmake \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DOpenMP_CXX_FLAG="-Xclang -fopenmp" \
-DOpenMP_CXX_INCLUDE_DIR=$(brew --prefix)/opt/libomp/include \
-DOpenMP_CXX_LIB_NAMES=libomp \
-DOpenMP_C_FLAG="-Xclang -fopenmp" \
-DOpenMP_C_INCLUDE_DIR=$(brew --prefix)/opt/libomp/include \
-DOpenMP_C_LIB_NAMES=libomp \
-DOpenMP_libomp_LIBRARY=$(brew --prefix)/opt/libomp/lib/libomp.dylib \
..
- uses: actions/upload-artifact@v4
if: failure()
with:
name: macOS 14 (M1) CMakeCache
path: ${{ env.FANS_BUILD_DIR }}/CMakeCache.txt
- uses: actions/upload-artifact@v4
if: failure()
with:
name: macOS 14 (M1) CMakeLogs
path: '${{ env.FANS_BUILD_DIR }}/CMakeFiles/*.log'
- uses: actions/upload-artifact@v4
if: failure()
with:
name: macOS 14 (M1) CompileCommands
path: ${{ env.FANS_BUILD_DIR }}/compile_commands.json
- name: Compile
working-directory: ${{ env.FANS_BUILD_DIR }}
run:
cmake --build . -j $(nproc) || cmake --build . -j1
- name: Tests
working-directory: ${{ env.FANS_BUILD_DIR }}
env:
CTEST_OUTPUT_ON_FAILURE: 1
run: ctest
- uses: actions/upload-artifact@v4
if: failure()
with:
name: macOS 14 (M1) CTest logs
path: ${{ env.FANS_BUILD_DIR }}/Testing/Temporary/LastTest.log