Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
5614d15
GRIDEDIT-2016 updated zlib from v1.2.13 to 'v1.2.13
ScottWillcox Oct 29, 2025
96e4378
GRIDEDIT-2016 removed setting custom xCode version.
ScottWillcox Oct 29, 2025
ba89c88
GRIDEDIT-2016 Updated google test framework from 1.13 to 1.17
ScottWillcox Oct 30, 2025
f9f330d
GRIDEDIT-2016 Added support for the (Apple)clang compiler on MacOS.
ScottWillcox Oct 30, 2025
91c162b
GRIDEDIT-2016 switched MacOS builds from gcc12 to clang.
ScottWillcox Oct 31, 2025
f0121cc
GRIDEDIT-2016 updated cache key.
ScottWillcox Oct 31, 2025
3c30093
GRIDEDIT-2016 added build step to validate that the contents of the r…
ScottWillcox Oct 31, 2025
ee22af0
GRIDEDIT-2016 added steps to install openMP on macOS agents.
ScottWillcox Oct 31, 2025
43767c0
GRIDEDIT-2016 removed cmake call that should not have been committed
ScottWillcox Oct 31, 2025
dddf391
GRIDEDIT-2016 added flags to cmake to find OpenMP for Clang
ScottWillcox Oct 31, 2025
374522f
GRIDEDIT-2016 removed macos runner check during openMP configuration
ScottWillcox Oct 31, 2025
8d39d3e
GRIDEDIT-2016 change locations of openMP
ScottWillcox Oct 31, 2025
0b3f70f
GRIDEDIT-2016 updated compiler settings for traingle.c file, add chec…
ScottWillcox Oct 31, 2025
88594de
GRIDEDIT-2016 Implemented GCC-only guards around the problematic #pra…
ScottWillcox Oct 31, 2025
f0aa660
GRIDEDIT-2016 set clang specific compiler flags.
ScottWillcox Oct 31, 2025
35857b1
GRIDEDIT-2016 fixing clang compilation issues.
ScottWillcox Oct 31, 2025
9908180
GRIDEDIT-2016 removed unused variable Mesh2DtoCurvilinear.n_maxNumRow…
ScottWillcox Oct 31, 2025
7a778c4
GRIDEDIT-2016 Be more linient for Eigen
ScottWillcox Oct 31, 2025
9690828
GRIDEDIT-2016 Updated Eigen to V5.0.0
ScottWillcox Oct 31, 2025
63f7f97
Merge branch 'master' into feature/GRIDEDIT-2016-MacOS-Github-actions…
ScottWillcox Nov 14, 2025
def6a18
GRIDEDIT-2016 removed gcc install from macOS
ScottWillcox Nov 14, 2025
aeee639
GRIDEDIT-2016 removing unused variables.
ScottWillcox Nov 14, 2025
7317cdc
GRIDEDIT-2016 changed cache key. force rebuild of cached dependencies.
ScottWillcox Nov 14, 2025
e2bf3c5
GRIDEDIT-2016 add verbose logging to cmake config.
ScottWillcox Nov 14, 2025
368299c
GRIDEDIT-2016 adding logging to better detect linking problems.
ScottWillcox Nov 14, 2025
b455533
Merge branch 'master' into feature/GRIDEDIT-2016-MacOS-Github-actions…
ScottWillcox Nov 20, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 37 additions & 21 deletions .github/workflows/build-and-test-workflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,35 +14,27 @@ on:

jobs:
build:
# Build platform
runs-on: ${{ inputs.platform }}

name: ${{ inputs.platform }}-${{ inputs.build_type }}

# The default compiler on macos is clang, switch to gcc. Specifying the version is necessary.
# It seems like gcc and g++ are symbolic links to the default clang and clang++ compilers, respectively.
# CMAKE_CXX_COMPILER_ID will evaluate to AppleClang rather than GNU on macos.
env:
CC: gcc-12
CXX: g++-12

# Build steps
steps:
# Step: Install GCC (macOS only)
- name: Install GCC
if: startsWith(runner.os, 'macOS')
run: |
brew install gcc@12
echo "CC=$(brew --prefix)/bin/gcc-12" >> $GITHUB_ENV
echo "CXX=$(brew --prefix)/bin/g++-12" >> $GITHUB_ENV

