diff --git a/var/spack/repos/builtin/packages/fms/enable-shared-libs.patch b/var/spack/repos/builtin/packages/fms/enable-shared-libs.patch new file mode 100644 index 00000000000000..9ca2c98f81ab87 --- /dev/null +++ b/var/spack/repos/builtin/packages/fms/enable-shared-libs.patch @@ -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 $ +- $) ++ if (SHARED_LIBS) ++ message(STATUS "Shared library target: ${libTgt}") ++ add_library(${libTgt} SHARED $ ++ $) ++ else () ++ message(STATUS "Static library target: ${libTgt}") ++ add_library(${libTgt} STATIC $ ++ $) ++ endif () + + target_include_directories(${libTgt} PUBLIC + $ +@@ -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) diff --git a/var/spack/repos/builtin/packages/fms/package.py b/var/spack/repos/builtin/packages/fms/package.py index 0bcf22034cf8d2..8441d2f3f93102 100644 --- a/var/spack/repos/builtin/packages/fms/package.py +++ b/var/spack/repos/builtin/packages/fms/package.py @@ -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"), @@ -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"), diff --git a/var/spack/repos/builtin/packages/py-netcdf4/package.py b/var/spack/repos/builtin/packages/py-netcdf4/package.py index e0bf493749e4c0..3316e69692d7d5 100644 --- a/var/spack/repos/builtin/packages/py-netcdf4/package.py +++ b/var/spack/repos/builtin/packages/py-netcdf4/package.py @@ -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 diff --git a/var/spack/repos/builtin/packages/py-ruamel-yaml-clib/package.py b/var/spack/repos/builtin/packages/py-ruamel-yaml-clib/package.py index bd9d97f49bd23b..2ae9ad5f568522 100644 --- a/var/spack/repos/builtin/packages/py-ruamel-yaml-clib/package.py +++ b/var/spack/repos/builtin/packages/py-ruamel-yaml-clib/package.py @@ -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)