Fixed FetchContent usage for new CMake reqs. (#4650)

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.
This commit is contained in:
Allen Byrne 2024-07-16 11:09:31 -05:00 committed by GitHub
parent 882404259c
commit 69dda039a2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 29 additions and 30 deletions

View File

@ -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")

View File

@ -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")
@ -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)

View File

@ -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