# Step: Checkout
- name: Checkout
uses: actions/checkout@v4
# Workaround for getting "git describe --tags" to work in cmake/get_version_from_git.cmake (Build step)
with:
fetch-depth: 0

# Step: Set compiler (use system Clang for all macOS versions)
- name: Set compiler (macOS Clang)
if: runner.os == 'macOS'
run: |
echo "Using system Clang for ${{ inputs.platform }}"
echo "CC=clang" >> "$GITHUB_ENV"
echo "CXX=clang++" >> "$GITHUB_ENV"
echo "Configured Clang toolchain: $(clang --version | head -n 1)"

# Step: Set paths
- name: Set paths
id: paths
Expand All @@ -59,13 +51,26 @@ jobs:
sudo apt-get install libboost-all-dev doxygen
fi

# Step: Install OpenMP
- name: Install OpenMP
run: brew install libomp

# Step: Set OpenMP environment variables
- name: Set OpenMP environment variables
run: |
echo "LDFLAGS=-L/opt/homebrew/opt/libomp/lib" >> $GITHUB_ENV
echo "CPPFLAGS=-I/opt/homebrew/opt/libomp/include" >> $GITHUB_ENV
echo "Debug: Checking OpenMP installation:"
ls -la /opt/homebrew/opt/libomp/lib/ || echo "OpenMP lib directory not found"
ls -la /opt/homebrew/opt/libomp/include/ || echo "OpenMP include directory not found"
file /opt/homebrew/opt/libomp/lib/libomp.dylib || echo "libomp.dylib not found"

# Step: Restore cached user-provided dependencies
- name: Restore cached user-provided dependencies
uses: actions/cache/restore@v4
id: restore-cached-external-dependencies
with:
key: ${{ inputs.platform }}-${{ inputs.build_type }}-cache-key-v4
restore-keys: ${{ inputs.platform }}-${{ inputs.build_type }}-cache-key-v4
key: ${{ inputs.platform }}-${{ inputs.build_type }}-cache-key-v5
path: ${{ steps.paths.outputs.ext_deps_dir }}/netcdf-c/install/netcdf-c

# Step: Check if netCDF cache directory already has contents (defensive guard)
Expand Down Expand Up @@ -95,7 +100,7 @@ jobs:
uses: actions/cache/save@v4
if: steps.check-nc-cache.outputs.has-deps == 'false'
with:
key: ${{ inputs.platform }}-${{ inputs.build_type }}-cache-key-v4
key: ${{ inputs.platform }}-${{ inputs.build_type }}-cache-key-v5
path: ${{ steps.paths.outputs.ext_deps_dir }}/netcdf-c/install/netcdf-c

# Step: CMake configuration
Expand All @@ -107,10 +112,21 @@ jobs:
-DCMAKE_BUILD_TYPE=${{ inputs.build_type }}
-DCMAKE_PREFIX_PATH=${{ steps.paths.outputs.ext_deps_dir }}/netcdf-c/install/netcdf-c
-DCMAKE_INSTALL_PREFIX=${{ steps.paths.outputs.install_dir }}
-DCMAKE_VERBOSE_MAKEFILE=ON
-DCMAKE_OSX_ARCHITECTURES=arm64
-DOpenMP_C_FLAGS="-Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include"
-DOpenMP_CXX_FLAGS="-Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include"
-DOpenMP_C_LIB_NAMES="omp"
-DOpenMP_CXX_LIB_NAMES="omp"
-DOpenMP_omp_LIBRARY="/opt/homebrew/opt/libomp/lib/libomp.dylib"
-DCMAKE_C_FLAGS="-Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include"
-DCMAKE_CXX_FLAGS="-Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include -v"
-DCMAKE_EXE_LINKER_FLAGS="-L/opt/homebrew/opt/libomp/lib -lomp -Wl,-v"
-DCMAKE_SHARED_LINKER_FLAGS="-L/opt/homebrew/opt/libomp/lib -lomp -Wl,-v"

