Skip to content
Draft
Show file tree
Hide file tree
Changes from 2 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
28 changes: 15 additions & 13 deletions cmake/compiler_config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,33 +9,35 @@ set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

# Add compiler-specific options and definitions per supported platform

if((UNIX OR WIN32) AND CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
#add_compile_options("-Werror;-Wall;-Wextra;-pedantic;-Wno-unused-function")
add_compile_options("$<$<CONFIG:RELEASE>:-O2>")
add_compile_options("$<$<CONFIG:DEBUG>:-g>")
elseif (UNIX)
add_compile_options("$<$<CONFIG:RELEASE>:-O2>")
add_compile_options("$<$<CONFIG:DEBUG>:-g>")
elseif (UNIX)
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()
message(FATAL_ERROR "Unsupported compiler. Only GNU is supported under Unix and Unix-like operating systems.")
message(FATAL_ERROR "Unsupported compiler. Only GNU is supported under Linux. Found ${CMAKE_CXX_COMPILER_ID}.")
endif()
elseif(WIN32)
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
add_compile_options("/EHsc;/MP;/W3;/WX")
add_compile_options("$<$<CONFIG:RELEASE>:/O2>")
add_compile_options("$<$<CONFIG:DEBUG>:/Od;/DEBUG>")
add_compile_definitions("_USE_MATH_DEFINES")
add_compile_definitions("_CRT_SECURE_NO_WARNINGS")
else()
message(FATAL_ERROR "Unsupported compiler. Only MSVC is supported under Windows.")
message(FATAL_ERROR "Unsupported compiler. Only MSVC is supported under Windows. Found ${CMAKE_CXX_COMPILER_ID}.")
endif()
else()
message(FATAL_ERROR "Unsupported platform. Only Unix, Unix-like, and Windows are supported.")
message(FATAL_ERROR "Unsupported platform. Only 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
4 changes: 4 additions & 0 deletions scripts/download_sonar_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ def get_build_wrapper(save_dir: Path) -> None:
url = "https://sonarcloud.io/static/cpp/build-wrapper-win-x86.zip"
elif platform.system() == "Linux":
url = "http://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip"
elif platform.system() == "Darwin":
url = "https://sonarcloud.io/static/cpp/build-wrapper-macosx-x86.zip"
else:
raise Exception("Unsupported OS used.")

Expand All @@ -51,6 +53,8 @@ def get_scanner(save_dir: Path) -> None:
url = f"https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-{SONAR_SCANNER_VERSION}-windows.zip"
elif platform.system() == "Linux":
url = f"https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-{SONAR_SCANNER_VERSION}-linux.zip"
elif platform.system() == "Darwin":
url = f"https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-{SONAR_SCANNER_VERSION}-macosx.zip"
else:
raise Exception("Unsupported OS used.")

Expand Down
16 changes: 11 additions & 5 deletions scripts/install_netcdf_static.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ Function Join-Paths {
}

# No need to download and extract m4 when platform is WIN32
if ($PSVersionTable.Platform -ne 'Unix') {
if ($IsWindows) {
# ----------------------------------------------------------------------------------------
# Download
# ----------------------------------------------------------------------------------------
Expand Down Expand Up @@ -307,7 +307,7 @@ $env:Path += (';' + $CurlInstallDir)
$HDF5BuildDir = (Join-Path $BuildDir $HDF5)
$HDF5InstallDir = (Join-Path $LocalInstallDir $HDF5)
$ZlibIncludeDir = (Join-Path $ZLIBInstallDir 'include')
if ($PSVersionTable.Platform -eq 'Unix') {
if ($IsLinux -or $IsMacOS) {
$ZlibStaticLibrary = (Join-Path (Join-Path $ZLIBInstallDir 'lib') 'libz.a')
}
else {
Expand Down Expand Up @@ -347,7 +347,7 @@ $NetCDFCMakeBuildOptions = @(`
'-DENABLE_DAP=OFF', `
'-DENABLE_BYTERANGE=OFF' `
)
if ($PSVersionTable.Platform -eq 'Unix') {
if ($IsLinux -or $IsMacOS) {
$NetCDFCMakeBuildOptions += '-DCMAKE_POSITION_INDEPENDENT_CODE=ON'
}

Expand All @@ -369,7 +369,7 @@ Invoke-BuildAndInstall `
Function Invoke-Post-Build-Steps() {
# Copy all necessary static libraries from the local instalaltion directory to the netcdf lib dir
$NetCDFLibDir = (Join-Path $NetCDFInstallDir 'lib')
if ($PSVersionTable.Platform -eq 'Unix') {
if ($IsLinux -or $IsMacOS) {
$NetCDFBinDir = (Join-Path $NetCDFInstallDir 'bin')
Copy-Item (Join-Paths $ZLIBInstallDir 'lib' 'libz.a') -Destination (Join-Path $NetCDFLibDir 'libz.a')
Copy-Item (Join-Paths $ZLIBInstallDir 'lib' 'libz.so') -Destination (Join-Path $NetCDFBinDir 'libz.so')
Expand Down Expand Up @@ -397,9 +397,15 @@ Function Invoke-Post-Build-Steps() {
}

# Replace the line above to list the public interface libararies in ${_IMPORT_PREFIX}/lib (libs copied and renamed above)
if ($PSVersionTable.Platform -eq 'Unix') {
if ($IsLinux) {
$NewLine = ' INTERFACE_LINK_LIBRARIES "dl;${_IMPORT_PREFIX}/lib/libhdf5_hl.a;${_IMPORT_PREFIX}/lib/libhdf5.a;${_IMPORT_PREFIX}/lib/libz.a;${_IMPORT_PREFIX}/bin/libz.so"'
}
elseif ($IsMacOS) {
$NewLine = $Line
$NewLine = $NewLine.Replace($HDF5InstallDir, '${_IMPORT_PREFIX}')
$NewLine = $NewLine.Replace($ZLIBInstallDir, '${_IMPORT_PREFIX}')
$NewLine = $NewLine.Replace($CurlInstallDir, '${_IMPORT_PREFIX}')
}
else {
$NewLine = ' INTERFACE_LINK_LIBRARIES "${_IMPORT_PREFIX}/lib/hdf5_hl-static.lib;${_IMPORT_PREFIX}/lib/hdf5-static.lib;${_IMPORT_PREFIX}/lib/zlib.lib"'
}
Expand Down
Loading