Skip to content

Commit

Permalink
Support macOS arm64 (#261 | GRIDEDIT-798)
Browse files Browse the repository at this point in the history
  • Loading branch information
evetion authored Jan 8, 2024
1 parent b3a5f3e commit 13a980d
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 24 deletions.
42 changes: 19 additions & 23 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,9 @@ jobs:
fail-fast: false
matrix:
platform:
#- 'ubuntu-latest'
- 'macos-latest'
# - ubuntu-latest
- macos-latest
- macos-13-xlarge
build_type:
- 'Release'
#- 'Debug'
Expand All @@ -43,7 +44,7 @@ jobs:
env:
CC: gcc-11
CXX: g++-11

# Build steps
steps:

Expand All @@ -62,22 +63,17 @@ jobs:
echo "ext_deps_dir=${{ github.workspace }}/external_dependencies" >> $GITHUB_OUTPUT
echo "install_dir=${{ github.workspace }}/install" >> $GITHUB_OUTPUT
# Step: Install system-provided dependencies
# macOS
- if: runner.os == 'macOS'
name: Install system-provided dependencies
run: | # brew update
brew install boost
brew install doxygen
# Linux
- if: runner.os == 'Linux'
name: Install system-provided dependencies
run: | # sudo apt-get update && sudo apt upgrade
sudo apt-get install libboost-all-dev
sudo apt-get install doxygen
- name: Install system-provided dependencies
run: |
if [ "${{ runner.os }}" == "macOS" ]; then
brew install boost doxygen netcdf
elif [ "${{ runner.os }}" == "Linux" ]; then
sudo apt-get install libboost-all-dev doxygen
fi
# Step: Restore cached user-provided dependencies
- name: Restore cached user-provided dependencies
- if: runner.os != 'macOS'
name: Restore cached user-provided dependencies
uses: actions/cache/restore@v3
id: restore-cached-external-dependencies
with:
Expand All @@ -87,7 +83,7 @@ jobs:

# Step: Build and install user-provided dependencies, executes only if no cache restored
- name: Build and install user-provided dependencies
if: steps.restore-cached-external-dependencies.outputs.cache-hit != 'true'
if: runner.os != 'macOS' && steps.restore-cached-external-dependencies.outputs.cache-hit != 'true'
# NetCDF Dependencies m4, curl, and openssl are provided by the build machine
run: >
pwsh ${{ github.workspace }}/scripts/install_netcdf_static.ps1
Expand All @@ -96,14 +92,14 @@ jobs:
-BuildType '${{ matrix.build_type }}'
-ParallelJobs 10
# Step: Cache user-provided dependencies, executes only if no cache restored
# Step: Cache user-provided dependencies, executes only if no cache restored
- name: Cache user-provided dependencies
uses: actions/cache/save@v3
if: steps.restore-cached-external-dependencies.outputs.cache-hit != 'true'
if: runner.os != 'macOS' && steps.restore-cached-external-dependencies.outputs.cache-hit != 'true'
with:
key: ${{ runner.os }}-cache-key
path: ${{ steps.paths.outputs.ext_deps_dir }}/netcdf-c/install/netcdf-c

# Step: CMake configuration
- name: Configure
run: >
Expand Down Expand Up @@ -139,4 +135,4 @@ jobs:
with:
name: meshkernel-${{ matrix.platform }}-${{ matrix.build_type }}
path: ${{ steps.paths.outputs.install_dir }}
if-no-files-found: error
if-no-files-found: error
10 changes: 9 additions & 1 deletion cmake/compiler_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,15 @@ set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# Add compiler-specific options and definitions per supported platform
if (UNIX)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
add_compile_options("-Werror;-Wall;-Wextra;-pedantic;-Wno-unused-function")
add_compile_options("-fvisibility=hidden;-Werror;-Wall;-Wextra;-pedantic;-Wno-unused-function")
if(APPLE AND (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm64"))
# CMake automatically sets -Xarch_arm64 (for clang) but gcc doesn't support it
unset(_CMAKE_APPLE_ARCHS_DEFAULT)
# Be lenient on macos with arm64 toolchain to prevent Eigen -Werror=deprecated-enum-enum-conversion error
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-enum-enum-conversion>)
# Suppress notes related to ABI changes
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-psabi>)
endif()
add_compile_options("$<$<CONFIG:RELEASE>:-O2>")
add_compile_options("$<$<CONFIG:DEBUG>:-g>")
else()
Expand Down

0 comments on commit 13a980d

Please sign in to comment.