Skip to content

Commit

Permalink
Fixed FetchContent usage for new CMake reqs. (#730)
Browse files Browse the repository at this point in the history
  • Loading branch information
byrnHDF authored Jul 18, 2024
1 parent b25a579 commit 50db097
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 26 deletions.
52 changes: 26 additions & 26 deletions config/cmake/HDFLibMacros.cmake
Original file line number Diff line number Diff line change
@@ -1,26 +1,30 @@
#-------------------------------------------------------------------------------
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 (HDF4_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 (HDF4_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(HDF4_ZLIB)
if(NOT hdf4_zlib_POPULATED)
FetchContent_Populate(HDF4_ZLIB)

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

add_subdirectory(${hdf4_zlib_SOURCE_DIR} ${hdf4_zlib_BINARY_DIR})
endif()
FetchContent_MakeAvailable(HDF4_ZLIB)

add_library(${HDF_PACKAGE_NAMESPACE}zlib-static ALIAS zlib-static)
set (H4_ZLIB_STATIC_LIBRARY "${HDF_PACKAGE_NAMESPACE}zlib-static")
Expand All @@ -39,23 +43,21 @@ macro (EXTERNAL_JPEG_LIBRARY compress_type)
FetchContent_Declare (JPEG
GIT_REPOSITORY ${JPEG_URL}
GIT_TAG ${JPEG_BRANCH}
PATCH_COMMAND ${CMAKE_COMMAND} -E copy
${HDF_RESOURCES_DIR}/JPEG/CMakeLists.txt
<SOURCE_DIR>/CMakeLists.txt
)
elseif (${compress_type} MATCHES "TGZ")
message (VERBOSE "Filter JPEG file ${JPEG_URL}")
FetchContent_Declare (JPEG
URL ${JPEG_URL}
URL_HASH ""
PATCH_COMMAND ${CMAKE_COMMAND} -E copy
${HDF_RESOURCES_DIR}/JPEG/CMakeLists.txt
<SOURCE_DIR>/CMakeLists.txt
)
endif ()
FetchContent_GetProperties(JPEG)
if(NOT jpeg_POPULATED)
FetchContent_Populate(JPEG)

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

add_subdirectory(${jpeg_SOURCE_DIR} ${jpeg_BINARY_DIR})
endif()
FetchContent_MakeAvailable(JPEG)

add_library(${HDF_PACKAGE_NAMESPACE}jpeg-static ALIAS jpeg-static)
set (H4_JPEG_STATIC_LIBRARY "${HDF_PACKAGE_NAMESPACE}jpeg-static")
Expand All @@ -75,23 +77,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 @@ -38,6 +38,13 @@ New features and changes
========================
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.

- Renamed HDF4_ENABLE_USING_MEMCHECKER to HDF4_USING_ANALYSIS_TOOL

The HDF4_USING_ANALYSIS_TOOL is used to indicate to test macros that
Expand Down

0 comments on commit 50db097

Please sign in to comment.