Skip to content

Commit

Permalink
Default built zlib system libs is expected to be shared.
Browse files Browse the repository at this point in the history
  • Loading branch information
byrnHDF committed Jan 29, 2025
1 parent fc03971 commit f54d538
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 13 deletions.
33 changes: 20 additions & 13 deletions CMakeFilters.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -85,26 +85,33 @@ endif ()
if(NOT DEFINED ZLIBNG_PACKAGE_NAME)
set(ZLIBNG_PACKAGE_NAME "zlib-ng")
endif ()
option (HDF5_ENABLE_ZLIB_SUPPORT "Enable Zlib Filters" OFF)
if (HDF5_ENABLE_ZLIB_SUPPORT)
if (NOT H5_ZLIB_HEADER)
if (NOT ZLIB_USE_EXTERNAL)
option (HDF5_DEFAULT_ZLIB_SYSTEM "Use the default system installed ZLIB" ON)
if (HDF5_USE_ZLIB_NG)
set (PACKAGE_NAME ${ZLIBNG_PACKAGE_NAME}${HDF_PACKAGE_EXT})
else ()
set (PACKAGE_NAME ${ZLIB_PACKAGE_NAME}${HDF_PACKAGE_EXT})
endif ()
set(ZLIB_FOUND FALSE)
if (HDF5_USE_ZLIB_STATIC)
set(ZLIB_SEARCH_TYPE static)
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
set(ZLIB_USE_STATIC_LIBS ${HDF5_USE_ZLIB_STATIC})
endif()
message (VERBOSE "Filter HDF5_ZLIB package name:${PACKAGE_NAME}")
if (HDF5_DEFAULT_ZLIB_SYSTEM)
# Expect that the default shared library is expected with FindZLIB.cmake
find_package (ZLIB MODULE)
else ()
set(ZLIB_SEARCH_TYPE shared)
# Expect that a correctly built library with CMake config files is available
if (HDF5_USE_ZLIB_STATIC)
set(ZLIB_SEARCH_TYPE static)
if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.24.0")
set(ZLIB_USE_STATIC_LIBS ${HDF5_USE_ZLIB_STATIC})
endif()
else ()
set(ZLIB_SEARCH_TYPE shared)
endif ()
find_package (ZLIB NAMES ${PACKAGE_NAME} CONFIG OPTIONAL_COMPONENTS ${ZLIB_SEARCH_TYPE})
endif ()
find_package (ZLIB NAMES ${PACKAGE_NAME} OPTIONAL_COMPONENTS ${ZLIB_SEARCH_TYPE})
set(H5_ZLIB_FOUND ${ZLIB_FOUND})
set(H5_ZLIB_FOUND ZLIB_FOUND})
if (H5_ZLIB_FOUND)
if (HDF5_USE_ZLIB_NG)
set (H5_ZLIB_HEADER "zlib-ng.h")
Expand All @@ -115,9 +122,10 @@ if (HDF5_ENABLE_ZLIB_SUPPORT)
set (H5_ZLIB_INCLUDE_DIRS ${H5_ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR})
# The FindZLIB.cmake module does not set an OUTPUT_NAME
# on the target. The target returned is: ZLIB::ZLIB
get_filename_component (libname ${ZLIB_LIBRARIES} NAME_WLE)
string (REGEX REPLACE "^lib" "" libname ${libname})
set_target_properties (ZLIB::ZLIB PROPERTIES OUTPUT_NAME ${libname})
# get_filename_component (libname ${ZLIB_LIBRARIES} NAME_WLE)
# string (REGEX REPLACE "^lib" "" libname ${libname})
message (VERBOSE "Filter HDF5_ZLIB name:$<TARGET_FILE_BASE_NAME:ZLIB::ZLIB>")
set_target_properties (ZLIB::ZLIB PROPERTIES OUTPUT_NAME $<TARGET_FILE_BASE_NAME:ZLIB::ZLIB>)
set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ZLIB::ZLIB)
endif ()
else ()
Expand Down Expand Up @@ -157,7 +165,6 @@ set(H5_SZIP_FOUND FALSE)
if(NOT DEFINED LIBAEC_PACKAGE_NAME)
set(LIBAEC_PACKAGE_NAME "libaec")
endif ()
option (HDF5_ENABLE_SZIP_SUPPORT "Use SZip Filter" OFF)
if (HDF5_ENABLE_SZIP_SUPPORT)
option (HDF5_ENABLE_SZIP_ENCODING "Use SZip Encoding" ON)
if (NOT SZIP_USE_EXTERNAL)
Expand Down
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ if (POLICY CMP0074)
cmake_policy (SET CMP0074 NEW)
endif ()

if (POLICY CMP0144)
# <PACKAGENAME> is the upper-cased package name.
cmake_policy (SET CMP0144 NEW)
endif ()

if (POLICY CMP0083)
# To control generation of Position Independent Executable (PIE) or not,
# some flags are required at link time.
Expand Down
1 change: 1 addition & 0 deletions release_docs/INSTALL_CMake.txt
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ if (BUILD_TESTING)
HDF5_ALLOW_EXTERNAL_SUPPORT "Allow External Library Building (NO GIT TGZ)" "NO"
HDF5_ENABLE_PLUGIN_SUPPORT "Enable PLUGIN Filters" OFF
HDF5_ENABLE_SZIP_SUPPORT "Use SZip Filter" OFF
HDF5_DEFAULT_ZLIB_SYSTEM "Use the default system installed ZLIB" ON
HDF5_ENABLE_ZLIB_SUPPORT "Enable Zlib Filters" OFF

if (HDF5_USE_ZLIB_NG)
Expand Down
7 changes: 7 additions & 0 deletions release_docs/RELEASE.txt
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,13 @@ Bug Fixes since HDF5-2.0.0 release

Configuration
-------------
- When using a system installed zlib library, the shared library is expected to
found in the system library path.

Setting the HDF5_DEFAULT_ZLIB_SYSTEM option to OFF, the system installed zlib,
or an alternate installed zlib library, is expected to have a correct
zlib-config.cmake file.

- Use pre-installed libaec compression library

The CMake logic for finding the libaec compression library has been
Expand Down

0 comments on commit f54d538

Please sign in to comment.