Skip to content

Commit

Permalink
Fixed FetchContent usage for new CMake reqs. (#4650)
Browse files Browse the repository at this point in the history
CMake version 3.30 changed the behavior of the FetchContent module to deprecate
the use of FetchContent_Populate() in favor of FetchContent_MakeAvailable(). Therefore,
the copying of HDF specialized CMakeLists.txt files to the dependent project's source
was implemented in the FetchContent_Declare() call.
  • Loading branch information
byrnHDF authored Jul 16, 2024
1 parent 8824042 commit 69dda03
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 30 deletions.
12 changes: 3 additions & 9 deletions config/cmake/HDF5PluginMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,9 @@ macro (EXTERNAL_PLUGIN_LIBRARY compress_type)
URL_HASH ""
)
endif ()
FetchContent_GetProperties(PLUGIN)
message (VERBOSE "HDF5_INCLUDE_DIR=${HDF5_INCLUDE_DIR}")
if(NOT PLUGIN_POPULATED)
FetchContent_Populate(PLUGIN)
include (${HDF_RESOURCES_DIR}/HDF5PluginCache.cmake)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
add_subdirectory(${plugin_SOURCE_DIR} ${plugin_BINARY_DIR})
endif ()
message (VERBOSE "HDF5_INCLUDE_DIR=${HDF5_INCLUDE_DIR}")
include (${HDF_RESOURCES_DIR}/HDF5PluginCache.cmake)
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
FetchContent_MakeAvailable(PLUGIN)
set (PLUGIN_BINARY_DIR "${plugin_BINARY_DIR}")
set (PLUGIN_SOURCE_DIR "${plugin_SOURCE_DIR}")
set (PLUGIN_LIBRARY "PLUGIN")
Expand Down
40 changes: 19 additions & 21 deletions config/cmake/HDFLibMacros.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@
#
#-------------------------------------------------------------------------------
macro (EXTERNAL_ZLIB_LIBRARY compress_type)
if (HDF5_USE_ZLIB_NG)
set (zlib_folder "ZLIBNG")
else ()
set (zlib_folder "ZLIB")
endif ()
if (${compress_type} MATCHES "GIT")
FetchContent_Declare (HDF5_ZLIB
GIT_REPOSITORY ${ZLIB_URL}
GIT_TAG ${ZLIB_BRANCH}
PATCH_COMMAND ${CMAKE_COMMAND} -E copy
${HDF_RESOURCES_DIR}/${zlib_folder}/CMakeLists.txt
<SOURCE_DIR>/CMakeLists.txt
)
elseif (${compress_type} MATCHES "TGZ")
message (VERBOSE "Filter ZLIB file ${ZLIB_URL}")
FetchContent_Declare (HDF5_ZLIB
URL ${ZLIB_URL}
URL_HASH ""
PATCH_COMMAND ${CMAKE_COMMAND} -E copy
${HDF_RESOURCES_DIR}/${zlib_folder}/CMakeLists.txt
<SOURCE_DIR>/CMakeLists.txt
)
endif ()
FetchContent_GetProperties(HDF5_ZLIB)
if(NOT hdf5_zlib_POPULATED)
FetchContent_Populate(HDF5_ZLIB)

# Copy an additional/replacement files into the populated source
if (HDF5_USE_ZLIB_NG)
file(COPY ${HDF_RESOURCES_DIR}/ZLIBNG/CMakeLists.txt DESTINATION ${hdf5_zlib_SOURCE_DIR})
else ()
file(COPY ${HDF_RESOURCES_DIR}/ZLIB/CMakeLists.txt DESTINATION ${hdf5_zlib_SOURCE_DIR})
endif ()

add_subdirectory(${hdf5_zlib_SOURCE_DIR} ${hdf5_zlib_BINARY_DIR})
endif()
FetchContent_MakeAvailable(HDF5_ZLIB)

add_library(${HDF_PACKAGE_NAMESPACE}zlib-static ALIAS zlib-static)
set (H5_ZLIB_STATIC_LIBRARY "${HDF_PACKAGE_NAMESPACE}zlib-static")
Expand All @@ -54,23 +54,21 @@ macro (EXTERNAL_SZIP_LIBRARY compress_type encoding)
FetchContent_Declare (SZIP
GIT_REPOSITORY ${SZIP_URL}
GIT_TAG ${SZIP_BRANCH}
PATCH_COMMAND ${CMAKE_COMMAND} -E copy
${HDF_RESOURCES_DIR}/LIBAEC/CMakeLists.txt
<SOURCE_DIR>/CMakeLists.txt
)
elseif (${compress_type} MATCHES "TGZ")
message (VERBOSE "Filter SZIP file ${SZIP_URL}")
FetchContent_Declare (SZIP
URL ${SZIP_URL}
URL_HASH ""
PATCH_COMMAND ${CMAKE_COMMAND} -E copy
${HDF_RESOURCES_DIR}/LIBAEC/CMakeLists.txt
<SOURCE_DIR>/CMakeLists.txt
)
endif ()
FetchContent_GetProperties(SZIP)
if(NOT szip_POPULATED)
FetchContent_Populate(SZIP)

# Copy an additional/replacement files into the populated source
file(COPY ${HDF_RESOURCES_DIR}/LIBAEC/CMakeLists.txt DESTINATION ${szip_SOURCE_DIR})

add_subdirectory(${szip_SOURCE_DIR} ${szip_BINARY_DIR})
endif()
FetchContent_MakeAvailable(SZIP)

add_library (${HDF_PACKAGE_NAMESPACE}szaec-static ALIAS szaec-static)
add_library (${HDF_PACKAGE_NAMESPACE}aec-static ALIAS aec-static)
Expand Down
7 changes: 7 additions & 0 deletions release_docs/RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1746,6 +1746,13 @@ Bug Fixes since HDF5-1.14.0 release

Configuration
-------------
- Corrected usage of FetchContent in the HDFLibMacros.cmake file.

CMake version 3.30 changed the behavior of the FetchContent module to deprecate
the use of FetchContent_Populate() in favor of FetchContent_MakeAvailable(). Therefore,
the copying of HDF specialized CMakeLists.txt files to the dependent project's source
was implemented in the FetchContent_Declare() call.

- Fixed/reverted an Autotools configure hack that causes problems on MacOS

A sed line in configure.ac was added in the past to paper over some
Expand Down

0 comments on commit 69dda03

Please sign in to comment.