Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
39 changes: 22 additions & 17 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,6 +51,16 @@ 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

# Step: Restore cached user-provided dependencies
- name: Restore cached user-provided dependencies
uses: actions/cache/restore@v4
Expand Down Expand Up @@ -107,6 +109,9 @@ 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_C_FLAGS="-Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include"
-DCMAKE_CXX_FLAGS="-Xpreprocessor -fopenmp -I/opt/homebrew/opt/libomp/include"
-DCMAKE_EXE_LINKER_FLAGS="-L/opt/homebrew/opt/libomp/lib -lomp"

# Step: CMake build
- name: Build
Expand Down
37 changes: 29 additions & 8 deletions cmake/compiler_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,43 @@ 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 arm64
if(CMAKE_HOST_SYSTEM_PROCESSOR MATCHES "arm64")
add_compile_options($<$<COMPILE_LANGUAGE:CXX>:-Wno-deprecated-enum-enum-conversion>)
endif()
# 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 +58,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
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
16 changes: 8 additions & 8 deletions extern/triangle/src/TriangleFacade.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
#include "triangle.h"

/**
* Calls the triangulate() C-routine
* Calls the triangulate() C-routine
*
* Note: all output arrays should be preallocated by the caller!
*
Expand Down Expand Up @@ -62,7 +62,7 @@ void Triangulation(int jatri,
double trisize)
{

struct triangulateio in, mid, out, vorout;
struct triangulateio in, mid, vorout;

int number, i, j, itri, maxnumtri;
int *trinumedge;
Expand All @@ -81,7 +81,7 @@ void Triangulation(int jatri,

in.numberofpointattributes = 0;
number = in.numberofpoints * in.numberofpointattributes * sizeof(REAL);
in.pointattributelist = (REAL *)NULL;
in.pointattributelist = (REAL *)NULL;
in.pointmarkerlist = (int *)NULL;

if (jatri == 1 || jatri == 3) {
Expand Down Expand Up @@ -130,14 +130,14 @@ void Triangulation(int jatri,
/* produce an edge list (e), a Voronoi diagram (v), and a triangle */
/* neighbor list (n). */

