@@ -156,6 +156,7 @@ set(HIGHFIVE_USE_BOOST OFF CACHE INTERNAL BOOL)
156
156
set (HIGHFIVE_UNIT_TESTS OFF CACHE INTERNAL BOOL )
157
157
set (HIGHFIVE_HAS_CONCEPTS OFF CACHE INTERNAL BOOL )
158
158
if (WIN32 OR APPLE )
159
+ set (HDF5_USE_STATIC_LIBRARIES ON CACHE INTERNAL BOOL )
159
160
set (HIGHFIVE_STATIC_HDF5 ON CACHE INTERNAL BOOL )
160
161
endif ()
161
162
FetchContent_Declare(
@@ -164,6 +165,36 @@ FetchContent_Declare(
164
165
URL_HASH SHA256=6301def8ceb9f4d7a595988612db288b448a3c0546f6c83417dab38c64994d7e
165
166
)
166
167
FetchContent_MakeAvailable(HighFive)
168
+ # from https://gitlab.kitware.com/cmake/cmake/-/issues/18872#note_1090297
169
+ # Since there is no compiler line to help us, add the additional required
170
+ # libraries manually.
171
+ set (_additional_libs sz aec z dl m)
172
+ foreach (_additional_lib IN LISTS _additional_libs)
173
+ # If both static and shared are available, prefer static to avoid libdl
174
+ # annoyances ("Using 'dlopen' in statically linked applications requires
175
+ # at runtime the shared libraries from the glibc version used for
176
+ # linking")
177
+ if (HDF5_USE_STATIC_LIBRARIES)
178
+ set (_libnames ${_additional_lib} lib${_additional_lib} .a)
179
+ else ()
180
+ set (_libnames ${_additional_lib} )
181
+ endif (HDF5_USE_STATIC_LIBRARIES)
182
+ set (_libvar "LIB_${_additional_lib} " )
183
+ find_library (${_libvar}
184
+ NAMES ${_libnames}
185
+ HINTS ${HDF5_ROOT}
186
+ PATH_SUFFIXES lib Lib
187
+ REQUIRED)
188
+ if (HDF5_FIND_DEBUG)
189
+ message (STATUS "${_additional_lib} (${_libvar} ): ${${_libvar} }" )
190
+ endif (HDF5_FIND_DEBUG)
191
+ if (${${_libvar} } STREQUAL "${_libvar} -NOTFOUND" )
192
+ message (FATAL_ERROR "${_additional_lib} not found, required for HDF5 install" )
193
+ endif ()
194
+ list (APPEND HDF5_LIBRARIES ${${_libvar} })
195
+ endforeach ()
196
+ list (REMOVE_DUPLICATES HDF5_LIBRARIES)
197
+
167
198
string (REGEX MATCH "-lR" R_LINK_LINE ${R_LDFLAGS} )
168
199
string (REGEX MATCH "-framework R" R_FRAMEWORK_LINE ${R_LDFLAGS} )
169
200
string (REPLACE " -lR" "" R_LDFLAGS ${R_LDFLAGS} )
@@ -177,7 +208,7 @@ if(LINUX)
177
208
target_link_libraries (RcppPlanc PRIVATE stdc++fs)
178
209
endif ()
179
210
endif ()
180
- target_link_libraries (RcppPlanc PRIVATE ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} HighFive hw_detect)
211
+ target_link_libraries (RcppPlanc PRIVATE ${BLAS_LIBRARIES} ${LAPACK_LIBRARIES} ${HDF5_LIBRARIES} HighFive hw_detect)
181
212
#target_include_directories(RcppPlanc BEFORE PRIVATE ${HighFive_BINARY_DIR}/include)
182
213
if (OpenMP_CXX_FOUND)
183
214
target_compile_options (RcppPlanc PRIVATE ${OpenMP_CXX_FLAGS} )
0 commit comments