Skip to content

Commit

Permalink
Changes to get Mac Sonoma 14.6.1 with Command Line Tools 15.3 working.
Browse files Browse the repository at this point in the history
  • Loading branch information
srherbener committed Aug 30, 2024
1 parent 33eea04 commit e830dda
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 2 deletions.
64 changes: 64 additions & 0 deletions var/spack/repos/builtin/packages/fms/enable-shared-libs.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 2ca5c652..5082a98e 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -52,14 +52,16 @@ endif()
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

# Build options
-option(OPENMP "Build FMS with OpenMP support" OFF)
-option(32BIT "Build 32-bit (r4) FMS library" ON)
-option(64BIT "Build 64-bit (r8) FMS library" OFF)
-option(FPIC "Build with position independent code" OFF)
+option(OPENMP "Build FMS with OpenMP support" OFF)
+option(32BIT "Build 32-bit (r4) FMS library" ON)
+option(64BIT "Build 64-bit (r8) FMS library" OFF)
+option(FPIC "Build with position independent code" OFF)
+option(SHARED_LIBS "Build shared/dynamic libraries" OFF)

# Options for compiler definitions
option(INTERNAL_FILE_NML "Enable compiler definition -DINTERNAL_FILE_NML" ON)
option(ENABLE_QUAD_PRECISION "Enable compiler definition -DENABLE_QUAD_PRECISION" ON)
+option(PORTABLE_KINDS "Enable compiler definition -DPORTABLE_KINDS" OFF)
option(GFS_PHYS "Enable compiler definition -DGFS_PHYS" OFF)
option(LARGEFILE "Enable compiler definition -Duse_LARGEFILE" OFF)
option(WITH_YAML "Enable compiler definition -Duse_yaml" OFF)
@@ -266,6 +268,10 @@ if(ENABLE_QUAD_PRECISION)
list(APPEND fms_defs ENABLE_QUAD_PRECISION)
endif()

+if(PORTABLE_KINDS)
+ list(APPEND fms_defs PORTABLE_KINDS)
+endif()
+
if(LARGEFILE)
list(APPEND fms_defs use_LARGEFILE)
endif()
@@ -360,8 +366,15 @@ foreach(kind ${kinds})
endif()

# FMS (C + Fortran)
- add_library(${libTgt} STATIC $<TARGET_OBJECTS:${libTgt}_c>
- $<TARGET_OBJECTS:${libTgt}_f>)
+ if (SHARED_LIBS)
+ message(STATUS "Shared library target: ${libTgt}")
+ add_library(${libTgt} SHARED $<TARGET_OBJECTS:${libTgt}_c>
+ $<TARGET_OBJECTS:${libTgt}_f>)
+ else ()
+ message(STATUS "Static library target: ${libTgt}")
+ add_library(${libTgt} STATIC $<TARGET_OBJECTS:${libTgt}_c>
+ $<TARGET_OBJECTS:${libTgt}_f>)
+ endif ()

target_include_directories(${libTgt} PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
@@ -397,7 +410,8 @@ foreach(kind ${kinds})
target_compile_definitions(${libTgt} PRIVATE "${fms_defs}")
target_compile_definitions(${libTgt} PRIVATE "${${kind}_defs}")

- target_link_libraries(${libTgt} PUBLIC NetCDF::NetCDF_Fortran
+ target_link_libraries(${libTgt} PUBLIC NetCDF::NetCDF_C
+ NetCDF::NetCDF_Fortran
MPI::MPI_Fortran)

if(OpenMP_Fortran_FOUND)
12 changes: 12 additions & 0 deletions var/spack/repos/builtin/packages/fms/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,17 @@ class Fms(CMakePackage):
when="@2023.03",
)

# macos needs shared libraries for version 2024.02
# What the following patch is providing is available in version 2024.03
# and newer so it is only needed to 2024.02
variant(
"sharedlibs",
description="Build shared libraries",
default=True,
when="@2024.02: %apple-clang@15:"
)
patch("enable-shared-libs.patch", when="@2024.02 %apple-clang@15: +sharedlibs")

variant(
"precision",
values=("32", "64"),
Expand Down Expand Up @@ -119,6 +130,7 @@ def cmake_args(self):
self.define_from_variant("GFS_PHYS"),
self.define_from_variant("OPENMP"),
self.define_from_variant("ENABLE_QUAD_PRECISION", "quad_precision"),
self.define_from_variant("SHARED_LIBS", "sharedlibs"),
self.define_from_variant("WITH_YAML", "yaml"),
self.define_from_variant("CONSTANTS"),
self.define_from_variant("LARGEFILE", "large_file"),
Expand Down
2 changes: 1 addition & 1 deletion var/spack/repos/builtin/packages/py-netcdf4/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class PyNetcdf4(PythonPackage):

def flag_handler(self, name, flags):
if name == "cflags":
if self.spec.satisfies("%oneapi"):
if self.spec.satisfies("%oneapi") or self.spec.satisfies("%apple-clang@15:"):
flags.append("-Wno-error=int-conversion")

return flags, None, None
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@ class PyRuamelYamlClib(PythonPackage):

def flag_handler(self, name, flags):
if name == "cflags":
if self.spec.satisfies("%oneapi"):
if self.spec.satisfies("%oneapi") or self.spec.satisfies(" %apple-clang@15:"):
flags.append("-Wno-error=incompatible-function-pointer-types")
return (flags, None, None)

0 comments on commit e830dda

Please sign in to comment.