# Step: CMake build
- name: Build
run: cmake --build ${{ steps.paths.outputs.build_dir }} --config ${{ inputs.build_type }} -j 4
run: cmake --build ${{ steps.paths.outputs.build_dir }} --config ${{ inputs.build_type }} -j 4 --verbose

# Step: Test
# Works if runner.os == 'Linux' or runner.os == 'macOS'
Expand Down
35 changes: 27 additions & 8 deletions cmake/compiler_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,41 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Add compiler-specific options and definitions per supported platform
if (UNIX)
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if(APPLE)
# macOS: support AppleClang / Clang (system toolchain). GCC may also be supported but Clang is preferred.
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
message(STATUS "Configuring build for macOS with ${CMAKE_CXX_COMPILER_ID} (${CMAKE_CXX_COMPILER_VERSION}).")
# Common warning and visibility flags
add_compile_options("-fvisibility=hidden;-Wall;-Wextra;-pedantic;-Werror;-Wno-unused-function")
# Be lenient for Eigen (deprecated enum conversion) on all macOS Clang builds
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-enum-enum-conversion>)
# Optimization / debug flags
add_compile_options("$<$<CONFIG:RELEASE>:-O2>")
add_compile_options("$<$<CONFIG:DEBUG>:-g>")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Fallback: allow GNU on macOS if explicitly selected
message(STATUS "Configuring build for macOS with GNU ${CMAKE_CXX_COMPILER_VERSION}.")
add_compile_options("-fvisibility=hidden;-Werror;-Wall;-Wextra;-pedantic;-Wno-unused-function")

if(APPLE AND (CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm64"))
if(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()
message(FATAL_ERROR "Unsupported compiler. Only GNU is supported under Linux. Found ${CMAKE_CXX_COMPILER_ID}.")
message(FATAL_ERROR "Unsupported compiler on macOS. Supported: AppleClang/Clang or GNU. Found ${CMAKE_CXX_COMPILER_ID}.")
endif()
elseif(UNIX)
# Linux: require GNU
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
message(STATUS "Configuring build for Linux with GNU ${CMAKE_CXX_COMPILER_VERSION}.")
add_compile_options("-fvisibility=hidden;-Werror;-Wall;-Wextra;-pedantic;-Wno-unused-function")
add_compile_options("$<$<CONFIG:RELEASE>:-O2>")
add_compile_options("$<$<CONFIG:DEBUG>:-g>")
else()
message(FATAL_ERROR "Unsupported compiler on Linux. Only GNU is supported. Found ${CMAKE_CXX_COMPILER_ID}.")
endif()
elseif(WIN32)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
Expand All @@ -37,7 +56,7 @@ elseif(WIN32)
message(FATAL_ERROR "Unsupported compiler. Only MSVC is supported under Windows. Found ${CMAKE_CXX_COMPILER_ID}.")
endif()
else()
message(FATAL_ERROR "Unsupported platform. Only Linux and Windows are supported.")
message(FATAL_ERROR "Unsupported platform. Only macOS, Linux and Windows are supported.")
endif()

# CMAKE_SOURCE_DIR is passed to the src in order to strip it out of the path of srcs where exceptions may occur
Expand Down
2 changes: 1 addition & 1 deletion cmake/fetch_content.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ if(${USE_LIBFMT})
FetchContent_Declare(
Eigen
GIT_REPOSITORY https://gitlab.com/libeigen/eigen.git
GIT_TAG 21cd3fe20990a5ac1d683806f605110962aac3f1
GIT_TAG 549bf8c75b6aae071cde2f28aa48f16ee3ae60b0
)

FetchContent_MakeAvailable(Eigen)
Expand Down
9 changes: 5 additions & 4 deletions extern/triangle/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ target_compile_definitions(
)

# platform-specific compiler options and definitions for disabling warnings
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
target_compile_options(${target_name} PRIVATE "-w")
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
target_compile_options(${target_name} PRIVATE "/w")
# Use the C compiler ID because this target is pure C. Disable warnings for GCC and Clang.
if(CMAKE_C_COMPILER_ID MATCHES "Clang|GNU")
target_compile_options(${target_name} PRIVATE -w)
elseif(CMAKE_C_COMPILER_ID STREQUAL "MSVC")
target_compile_options(${target_name} PRIVATE /w)
endif()

# group the sources and headers in IDE project generation
Expand Down
5 changes: 3 additions & 2 deletions libs/MeshKernel/include/MeshKernel/Constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,15 @@
#include <limits>
#include <math.h>

#if defined(__linux__) || defined(__APPLE__)
#if defined(__GNUC__) && !defined(__clang__)
// GCC only: suppress -Wmaybe-uninitialized (not recognized by Clang / AppleClang)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif

#include <Eigen/Core>

#if defined(__linux__) || defined(__APPLE__)
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif

Expand Down
9 changes: 9 additions & 0 deletions libs/MeshKernel/include/MeshKernel/LandBoundaries.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@

#include <memory>

#if defined(__clang__)
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdefaulted-function-deleted"
#endif

namespace meshkernel
{
class Polygons;
Expand Down Expand Up @@ -246,3 +251,7 @@ namespace meshkernel
};

} // namespace meshkernel

#if defined(__clang__)
#pragma clang diagnostic pop
#endif
3 changes: 1 addition & 2 deletions libs/MeshKernel/include/MeshKernel/Mesh2DToCurvilinear.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,7 @@ namespace meshkernel
{1, 0},
{0, 1}}}; ///< increments for the new nodes depending on the node direction