if (jatri == 1)
if (jatri == 1)
{
/* triangulate("pcAevnQP", &in, &mid, &vorout); */

triangulate("-Qpc", &in, &mid, &vorout);

}
else if (jatri == 3)
else if (jatri == 3)
{
/* Also produce edge-to-node mapping and tri-to-edge mapping
(uses quite a bit more memory!) */
Expand Down Expand Up @@ -165,7 +165,7 @@ void Triangulation(int jatri,
}
free(trinumedge);
}
else
else
{
i = sprintf(opties, "-Q-Y-q30.0-D-a%f", trisize);

Expand Down Expand Up @@ -193,7 +193,7 @@ void Triangulation(int jatri,


*numtri = mid.numberoftriangles;
if (*numtri > maxnumtri)
if (*numtri > maxnumtri)
{
printf("Triangulation: unsufficient mem for triangle nodes in index (%d > %d)\n", *numtri, maxnumtri);
*numtri = -*numtri; // serves as error indicator
Expand Down Expand Up @@ -231,4 +231,4 @@ void Triangulation(int jatri,
free(vorout.normlist);

return;
}
}
21 changes: 15 additions & 6 deletions extern/triangle/src/triangle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1376,6 +1376,8 @@ REAL area; /* The area of the triangle. */
REAL oalen, dalen, odlen;
REAL maxlen;

(void)(area);

dxoa = triorg[0] - triapex[0];
dyoa = triorg[1] - triapex[1];
dxda = tridest[0] - triapex[0];
Expand Down Expand Up @@ -3264,7 +3266,7 @@ void info()
/* */
/*****************************************************************************/

void internalerror()
void internalerror(void)
{
printf(" Please report this bug to jrs@cs.berkeley.edu\n");
printf(" Include the message above, your input data set, and the exact\n");
Expand Down Expand Up @@ -3769,6 +3771,8 @@ struct osub *s;
struct otri printtri;
vertex printvertex;

(void)(b);

printf("subsegment x%llx with orientation %d and mark %d:\n",
(unsigned long long) s->ss, s->ssorient, mark(*s));
sdecode(s->ss[0], printsh);
Expand Down Expand Up @@ -3946,7 +3950,7 @@ int alignment;
/* - The parameter `alignment'. */
/* - sizeof(VOID *), so the stack of dead items can be maintained */
/* without unaligned accesses. */
if (alignment > sizeof(VOID *)) {
if (alignment > (int)sizeof(VOID *)) {
pool->alignbytes = alignment;
} else {
pool->alignbytes = sizeof(VOID *);
Expand Down Expand Up @@ -4346,8 +4350,8 @@ struct behavior *b;
/* integer index can occupy the same space as the subsegment pointers */
/* or attributes or area constraint or extra nodes. */
if ((b->voronoi || b->neighbors) &&
(trisize < 6 * sizeof(triangle) + sizeof(int))) {
trisize = 6 * sizeof(triangle) + sizeof(int);
(trisize < 6 * (int)sizeof(triangle) + (int)sizeof(int))) {
trisize = 6 * (int)sizeof(triangle) + (int)sizeof(int);
}

/* Having determined the memory size of a triangle, initialize the pool. */
Expand Down Expand Up @@ -4883,7 +4887,7 @@ struct osub *newsubseg;
/* */
/*****************************************************************************/

void exactinit()
void exactinit(void)
{
REAL half;
REAL check, lastcheck;
Expand Down Expand Up @@ -11774,6 +11778,7 @@ vertex endpoint2;
/* Inserting the vertex may have caused edge flips. We wish to rediscover */
/* the edge connecting endpoint1 to the new intersection vertex. */
collinear = finddirection(m, b, splittri, endpoint1);
(void)(collinear);
dest(*splittri, rightvertex);
apex(*splittri, leftvertex);
if ((leftvertex[0] == endpoint1[0]) && (leftvertex[1] == endpoint1[1])) {
Expand Down Expand Up @@ -13189,6 +13194,7 @@ struct behavior *b;
while (subsegloop.ss != (subseg *) NULL) {
/* If the segment is encroached, add it to the list. */
dummy = checkseg4encroach(m, b, &subsegloop);
(void)(dummy);
subsegloop.ss = subsegtraverse(m);
}
}
Expand All @@ -13203,7 +13209,7 @@ struct behavior *b;

#ifndef CDT_ONLY

void precisionerror()
void precisionerror(void)
{
printf("Try increasing the area criterion and/or reducing the minimum\n");
printf(" allowable angle so that tiny triangles are not created.\n");
Expand Down Expand Up @@ -13426,6 +13432,7 @@ int triflaws;
dummy = checkseg4encroach(m, b, &currentenc);
snextself(currentenc);
dummy = checkseg4encroach(m, b, &currentenc);
(void)(dummy);
}

badsubsegdealloc(m, encloop);
Expand Down Expand Up @@ -14580,6 +14587,7 @@ char **argv;
tlist[vertexindex++] = vertexmark(p1);
tlist[vertexindex++] = vertexmark(p2);
tlist[vertexindex++] = vertexmark(p3);
(void)(elementnumber);
#else /* not TRILIBRARY */
/* Triangle number, indices for three vertices. */
fprintf(outfile, "%4ld %4d %4d %4d", elementnumber,
Expand Down Expand Up @@ -15112,6 +15120,7 @@ char **argv;
normlist[coordindex++] = tdest[1] - torg[1];
elist[coordindex] = -1;
normlist[coordindex++] = torg[0] - tdest[0];
(void)(vedgenumber);
#else /* not TRILIBRARY */
/* Write an infinite ray. Edge number, index of one endpoint, -1, */
/* and x and y coordinates of a vector representing the */
Expand Down
4 changes: 2 additions & 2 deletions libs/MeshKernel/include/MeshKernel/Constants.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@
#include <limits>
#include <math.h>

#if defined(__linux__) || defined(__APPLE__)
#if (defined(__linux__) && !(__clang__)) || defined(__APPLE__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif

#include <Eigen/Core>

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

Expand Down
3 changes: 0 additions & 3 deletions libs/MeshKernel/include/MeshKernel/LandBoundaries.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ namespace meshkernel
WholeMesh = 4
};

/// @brief Default constructor
LandBoundaries() = default;

/// @brief Constructor
/// @param[in] landBoundary A vector of points defining the land boundary.
/// @param[in] mesh The current 2d mesh.
Expand Down
2 changes: 0 additions & 2 deletions libs/MeshKernel/include/MeshKernel/Mesh2DToCurvilinear.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,6 @@ 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
4 changes: 2 additions & 2 deletions libs/MeshKernel/include/MeshKernel/ProjectionConversions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

#include <string>

#if defined(__linux__) || defined(__APPLE__)
#if (defined(__linux__) && !(__clang__)) || defined(__APPLE__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif
Expand All @@ -39,7 +39,7 @@
#include <boost/geometry/srs/epsg.hpp>
#undef BOOST_ALLOW_DEPRECATED_HEADERS

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

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

#ifdef __linux__
#if defined(__linux__) && !(__clang__)
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#endif

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

Expand Down
Loading
Loading