@@ -124,6 +124,20 @@ class NetcdfC(CMakePackage, AutotoolsPackage):
124124 when = "@4.9.0:4.9.2" ,
125125 )
126126
127+ # https://github.com/Unidata/netcdf-c/issues/3199
128+ patch ("cmakelists_mpi_symbols.patch" , when = "build_system=cmake" )
129+
130+ def patch (self ):
131+ """Fix bad code in ncgen/CMakeLists.txt that removes
132+ the rpath for dependencies like hdf5."""
133+ if self .spec .satisfies ("build_system=cmake" ):
134+ filter_file (
135+ "SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)" ,
136+ "#SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)" ,
137+ "ncgen/CMakeLists.txt" ,
138+ string = True ,
139+ )
140+
127141 variant ("mpi" , default = True , description = "Enable parallel I/O for netcdf-4" )
128142 variant ("parallel-netcdf" , default = False , description = "Enable parallel I/O for classic files" )
129143 variant ("hdf4" , default = False , description = "Enable HDF4 support" )
@@ -288,16 +302,6 @@ class NetcdfC(CMakePackage, AutotoolsPackage):
288302
289303 build_system ("cmake" , "autotools" , default = default_build_system )
290304
291- def patch (self ):
292- """Fix bad code in ncgen/CMakeLists.txt that removes
293- the rpath for dependencies like hdf5."""
294- filter_file (
295- "SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)" ,
296- "#SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE)" ,
297- "ncgen/CMakeLists.txt" ,
298- string = True
299- )
300-
301305 def setup_run_environment (self , env : EnvironmentModifications ) -> None :
302306 if self .spec .satisfies ("@4.9.0:+shared" ):
303307 # Both HDF5 and NCZarr backends honor the same environment variable:
@@ -358,6 +362,8 @@ def cmake_args(self):
358362 self .define ("ENABLE_LARGE_FILE_SUPPORT" , True ),
359363 self .define_from_variant ("NETCDF_ENABLE_LOGGING" , "logging" ),
360364 ]
365+ if any (self .spec .satisfies (s ) for s in ["+mpi" , "+parallel-netcdf" , "^hdf5+mpi~shared" ]):
366+ base_cmake_args .append (self .define ("CMAKE_C_COMPILER" , self .spec ["mpi" ].mpicc ))
361367 if "+parallel-netcdf" in self .pkg .spec :
362368 base_cmake_args .append (self .define ("ENABLE_PNETCDF" , True ))
363369 if self .pkg .spec .satisfies ("@4.3.1:" ):
0 commit comments