const int n_maxNumRowsColumns = 1000000; ///< The maximum number of allowed rows or columns


MatrixWithNegativeIndices m_mapping; ///< Unstructured node indices in the curvilinear grid
};

Expand Down
5 changes: 3 additions & 2 deletions libs/MeshKernel/include/MeshKernel/ProjectionConversions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@

#include <string>

#if defined(__linux__) || defined(__APPLE__)
#if defined(__GNUC__) && !defined(__clang__)
// GCC only: suppress -Wmaybe-uninitialized (Clang/AppleClang doesn't support it)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
Expand All @@ -39,7 +40,7 @@
#include <boost/geometry/srs/epsg.hpp>
#undef BOOST_ALLOW_DEPRECATED_HEADERS

#if defined(__linux__) || defined(__APPLE__)
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,15 @@
#include "MeshKernel/Definitions.hpp"
#include "MeshKernel/Exceptions.hpp"

#ifdef __linux__
#if defined(__GNUC__) && !defined(__clang__)
// GCC only: suppress -Wmaybe-uninitialized (Clang does not have this warning group)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif

#include <Eigen/Core>
#include <Eigen/Eigenvalues>
#ifdef __linux__
#if defined(__GNUC__) && !defined(__clang__)
#pragma GCC diagnostic pop
#endif

Expand Down
2 changes: 1 addition & 1 deletion libs/MeshKernel/src/Mesh2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2672,7 +2672,7 @@ std::vector<int> Mesh2D::NodeMaskFromPolygon(const Polygons& polygon, bool insid

for (UInt i = 0; i < nodeMask.size(); ++i)
{
auto isInPolygon = nodePolygonIndices[i];
bool isInPolygon = static_cast<bool>(nodePolygonIndices[i]);
if (!inside)
{
isInPolygon = !isInPolygon;
Expand Down
2 changes: 0 additions & 2 deletions tools/test_utils/src/MakeCurvilinearGrids.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ size_t CurvilinearGridCountValidNodes(meshkernelapi::CurvilinearGrid const& curv
size_t CurvilinearGridCountValidNodes(meshkernel::CurvilinearGrid const& curvilinearGrid)
{
size_t validNodes = 0;
size_t index = 0;
for (meshkernel::UInt n = 0; n < curvilinearGrid.NumN(); ++n)
{
for (meshkernel::UInt m = 0; m < curvilinearGrid.NumM(); ++m)
Expand All @@ -34,7 +33,6 @@ size_t CurvilinearGridCountValidNodes(meshkernel::CurvilinearGrid const& curvili
{
validNodes++;
}
index++;
}
}
return validNodes;
Expand Down
Loading