mirror of
https://github.com/HDFGroup/hdf5.git
synced 2026-09-25 04:09:44 +03:00
Improvements to CMake logic for handling filters (#6287)
* Re-write zlib/szip CMake logic for clarity * Update external libaec, zlib-ng and zlib builds to not use patching process * Add FindZLIBNG module to locate zlib-ng on system * Rework HDF5 filter plugins support
This commit is contained in:
@@ -106,7 +106,6 @@ jobs:
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCODE_COVERAGE:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_ZLIB_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_ENCODING:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PLUGIN_SUPPORT:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLIBAEC_USE_LOCALCONTENT:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_USE_LOCALCONTENT:BOOL=OFF")
|
||||
|
||||
@@ -102,7 +102,6 @@ jobs:
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_ZLIB_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_ENCODING:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PLUGIN_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLIBAEC_USE_LOCALCONTENT:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_USE_LOCALCONTENT:BOOL=OFF")
|
||||
|
||||
@@ -458,6 +458,7 @@ jobs:
|
||||
-DHDF5_ENABLE_ZLIB_SUPPORT:BOOL=ON \
|
||||
-DZLIB_USE_LOCALCONTENT:BOOL=OFF \
|
||||
-DZLIB_USE_EXTERNAL:BOOL=OFF \
|
||||
-DHDF5_USE_ZLIB_STATIC:BOOL=OFF \
|
||||
-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=OFF \
|
||||
-DHDF5_ENABLE_SZIP_ENCODING:BOOL=OFF \
|
||||
-DLIBAEC_USE_LOCALCONTENT:BOOL=OFF \
|
||||
@@ -571,8 +572,8 @@ jobs:
|
||||
-DHDF5_ENABLE_MIRROR_VFD:BOOL=ON \
|
||||
-DHDF5_ENABLE_DIRECT_VFD:BOOL=ON \
|
||||
-DHDF5_ENABLE_ZLIB_SUPPORT:BOOL=OFF \
|
||||
-DHDF5_ENABLE_SZIP_SUPPORT:=BOOL=OFF \
|
||||
-DHDF5_ENABLE_SZIP_ENCODING:=BOOL=OFF \
|
||||
-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=OFF \
|
||||
-DHDF5_ENABLE_SZIP_ENCODING:BOOL=OFF \
|
||||
$GITHUB_WORKSPACE
|
||||
shell: bash
|
||||
|
||||
|
||||
@@ -145,7 +145,6 @@ jobs:
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_ZLIB_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_ENCODING:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PLUGIN_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLIBAEC_USE_LOCALCONTENT:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_USE_LOCALCONTENT:BOOL=OFF")
|
||||
@@ -262,7 +261,6 @@ jobs:
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_ZLIB_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_ENCODING:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PLUGIN_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLIBAEC_USE_LOCALCONTENT:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_USE_LOCALCONTENT:BOOL=OFF")
|
||||
|
||||
@@ -123,7 +123,6 @@ jobs:
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_ZLIB_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_ENCODING:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PLUGIN_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLIBAEC_USE_LOCALCONTENT:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_USE_LOCALCONTENT:BOOL=OFF")
|
||||
@@ -221,7 +220,6 @@ jobs:
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_ZLIB_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_ENCODING:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PLUGIN_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLIBAEC_USE_LOCALCONTENT:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_USE_LOCALCONTENT:BOOL=OFF")
|
||||
@@ -343,7 +341,6 @@ jobs:
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_ZLIB_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_ENCODING:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PLUGIN_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLIBAEC_USE_LOCALCONTENT:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_USE_LOCALCONTENT:BOOL=OFF")
|
||||
@@ -461,7 +458,6 @@ jobs:
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_ZLIB_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_ENCODING:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PLUGIN_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLIBAEC_USE_LOCALCONTENT:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_USE_LOCALCONTENT:BOOL=OFF")
|
||||
@@ -576,7 +572,6 @@ jobs:
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_ZLIB_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_ENCODING:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PLUGIN_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLIBAEC_USE_LOCALCONTENT:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_USE_LOCALCONTENT:BOOL=OFF")
|
||||
@@ -684,7 +679,6 @@ jobs:
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_ZLIB_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_ENCODING:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PLUGIN_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLIBAEC_USE_LOCALCONTENT:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_USE_LOCALCONTENT:BOOL=OFF")
|
||||
@@ -800,7 +794,6 @@ jobs:
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_ZLIB_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_ENCODING:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_PLUGIN_SUPPORT:BOOL=ON")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DLIBAEC_USE_LOCALCONTENT:BOOL=OFF")
|
||||
set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_USE_LOCALCONTENT:BOOL=OFF")
|
||||
|
||||
@@ -155,8 +155,6 @@ jobs:
|
||||
-DHDF5_BUILD_CPP_LIB:BOOL=ON \
|
||||
-DHDF5_ENABLE_ZLIB_SUPPORT:BOOL=ON \
|
||||
-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON \
|
||||
-DHDF5_ENABLE_SZIP_ENCODING:BOOL=ON \
|
||||
-DHDF5_ENABLE_PLUGIN_SUPPORT:BOOL=ON \
|
||||
-DLIBAEC_USE_LOCALCONTENT=OFF \
|
||||
-DZLIB_USE_LOCALCONTENT=OFF \
|
||||
-DHDF5_ENABLE_ROS3_VFD:BOOL=ON \
|
||||
@@ -182,8 +180,6 @@ jobs:
|
||||
-DHDF5_BUILD_CPP_LIB:BOOL=ON \
|
||||
-DHDF5_ENABLE_ZLIB_SUPPORT:BOOL=ON \
|
||||
-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON \
|
||||
-DHDF5_ENABLE_SZIP_ENCODING:BOOL=ON \
|
||||
-DHDF5_ENABLE_PLUGIN_SUPPORT:BOOL=ON \
|
||||
-DLIBAEC_USE_LOCALCONTENT=OFF \
|
||||
-DZLIB_USE_LOCALCONTENT=OFF \
|
||||
-DHDF5_ENABLE_ROS3_VFD:BOOL=ON \
|
||||
@@ -317,8 +313,6 @@ jobs:
|
||||
-DHDF5_BUILD_CPP_LIB:BOOL=ON \
|
||||
-DHDF5_ENABLE_ZLIB_SUPPORT:BOOL=ON \
|
||||
-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON \
|
||||
-DHDF5_ENABLE_SZIP_ENCODING:BOOL=ON \
|
||||
-DHDF5_ENABLE_PLUGIN_SUPPORT:BOOL=ON \
|
||||
-DLIBAEC_USE_LOCALCONTENT=OFF \
|
||||
-DZLIB_USE_LOCALCONTENT=OFF \
|
||||
-DHDF5_ENABLE_ROS3_VFD:BOOL=ON \
|
||||
@@ -344,8 +338,6 @@ jobs:
|
||||
-DHDF5_BUILD_CPP_LIB:BOOL=ON \
|
||||
-DHDF5_ENABLE_ZLIB_SUPPORT:BOOL=ON \
|
||||
-DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON \
|
||||
-DHDF5_ENABLE_SZIP_ENCODING:BOOL=ON \
|
||||
-DHDF5_ENABLE_PLUGIN_SUPPORT:BOOL=ON \
|
||||
-DLIBAEC_USE_LOCALCONTENT=OFF \
|
||||
-DZLIB_USE_LOCALCONTENT=OFF \
|
||||
-DHDF5_ENABLE_ROS3_VFD:BOOL=ON \
|
||||
|
||||
@@ -90,3 +90,13 @@ option (HDF5_BUILD_EXAMPLES "Build HDF5 Library Examples" ON)
|
||||
|
||||
option (BUILD_TESTING "Build HDF5 Unit Testing" ON)
|
||||
|
||||
#################################
|
||||
# Options with multiple choices #
|
||||
#################################
|
||||
set (allow_external_support_types "NO" "GIT" "TGZ")
|
||||
set (HDF5_ALLOW_EXTERNAL_SUPPORT "NO" CACHE STRING "If not set to NO, specifies where to obtain sources when building or using external libraries (NO GIT TGZ)")
|
||||
set_property (CACHE HDF5_ALLOW_EXTERNAL_SUPPORT PROPERTY STRINGS ${allow_external_support_types})
|
||||
if (NOT "${HDF5_ALLOW_EXTERNAL_SUPPORT}" IN_LIST allow_external_support_types)
|
||||
message (FATAL_ERROR "HDF5_ALLOW_EXTERNAL_SUPPORT must be set to one of ${allow_external_support_types}")
|
||||
endif ()
|
||||
|
||||
|
||||
@@ -1,254 +0,0 @@
|
||||
#
|
||||
# Copyright by The HDF Group.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of HDF5. The full HDF5 copyright notice, including
|
||||
# terms governing use, modification, and redistribution, is contained in
|
||||
# the LICENSE file, which can be found at the root of the source code
|
||||
# distribution tree, or in https://www.hdfgroup.org/licenses.
|
||||
# If you do not have access to either file, you may request a copy from
|
||||
# help@hdfgroup.org.
|
||||
#
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# HDF5 CMake Filter Support Configuration
|
||||
# -----------------------------------------------------------------------------
|
||||
# This CMake module configures support for external compression filters in HDF5,
|
||||
# specifically ZLIB (including zlib-ng) and SZIP (libaec). It provides options
|
||||
# for enabling/disabling filter support, selecting static/shared builds, and
|
||||
# controlling how dependencies are found or built (external, local, or via GIT/TGZ).
|
||||
#
|
||||
# Key Features:
|
||||
# - Options to enable/disable ZLIB and SZIP support, and select static/shared linking.
|
||||
# - Support for using zlib-ng as a drop-in replacement for zlib.
|
||||
# - Support for building dependencies externally (via GIT or TGZ) or using system libraries.
|
||||
# - Handles configuration of include directories, library targets, and CMake variables
|
||||
# for downstream use.
|
||||
# - Sets up required variables for HDF5 to use the DEFLATE and SZIP filters.
|
||||
#
|
||||
# Usage:
|
||||
# HDF5 includes this file from the main CMakeLists.txt if ZLIB or SZIP filter support in HDF5
|
||||
# is enabled. Configure options as needed before including this file.
|
||||
#
|
||||
# See comments throughout for details on each option and logic branch.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# Specify major options at the top of the file
|
||||
# -----------------------------------------------------------------------------
|
||||
cmake_dependent_option (HDF5_USE_ZLIB_NG "Use zlib-ng library as zlib library" OFF HDF5_ENABLE_ZLIB_SUPPORT OFF)
|
||||
cmake_dependent_option (HDF5_USE_ZLIB_STATIC "Find static zlib library" OFF HDF5_ENABLE_ZLIB_SUPPORT OFF)
|
||||
cmake_dependent_option (HDF5_USE_LIBAEC_STATIC "Find static AEC library" OFF HDF5_ENABLE_SZIP_SUPPORT OFF)
|
||||
option (ZLIB_USE_EXTERNAL "Use External Library Building for ZLIB" OFF)
|
||||
mark_as_advanced (ZLIB_USE_EXTERNAL)
|
||||
option (SZIP_USE_EXTERNAL "Use External Library Building for SZIP" OFF)
|
||||
mark_as_advanced (SZIP_USE_EXTERNAL)
|
||||
cmake_dependent_option (ZLIB_USE_LOCALCONTENT "Use local file for ZLIB FetchContent" OFF HDF5_ENABLE_ZLIB_SUPPORT OFF)
|
||||
mark_as_advanced (ZLIB_USE_LOCALCONTENT)
|
||||
cmake_dependent_option (LIBAEC_USE_LOCALCONTENT "Use local file for LIBAEC FetchContent" OFF HDF5_ENABLE_SZIP_SUPPORT OFF)
|
||||
mark_as_advanced (LIBAEC_USE_LOCALCONTENT)
|
||||
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# the ExternalProject module is needed for building compression libraries from source
|
||||
include (ExternalProject)
|
||||
|
||||
# If compression libraries will be built from source, then choose which method and
|
||||
# source location.
|
||||
#option (HDF5_ALLOW_EXTERNAL_SUPPORT "Allow External Library Building (NO GIT TGZ)" "NO")
|
||||
set (HDF5_ALLOW_EXTERNAL_SUPPORT "NO" CACHE STRING "Allow External Library Building (NO GIT TGZ)")
|
||||
set_property (CACHE HDF5_ALLOW_EXTERNAL_SUPPORT PROPERTY STRINGS NO GIT TGZ)
|
||||
if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ")
|
||||
if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT")
|
||||
if (HDF5_USE_ZLIB_NG)
|
||||
set (ZLIB_URL ${ZLIBNG_GIT_URL} CACHE STRING "Path to zlib-ng git repository")
|
||||
set (ZLIB_BRANCH ${ZLIBNG_GIT_BRANCH})
|
||||
else ()
|
||||
set (ZLIB_URL ${ZLIB_GIT_URL} CACHE STRING "Path to zlib git repository")
|
||||
set (ZLIB_BRANCH ${ZLIB_GIT_BRANCH})
|
||||
endif ()
|
||||
|
||||
set (SZIP_URL ${LIBAEC_GIT_URL} CACHE STRING "Path to szip git repository")
|
||||
set (SZIP_BRANCH ${LIBAEC_GIT_BRANCH})
|
||||
elseif (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ")
|
||||
if (NOT TGZPATH)
|
||||
set (TGZPATH ${HDF5_SOURCE_DIR})
|
||||
endif ()
|
||||
if (NOT ZLIB_USE_LOCALCONTENT)
|
||||
if (HDF5_USE_ZLIB_NG)
|
||||
set (ZLIB_URL ${ZLIBNG_TGZ_ORIGPATH}/${ZLIBNG_TGZ_NAME})
|
||||
else ()
|
||||
set (ZLIB_URL ${ZLIB_TGZ_ORIGPATH}/${ZLIB_TGZ_NAME})
|
||||
endif ()
|
||||
else ()
|
||||
if (HDF5_USE_ZLIB_NG)
|
||||
set (ZLIB_URL ${TGZPATH}/${ZLIBNG_TGZ_NAME})
|
||||
else ()
|
||||
set (ZLIB_URL ${TGZPATH}/${ZLIB_TGZ_NAME})
|
||||
endif ()
|
||||
if (NOT EXISTS "${ZLIB_URL}")
|
||||
set (HDF5_ENABLE_ZLIB_SUPPORT OFF CACHE BOOL "" FORCE)
|
||||
message (VERBOSE "Filter ZLIB file ${ZLIB_URL} not found")
|
||||
endif ()
|
||||
endif ()
|
||||
message (VERBOSE "Filter ZLIB URL is ${ZLIB_URL}")
|
||||
|
||||
if (NOT LIBAEC_USE_LOCALCONTENT)
|
||||
set (SZIP_URL ${LIBAEC_TGZ_ORIGPATH}/${LIBAEC_TGZ_NAME})
|
||||
else ()
|
||||
set (SZIP_URL ${TGZPATH}/${LIBAEC_TGZ_NAME})
|
||||
if (NOT EXISTS "${SZIP_URL}")
|
||||
set (HDF5_ENABLE_SZIP_SUPPORT OFF CACHE BOOL "" FORCE)
|
||||
message (VERBOSE "Filter SZIP file ${SZIP_URL} not found")
|
||||
endif ()
|
||||
endif ()
|
||||
message (VERBOSE "Filter SZIP URL is ${SZIP_URL}")
|
||||
|
||||
else ()
|
||||
set (HDF5_ENABLE_ZLIB_SUPPORT OFF CACHE BOOL "" FORCE)
|
||||
set (ZLIB_USE_EXTERNAL OFF CACHE BOOL "Use External Library Building for ZLIB else search")
|
||||
set (HDF5_ENABLE_SZIP_SUPPORT OFF CACHE BOOL "" FORCE)
|
||||
set (SZIP_USE_EXTERNAL OFF CACHE BOOL "Use External Library Building for SZIP else search")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Option for ZLib support
|
||||
#-----------------------------------------------------------------------------
|
||||
set (H5_ZLIB_FOUND FALSE)
|
||||
# Choose which zlib package to use by name
|
||||
if (NOT DEFINED ZLIB_PACKAGE_NAME)
|
||||
set (ZLIB_PACKAGE_NAME "zlib")
|
||||
endif ()
|
||||
if (NOT DEFINED ZLIBNG_PACKAGE_NAME)
|
||||
set (ZLIBNG_PACKAGE_NAME "zlib-ng")
|
||||
endif ()
|
||||
if (HDF5_ENABLE_ZLIB_SUPPORT)
|
||||
if (NOT H5_ZLIB_HEADER) # This checks if zlib has already been found/built
|
||||
if (NOT ZLIB_USE_EXTERNAL) # This checks if zlib should be found on the system or built from an external source
|
||||
cmake_dependent_option (HDF5_MODULE_MODE_ZLIB "Prefer module mode to find ZLIB" ON "NOT ZLIB_USE_EXTERNAL" OFF)
|
||||
mark_as_advanced (HDF5_MODULE_MODE_ZLIB)
|
||||
if (HDF5_USE_ZLIB_NG)
|
||||
set (HDF5_MODULE_MODE_ZLIB OFF CACHE BOOL "" FORCE)
|
||||
set (Z_PACKAGE_NAME ${ZLIBNG_PACKAGE_NAME}${HDF_PACKAGE_EXT})
|
||||
else ()
|
||||
set (Z_PACKAGE_NAME ${ZLIB_PACKAGE_NAME}${HDF_PACKAGE_EXT})
|
||||
endif ()
|
||||
set (ZLIB_FOUND FALSE)
|
||||
message (VERBOSE "Filter HDF5_ZLIB package name:${Z_PACKAGE_NAME}")
|
||||
if (HDF5_MODULE_MODE_ZLIB)
|
||||
# Expect that the default shared library is expected with FindZLIB.cmake
|
||||
find_package (ZLIB MODULE)
|
||||
else ()
|
||||
# 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 ${Z_PACKAGE_NAME} CONFIG OPTIONAL_COMPONENTS ${ZLIB_SEARCH_TYPE})
|
||||
endif ()
|
||||
set (H5_ZLIB_FOUND ${ZLIB_FOUND})
|
||||
if (H5_ZLIB_FOUND)
|
||||
if (HDF5_USE_ZLIB_NG)
|
||||
set (H5_ZLIB_HEADER "zlib-ng.h")
|
||||
else ()
|
||||
set (H5_ZLIB_HEADER "zlib.h")
|
||||
endif ()
|
||||
set (H5_ZLIB_INCLUDE_DIR_GEN ${ZLIB_INCLUDE_DIR})
|
||||
set (H5_ZLIB_INCLUDE_DIRS ${H5_ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR})
|
||||
set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ZLIB::ZLIB)
|
||||
endif ()
|
||||
else ()
|
||||
if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ")
|
||||
EXTERNAL_ZLIB_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT})
|
||||
message (VERBOSE "Filter HDF5_ZLIB is built")
|
||||
set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${H5_ZLIB_STATIC_LIBRARY})
|
||||
endif ()
|
||||
endif ()
|
||||
else ()
|
||||
# This project is being called from within another and ZLib is already configured
|
||||
set (H5_ZLIB_FOUND TRUE)
|
||||
endif ()
|
||||
if (H5_ZLIB_FOUND)
|
||||
set (H5_HAVE_FILTER_DEFLATE 1)
|
||||
set (H5_HAVE_ZLIB_H 1)
|
||||
if (HDF5_USE_ZLIB_NG AND NOT ZLIB_COMPAT)
|
||||
set (H5_HAVE_ZLIBNG_H 1)
|
||||
endif ()
|
||||
set (H5_HAVE_LIBZ 1)
|
||||
if (H5_HAVE_FILTER_DEFLATE)
|
||||
set (EXTERNAL_FILTERS "${EXTERNAL_FILTERS} DEFLATE")
|
||||
endif ()
|
||||
set (HDF5_COMP_INCLUDE_DIRECTORIES "${HDF5_COMP_INCLUDE_DIRECTORIES};${H5_ZLIB_INCLUDE_DIRS}")
|
||||
message (VERBOSE "Filter HDF5_ZLIB is ON")
|
||||
else ()
|
||||
set (HDF5_ENABLE_ZLIB_SUPPORT OFF CACHE BOOL "" FORCE)
|
||||
message (FATAL_ERROR " ZLib support in HDF5 was enabled but not found")
|
||||
endif ()
|
||||
message (VERBOSE "H5_ZLIB_HEADER=${H5_ZLIB_HEADER}")
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Option for SzLib support
|
||||
#-----------------------------------------------------------------------------
|
||||
set (H5_SZIP_FOUND FALSE)
|
||||
# Choose which szip package to use by name
|
||||
if (NOT DEFINED LIBAEC_PACKAGE_NAME)
|
||||
set (LIBAEC_PACKAGE_NAME "libaec")
|
||||
endif ()
|
||||
if (HDF5_ENABLE_SZIP_SUPPORT)
|
||||
cmake_dependent_option (HDF5_ENABLE_SZIP_ENCODING "Use SZip Encoding" ON HDF5_ENABLE_SZIP_SUPPORT OFF)
|
||||
if (NOT SZIP_USE_EXTERNAL) # This checks if szip should be found on the system or built from an external source
|
||||
if (HDF5_USE_LIBAEC_STATIC)
|
||||
set (LIBAEC_SEARCH_TYPE "static")
|
||||
else ()
|
||||
set (LIBAEC_SEARCH_TYPE "shared")
|
||||
endif ()
|
||||
set (libaec_USE_STATIC_LIBS ${HDF5_USE_LIBAEC_STATIC})
|
||||
set (SZIP_FOUND FALSE)
|
||||
find_package (${LIBAEC_PACKAGE_NAME} OPTIONAL_COMPONENTS ${LIBAEC_SEARCH_TYPE})
|
||||
set (H5_SZIP_FOUND ${${LIBAEC_PACKAGE_NAME}_FOUND})
|
||||
if (H5_SZIP_FOUND)
|
||||
set (H5_SZIP_INCLUDE_DIR_GEN ${SZIP_INCLUDE_DIR})
|
||||
set (H5_SZIP_INCLUDE_DIRS ${H5_SZIP_INCLUDE_DIRS} ${SZIP_INCLUDE_DIR})
|
||||
if (LIBAEC_PACKAGE_NAME STREQUAL "libaec")
|
||||
# When using libaec to replace SZIP, we require that the libsz compatibility library is available
|
||||
if (NOT libsz_FOUND)
|
||||
set (HDF5_ENABLE_SZIP_SUPPORT OFF CACHE BOOL "" FORCE)
|
||||
message (FATAL_ERROR "SZIP support in HDF5 was enabled and libaec was found, but no libsz compatibility library was found")
|
||||
endif ()
|
||||
set (LINK_COMP_LIBS ${LINK_COMP_LIBS} libaec::sz libaec::aec)
|
||||
else ()
|
||||
set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_LIBRARIES})
|
||||
endif ()
|
||||
endif ()
|
||||
message (VERBOSE "H5_SZIP_FOUND=${SZIP_FOUND} and LINK_COMP_LIBS=${LINK_COMP_LIBS}")
|
||||
else ()
|
||||
if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ")
|
||||
EXTERNAL_SZIP_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT} ${HDF5_ENABLE_SZIP_ENCODING})
|
||||
message (VERBOSE "Filter SZIP is built using library AEC")
|
||||
set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${H5_SZIP_STATIC_LIBRARY})
|
||||
endif ()
|
||||
endif ()
|
||||
message (VERBOSE "LINK_COMP_LIBS=${LINK_COMP_LIBS}")
|
||||
if (H5_SZIP_FOUND)
|
||||
set (H5_HAVE_FILTER_SZIP 1)
|
||||
set (H5_HAVE_SZLIB_H 1)
|
||||
set (H5_HAVE_LIBSZ 1)
|
||||
set (HDF5_COMP_INCLUDE_DIRECTORIES "${HDF5_COMP_INCLUDE_DIRECTORIES};${H5_SZIP_INCLUDE_DIRS}")
|
||||
message (VERBOSE "Filter SZIP is ON")
|
||||
if (H5_HAVE_FILTER_SZIP)
|
||||
set (EXTERNAL_FILTERS "${EXTERNAL_FILTERS} DECODE")
|
||||
endif ()
|
||||
if (HDF5_ENABLE_SZIP_ENCODING)
|
||||
set (H5_HAVE_SZIP_ENCODER 1)
|
||||
set (EXTERNAL_FILTERS "${EXTERNAL_FILTERS} ENCODE")
|
||||
endif ()
|
||||
else ()
|
||||
set (HDF5_ENABLE_SZIP_SUPPORT OFF CACHE BOOL "" FORCE)
|
||||
message (FATAL_ERROR "SZIP support in HDF5 was enabled but not found")
|
||||
endif ()
|
||||
endif ()
|
||||
+56
-52
@@ -50,45 +50,46 @@ endif ()
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add Target(s) to CMake Install for import into other projects
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT HDF5_EXTERNALLY_CONFIGURED)
|
||||
if (HDF5_EXPORTED_TARGETS)
|
||||
if (HDF5_ENABLE_JNI)
|
||||
install (
|
||||
EXPORT ${HDF5_EXPORTED_TARGETS}_java
|
||||
DESTINATION ${HDF5_INSTALL_CMAKE_DIR}
|
||||
FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}_java-targets.cmake
|
||||
NAMESPACE ${HDF_PACKAGE_NAMESPACE}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
if (BUILD_STATIC_LIBS AND BUILD_SHARED_LIBS)
|
||||
install (
|
||||
EXPORT ${HDF5_EXPORTED_TARGETS}_static
|
||||
DESTINATION ${HDF5_INSTALL_CMAKE_DIR}
|
||||
FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}_static-targets.cmake
|
||||
NAMESPACE ${HDF_PACKAGE_NAMESPACE}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
if (HDF5_EXPORTED_TARGETS AND NOT HDF5_EXTERNALLY_CONFIGURED)
|
||||
if (HDF5_ENABLE_JNI)
|
||||
install (
|
||||
EXPORT ${HDF5_EXPORTED_TARGETS}
|
||||
EXPORT ${HDF5_EXPORTED_TARGETS}_java
|
||||
DESTINATION ${HDF5_INSTALL_CMAKE_DIR}
|
||||
FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-targets.cmake
|
||||
FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}_java-targets.cmake
|
||||
NAMESPACE ${HDF_PACKAGE_NAMESPACE}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (BUILD_STATIC_LIBS AND BUILD_SHARED_LIBS)
|
||||
install (
|
||||
EXPORT ${HDF5_EXPORTED_TARGETS}_static
|
||||
DESTINATION ${HDF5_INSTALL_CMAKE_DIR}
|
||||
FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}_static-targets.cmake
|
||||
NAMESPACE ${HDF_PACKAGE_NAMESPACE}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
install (
|
||||
EXPORT ${HDF5_EXPORTED_TARGETS}
|
||||
DESTINATION ${HDF5_INSTALL_CMAKE_DIR}
|
||||
FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-targets.cmake
|
||||
NAMESPACE ${HDF_PACKAGE_NAMESPACE}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Export all exported targets to the build tree for use by parent project
|
||||
# If built as a sub-project or if cross-compiling, export all exported targets
|
||||
# to the build tree
|
||||
#-----------------------------------------------------------------------------
|
||||
export (
|
||||
TARGETS ${HDF5_LIBRARIES_TO_EXPORT} ${HDF5_LIB_DEPENDENCIES} ${HDF5_UTILS_TO_EXPORT}
|
||||
FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-targets.cmake
|
||||
NAMESPACE ${HDF_PACKAGE_NAMESPACE}
|
||||
)
|
||||
if (HDF5_EXTERNALLY_CONFIGURED OR CMAKE_CROSSCOMPILING)
|
||||
export (
|
||||
TARGETS ${HDF5_LIBRARIES_TO_EXPORT} ${HDF5_LIB_DEPENDENCIES} ${HDF5_UTILS_TO_EXPORT}
|
||||
FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-targets.cmake
|
||||
NAMESPACE ${HDF_PACKAGE_NAMESPACE}
|
||||
APPEND
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Set includes needed for build
|
||||
@@ -177,6 +178,11 @@ install (
|
||||
DESTINATION ${HDF5_INSTALL_CMAKE_DIR}/Modules
|
||||
COMPONENT configinstall
|
||||
)
|
||||
install (
|
||||
FILES ${CMAKE_SOURCE_DIR}/config/cmake/FindZLIBNG.cmake
|
||||
DESTINATION ${HDF5_INSTALL_CMAKE_DIR}/Modules
|
||||
COMPONENT configinstall
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure the libhdf5.settings file with library info
|
||||
@@ -524,31 +530,29 @@ The HDF5 data model, file format, API, library, and tools are open and distribut
|
||||
|
||||
set (CPACK_INSTALL_CMAKE_PROJECTS "${HDF5_BINARY_DIR};HDF5;ALL;/")
|
||||
|
||||
if (HDF5_PACKAGE_EXTLIBS)
|
||||
if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ")
|
||||
if (H5_ZLIB_FOUND AND ZLIB_USE_EXTERNAL)
|
||||
if (WIN32)
|
||||
set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${H5_ZLIB_INCLUDE_DIR_GEN};HDF5_ZLIB;ALL;/")
|
||||
else ()
|
||||
set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${H5_ZLIB_INCLUDE_DIR_GEN};HDF5_ZLIB;libraries;/")
|
||||
set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${H5_ZLIB_INCLUDE_DIR_GEN};HDF5_ZLIB;configinstall;/")
|
||||
endif ()
|
||||
if (HDF5_PACKAGE_EXTLIBS AND (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT|TGZ"))
|
||||
if (H5_ZLIB_FOUND AND ZLIB_USE_EXTERNAL)
|
||||
if (WIN32)
|
||||
set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${H5_ZLIB_INCLUDE_DIR_GEN};HDF5_ZLIB;ALL;/")
|
||||
else ()
|
||||
set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${H5_ZLIB_INCLUDE_DIR_GEN};HDF5_ZLIB;libraries;/")
|
||||
set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${H5_ZLIB_INCLUDE_DIR_GEN};HDF5_ZLIB;configinstall;/")
|
||||
endif ()
|
||||
if (H5_SZIP_FOUND AND SZIP_USE_EXTERNAL)
|
||||
set (SZIP_PROJNAME "${LIBAEC_PACKAGE_NAME}")
|
||||
if (WIN32)
|
||||
set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${H5_SZIP_INCLUDE_DIR_GEN};${SZIP_PROJNAME};ALL;/")
|
||||
else ()
|
||||
set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${H5_SZIP_INCLUDE_DIR_GEN};${SZIP_PROJNAME};libraries;/")
|
||||
set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${H5_SZIP_INCLUDE_DIR_GEN};${SZIP_PROJNAME};configinstall;/")
|
||||
endif ()
|
||||
endif ()
|
||||
if (H5_SZIP_FOUND AND SZIP_USE_EXTERNAL)
|
||||
set (SZIP_PROJNAME "${LIBAEC_PACKAGE_NAME}")
|
||||
if (WIN32)
|
||||
set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${H5_SZIP_INCLUDE_DIR_GEN};${SZIP_PROJNAME};ALL;/")
|
||||
else ()
|
||||
set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${H5_SZIP_INCLUDE_DIR_GEN};${SZIP_PROJNAME};libraries;/")
|
||||
set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${H5_SZIP_INCLUDE_DIR_GEN};${SZIP_PROJNAME};configinstall;/")
|
||||
endif ()
|
||||
if (PLUGIN_FOUND AND PLUGIN_USE_EXTERNAL)
|
||||
if (WIN32)
|
||||
set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${PLUGIN_BINARY_DIR};PLUGIN;ALL;/")
|
||||
else ()
|
||||
set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${PLUGIN_BINARY_DIR};PLUGIN;libraries;/")
|
||||
endif ()
|
||||
endif ()
|
||||
if (HDF5_PLUGINS_FOUND AND PLUGIN_USE_EXTERNAL)
|
||||
if (WIN32)
|
||||
set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${PLUGIN_BINARY_DIR};PLUGIN;ALL;/")
|
||||
else ()
|
||||
set (CPACK_INSTALL_CMAKE_PROJECTS "${CPACK_INSTALL_CMAKE_PROJECTS};${PLUGIN_BINARY_DIR};PLUGIN;libraries;/")
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
+14
-20
@@ -549,8 +549,6 @@ include (${HDF_CONFIG_DIR}/HDFMacros.cmake)
|
||||
|
||||
HDF_DIR_PATHS(${HDF5_PACKAGE_NAME})
|
||||
|
||||
include (${HDF_RESOURCES_DIR}/HDFLibMacros.cmake)
|
||||
include (${HDF_RESOURCES_DIR}/HDF5PluginMacros.cmake)
|
||||
include (${HDF_CONFIG_DIR}/HDF5Macros.cmake)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@@ -959,11 +957,18 @@ include (UserMacros.cmake)
|
||||
include (config/CacheURLs.cmake)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Include filter (zlib, szip, etc.) macros
|
||||
# Include filter (zlib, szip, etc.) support
|
||||
#-----------------------------------------------------------------------------
|
||||
if (HDF5_ENABLE_ZLIB_SUPPORT OR HDF5_ENABLE_SZIP_SUPPORT)
|
||||
include (CMakeFilters.cmake)
|
||||
endif ()
|
||||
unset (SETTINGS_EXTERNAL_FILTERS)
|
||||
include (${HDF_CONFIG_DIR}/HDF5UseZLIB.cmake)
|
||||
include (${HDF_CONFIG_DIR}/HDF5UseLibaec.cmake)
|
||||
|
||||
# Process list of filters for libhdf5.settings (and the H5build_settings string)
|
||||
list (REMOVE_DUPLICATES SETTINGS_EXTERNAL_FILTERS)
|
||||
string (REPLACE ";" " " SETTINGS_EXTERNAL_FILTERS "${SETTINGS_EXTERNAL_FILTERS}")
|
||||
|
||||
# Print out compression libraries linked for debugging
|
||||
message (VERBOSE "LINK_COMP_LIBS=${LINK_COMP_LIBS}")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Include external VOL connectors
|
||||
@@ -1174,17 +1179,6 @@ endif ()
|
||||
#-----------------------------------------------------------------------------
|
||||
add_subdirectory (src)
|
||||
|
||||
if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ")
|
||||
if ((H5_ZLIB_FOUND AND ZLIB_USE_EXTERNAL) OR (H5_SZIP_FOUND AND SZIP_USE_EXTERNAL))
|
||||
if (BUILD_STATIC_LIBS)
|
||||
add_dependencies (${HDF5_LIB_TARGET} ${LINK_COMP_LIBS})
|
||||
endif ()
|
||||
if (BUILD_SHARED_LIBS)
|
||||
add_dependencies (${HDF5_LIBSH_TARGET} ${LINK_COMP_LIBS})
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Dashboard and Testing Settings
|
||||
#-----------------------------------------------------------------------------
|
||||
@@ -1242,9 +1236,9 @@ if (HDF5_ENABLE_PLUGIN_SUPPORT)
|
||||
else ()
|
||||
include (CMakePlugins.cmake)
|
||||
|
||||
if (HDF5_PACKAGE_EXTLIBS AND NOT HDF5_NO_PACKAGES AND PLUGIN_FOUND)
|
||||
PACKAGE_PLUGIN_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT})
|
||||
endif ()
|
||||
# if (HDF5_PACKAGE_EXTLIBS AND NOT HDF5_NO_PACKAGES AND HDF5_PLUGINS_FOUND)
|
||||
# PACKAGE_PLUGIN_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT})
|
||||
# endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
|
||||
+134
-42
@@ -32,64 +32,156 @@
|
||||
# See comments throughout for details on each option and logic branch.
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# The FetchContent module is needed for building filter plugins from source
|
||||
# -----------------------------------------------------------------------------
|
||||
include (FetchContent)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Specify major options at the top of the file
|
||||
# -----------------------------------------------------------------------------
|
||||
option (PLUGIN_USE_EXTERNAL "Use External Library Building for filter PLUGIN else search" OFF)
|
||||
cmake_dependent_option (PLUGIN_USE_LOCALCONTENT "Use local file for PLUGIN FetchContent" OFF PLUGIN_USE_EXTERNAL OFF)
|
||||
|
||||
include (ExternalProject)
|
||||
# Function to find an HDF5 filter plugins installation on the system with
|
||||
# find_package()
|
||||
function (system_hdf5_plugins_library)
|
||||
set (HDF5_PLUGINS_FOUND FALSE)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Option for enabling filter plugin support by building the plugins from external sources
|
||||
# -----------------------------------------------------------------------------
|
||||
#option (HDF5_ALLOW_EXTERNAL_SUPPORT "Allow External Library Building (NO GIT TGZ)" "NO")
|
||||
set (HDF5_ALLOW_EXTERNAL_SUPPORT "NO" CACHE STRING "Allow External Library Building (NO GIT TGZ)")
|
||||
set_property (CACHE HDF5_ALLOW_EXTERNAL_SUPPORT PROPERTY STRINGS NO GIT TGZ)
|
||||
if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ")
|
||||
set (PLUGIN_USE_EXTERNAL ON CACHE BOOL "Use External Library Building for PLUGIN else search" FORCE)
|
||||
if (DEFINED PLUGIN_PACKAGE_NAME)
|
||||
set (_package_name "${PLUGIN_PACKAGE_NAME}")
|
||||
else ()
|
||||
set (_package_name "${HDF5_FILTER_PLUGINS_PACKAGE_NAME}")
|
||||
endif ()
|
||||
|
||||
find_package (HDF5_PLUGINS NAMES ${_package_name}${HDF_PACKAGE_EXT})
|
||||
|
||||
set (HDF5_PLUGINS_FOUND "${HDF5_PLUGINS_FOUND}" PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
# Function to retrieve the HDF5 filter plugins project from external source (if
|
||||
# necessary) and add it to the build process
|
||||
#
|
||||
# NOTE: This function does NOT patch the upstream HDF5 filter plugins project and
|
||||
# will need maintenance for any changes in the CMake target names, installed
|
||||
# configuration files, etc. in new releases.
|
||||
function (external_hdf5_plugins_library)
|
||||
if (NOT HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT|TGZ")
|
||||
message (FATAL_ERROR "HDF5_ALLOW_EXTERNAL_SUPPORT must be 'GIT' or 'TGZ' when PLUGIN_USE_EXTERNAL is ON (Current setting: ${HDF5_ALLOW_EXTERNAL_SUPPORT})")
|
||||
endif ()
|
||||
|
||||
# Setup for FetchContent
|
||||
if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT")
|
||||
set (PLUGIN_URL ${PLUGIN_GIT_URL} CACHE STRING "Path to PLUGIN git repository")
|
||||
set (PLUGIN_BRANCH ${PLUGIN_GIT_BRANCH})
|
||||
elseif (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ")
|
||||
if (NOT H5PL_TGZPATH)
|
||||
if (PLUGIN_USE_LOCALCONTENT)
|
||||
message (FATAL_ERROR "HDF5_ALLOW_EXTERNAL_SUPPORT '${HDF5_ALLOW_EXTERNAL_SUPPORT}' and PLUGIN_USE_LOCALCONTENT options are mutually exclusive")
|
||||
endif ()
|
||||
|
||||
if (DEFINED PLUGIN_GIT_URL)
|
||||
# PLUGIN_GIT_URL is deprecated, but still available
|
||||
set (_plugins_url "${PLUGIN_GIT_URL}")
|
||||
else ()
|
||||
set (_plugins_url "${HDF5_FILTER_PLUGINS_GIT_URL}")
|
||||
endif ()
|
||||
|
||||
if (DEFINED PLUGIN_GIT_BRANCH)
|
||||
# PLUGIN_GIT_BRANCH is deprecated, but still available
|
||||
set (_plugins_tag "${PLUGIN_GIT_BRANCH}")
|
||||
else ()
|
||||
set (_plugins_tag "${HDF5_FILTER_PLUGINS_GIT_TAG}")
|
||||
endif ()
|
||||
|
||||
message (STATUS "HDF5 filter plugins project will be built from source ${_plugins_url} (tag ${_plugins_tag})")
|
||||
|
||||
# Instruct FetchContent to retrieve HDF5 filter plugins project from GIT
|
||||
FetchContent_Declare (HDF5_FILTER_PLUGINS
|
||||
GIT_REPOSITORY ${_plugins_url}
|
||||
GIT_TAG ${_plugins_tag}
|
||||
)
|
||||
else () # HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ"
|
||||
if (NOT DEFINED H5PL_TGZPATH)
|
||||
set (H5PL_TGZPATH ${TGZPATH})
|
||||
endif ()
|
||||
if (NOT PLUGIN_USE_LOCALCONTENT)
|
||||
set (PLUGIN_URL ${PLUGIN_TGZ_ORIGPATH}/${PLUGIN_TGZ_NAME})
|
||||
|
||||
if (DEFINED PLUGIN_TGZ_NAME)
|
||||
# PLUGIN_TGZ_NAME is deprecated, but still available
|
||||
set (_tgz_name "${PLUGIN_TGZ_NAME}")
|
||||
else ()
|
||||
if (NOT H5PL_TGZPATH)
|
||||
set (H5PL_TGZPATH ${TGZPATH})
|
||||
endif ()
|
||||
set (PLUGIN_URL ${H5PL_TGZPATH}/${PLUGIN_TGZ_NAME})
|
||||
if (NOT EXISTS "${PLUGIN_URL}")
|
||||
set (HDF5_ENABLE_PLUGIN_SUPPORT OFF CACHE BOOL "" FORCE)
|
||||
message (VERBOSE "Filter PLUGIN file ${PLUGIN_URL} not found")
|
||||
endif ()
|
||||
set (_tgz_name "${HDF5_FILTER_PLUGINS_TGZ_NAME}")
|
||||
endif ()
|
||||
message (VERBOSE "Filter PLUGIN file is ${PLUGIN_URL}")
|
||||
else ()
|
||||
set (PLUGIN_USE_EXTERNAL OFF CACHE BOOL "Use External Library Building for PLUGIN else search")
|
||||
message (VERBOSE "Filter PLUGIN not built")
|
||||
|
||||
if (PLUGIN_USE_LOCALCONTENT)
|
||||
# Use specified HDF5 filter plugins .tgz file from system
|
||||
set (_plugins_url ${H5PL_TGZPATH}/${_tgz_name})
|
||||
else ()
|
||||
if (DEFINED PLUGIN_TGZ_ORIGPATH)
|
||||
# PLUGIN_TGZ_ORIGPATH is deprecated, but still available
|
||||
set (_tgz_origpath "${PLUGIN_TGZ_ORIGPATH}")
|
||||
else ()
|
||||
set (_tgz_origpath "${HDF5_FILTER_PLUGINS_TGZ_ORIGPATH}")
|
||||
endif ()
|
||||
|
||||
# Use HDF5 filter plugins .tgz file HDF5_FILTER_PLUGINS_TGZ_NAME / PLUGIN_TGZ_NAME downloaded
|
||||
# from base URL HDF5_FILTER_PLUGINS_TGZ_ORIGPATH / PLUGIN_TGZ_ORIGPATH
|
||||
set (_plugins_url "${_tgz_origpath}/${_tgz_name}")
|
||||
endif ()
|
||||
|
||||
if (PLUGIN_USE_LOCALCONTENT AND NOT EXISTS "${_plugins_url}")
|
||||
message (FATAL_ERROR "HDF5 filter plugins file ${_plugins_url} not found (try setting TGZPATH to a directory containing ${_tgz_name})")
|
||||
endif ()
|
||||
|
||||
message (STATUS "HDF5 filter plugins project will be built from source ${_plugins_url}")
|
||||
|
||||
# Instruct FetchContent to retrieve HDF5 filter plugins project from .tgz file
|
||||
FetchContent_Declare (HDF5_FILTER_PLUGINS
|
||||
URL ${_plugins_url}
|
||||
URL_HASH ""
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Include HDF5 filter plugins CMake cache configuration
|
||||
include (${HDF_RESOURCES_DIR}/HDF5PluginCache.cmake)
|
||||
|
||||
# Set other options for build
|
||||
set (CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
||||
|
||||
if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR NOT PLUGIN_USE_LOCALCONTENT)
|
||||
message (VERBOSE "Fetching and configuring HDF5 filter plugins project")
|
||||
else ()
|
||||
message (VERBOSE "Configuring HDF5 filter plugins project")
|
||||
endif ()
|
||||
|
||||
# Make HDF5 filter plugins project available for the build
|
||||
FetchContent_MakeAvailable (HDF5_FILTER_PLUGINS)
|
||||
|
||||
# Set HDF5 filter plugins directory and status variables
|
||||
set (PLUGIN_BINARY_DIR "${plugin_BINARY_DIR}" PARENT_SCOPE)
|
||||
|
||||
set (HDF5_PLUGINS_FOUND TRUE PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Option for PLUGIN support
|
||||
# Option for HDF5 filter plugins support
|
||||
#-----------------------------------------------------------------------------
|
||||
if (HDF5_ENABLE_PLUGIN_SUPPORT)
|
||||
if (NOT PLUGIN_USE_EXTERNAL) # This checks if plugins should be found on the system or built from an external source
|
||||
find_package (PLUGIN NAMES ${PLUGIN_PACKAGE_NAME}${HDF_PACKAGE_EXT})
|
||||
if (NOT PLUGIN_FOUND)
|
||||
find_package (PLUGIN) # Legacy find
|
||||
endif ()
|
||||
set (HDF5_PLUGINS_FOUND FALSE)
|
||||
|
||||
if (NOT PLUGIN_USE_EXTERNAL)
|
||||
# Find HDF5 filter plugins installation on the system
|
||||
system_hdf5_plugins_library ()
|
||||
else ()
|
||||
if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ")
|
||||
EXTERNAL_PLUGIN_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT})
|
||||
message (STATUS "Filter PLUGIN is built")
|
||||
endif ()
|
||||
# Retrieve HDF5 filter plugins from external source (if necessary) and add
|
||||
# them to the build process. Note that in this case "external" could also
|
||||
# mean a local .tgz file on the system
|
||||
external_hdf5_plugins_library ()
|
||||
endif ()
|
||||
if (PLUGIN_FOUND)
|
||||
message (STATUS "Filter PLUGIN is ON")
|
||||
|
||||
if (HDF5_PLUGINS_FOUND)
|
||||
message (VERBOSE "External HDF5 filter plugins are enabled")
|
||||
else ()
|
||||
set (HDF5_ENABLE_PLUGIN_SUPPORT OFF CACHE BOOL "" FORCE)
|
||||
message (FATAL_ERROR " PLUGIN support in HDF5 was enabled but not found")
|
||||
if (PLUGIN_USE_EXTERNAL)
|
||||
message (FATAL_ERROR "External support for HDF5 filter plugins was enabled, but couldn't be processed")
|
||||
else ()
|
||||
message (FATAL_ERROR "Support for filter plugins in HDF5 was enabled, but an HDF5 filter plugins installation couldn't be found")
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
+11
-10
@@ -29,11 +29,11 @@
|
||||
},
|
||||
"ZLIB_TGZ_ORIGPATH": {
|
||||
"type": "STRING",
|
||||
"value": "https://github.com/madler/zlib/releases/download/v1.3.1"
|
||||
"value": "https://github.com/madler/zlib/releases/download/v1.3.2"
|
||||
},
|
||||
"ZLIB_TGZ_NAME": {
|
||||
"type": "STRING",
|
||||
"value": "zlib-1.3.1.tar.gz"
|
||||
"value": "zlib-1.3.2.tar.gz"
|
||||
},
|
||||
"ZLIBNG_PACKAGE_NAME": {
|
||||
"type": "STRING",
|
||||
@@ -45,7 +45,7 @@
|
||||
},
|
||||
"ZLIBNG_TGZ_NAME": {
|
||||
"type": "STRING",
|
||||
"value": "2.2.4.tar.gz"
|
||||
"value": "2.3.3.tar.gz"
|
||||
},
|
||||
"LIBAEC_PACKAGE_NAME": {
|
||||
"type": "STRING",
|
||||
@@ -53,11 +53,11 @@
|
||||
},
|
||||
"LIBAEC_TGZ_ORIGPATH": {
|
||||
"type": "STRING",
|
||||
"value": "https://github.com/MathisRosenhauer/libaec/releases/download/v1.1.3"
|
||||
"value": "https://github.com/MathisRosenhauer/libaec/releases/download/v1.1.6"
|
||||
},
|
||||
"LIBAEC_TGZ_NAME": {
|
||||
"type": "STRING",
|
||||
"value": "libaec-1.1.3.tar.gz"
|
||||
"value": "libaec-1.1.6.tar.gz"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -209,15 +209,15 @@
|
||||
"type": "STRING",
|
||||
"value": "TGZ"
|
||||
},
|
||||
"PLUGIN_PACKAGE_NAME": {
|
||||
"HDF5_FILTER_PLUGINS_PACKAGE_NAME": {
|
||||
"type": "STRING",
|
||||
"value": "pl"
|
||||
"value": "h5pl"
|
||||
},
|
||||
"PLUGIN_TGZ_ORIGPATH": {
|
||||
"HDF5_FILTER_PLUGINS_TGZ_ORIGPATH": {
|
||||
"type": "STRING",
|
||||
"value": "https://github.com/HDFGroup/hdf5_plugins/releases/download/snapshot"
|
||||
},
|
||||
"PLUGIN_TGZ_NAME": {
|
||||
"HDF5_FILTER_PLUGINS_TGZ_NAME": {
|
||||
"type": "STRING",
|
||||
"value": "hdf5_plugins-master.tar.gz"
|
||||
}
|
||||
@@ -232,7 +232,8 @@
|
||||
"ci-base-tgz"
|
||||
],
|
||||
"cacheVariables": {
|
||||
"PLUGIN_USE_LOCALCONTENT": "OFF"
|
||||
"PLUGIN_USE_LOCALCONTENT": "OFF",
|
||||
"PLUGIN_USE_EXTERNAL": "ON"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
||||
+68
-32
@@ -13,38 +13,56 @@
|
||||
########################
|
||||
# compression options
|
||||
########################
|
||||
set (ZLIB_VERSION "1.3.2" CACHE INTERNAL "Version of zlib to use when building from external source")
|
||||
set (ZLIB_PACKAGE_NAME "zlib" CACHE STRING "Name of ZLIB package")
|
||||
mark_as_advanced (ZLIB_PACKAGE_NAME)
|
||||
set (ZLIB_TGZ_NAME "zlib-1.3.1.tar.gz" CACHE STRING "Use HDF5_ZLib from compressed file")
|
||||
set (ZLIB_TGZ_ORIGPATH "https://github.com/madler/zlib/releases/download/v1.3.1" CACHE STRING "Use ZLIB from original location")
|
||||
set (ZLIB_TGZ_NAME "zlib-${ZLIB_VERSION}.tar.gz" CACHE STRING "Base name of zlib compressed file")
|
||||
set (ZLIB_TGZ_ORIGPATH "https://github.com/madler/zlib/releases/download/v${ZLIB_VERSION}" CACHE STRING "URL to retrieve external zlib compressed file from")
|
||||
mark_as_advanced (ZLIB_TGZ_NAME)
|
||||
mark_as_advanced (ZLIB_TGZ_ORIGPATH)
|
||||
set (ZLIB_GIT_URL "https://github.com/madler/zlib.git" CACHE STRING "Use ZLIB from GitHub repository")
|
||||
set (ZLIB_GIT_BRANCH "develop" CACHE STRING "")
|
||||
set (ZLIB_GIT_URL "https://github.com/madler/zlib.git" CACHE STRING "GIT URL to retrieve external zlib source from")
|
||||
set (ZLIB_GIT_TAG "v${ZLIB_VERSION}" CACHE STRING "GIT tag to retrieve external zlib source from")
|
||||
mark_as_advanced (ZLIB_GIT_URL)
|
||||
mark_as_advanced (ZLIB_GIT_BRANCH)
|
||||
mark_as_advanced (ZLIB_GIT_TAG)
|
||||
# DEPRECATED
|
||||
unset (ZLIB_GIT_BRANCH)
|
||||
if (DEFINED ZLIB_GIT_BRANCH)
|
||||
message (DEPRECATION "ZLIB_GIT_BRANCH has been deprecated in favor of ZLIB_GIT_TAG")
|
||||
endif ()
|
||||
|
||||
set (ZLIBNG_PACKAGE_NAME "zlib-ng" CACHE STRING "Name of ZLIBNG package")
|
||||
set (ZLIBNG_VERSION "2.3.3" CACHE INTERNAL "Version of zlib-ng to use when building from external source")
|
||||
set (ZLIBNG_PACKAGE_NAME "ZLIBNG" CACHE STRING "Name of zlib-ng package")
|
||||
mark_as_advanced (ZLIBNG_PACKAGE_NAME)
|
||||
set (ZLIBNG_TGZ_NAME "2.2.4.tar.gz" CACHE STRING "Use HDF5_ZLib from compressed file")
|
||||
set (ZLIBNG_TGZ_ORIGPATH "https://github.com/zlib-ng/zlib-ng/archive/refs/tags" CACHE STRING "Use ZLIBNG from original location")
|
||||
set (ZLIBNG_TGZ_NAME "${ZLIBNG_VERSION}.tar.gz" CACHE STRING "Base name of zlib-ng compressed file")
|
||||
set (ZLIBNG_TGZ_ORIGPATH "https://github.com/zlib-ng/zlib-ng/archive/refs/tags" CACHE STRING "URL to retrieve external zlib-ng compressed file from")
|
||||
mark_as_advanced (ZLIBNG_TGZ_NAME)
|
||||
mark_as_advanced (ZLIBNG_TGZ_ORIGPATH)
|
||||
set (ZLIBNG_GIT_URL "https://github.com/zlib-ng/zlib-ng.git" CACHE STRING "Use ZLIBNG from GitHub repository")
|
||||
set (ZLIBNG_GIT_BRANCH "develop" CACHE STRING "")
|
||||
set (ZLIBNG_GIT_URL "https://github.com/zlib-ng/zlib-ng.git" CACHE STRING "GIT URL to retrieve external zlib-ng source from")
|
||||
set (ZLIBNG_GIT_TAG "${ZLIBNG_VERSION}" CACHE STRING "GIT tag to retrieve external zlib-ng source from")
|
||||
mark_as_advanced (ZLIBNG_GIT_URL)
|
||||
mark_as_advanced (ZLIBNG_GIT_BRANCH)
|
||||
mark_as_advanced (ZLIBNG_GIT_TAG)
|
||||
# DEPRECATED
|
||||
unset (ZLIBNG_GIT_BRANCH)
|
||||
if (DEFINED ZLIBNG_GIT_BRANCH)
|
||||
message (DEPRECATION "ZLIBNG_GIT_BRANCH has been deprecated in favor of ZLIBNG_GIT_TAG")
|
||||
endif ()
|
||||
|
||||
set (LIBAEC_VERSION "1.1.6" CACHE INTERNAL "Version of LIBAEC to use when building from external source")
|
||||
set (LIBAEC_PACKAGE_NAME "libaec" CACHE STRING "Name of AEC SZIP package")
|
||||
mark_as_advanced (LIBAEC_PACKAGE_NAME)
|
||||
set (LIBAEC_TGZ_NAME "libaec-1.1.3.tar.gz" CACHE STRING "Use SZip AEC from compressed file")
|
||||
set (LIBAEC_TGZ_ORIGPATH "https://github.com/MathisRosenhauer/libaec/releases/download/v1.1.3" CACHE STRING "Use LIBAEC from original location")
|
||||
set (LIBAEC_TGZ_NAME "libaec-${LIBAEC_VERSION}.tar.gz" CACHE STRING "Base name of LIBAEC compressed file")
|
||||
set (LIBAEC_TGZ_ORIGPATH "https://github.com/MathisRosenhauer/libaec/releases/download/v${LIBAEC_VERSION}" CACHE STRING "URL to retrieve external LIBAEC compressed file from")
|
||||
mark_as_advanced (LIBAEC_TGZ_NAME)
|
||||
mark_as_advanced (LIBAEC_TGZ_ORIGPATH)
|
||||
set (LIBAEC_GIT_URL "https://github.com/MathisRosenhauer/libaec.git" CACHE STRING "Use LIBAEC from GitHub repository")
|
||||
set (LIBAEC_GIT_BRANCH "v1.1.3" CACHE STRING "")
|
||||
set (LIBAEC_GIT_URL "https://github.com/MathisRosenhauer/libaec.git" CACHE STRING "GIT URL to retrieve external LIBAEC source from")
|
||||
set (LIBAEC_GIT_TAG "v${LIBAEC_VERSION}" CACHE STRING "GIT tag to retrieve external LIBAEC source from")
|
||||
mark_as_advanced (LIBAEC_GIT_URL)
|
||||
mark_as_advanced (LIBAEC_GIT_BRANCH)
|
||||
mark_as_advanced (LIBAEC_GIT_TAG)
|
||||
# DEPRECATED
|
||||
unset (LIBAEC_GIT_BRANCH)
|
||||
if (DEFINED LIBAEC_GIT_BRANCH)
|
||||
message (DEPRECATION "LIBAEC_GIT_BRANCH has been deprecated in favor of LIBAEC_GIT_TAG")
|
||||
endif ()
|
||||
|
||||
########################
|
||||
# API test options
|
||||
@@ -57,17 +75,32 @@ mark_as_advanced (KWSYS_TGZ_NAME)
|
||||
########################
|
||||
# filter plugin options
|
||||
########################
|
||||
|
||||
set (PLUGIN_TGZ_ORIGPATH "https://github.com/HDFGroup/hdf5_plugins/releases/download/snapshot" CACHE STRING "Use PLUGINS from original location")
|
||||
set (PLUGIN_TGZ_NAME "hdf5_plugins-master.tar.gz" CACHE STRING "Use PLUGINS from compressed file")
|
||||
mark_as_advanced (PLUGIN_TGZ_ORIGPATH)
|
||||
mark_as_advanced (PLUGIN_TGZ_NAME)
|
||||
set (PLUGIN_PACKAGE_NAME "pl" CACHE STRING "Name of PLUGIN package")
|
||||
mark_as_advanced (PLUGIN_PACKAGE_NAME)
|
||||
set (PLUGIN_GIT_URL "https://github.com/HDFGroup/hdf5_plugins.git" CACHE STRING "Use plugins from HDF Group repository")
|
||||
set (PLUGIN_GIT_BRANCH "master" CACHE STRING "")
|
||||
mark_as_advanced (PLUGIN_GIT_URL)
|
||||
mark_as_advanced (PLUGIN_GIT_BRANCH)
|
||||
set (HDF5_FILTER_PLUGINS_PACKAGE_NAME "h5pl" CACHE STRING "Name of HDF5 filter plugins package")
|
||||
mark_as_advanced (HDF5_FILTER_PLUGINS_PACKAGE_NAME)
|
||||
set (HDF5_FILTER_PLUGINS_TGZ_NAME "hdf5_plugins-master.tar.gz" CACHE STRING "Base name of HDF5 filter plugins compressed file")
|
||||
set (HDF5_FILTER_PLUGINS_TGZ_ORIGPATH "https://github.com/HDFGroup/hdf5_plugins/releases/download/snapshot" CACHE STRING "URL to retrieve external HDF5 filter plugins compressed file from")
|
||||
mark_as_advanced (HDF5_FILTER_PLUGINS_TGZ_NAME)
|
||||
mark_as_advanced (HDF5_FILTER_PLUGINS_TGZ_ORIGPATH)
|
||||
set (HDF5_FILTER_PLUGINS_GIT_URL "https://github.com/HDFGroup/hdf5_plugins.git" CACHE STRING "GIT URL to retrieve external HDF5 filter plugins source from")
|
||||
set (HDF5_FILTER_PLUGINS_GIT_TAG "master" CACHE STRING "GIT tag to retrieve external HDF5 filter plugins source from")
|
||||
mark_as_advanced (HDF5_FILTER_PLUGINS_GIT_URL)
|
||||
mark_as_advanced (HDF5_FILTER_PLUGINS_GIT_TAG)
|
||||
# DEPRECATED
|
||||
if (DEFINED PLUGIN_PACKAGE_NAME)
|
||||
message (DEPRECATION "PLUGIN_PACKAGE_NAME has been deprecated in favor of HDF5_FILTER_PLUGINS_PACKAGE_NAME")
|
||||
endif ()
|
||||
if (DEFINED PLUGIN_TGZ_NAME)
|
||||
message (DEPRECATION "PLUGIN_TGZ_NAME has been deprecated in favor of HDF5_FILTER_PLUGINS_TGZ_NAME")
|
||||
endif ()
|
||||
if (DEFINED PLUGIN_TGZ_ORIGPATH)
|
||||
message (DEPRECATION "PLUGIN_TGZ_ORIGPATH has been deprecated in favor of HDF5_FILTER_PLUGINS_TGZ_ORIGPATH")
|
||||
endif ()
|
||||
if (DEFINED PLUGIN_GIT_URL)
|
||||
message (DEPRECATION "PLUGIN_GIT_URL has been deprecated in favor of HDF5_FILTER_PLUGINS_GIT_URL")
|
||||
endif ()
|
||||
if (DEFINED PLUGIN_GIT_BRANCH)
|
||||
message (DEPRECATION "PLUGIN_GIT_BRANCH has been deprecated in favor of HDF5_FILTER_PLUGINS_GIT_TAG")
|
||||
endif ()
|
||||
|
||||
###########
|
||||
# bitgroom
|
||||
@@ -102,13 +135,14 @@ mark_as_advanced (BSHUF_PACKAGE_NAME)
|
||||
# blosc
|
||||
########
|
||||
|
||||
set (HDF5_BLOSC_VERSION "1.21.6" CACHE INTERNAL "Version of Blosc to use when building from external source")
|
||||
set (BLOSC_GIT_URL "https://github.com/Blosc/c-blosc.git" CACHE STRING "Use BLOSC from Github repository")
|
||||
set (BLOSC_GIT_BRANCH "main" CACHE STRING "")
|
||||
mark_as_advanced (BLOSC_GIT_URL)
|
||||
mark_as_advanced (BLOSC_GIT_BRANCH)
|
||||
|
||||
set (BLOSC_TGZ_ORIGPATH "https://github.com/Blosc/c-blosc/archive/refs/tags" CACHE STRING "Use PLUGINS from original location")
|
||||
set (BLOSC_TGZ_NAME "c-blosc-1.21.6.tar.gz" CACHE STRING "Use BLOSC from compressed file")
|
||||
set (BLOSC_TGZ_NAME "c-blosc-${HDF5_BLOSC_VERSION}.tar.gz" CACHE STRING "Use BLOSC from compressed file")
|
||||
mark_as_advanced (BLOSC_TGZ_ORIGPATH)
|
||||
mark_as_advanced (BLOSC_TGZ_NAME)
|
||||
|
||||
@@ -132,13 +166,14 @@ mark_as_advanced (BLOSC_ZLIB_PACKAGE_NAME)
|
||||
# blosc2
|
||||
########
|
||||
|
||||
set (HDF5_BLOSC2_VERSION "2.17.1" CACHE INTERNAL "Version of Blosc2 to use when building from external source")
|
||||
set (BLOSC2_GIT_URL "https://github.com/Blosc/c-blosc2.git" CACHE STRING "Use BLOSC2 from Github repository")
|
||||
set (BLOSC2_GIT_BRANCH "main" CACHE STRING "")
|
||||
mark_as_advanced (BLOSC2_GIT_URL)
|
||||
mark_as_advanced (BLOSC2_GIT_BRANCH)
|
||||
|
||||
set (BLOSC2_TGZ_ORIGPATH "https://github.com/Blosc/c-blosc2/archive/refs/tags" CACHE STRING "Use PLUGINS from original location")
|
||||
set (BLOSC2_TGZ_NAME "c-blosc2-2.17.1.tar.gz" CACHE STRING "Use BLOSC2 from compressed file")
|
||||
set (BLOSC2_TGZ_NAME "c-blosc2-${HDF5_BLOSC2_VERSION}.tar.gz" CACHE STRING "Use BLOSC2 from compressed file")
|
||||
mark_as_advanced (BLOSC2_TGZ_ORIGPATH)
|
||||
mark_as_advanced (BLOSC2_TGZ_NAME)
|
||||
|
||||
@@ -282,13 +317,14 @@ mark_as_advanced (ZFP_PACKAGE_NAME)
|
||||
# zstd
|
||||
######
|
||||
|
||||
set (ZSTD_GIT_URL "https://github.com/facebook/zstd.git" CACHE STRING "Use ZSTD from GitHub repository")
|
||||
set (HDF5_ZSTD_VERSION "1.5.7" CACHE INTERNAL "Version of Zstd to use when building from external source")
|
||||
set (ZSTD_GIT_URL "https://github.com/facebook/zstd.git" CACHE STRING "Use ZSTD from GitHub repository")
|
||||
set (ZSTD_GIT_BRANCH "dev" CACHE STRING "")
|
||||
mark_as_advanced (ZSTD_GIT_URL)
|
||||
mark_as_advanced (ZSTD_GIT_BRANCH)
|
||||
|
||||
set (ZSTD_TGZ_ORIGPATH "https://github.com/facebook/zstd/releases/download/v1.5.7" CACHE STRING "Use PLUGINS from original location")
|
||||
set (ZSTD_TGZ_NAME "zstd-1.5.7.tar.gz" CACHE STRING "Use ZSTD from compressed file")
|
||||
set (ZSTD_TGZ_ORIGPATH "https://github.com/facebook/zstd/releases/download/v${HDF5_ZSTD_VERSION}" CACHE STRING "Use PLUGINS from original location")
|
||||
set (ZSTD_TGZ_NAME "zstd-${HDF5_ZSTD_VERSION}.tar.gz" CACHE STRING "Use ZSTD from compressed file")
|
||||
mark_as_advanced (ZSTD_TGZ_ORIGPATH)
|
||||
mark_as_advanced (ZSTD_TGZ_NAME)
|
||||
|
||||
|
||||
@@ -0,0 +1,269 @@
|
||||
#
|
||||
# Copyright by The HDF Group.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of HDF5. The full HDF5 copyright notice, including
|
||||
# terms governing use, modification, and redistribution, is contained in
|
||||
# the LICENSE file, which can be found at the root of the source code
|
||||
# distribution tree, or in https://www.hdfgroup.org/licenses.
|
||||
# If you do not have access to either file, you may request a copy from
|
||||
# help@hdfgroup.org.
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
# HDF5 CMake Libaec Support Configuration
|
||||
# -----------------------------------------------------------------------------
|
||||
# This CMake module configures support for libaec in HDF5. It provides options
|
||||
# for enabling/disabling libaec support, selecting static/shared builds, and
|
||||
# controlling how libaec is found or built (from system-installed libraries,
|
||||
# from local source code on the system, or externally via the GIT/TGZ options
|
||||
# for HDF5_ALLOW_EXTERNAL_SUPPORT).
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# the FetchContent module is needed for building compression libraries from source
|
||||
# -----------------------------------------------------------------------------
|
||||
include (FetchContent)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Specify major options at the top of the file
|
||||
# -----------------------------------------------------------------------------
|
||||
cmake_dependent_option (HDF5_USE_LIBAEC_STATIC "Find static AEC library" OFF HDF5_ENABLE_SZIP_SUPPORT OFF)
|
||||
cmake_dependent_option (HDF5_ENABLE_SZIP_ENCODING "Use SZip Encoding" ON HDF5_ENABLE_SZIP_SUPPORT OFF)
|
||||
cmake_dependent_option (SZIP_USE_EXTERNAL "Use External Library Building for SZIP" OFF HDF5_ENABLE_SZIP_SUPPORT OFF)
|
||||
mark_as_advanced (SZIP_USE_EXTERNAL)
|
||||
cmake_dependent_option (LIBAEC_USE_LOCALCONTENT "Use local file for LIBAEC FetchContent" OFF HDF5_ENABLE_SZIP_SUPPORT OFF)
|
||||
mark_as_advanced (LIBAEC_USE_LOCALCONTENT)
|
||||
|
||||
# Function to find libaec/szip on the system with find_package()
|
||||
function (system_szip_library)
|
||||
set (SZIP_FOUND FALSE)
|
||||
|
||||
if (NOT DEFINED LIBAEC_PACKAGE_NAME)
|
||||
message (FATAL_ERROR "LIBAEC_PACKAGE_NAME is undefined")
|
||||
endif ()
|
||||
|
||||
if (HDF5_USE_LIBAEC_STATIC)
|
||||
set (LIBAEC_SEARCH_TYPE "static")
|
||||
else ()
|
||||
set (LIBAEC_SEARCH_TYPE "shared")
|
||||
endif ()
|
||||
set (libaec_USE_STATIC_LIBS ${HDF5_USE_LIBAEC_STATIC})
|
||||
|
||||
# For "libaec", start with our own Findlibaec.cmake module that prefers a
|
||||
# CONFIG find mode if possible and falls back to MODULE find mode if necessary.
|
||||
# For "szip", use CMake's standard MODULE find mode followed by a CONFIG find
|
||||
# mode.
|
||||
find_package (${LIBAEC_PACKAGE_NAME} OPTIONAL_COMPONENTS ${LIBAEC_SEARCH_TYPE})
|
||||
|
||||
if (${${LIBAEC_PACKAGE_NAME}_FOUND})
|
||||
set (H5_SZIP_INCLUDE_DIR_GEN ${SZIP_INCLUDE_DIR} PARENT_SCOPE)
|
||||
set (H5_SZIP_INCLUDE_DIRS ${H5_SZIP_INCLUDE_DIRS} ${SZIP_INCLUDE_DIR} PARENT_SCOPE)
|
||||
|
||||
if (LIBAEC_PACKAGE_NAME MATCHES "libaec")
|
||||
# When using libaec to replace SZIP, we require that the libsz compatibility library is available
|
||||
if (NOT libsz_FOUND)
|
||||
message (FATAL_ERROR "Libaec support in HDF5 was enabled and libaec was found, but no libsz compatibility library was found")
|
||||
endif ()
|
||||
|
||||
set (LINK_COMP_LIBS ${LINK_COMP_LIBS} libaec::sz libaec::aec PARENT_SCOPE)
|
||||
else ()
|
||||
set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_LIBRARIES} PARENT_SCOPE)
|
||||
endif ()
|
||||
|
||||
set (H5_SZIP_FOUND TRUE PARENT_SCOPE)
|
||||
endif ()
|
||||
endfunction ()
|
||||
|
||||
# Function to retrieve libaec/szip from external source (if necessary) and add it
|
||||
# to the build process
|
||||
#
|
||||
# NOTE: This function does NOT patch upstream libaec and will need maintenance for
|
||||
# any changes in the CMake target names, installed configuration files, etc. in new
|
||||
# releases.
|
||||
function (external_szip_library)
|
||||
if (NOT HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT|TGZ")
|
||||
message (FATAL_ERROR "HDF5_ALLOW_EXTERNAL_SUPPORT must be 'GIT' or 'TGZ' when SZIP_USE_EXTERNAL is ON (Current setting: ${HDF5_ALLOW_EXTERNAL_SUPPORT})")
|
||||
endif ()
|
||||
|
||||
# Setup for FetchContent
|
||||
if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT")
|
||||
if (LIBAEC_USE_LOCALCONTENT)
|
||||
message (FATAL_ERROR "HDF5_ALLOW_EXTERNAL_SUPPORT '${HDF5_ALLOW_EXTERNAL_SUPPORT}' and LIBAEC_USE_LOCALCONTENT options are mutually exclusive")
|
||||
endif ()
|
||||
|
||||
set (SZIP_URL ${LIBAEC_GIT_URL})
|
||||
|
||||
if (DEFINED LIBAEC_GIT_BRANCH)
|
||||
# LIBAEC_GIT_BRANCH is deprecated, but still available
|
||||
set (SZIP_TAG ${LIBAEC_GIT_BRANCH})
|
||||
else ()
|
||||
set (SZIP_TAG ${LIBAEC_GIT_TAG})
|
||||
endif ()
|
||||
|
||||
message (STATUS "Filter libaec will be built from source ${SZIP_URL} (tag ${SZIP_TAG})")
|
||||
|
||||
# Instruct FetchContent to retrieve libaec from GIT
|
||||
FetchContent_Declare (SZIP
|
||||
GIT_REPOSITORY ${SZIP_URL}
|
||||
GIT_TAG ${SZIP_TAG}
|
||||
)
|
||||
else () # HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ"
|
||||
if (NOT DEFINED TGZPATH)
|
||||
set (TGZPATH ${HDF5_SOURCE_DIR})
|
||||
endif ()
|
||||
|
||||
if (LIBAEC_USE_LOCALCONTENT)
|
||||
# Use specified libaec .tgz file from system
|
||||
set (SZIP_URL ${TGZPATH}/${LIBAEC_TGZ_NAME})
|
||||
else ()
|
||||
# Use libaec .tgz file LIBAEC_TGZ_NAME downloaded from base URL LIBAEC_TGZ_ORIGPATH
|
||||
set (SZIP_URL ${LIBAEC_TGZ_ORIGPATH}/${LIBAEC_TGZ_NAME})
|
||||
endif ()
|
||||
|
||||
if (LIBAEC_USE_LOCALCONTENT AND NOT EXISTS "${SZIP_URL}")
|
||||
message (FATAL_ERROR "Filter SZIP file ${SZIP_URL} not found (try setting TGZPATH to a directory containing ${LIBAEC_TGZ_NAME})")
|
||||
endif ()
|
||||
|
||||
message (STATUS "Filter libaec will be built from source ${SZIP_URL}")
|
||||
|
||||
# Instruct FetchContent to retrieve libaec from .tgz file
|
||||
FetchContent_Declare (SZIP
|
||||
URL ${SZIP_URL}
|
||||
URL_HASH ""
|
||||
)
|
||||
endif ()
|
||||
|
||||
# Set libaec shared/static library building based off of preference variable
|
||||
if (HDF5_USE_LIBAEC_STATIC)
|
||||
set (BUILD_SHARED_LIBS OFF)
|
||||
set (BUILD_STATIC_LIBS ON)
|
||||
else ()
|
||||
set (BUILD_SHARED_LIBS ON)
|
||||
set (BUILD_STATIC_LIBS OFF)
|
||||
endif ()
|
||||
|
||||
# Set libaec options for build. Include libaec packaging logic and override
|
||||
# installation of files into the library's CMake install directory
|
||||
set (BUILD_TESTING OFF)
|
||||
set (libaec_INSTALL_CMAKEDIR "${HDF5_INSTALL_CMAKE_DIR}" CACHE INTERNAL "")
|
||||
set (libaec_INCLUDE_PACKAGING ON CACHE INTERNAL "")
|
||||
|
||||
if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR NOT LIBAEC_USE_LOCALCONTENT)
|
||||
message (VERBOSE "Fetching and configuring filter libaec")
|
||||
else ()
|
||||
message (VERBOSE "Configuring filter libaec")
|
||||
endif ()
|
||||
|
||||
# Make SZIP (libaec) available for the build
|
||||
FetchContent_MakeAvailable (SZIP)
|
||||
|
||||
# Hide libaec-specific items from the GUI by default
|
||||
mark_as_advanced (AEC_FUZZING)
|
||||
|
||||
# Set expected target names, based on shared/static preference
|
||||
# NOTE: These must be maintained with new releases of upstream libaec in
|
||||
# order to avoid having to patch the source when exporting targets.
|
||||
if (BUILD_STATIC_LIBS)
|
||||
set (h5_aec_target_name aec-static)
|
||||
set (h5_aec_objects_target_name aec-static-objects)
|
||||
set (h5_sz_target_name sz-static)
|
||||
set (h5_sz_objects_target_name sz-static-objects)
|
||||
set (h5_aec_export_file_name "libaec_static-targets.cmake")
|
||||
else ()
|
||||
set (h5_aec_target_name aec-shared)
|
||||
set (h5_aec_objects_target_name aec-shared-objects)
|
||||
set (h5_sz_target_name sz-shared)
|
||||
set (h5_sz_objects_target_name sz-shared-objects)
|
||||
set (h5_aec_export_file_name "libaec_shared-targets.cmake")
|
||||
endif ()
|
||||
set (libaec_targets
|
||||
"${h5_aec_target_name}" "${h5_aec_objects_target_name}"
|
||||
"${h5_sz_target_name}" "${h5_sz_objects_target_name}"
|
||||
)
|
||||
foreach (libaec_target ${libaec_targets})
|
||||
if (NOT TARGET ${libaec_target})
|
||||
message (FATAL_ERROR "Expected target ${libaec_target} is missing from build of external libaec")
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
# Optionally add namespace aliases for targets
|
||||
if (HDF_PACKAGE_NAMESPACE)
|
||||
foreach (libaec_target ${libaec_targets})
|
||||
if (NOT TARGET ${HDF_PACKAGE_NAMESPACE}${libaec_target})
|
||||
add_library (${HDF_PACKAGE_NAMESPACE}${libaec_target} ALIAS ${libaec_target})
|
||||
endif ()
|
||||
endforeach ()
|
||||
endif ()
|
||||
|
||||
set (H5_SZIP_LIBRARY "${HDF_PACKAGE_NAMESPACE}${h5_aec_target_name};${HDF_PACKAGE_NAMESPACE}${h5_sz_target_name}")
|
||||
|
||||
# Set include directories for generated and source headers
|
||||
set (H5_SZIP_INCLUDE_DIR_GEN "${szip_BINARY_DIR}" PARENT_SCOPE)
|
||||
set (H5_SZIP_INCLUDE_DIR "${szip_SOURCE_DIR}/include" PARENT_SCOPE)
|
||||
set (H5_SZIP_INCLUDE_DIRS ${H5_SZIP_INCLUDE_DIR_GEN} ${H5_SZIP_INCLUDE_DIR} PARENT_SCOPE)
|
||||
|
||||
set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${H5_SZIP_LIBRARY} PARENT_SCOPE)
|
||||
|
||||
# If built as a sub-project or if cross-compiling, export all exported
|
||||
# targets to the build tree. Append to main targets file but keep
|
||||
# "libaec::" namespace from upstream.
|
||||
if (HDF5_EXTERNALLY_CONFIGURED OR CMAKE_CROSSCOMPILING)
|
||||
export (
|
||||
TARGETS ${libaec_targets}
|
||||
FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-targets.cmake
|
||||
NAMESPACE libaec::
|
||||
APPEND
|
||||
)
|
||||
endif ()
|
||||
|
||||
set (H5_SZIP_FOUND TRUE PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
# Main logic for libaec/szip support
|
||||
if (HDF5_ENABLE_SZIP_SUPPORT)
|
||||
set (H5_SZIP_FOUND FALSE)
|
||||
|
||||
# Set package name for libaec/szip if not already set
|
||||
if (NOT DEFINED LIBAEC_PACKAGE_NAME)
|
||||
set (LIBAEC_PACKAGE_NAME "libaec")
|
||||
endif ()
|
||||
|
||||
if (NOT SZIP_USE_EXTERNAL)
|
||||
# Find libaec/szip on the system
|
||||
system_szip_library ()
|
||||
else ()
|
||||
# Retrieve libaec/szip from external source (if necessary) and add it to the build process
|
||||
# Note that in this case "external" could also mean a local .tgz file on the system
|
||||
external_szip_library ()
|
||||
endif ()
|
||||
|
||||
if (H5_SZIP_FOUND)
|
||||
# Set variables used later on in build process
|
||||
set (H5_HAVE_FILTER_SZIP 1)
|
||||
set (H5_HAVE_SZLIB_H 1)
|
||||
set (H5_HAVE_LIBSZ 1)
|
||||
set (HDF5_COMP_INCLUDE_DIRECTORIES "${HDF5_COMP_INCLUDE_DIRECTORIES};${H5_SZIP_INCLUDE_DIRS}")
|
||||
if (HDF5_ENABLE_SZIP_ENCODING)
|
||||
set (H5_HAVE_SZIP_ENCODER 1)
|
||||
endif ()
|
||||
|
||||
# Set variables for libhdf5.settings (and the H5build_settings string)
|
||||
if (LIBAEC_PACKAGE_NAME MATCHES "libaec")
|
||||
string (TOUPPER "${LIBAEC_PACKAGE_NAME}" LIBAEC_PACKAGE_NAME_UPPER)
|
||||
list (APPEND SETTINGS_EXTERNAL_FILTERS "${LIBAEC_PACKAGE_NAME_UPPER}")
|
||||
else ()
|
||||
list (APPEND SETTINGS_EXTERNAL_FILTERS "SZIP(DECODE)")
|
||||
if (HDF5_ENABLE_SZIP_ENCODING)
|
||||
list (APPEND SETTINGS_EXTERNAL_FILTERS "SZIP(ENCODE)")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
message (VERBOSE "Filter ${LIBAEC_PACKAGE_NAME} is ON")
|
||||
else ()
|
||||
if (SZIP_USE_EXTERNAL)
|
||||
message (FATAL_ERROR "External support for ${LIBAEC_PACKAGE_NAME} in HDF5 was enabled, but couldn't be processed")
|
||||
else ()
|
||||
message (FATAL_ERROR "Support for ${LIBAEC_PACKAGE_NAME} in HDF5 was enabled, but ${LIBAEC_PACKAGE_NAME} couldn't be found")
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
@@ -0,0 +1,566 @@
|
||||
#
|
||||
# Copyright by The HDF Group.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of HDF5. The full HDF5 copyright notice, including
|
||||
# terms governing use, modification, and redistribution, is contained in
|
||||
# the LICENSE file, which can be found at the root of the source code
|
||||
# distribution tree, or in https://www.hdfgroup.org/licenses.
|
||||
# If you do not have access to either file, you may request a copy from
|
||||
# help@hdfgroup.org.
|
||||
#
|
||||
# -----------------------------------------------------------------------------
|
||||
# HDF5 CMake Zlib(-ng) Support Configuration
|
||||
# -----------------------------------------------------------------------------
|
||||
# This CMake module configures support for zlib in HDF5. It provides options
|
||||
# for enabling/disabling zlib(-ng) support, selecting static/shared builds, and
|
||||
# controlling how zlib(-ng) is found or built (from system-installed libraries,
|
||||
# from local source code on the system, or externally via the GIT/TGZ options
|
||||
# for HDF5_ALLOW_EXTERNAL_SUPPORT).
|
||||
# -----------------------------------------------------------------------------
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# the FetchContent module is needed for building compression libraries from source
|
||||
# -----------------------------------------------------------------------------
|
||||
include (FetchContent)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Specify major options at the top of the file
|
||||
# -----------------------------------------------------------------------------
|
||||
cmake_dependent_option (HDF5_USE_ZLIB_NG "Use zlib-ng library as zlib library" OFF HDF5_ENABLE_ZLIB_SUPPORT OFF)
|
||||
cmake_dependent_option (HDF5_USE_ZLIB_STATIC "Find static zlib library" OFF HDF5_ENABLE_ZLIB_SUPPORT OFF)
|
||||
cmake_dependent_option (HDF5_MODULE_MODE_ZLIB "Prefer module mode to find ZLIB" ON "HDF5_ENABLE_ZLIB_SUPPORT;NOT ZLIB_USE_EXTERNAL;NOT HDF5_USE_ZLIB_NG" OFF)
|
||||
mark_as_advanced (HDF5_MODULE_MODE_ZLIB)
|
||||
cmake_dependent_option (ZLIB_USE_EXTERNAL "Use External Library Building for ZLIB" OFF HDF5_ENABLE_ZLIB_SUPPORT OFF)
|
||||
mark_as_advanced (ZLIB_USE_EXTERNAL)
|
||||
cmake_dependent_option (ZLIB_USE_LOCALCONTENT "Use local file for ZLIB FetchContent" OFF HDF5_ENABLE_ZLIB_SUPPORT OFF)
|
||||
mark_as_advanced (ZLIB_USE_LOCALCONTENT)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# ZLib support
|
||||
#-----------------------------------------------------------------------------
|
||||
# Function to find zlib on the system with find_package()
|
||||
function (system_zlib_library)
|
||||
set (ZLIB_FOUND FALSE)
|
||||
|
||||
# Set package name for zlib if not already set
|
||||
if (NOT DEFINED ZLIB_PACKAGE_NAME)
|
||||
set (ZLIB_PACKAGE_NAME "zlib")
|
||||
endif ()
|
||||
|
||||
set (Z_PACKAGE_NAME ${ZLIB_PACKAGE_NAME}${HDF_PACKAGE_EXT})
|
||||
string (TOUPPER "${Z_PACKAGE_NAME}" Z_PACKAGE_NAME_TOUPPER)
|
||||
message (VERBOSE "Filter zlib package name: ${Z_PACKAGE_NAME}")
|
||||
|
||||
if (HDF5_MODULE_MODE_ZLIB)
|
||||
# Find Zlib (shared or static) via FindZLIB.cmake
|
||||
set (ZLIB_USE_STATIC_LIBS ${HDF5_USE_ZLIB_STATIC})
|
||||
find_package (ZLIB MODULE)
|
||||
else ()
|
||||
# Expect that a correctly built library with CMake config files is available
|
||||
if (HDF5_USE_ZLIB_STATIC)
|
||||
set (ZLIB_SEARCH_TYPE "static")
|
||||
else ()
|
||||
set (ZLIB_SEARCH_TYPE "shared")
|
||||
endif ()
|
||||
find_package (ZLIB NAMES "${Z_PACKAGE_NAME_TOUPPER}" "${Z_PACKAGE_NAME}" CONFIG OPTIONAL_COMPONENTS ${ZLIB_SEARCH_TYPE})
|
||||
endif ()
|
||||
|
||||
if (ZLIB_FOUND)
|
||||
set (H5_ZLIB_HEADER "zlib.h" PARENT_SCOPE)
|
||||
set (H5_ZLIB_INCLUDE_DIR_GEN ${ZLIB_INCLUDE_DIR} PARENT_SCOPE)
|
||||
set (H5_ZLIB_INCLUDE_DIRS ${H5_ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR} PARENT_SCOPE)
|
||||
set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ZLIB::ZLIB PARENT_SCOPE)
|
||||
|
||||
set (H5_ZLIB_FOUND TRUE PARENT_SCOPE)
|
||||
endif ()
|
||||
endfunction ()
|
||||
|
||||
# Function to retrieve zlib from external source (if necessary) and add it to
|
||||
# the build process
|
||||
#
|
||||
# NOTE: This function does NOT patch upstream zlib and will need maintenance for
|
||||
# any changes in the CMake target names, installed configuration files, etc. in new
|
||||
# releases.
|
||||
function (external_zlib_library)
|
||||
if (NOT HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT|TGZ")
|
||||
message (FATAL_ERROR "HDF5_ALLOW_EXTERNAL_SUPPORT must be 'GIT' or 'TGZ' when ZLIB_USE_EXTERNAL is ON (Current setting: ${HDF5_ALLOW_EXTERNAL_SUPPORT})")
|
||||
endif ()
|
||||
|
||||
# Setup for FetchContent
|
||||
if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT")
|
||||
if (ZLIB_USE_LOCALCONTENT)
|
||||
message (FATAL_ERROR "HDF5_ALLOW_EXTERNAL_SUPPORT '${HDF5_ALLOW_EXTERNAL_SUPPORT}' and ZLIB_USE_LOCALCONTENT options are mutually exclusive")
|
||||
endif ()
|
||||
|
||||
set (ZLIB_URL ${ZLIB_GIT_URL})
|
||||
|
||||
if (DEFINED ZLIB_GIT_BRANCH)
|
||||
# ZLIB_GIT_BRANCH is deprecated, but still available
|
||||
set (ZLIB_TAG ${ZLIB_GIT_BRANCH})
|
||||
else ()
|
||||
set (ZLIB_TAG ${ZLIB_GIT_TAG})
|
||||
endif ()
|
||||
|
||||
message (STATUS "Filter zlib will be built from source ${ZLIB_URL} (tag ${ZLIB_TAG})")
|
||||
|
||||
# Instruct FetchContent to retrieve ZLIB from GIT
|
||||
FetchContent_Declare (HDF5_ZLIB
|
||||
GIT_REPOSITORY ${ZLIB_URL}
|
||||
GIT_TAG ${ZLIB_TAG}
|
||||
)
|
||||
else () # HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ"
|
||||
if (NOT DEFINED TGZPATH)
|
||||
set (TGZPATH ${HDF5_SOURCE_DIR})
|
||||
endif ()
|
||||
|
||||
if (ZLIB_USE_LOCALCONTENT)
|
||||
# Use specified zlib .tgz file from system
|
||||
set (ZLIB_URL ${TGZPATH}/${ZLIB_TGZ_NAME})
|
||||
else ()
|
||||
# Use zlib .tgz file ZLIB_TGZ_NAME downloaded from base URL ZLIB_TGZ_ORIGPATH
|
||||
set (ZLIB_URL ${ZLIB_TGZ_ORIGPATH}/${ZLIB_TGZ_NAME})
|
||||
endif ()
|
||||
|
||||
if (ZLIB_USE_LOCALCONTENT AND NOT EXISTS "${ZLIB_URL}")
|
||||
message (FATAL_ERROR "Filter zlib file ${ZLIB_URL} not found (try setting TGZPATH to a directory containing ${ZLIB_TGZ_NAME})")
|
||||
endif ()
|
||||
|
||||
message (STATUS "Filter zlib will be built from source ${ZLIB_URL}")
|
||||
|
||||
# Instruct FetchContent to retrieve ZLIB from .tgz file
|
||||
FetchContent_Declare (HDF5_ZLIB
|
||||
URL ${ZLIB_URL}
|
||||
URL_HASH ""
|
||||
)
|
||||
endif ()
|
||||
|
||||
# Set zlib shared/static library building based off of preference variable
|
||||
if (HDF5_USE_ZLIB_STATIC)
|
||||
set (BUILD_SHARED_LIBS OFF)
|
||||
set (ZLIB_BUILD_SHARED OFF)
|
||||
set (BUILD_STATIC_LIBS ON)
|
||||
set (ZLIB_BUILD_STATIC ON)
|
||||
else ()
|
||||
set (BUILD_SHARED_LIBS ON)
|
||||
set (ZLIB_BUILD_SHARED ON)
|
||||
set (BUILD_STATIC_LIBS OFF)
|
||||
set (ZLIB_BUILD_STATIC OFF)
|
||||
endif ()
|
||||
|
||||
# Set zlib options for build
|
||||
set (CMAKE_INSTALL_BINDIR ${${HDF5_PACKAGE_NAME}_INSTALL_BIN_DIR})
|
||||
set (CMAKE_INSTALL_LIBDIR ${${HDF5_PACKAGE_NAME}_INSTALL_LIB_DIR})
|
||||
set (CMAKE_INSTALL_INCLUDEDIR ${${HDF5_PACKAGE_NAME}_INSTALL_INCLUDE_DIR})
|
||||
set (CMAKE_INSTALL_DOCDIR ${${HDF5_PACKAGE_NAME}_INSTALL_DOC_DIR})
|
||||
set (ZLIB_BUILD_TESTING OFF)
|
||||
set (ZLIB_INSTALL ON)
|
||||
|
||||
# Set variables for use in HDF5 CMake configuration file when locating
|
||||
# the installed CMake files, as they may not be in the same location as
|
||||
# our targets file
|
||||
set (${HDF5_PACKAGE_NAME}_ZLIB_INSTALL_NAME "zlib")
|
||||
set (${HDF5_PACKAGE_NAME}_ZLIB_INSTALL_NAME "zlib" PARENT_SCOPE)
|
||||
set (${HDF5_PACKAGE_NAME}_ZLIB_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${${HDF5_PACKAGE_NAME}_ZLIB_INSTALL_NAME}" PARENT_SCOPE)
|
||||
|
||||
if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR NOT ZLIB_USE_LOCALCONTENT)
|
||||
message (VERBOSE "Fetching and configuring filter zlib")
|
||||
else ()
|
||||
message (VERBOSE "Configuring filter zlib")
|
||||
endif ()
|
||||
|
||||
# Make zlib available for the build
|
||||
FetchContent_MakeAvailable (HDF5_ZLIB)
|
||||
|
||||
# Hide zlib-ng-specific items from the GUI by default
|
||||
mark_as_advanced (ZLIB_BUILD_ADA)
|
||||
mark_as_advanced (ZLIB_BUILD_BLAST)
|
||||
mark_as_advanced (ZLIB_BUILD_IOSTREAM3)
|
||||
mark_as_advanced (ZLIB_BUILD_MINIZIP)
|
||||
mark_as_advanced (ZLIB_BUILD_PUFF)
|
||||
mark_as_advanced (ZLIB_BUILD_SHARED)
|
||||
mark_as_advanced (ZLIB_BUILD_STATIC)
|
||||
mark_as_advanced (ZLIB_BUILD_TESTING)
|
||||
mark_as_advanced (ZLIB_INSTALL)
|
||||
mark_as_advanced (ZLIB_WITH_CRC32VX)
|
||||
mark_as_advanced (ZLIB_WITH_GVMAT64)
|
||||
mark_as_advanced (ZLIB_WITH_INFBACK9)
|
||||
|
||||
# Set expected target names, based on shared/static preference
|
||||
# NOTE: These must be maintained with new releases of upstream zlib in
|
||||
# order to avoid having to patch the source when exporting targets.
|
||||
if (HDF5_USE_ZLIB_STATIC)
|
||||
set (zlib_targets ZLIB::ZLIBSTATIC)
|
||||
else ()
|
||||
set (zlib_targets ZLIB::ZLIB)
|
||||
endif ()
|
||||
foreach (zlib_target ${zlib_targets})
|
||||
if (NOT TARGET ${zlib_target})
|
||||
message (FATAL_ERROR "Expected target ${zlib_target} is missing from build of external zlib")
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
# Optionally add namespace alias for base non-aliased targets
|
||||
if (HDF5_USE_ZLIB_STATIC)
|
||||
set (zlib_base_target zlibstatic)
|
||||
else ()
|
||||
set (zlib_base_target zlib)
|
||||
endif ()
|
||||
if (HDF_PACKAGE_NAMESPACE AND NOT TARGET ${HDF_PACKAGE_NAMESPACE}${zlib_base_target})
|
||||
add_library (${HDF_PACKAGE_NAMESPACE}${zlib_base_target} ALIAS ${zlib_base_target})
|
||||
endif ()
|
||||
|
||||
set (H5_ZLIB_HEADER "zlib.h" PARENT_SCOPE)
|
||||
|
||||
# Set include directories for generated and source headers
|
||||
set (H5_ZLIB_INCLUDE_DIR_GEN "${hdf5_zlib_BINARY_DIR}" PARENT_SCOPE)
|
||||
set (H5_ZLIB_INCLUDE_DIR "${hdf5_zlib_SOURCE_DIR}" PARENT_SCOPE)
|
||||
set (H5_ZLIB_INCLUDE_DIRS ${H5_ZLIB_INCLUDE_DIR_GEN} ${H5_ZLIB_INCLUDE_DIR} PARENT_SCOPE)
|
||||
|
||||
set (H5_ZLIB_LIBRARY "${HDF_PACKAGE_NAMESPACE}${zlib_base_target}")
|
||||
set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${H5_ZLIB_LIBRARY} PARENT_SCOPE)
|
||||
|
||||
# If built as a sub-project or if cross-compiling, export all exported
|
||||
# targets to the build tree. Append to main targets file but keep
|
||||
# namespace from upstream.
|
||||
if (HDF5_EXTERNALLY_CONFIGURED OR CMAKE_CROSSCOMPILING)
|
||||
# NOTE: The export namespace should be maintained with upstream zlib
|
||||
export (
|
||||
TARGETS ${zlib_base_target}
|
||||
FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-targets.cmake
|
||||
NAMESPACE ZLIB::
|
||||
APPEND
|
||||
)
|
||||
endif ()
|
||||
|
||||
set (H5_ZLIB_FOUND TRUE PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
# Main logic for zlib support
|
||||
if (HDF5_ENABLE_ZLIB_SUPPORT AND NOT HDF5_USE_ZLIB_NG)
|
||||
set (H5_ZLIB_FOUND FALSE)
|
||||
|
||||
if (H5_ZLIB_HEADER)
|
||||
# This project is being called from within another and ZLib is already configured
|
||||
set (H5_ZLIB_FOUND TRUE)
|
||||
elseif (NOT ZLIB_USE_EXTERNAL)
|
||||
# Find zlib on the system
|
||||
system_zlib_library ()
|
||||
else ()
|
||||
# Retrieve zlib from external source (if necessary) and add it to the build process
|
||||
# Note that in this case "external" could also mean a local .tgz file on the system
|
||||
external_zlib_library ()
|
||||
endif ()
|
||||
|
||||
if (H5_ZLIB_FOUND)
|
||||
# Set variables used later on in build process
|
||||
set (H5_HAVE_FILTER_DEFLATE 1)
|
||||
set (H5_HAVE_ZLIB_H 1)
|
||||
set (H5_HAVE_LIBZ 1)
|
||||
set (HDF5_COMP_INCLUDE_DIRECTORIES "${HDF5_COMP_INCLUDE_DIRECTORIES};${H5_ZLIB_INCLUDE_DIRS}")
|
||||
|
||||
# Set variables for libhdf5.settings (and the H5build_settings string)
|
||||
list (APPEND SETTINGS_EXTERNAL_FILTERS "DEFLATE(ZLIB)")
|
||||
|
||||
message (VERBOSE "Filter zlib is ON; H5_ZLIB_HEADER=${H5_ZLIB_HEADER}")
|
||||
else ()
|
||||
if (ZLIB_USE_EXTERNAL)
|
||||
message (FATAL_ERROR "External support for zlib in HDF5 was enabled, but couldn't be processed")
|
||||
else ()
|
||||
message (FATAL_ERROR "Support for zlib in HDF5 was enabled, but zlib couldn't be found")
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# ZLib-ng support
|
||||
#-----------------------------------------------------------------------------
|
||||
# Function to find zlib-ng on the system with find_package()
|
||||
function (system_zlib_ng_library)
|
||||
set (ZLIB_FOUND FALSE)
|
||||
|
||||
# Set package name for zlib-ng if not already set
|
||||
if (NOT DEFINED ZLIBNG_PACKAGE_NAME)
|
||||
set (ZLIBNG_PACKAGE_NAME "ZLIBNG")
|
||||
endif ()
|
||||
|
||||
set (Z_PACKAGE_NAME ${ZLIBNG_PACKAGE_NAME}${HDF_PACKAGE_EXT})
|
||||
message (VERBOSE "Filter zlib-ng package name: ${Z_PACKAGE_NAME}")
|
||||
|
||||
if (HDF5_USE_ZLIB_STATIC)
|
||||
set (ZLIBNG_SEARCH_TYPE "static")
|
||||
else ()
|
||||
set (ZLIBNG_SEARCH_TYPE "shared")
|
||||
endif ()
|
||||
set (ZLIBNG_USE_STATIC_LIBS ${HDF5_USE_ZLIB_STATIC})
|
||||
|
||||
# If the package name is left as the default "ZLIBNG", start with our own
|
||||
# FindZLIBNG.cmake module that prefers a CONFIG find mode if possible and
|
||||
# falls back to MODULE find mode if necessary. This allows locating zlib-ng
|
||||
# installations that were built with Autotools, as CMake doesn't currently
|
||||
# have a FindZLIBNG module and will only locate CMake-built installations.
|
||||
# Note that the default package name is ZLIBNG to not conflict with the
|
||||
# actual CMake package name of "zlib-ng". This way, ZLIBNG_PACKAGE_NAME can
|
||||
# still be specified as "zlib-ng" to avoid our custom module if desired.
|
||||
find_package (${ZLIBNG_PACKAGE_NAME} OPTIONAL_COMPONENTS "${ZLIBNG_SEARCH_TYPE}")
|
||||
|
||||
if (${${ZLIBNG_PACKAGE_NAME}_FOUND})
|
||||
if (NOT ${ZLIBNG_PACKAGE_NAME}_ZLIB_COMPAT)
|
||||
set (H5_ZLIB_HEADER "zlib-ng.h" PARENT_SCOPE)
|
||||
else ()
|
||||
set (H5_ZLIB_HEADER "zlib.h" PARENT_SCOPE)
|
||||
|
||||
message (VERBOSE "zlib-ng was built with zlib compatibility")
|
||||
endif ()
|
||||
set (${ZLIBNG_PACKAGE_NAME}_ZLIB_COMPAT ${${ZLIBNG_PACKAGE_NAME}_ZLIB_COMPAT} PARENT_SCOPE)
|
||||
|
||||
set (H5_ZLIB_INCLUDE_DIR_GEN ${ZLIBNG_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
set (H5_ZLIB_INCLUDE_DIRS ${H5_ZLIB_INCLUDE_DIRS} ${ZLIBNG_INCLUDE_DIRS} PARENT_SCOPE)
|
||||
|
||||
if (NOT ZLIBNG_ZLIB_COMPAT)
|
||||
if (ZLIBNG_USE_STATIC_LIBS)
|
||||
set (_zlibng_target_name "zlib-ng::zlibstatic")
|
||||
else ()
|
||||
set (_zlibng_target_name "zlib-ng::zlib")
|
||||
endif ()
|
||||
else ()
|
||||
if (ZLIBNG_USE_STATIC_LIBS)
|
||||
set (_zlibng_target_name "ZLIB::zlibstatic")
|
||||
else ()
|
||||
set (_zlibng_target_name "ZLIB::ZLIB")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (TARGET ${_zlibng_target_name})
|
||||
set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${_zlibng_target_name} PARENT_SCOPE)
|
||||
set (H5_ZLIB_FOUND TRUE PARENT_SCOPE)
|
||||
else ()
|
||||
set (H5_ZLIB_FOUND FALSE PARENT_SCOPE)
|
||||
endif ()
|
||||
endif ()
|
||||
endfunction ()
|
||||
|
||||
# Function to retrieve zlib-ng from external source (if necessary) and add it to
|
||||
# the build process
|
||||
#
|
||||
# NOTE: This function does NOT patch upstream zlib-ng and will need maintenance for
|
||||
# any changes in the CMake target names, installed configuration files, etc. in new
|
||||
# releases.
|
||||
function (external_zlib_ng_library)
|
||||
if (NOT HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT|TGZ")
|
||||
message (FATAL_ERROR "HDF5_ALLOW_EXTERNAL_SUPPORT must be 'GIT' or 'TGZ' when ZLIB_USE_EXTERNAL is ON (Current setting: ${HDF5_ALLOW_EXTERNAL_SUPPORT})")
|
||||
endif ()
|
||||
|
||||
# Setup for FetchContent
|
||||
if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT")
|
||||
if (ZLIB_USE_LOCALCONTENT)
|
||||
message (FATAL_ERROR "HDF5_ALLOW_EXTERNAL_SUPPORT '${HDF5_ALLOW_EXTERNAL_SUPPORT}' and ZLIB_USE_LOCALCONTENT options are mutually exclusive")
|
||||
endif ()
|
||||
|
||||
set (ZLIBNG_URL ${ZLIBNG_GIT_URL})
|
||||
|
||||
if (DEFINED ZLIBNG_GIT_BRANCH)
|
||||
# ZLIBNG_GIT_BRANCH is deprecated, but still available
|
||||
set (ZLIBNG_TAG ${ZLIBNG_GIT_BRANCH})
|
||||
else ()
|
||||
set (ZLIBNG_TAG ${ZLIBNG_GIT_TAG})
|
||||
endif ()
|
||||
|
||||
message (STATUS "Filter zlib-ng will be built from source ${ZLIBNG_URL} (tag ${ZLIBNG_TAG})")
|
||||
|
||||
# Instruct FetchContent to retrieve zlib-ng from GIT
|
||||
FetchContent_Declare (HDF5_ZLIB
|
||||
GIT_REPOSITORY ${ZLIBNG_URL}
|
||||
GIT_TAG ${ZLIBNG_TAG}
|
||||
)
|
||||
else () # HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ"
|
||||
if (NOT DEFINED TGZPATH)
|
||||
set (TGZPATH ${HDF5_SOURCE_DIR})
|
||||
endif ()
|
||||
|
||||
if (ZLIB_USE_LOCALCONTENT)
|
||||
# Use specified zlib-ng .tgz file from system
|
||||
set (ZLIBNG_URL ${TGZPATH}/${ZLIBNG_TGZ_NAME})
|
||||
else ()
|
||||
# Use zlib-ng .tgz file ZLIBNG_TGZ_NAME downloaded from base URL ZLIBNG_TGZ_ORIGPATH
|
||||
set (ZLIBNG_URL ${ZLIBNG_TGZ_ORIGPATH}/${ZLIBNG_TGZ_NAME})
|
||||
endif ()
|
||||
|
||||
if (ZLIB_USE_LOCALCONTENT AND NOT EXISTS "${ZLIBNG_URL}")
|
||||
message (FATAL_ERROR "Filter zlib-ng file ${ZLIBNG_URL} not found (try setting TGZPATH to a directory containing ${ZLIBNG_TGZ_NAME})")
|
||||
endif ()
|
||||
|
||||
message (STATUS "Filter zlib-ng will be built from source ${ZLIBNG_URL}")
|
||||
|
||||
# Instruct FetchContent to retrieve zlib-ng from .tgz file
|
||||
FetchContent_Declare (HDF5_ZLIB
|
||||
URL ${ZLIBNG_URL}
|
||||
URL_HASH ""
|
||||
)
|
||||
endif ()
|
||||
|
||||
# Set zlib-ng shared/static library building based off of preference variable
|
||||
if (HDF5_USE_ZLIB_STATIC)
|
||||
set (BUILD_SHARED_LIBS OFF)
|
||||
set (BUILD_STATIC_LIBS ON)
|
||||
else ()
|
||||
set (BUILD_SHARED_LIBS ON)
|
||||
set (BUILD_STATIC_LIBS OFF)
|
||||
endif ()
|
||||
|
||||
# Set zlib-ng options for build
|
||||
set (CMAKE_INSTALL_BINDIR ${${HDF5_PACKAGE_NAME}_INSTALL_BIN_DIR})
|
||||
set (CMAKE_INSTALL_LIBDIR ${${HDF5_PACKAGE_NAME}_INSTALL_LIB_DIR})
|
||||
set (CMAKE_INSTALL_INCLUDEDIR ${${HDF5_PACKAGE_NAME}_INSTALL_INCLUDE_DIR})
|
||||
set (BUILD_TESTING OFF)
|
||||
|
||||
# Set variables for use in HDF5 CMake configuration file when locating
|
||||
# the installed targets file, as it may not be in the same location as
|
||||
# our targets file
|
||||
if (ZLIB_COMPAT)
|
||||
set (${HDF5_PACKAGE_NAME}_ZLIBNG_INSTALL_NAME "ZLIB")
|
||||
set (${HDF5_PACKAGE_NAME}_ZLIBNG_INSTALL_NAME "ZLIB" PARENT_SCOPE)
|
||||
set (${HDF5_PACKAGE_NAME}_ZLIBNG_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${${HDF5_PACKAGE_NAME}_ZLIBNG_INSTALL_NAME}" PARENT_SCOPE)
|
||||
else ()
|
||||
set (${HDF5_PACKAGE_NAME}_ZLIBNG_INSTALL_NAME "zlib-ng")
|
||||
set (${HDF5_PACKAGE_NAME}_ZLIBNG_INSTALL_NAME "zlib-ng" PARENT_SCOPE)
|
||||
set (${HDF5_PACKAGE_NAME}_ZLIBNG_INSTALL_CMAKEDIR "${CMAKE_INSTALL_LIBDIR}/cmake/${${HDF5_PACKAGE_NAME}_ZLIBNG_INSTALL_NAME}" PARENT_SCOPE)
|
||||
endif ()
|
||||
|
||||
if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR NOT ZLIB_USE_LOCALCONTENT)
|
||||
message (VERBOSE "Fetching and configuring filter zlib-ng")
|
||||
else ()
|
||||
message (VERBOSE "Configuring filter zlib-ng")
|
||||
endif ()
|
||||
|
||||
# Make zlib-ng available for the build
|
||||
FetchContent_MakeAvailable (HDF5_ZLIB)
|
||||
|
||||
# Hide zlib-ng-specific items from the GUI by default
|
||||
mark_as_advanced (WITH_AVX512)
|
||||
mark_as_advanced (WITH_AVX512VNNI)
|
||||
mark_as_advanced (WITH_BENCHMARKS)
|
||||
mark_as_advanced (WITH_BENCHMARK_APPS)
|
||||
mark_as_advanced (WITH_CODE_COVERAGE)
|
||||
mark_as_advanced (WITH_FUZZERS)
|
||||
mark_as_advanced (WITH_GTEST)
|
||||
mark_as_advanced (WITH_GZFILEOP)
|
||||
mark_as_advanced (WITH_MAINTAINER_WARNINGS)
|
||||
mark_as_advanced (WITH_NATIVE_INSTRUCTIONS)
|
||||
mark_as_advanced (WITH_NEW_STRATEGIES)
|
||||
mark_as_advanced (WITH_OPTIM)
|
||||
mark_as_advanced (WITH_RUNTIME_CPU_DETECTION)
|
||||
mark_as_advanced (WITH_SANITIZER)
|
||||
mark_as_advanced (WITH_VPCLMULQDQ)
|
||||
mark_as_advanced (ZLIB_ALIASES)
|
||||
mark_as_advanced (ZLIB_COMPAT)
|
||||
|
||||
# Set expected target names, based on shared/static preference
|
||||
# NOTE: These must be maintained with new releases of upstream zlib-ng in
|
||||
# order to avoid having to patch the source when exporting targets.
|
||||
if (HDF5_USE_ZLIB_STATIC)
|
||||
set (zlib_ng_targets zlib-ng-static)
|
||||
else ()
|
||||
set (zlib_ng_targets zlib-ng)
|
||||
endif ()
|
||||
foreach (zlib_ng_target ${zlib_ng_targets})
|
||||
if (NOT TARGET ${zlib_ng_target})
|
||||
message (FATAL_ERROR "Expected target ${zlib_ng_target} is missing from build of external zlib-ng")
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
# Optionally add namespace alias for targets
|
||||
if (HDF_PACKAGE_NAMESPACE)
|
||||
foreach (zlib_ng_target ${zlib_ng_targets})
|
||||
if (NOT TARGET ${HDF_PACKAGE_NAMESPACE}${zlib_ng_target})
|
||||
add_library (${HDF_PACKAGE_NAMESPACE}${zlib_ng_target} ALIAS ${zlib_ng_target})
|
||||
endif ()
|
||||
endforeach ()
|
||||
endif ()
|
||||
|
||||
# Set the correct header for zlib-ng compatibility
|
||||
if (ZLIB_COMPAT)
|
||||
set (H5_ZLIB_HEADER "zlib.h" PARENT_SCOPE)
|
||||
else ()
|
||||
set (H5_ZLIB_HEADER "zlib-ng.h" PARENT_SCOPE)
|
||||
endif ()
|
||||
|
||||
# Set include directories for generated and source headers
|
||||
set (H5_ZLIB_INCLUDE_DIR_GEN "${hdf5_zlib_BINARY_DIR}" PARENT_SCOPE)
|
||||
set (H5_ZLIB_INCLUDE_DIR "${hdf5_zlib_SOURCE_DIR}" PARENT_SCOPE)
|
||||
set (H5_ZLIB_INCLUDE_DIRS ${H5_ZLIB_INCLUDE_DIR_GEN} ${H5_ZLIB_INCLUDE_DIR} PARENT_SCOPE)
|
||||
|
||||
if (HDF5_USE_ZLIB_STATIC)
|
||||
set (H5_ZLIB_LIBRARY "${HDF_PACKAGE_NAMESPACE}zlib-ng-static")
|
||||
else ()
|
||||
set (H5_ZLIB_LIBRARY "${HDF_PACKAGE_NAMESPACE}zlib-ng")
|
||||
endif ()
|
||||
set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${H5_ZLIB_LIBRARY} PARENT_SCOPE)
|
||||
|
||||
# If built as a sub-project or if cross-compiling, export all exported
|
||||
# targets to the build tree. Append to main targets file but keep
|
||||
# namespace from upstream.
|
||||
if (HDF5_EXTERNALLY_CONFIGURED OR CMAKE_CROSSCOMPILING)
|
||||
# NOTE: The export namespace should be maintained with upstream zlib-ng
|
||||
if (ZLIB_COMPAT)
|
||||
set (zlib_ng_export_name ZLIB)
|
||||
else ()
|
||||
set (zlib_ng_export_name zlib-ng)
|
||||
endif ()
|
||||
export (
|
||||
TARGETS ${zlib_ng_targets}
|
||||
FILE ${HDF5_PACKAGE}${HDF_PACKAGE_EXT}-targets.cmake
|
||||
NAMESPACE ${zlib_ng_export_name}::
|
||||
APPEND
|
||||
)
|
||||
endif ()
|
||||
|
||||
set (H5_ZLIB_FOUND TRUE PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
# Main logic for zlib-ng support
|
||||
if (HDF5_ENABLE_ZLIB_SUPPORT AND HDF5_USE_ZLIB_NG)
|
||||
set (H5_ZLIB_FOUND FALSE)
|
||||
|
||||
if (HDF5_MODULE_MODE_ZLIB)
|
||||
message (FATAL_ERROR "HDF5_USE_ZLIB_NG and HDF5_MODULE_MODE_ZLIB options are mutually exclusive")
|
||||
endif ()
|
||||
|
||||
if (H5_ZLIB_HEADER)
|
||||
# This project is being called from within another and ZLib is already configured
|
||||
set (H5_ZLIB_FOUND TRUE)
|
||||
elseif (NOT ZLIB_USE_EXTERNAL)
|
||||
# Find zlib-ng on the system
|
||||
system_zlib_ng_library ()
|
||||
else ()
|
||||
# Retrieve zlib-ng from external source (if necessary) and add it to the build process
|
||||
# Note that in this case "external" could also mean a local .tgz file on the system
|
||||
external_zlib_ng_library ()
|
||||
endif ()
|
||||
|
||||
if (H5_ZLIB_FOUND)
|
||||
# Set variables used later on in build process
|
||||
set (H5_HAVE_FILTER_DEFLATE 1)
|
||||
set (H5_HAVE_ZLIB_H 1)
|
||||
if (NOT ZLIB_COMPAT AND NOT ZLIBNG_ZLIB_COMPAT)
|
||||
set (H5_HAVE_ZLIBNG_H 1)
|
||||
endif ()
|
||||
set (H5_HAVE_LIBZ 1)
|
||||
set (HDF5_COMP_INCLUDE_DIRECTORIES "${HDF5_COMP_INCLUDE_DIRECTORIES};${H5_ZLIB_INCLUDE_DIRS}")
|
||||
|
||||
# Set variables for libhdf5.settings (and the H5build_settings string)
|
||||
if (ZLIB_COMPAT OR ZLIBNG_ZLIB_COMPAT)
|
||||
list (APPEND SETTINGS_EXTERNAL_FILTERS "DEFLATE(ZLIB-NG WITH ZLIB COMPAT MODE)")
|
||||
else ()
|
||||
list (APPEND SETTINGS_EXTERNAL_FILTERS "DEFLATE(ZLIB-NG)")
|
||||
endif ()
|
||||
|
||||
message (VERBOSE "Filter zlib-ng is ON; H5_ZLIB_HEADER=${H5_ZLIB_HEADER}")
|
||||
else ()
|
||||
if (ZLIB_USE_EXTERNAL)
|
||||
message (FATAL_ERROR "External support for zlib-ng in HDF5 was enabled, but couldn't be processed")
|
||||
else ()
|
||||
message (FATAL_ERROR "Support for zlib-ng in HDF5 was enabled, but zlib-ng couldn't be found")
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
@@ -497,7 +497,6 @@ macro (HDF_DIR_PATHS package_prefix)
|
||||
if (NOT ${package_prefix}_INSTALL_DOC_DIR)
|
||||
set (${package_prefix}_INSTALL_DOC_DIR ${${package_prefix}_INSTALL_DATA_DIR})
|
||||
endif ()
|
||||
message (STATUS "Final: ${${package_prefix}_INSTALL_DOC_DIR}")
|
||||
|
||||
# Append the needed INSTALL_RPATH for HDF Standard binary packages
|
||||
if (APPLE)
|
||||
@@ -516,8 +515,6 @@ macro (HDF_DIR_PATHS package_prefix)
|
||||
SET_HDF_BUILD_TYPE()
|
||||
|
||||
SET_HDF_OUTPUT_DIRS(${package_prefix})
|
||||
|
||||
include (FetchContent)
|
||||
endmacro ()
|
||||
|
||||
# ADD_H5_FLAGS: Parse and add compiler flags from a file.
|
||||
|
||||
@@ -0,0 +1,386 @@
|
||||
#
|
||||
# Copyright by The HDF Group.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of HDF5. The full HDF5 copyright notice, including
|
||||
# terms governing use, modification, and redistribution, is contained in
|
||||
# the LICENSE file, which can be found at the root of the source code
|
||||
# distribution tree, or in https://www.hdfgroup.org/licenses.
|
||||
# If you do not have access to either file, you may request a copy from
|
||||
# help@hdfgroup.org.
|
||||
#
|
||||
#########################################################################
|
||||
|
||||
# CMake module to find the zlib-ng library on the system, preferring to
|
||||
# make use of a CMake configuration file for the library if one is found.
|
||||
# Derived from the FindZLIB.cmake file that is included with CMake.
|
||||
#
|
||||
# Imported Targets
|
||||
# ^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# If a CMake configuration file cannot be located, this module defines
|
||||
# the following `IMPORTED` targets:
|
||||
#
|
||||
# ``zlib-ng::zlib``
|
||||
# The zlib-ng library, if found and only if zlib-ng was NOT built with
|
||||
# zlib compatibility.
|
||||
#
|
||||
# ``zlib-ng::zlibstatic``
|
||||
# The static zlib-ng library, if found and only if zlib-ng was NOT built
|
||||
# with zlib compatibility.
|
||||
#
|
||||
# ``ZLIB::ZLIB``
|
||||
# The zlib-ng library, if found and only if zlib-ng was built with zlib
|
||||
# compatibility.
|
||||
#
|
||||
# ``ZLIB::zlibstatic``
|
||||
# The static zlib-ng library, if found and only if zlib-ng was built with
|
||||
# zlib compatibility.
|
||||
#
|
||||
# Result Variables
|
||||
# ^^^^^^^^^^^^^^^^
|
||||
#
|
||||
# This module defines the following variables:
|
||||
#
|
||||
# ``ZLIBNG_FOUND``
|
||||
# "True" if ``zlib-ng`` is found.
|
||||
#
|
||||
# ``ZLIBNG_INCLUDE_DIRS``
|
||||
# The zlib-ng include directories.
|
||||
#
|
||||
# ``ZLIBNG_LIBRARIES``
|
||||
# The libraries to link against when using zlib-ng.
|
||||
#
|
||||
# ``ZLIBNG_VERSION``
|
||||
# The version of zlib-ng found. May not be set if a version number
|
||||
# can't be parsed from zlib-ng.h/zlib.h or a pkg-config file.
|
||||
#
|
||||
# ``ZLIB_VERSION``
|
||||
# The version of zlib found. May not be set if a version number
|
||||
# can't be parsed from zlib-ng.h/zlib.h or a pkg-config file. Will
|
||||
# only be set if ZLIBNG_ZLIB_COMPAT is TRUE.
|
||||
#
|
||||
# ``ZLIBNG_ZLIB_COMPAT``
|
||||
# "True" if zlib-ng was built with zlib compatibility.
|
||||
#
|
||||
# Hints
|
||||
# ^^^^^
|
||||
#
|
||||
# Set ``ZLIBNG_ROOT`` to a directory which contains a zlib-ng installation.
|
||||
#
|
||||
|
||||
include (FindPackageHandleStandardArgs)
|
||||
|
||||
set (ZLIBNG_VALID_COMPONENTS
|
||||
shared
|
||||
static
|
||||
)
|
||||
|
||||
set (ZLIBNG_ZLIB_COMPAT FALSE)
|
||||
|
||||
macro (get_zlibng_version header)
|
||||
file (STRINGS "${header}" zlibng_version_str REGEX "^#define[\t ]+ZLIBNG_VERSION[\t ]+\".*\"")
|
||||
endmacro ()
|
||||
|
||||
# First, check to see if zlib-ng was built with CMake and has a zlib-ng-config.cmake
|
||||
# file available for use.
|
||||
if (DEFINED ZLIBNG_ROOT AND NOT ZLIBNG_FIND_QUIETLY)
|
||||
message (VERBOSE "Looking for zlib-ng CMake configuration file at ${ZLIBNG_ROOT}")
|
||||
endif ()
|
||||
find_package (ZLIBNG QUIET CONFIG NAMES "zlib-ng")
|
||||
mark_as_advanced (ZLIBNG_DIR)
|
||||
|
||||
# If zlib-ng wasn't found, try finding zlib in case zlib-ng was built with zlib
|
||||
# compatibility
|
||||
if (NOT ZLIBNG_FOUND)
|
||||
set (ZLIBNG_FOUND FALSE)
|
||||
unset (ZLIBNG_DIR)
|
||||
|
||||
find_package (ZLIBNG QUIET CONFIG NAMES "zlib")
|
||||
if (ZLIBNG_FOUND)
|
||||
# Searching by name "zlib" should be enough to only locate zlib-ng's zlib,
|
||||
# but check the header file just in case
|
||||
if (DEFINED ZLIB_INCLUDE_DIR AND EXISTS "${ZLIB_INCLUDE_DIR}/zlib.h")
|
||||
# Accept zlib.h only if it defines ZLIBNG_VERSION so we don't pick
|
||||
# up a regular zlib installation for zlib-ng
|
||||
get_zlibng_version ("${ZLIB_INCLUDE_DIR}/zlib.h")
|
||||
if (zlibng_version_str)
|
||||
set (ZLIBNG_ZLIB_COMPAT TRUE)
|
||||
else ()
|
||||
if (NOT ZLIBNG_FIND_QUIETLY)
|
||||
message (VERBOSE "Rejecting zlib.h file that doesn't define ZLIBNG_VERSION")
|
||||
endif ()
|
||||
|
||||
set (ZLIBNG_FOUND FALSE)
|
||||
endif ()
|
||||
unset (get_zlibng_version)
|
||||
else ()
|
||||
set (ZLIBNG_FOUND FALSE)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# If a zlib-ng-config.cmake (or zlib-config.cmake) file is available for use, prefer that
|
||||
if (ZLIBNG_FOUND)
|
||||
unset (ZLIBNG_shared_FOUND)
|
||||
unset (ZLIBNG_static_FOUND)
|
||||
|
||||
# Set variables that this module returns
|
||||
if (NOT ZLIBNG_ZLIB_COMPAT)
|
||||
if (NOT TARGET zlib-ng::zlib AND NOT TARGET zlib-ng::zlibstatic)
|
||||
set (ZLIBNG_FOUND FALSE)
|
||||
set (ZLIBNG_NOT_FOUND_MESSAGE "zlib-ng was found but CMake targets (zlib-ng::zlib, zlib-ng::zlibstatic) were missing")
|
||||
return ()
|
||||
endif ()
|
||||
|
||||
if (TARGET zlib-ng::zlib)
|
||||
set (ZLIBNG_shared_FOUND TRUE)
|
||||
if (NOT ZLIBNG_USE_STATIC_LIBS)
|
||||
set (ZLIBNG_LIBRARIES "zlib-ng::zlib")
|
||||
endif ()
|
||||
endif ()
|
||||
if (TARGET zlib-ng::zlibstatic)
|
||||
set (ZLIBNG_static_FOUND TRUE)
|
||||
if (ZLIBNG_USE_STATIC_LIBS)
|
||||
set (ZLIBNG_LIBRARIES "zlib-ng::zlibstatic")
|
||||
endif ()
|
||||
endif ()
|
||||
else ()
|
||||
if (NOT TARGET ZLIB::ZLIB AND NOT TARGET ZLIB::zlibstatic)
|
||||
set (ZLIBNG_FOUND FALSE)
|
||||
set (ZLIBNG_NOT_FOUND_MESSAGE "zlib-ng was found but CMake targets (ZLIB::ZLIB, ZLIB::zlibstatic) were missing")
|
||||
return ()
|
||||
endif ()
|
||||
|
||||
if (TARGET ZLIB::ZLIB)
|
||||
set (ZLIBNG_shared_FOUND TRUE)
|
||||
if (NOT ZLIBNG_USE_STATIC_LIBS)
|
||||
set (ZLIBNG_LIBRARIES "ZLIB::ZLIB")
|
||||
endif ()
|
||||
endif ()
|
||||
if (TARGET ZLIB::zlibstatic)
|
||||
set (ZLIBNG_static_FOUND TRUE)
|
||||
if (ZLIBNG_USE_STATIC_LIBS)
|
||||
set (ZLIBNG_LIBRARIES "ZLIB::zlibstatic")
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Determine zlib-ng include directory (or directories)
|
||||
foreach (zlibng_target ${ZLIBNG_LIBRARIES})
|
||||
if (NOT TARGET ${zlibng_target})
|
||||
continue ()
|
||||
endif ()
|
||||
|
||||
get_target_property (zlibng_include_dir_prop ${zlibng_target} INTERFACE_INCLUDE_DIRECTORIES)
|
||||
if (zlibng_include_dir_prop)
|
||||
list (APPEND ZLIBNG_INCLUDE_DIRS "${zlibng_include_dir_prop}")
|
||||
endif ()
|
||||
endforeach ()
|
||||
list (REMOVE_DUPLICATES ZLIBNG_INCLUDE_DIRS)
|
||||
unset (zlibng_include_dir_prop)
|
||||
|
||||
find_package_handle_standard_args (ZLIBNG
|
||||
REQUIRED_VARS ZLIBNG_LIBRARIES ZLIBNG_INCLUDE_DIRS
|
||||
VERSION_VAR ZLIBNG_VERSION
|
||||
HANDLE_COMPONENTS
|
||||
CONFIG_MODE
|
||||
)
|
||||
if (ZLIBNG_FOUND AND ZLIBNG_DIR AND NOT ZLIBNG_FIND_QUIETLY)
|
||||
message (VERBOSE "Found existing zlib-ng CMake configuration file at ${ZLIBNG_DIR}")
|
||||
endif ()
|
||||
|
||||
return ()
|
||||
elseif (DEFINED ZLIBNG_NOT_FOUND_MESSAGE AND NOT ZLIBNG_FIND_QUIETLY)
|
||||
message (VERBOSE "Couldn't load zlib-ng from CMake configuration file: ${ZLIBNG_NOT_FOUND_MESSAGE}")
|
||||
endif ()
|
||||
|
||||
# Try to find a zlib-ng pkg-config file
|
||||
find_package (PkgConfig QUIET)
|
||||
if (PKG_CONFIG_FOUND)
|
||||
pkg_check_modules (PC_ZLIBNG QUIET zlib-ng)
|
||||
# If zlib-ng wasn't found, try finding zlib in case zlib-ng was built
|
||||
# with zlib compatibility
|
||||
if (NOT PC_ZLIBNG_FOUND)
|
||||
# Check for zlib.pc from zlib-ng before populating scope with variables
|
||||
# from the module
|
||||
pkg_get_variable (zlib_pkg_includedir zlib "includedir")
|
||||
if (zlib_pkg_includedir AND EXISTS "${zlib_pkg_includedir}/zlib.h")
|
||||
# Accept zlib.h only if it defines ZLIBNG_VERSION so we don't pick
|
||||
# up a regular zlib installation for zlib-ng
|
||||
get_zlibng_version ("${zlib_pkg_includedir}/zlib.h")
|
||||
if (zlibng_version_str)
|
||||
pkg_check_modules (PC_ZLIBNG QUIET zlib)
|
||||
endif ()
|
||||
unset (zlibng_version_str)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Find the zlib-ng.h header file
|
||||
find_path (ZLIBNG_INCLUDE_DIR
|
||||
NAMES zlib-ng.h
|
||||
HINTS ${ZLIBNG_ROOT} ${PC_ZLIBNG_INCLUDE_DIRS}
|
||||
DOC "Path to the zlib-ng.h header file"
|
||||
)
|
||||
mark_as_advanced (ZLIBNG_INCLUDE_DIR)
|
||||
|
||||
# If not found, try to find the zlib.h header file
|
||||
if (NOT ZLIBNG_INCLUDE_DIR)
|
||||
if (NOT ZLIBNG_FIND_QUIETLY)
|
||||
message (VERBOSE "Couldn't find zlib-ng.h, searching for zlib.h")
|
||||
endif ()
|
||||
|
||||
find_path (ZLIBNG_INCLUDE_DIR
|
||||
NAMES zlib.h
|
||||
HINTS ${ZLIBNG_ROOT} ${PC_ZLIBNG_INCLUDE_DIRS}
|
||||
DOC "Path to the zlib.h header file"
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (ZLIBNG_INCLUDE_DIR AND EXISTS "${ZLIBNG_INCLUDE_DIR}/zlib.h")
|
||||
# Accept zlib.h only if it defines ZLIBNG_VERSION so we don't pick
|
||||
# up a regular zlib installation for zlib-ng
|
||||
get_zlibng_version ("${ZLIBNG_INCLUDE_DIR}/zlib.h")
|
||||
if (NOT zlibng_version_str)
|
||||
if (NOT ZLIBNG_FIND_QUIETLY)
|
||||
message (VERBOSE "Rejecting zlib.h file that doesn't define ZLIBNG_VERSION")
|
||||
endif ()
|
||||
return ()
|
||||
else ()
|
||||
set (ZLIBNG_ZLIB_COMPAT TRUE)
|
||||
endif ()
|
||||
unset (zlibng_version_str)
|
||||
endif ()
|
||||
|
||||
# Find the appropriate library based on zlib compatibility
|
||||
if (NOT ZLIBNG_LIBRARY)
|
||||
if (ZLIBNG_USE_STATIC_LIBS)
|
||||
unset (_zlibng_find_lib_suffixes_orig)
|
||||
if (DEFINED CMAKE_FIND_LIBRARY_SUFFIXES)
|
||||
set (_zlibng_find_lib_suffixes_orig "${CMAKE_FIND_LIBRARY_SUFFIXES}")
|
||||
endif ()
|
||||
if (WIN32)
|
||||
set (CMAKE_FIND_LIBRARY_SUFFIXES .lib .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
|
||||
else ()
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (NOT ZLIBNG_ZLIB_COMPAT)
|
||||
if (ZLIBNG_USE_STATIC_LIBS)
|
||||
set (_zlibng_lib_names zlibstatic-ng zlib-ng z-ng)
|
||||
else ()
|
||||
set (_zlibng_lib_names z-ng zlib-ng zlibstatic-ng)
|
||||
endif ()
|
||||
|
||||
# Find the zlib-ng library
|
||||
find_library (ZLIBNG_LIBRARY
|
||||
NAMES ${_zlibng_lib_names}
|
||||
HINTS ${ZLIBNG_ROOT} ${PC_ZLIBNG_LIBRARY_DIRS}
|
||||
PATH_SUFFIXES lib lib64
|
||||
DOC "Path to the zlib-ng library file"
|
||||
)
|
||||
else ()
|
||||
if (ZLIBNG_USE_STATIC_LIBS)
|
||||
set (_zlibng_lib_names zlibstatic zlib z)
|
||||
else ()
|
||||
set (_zlibng_lib_names z zlib zlibstatic)
|
||||
endif ()
|
||||
|
||||
# Find the zlib library
|
||||
find_library (ZLIBNG_LIBRARY
|
||||
NAMES ${_zlibng_lib_names}
|
||||
HINTS ${ZLIBNG_ROOT} ${PC_ZLIBNG_LIBRARY_DIRS}
|
||||
PATH_SUFFIXES lib lib64
|
||||
DOC "Path to the zlib library file"
|
||||
)
|
||||
endif ()
|
||||
mark_as_advanced (ZLIBNG_LIBRARY)
|
||||
unset (_zlibng_lib_names)
|
||||
|
||||
if (DEFINED _zlibng_find_lib_suffixes_orig)
|
||||
set (CMAKE_FIND_LIBRARY_SUFFIXES "${_zlibng_find_lib_suffixes_orig}")
|
||||
else ()
|
||||
set (CMAKE_FIND_LIBRARY_SUFFIXES)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Determine zlib-ng version from zlib(-ng).h or from pkg-config file
|
||||
if (ZLIBNG_INCLUDE_DIR)
|
||||
if (NOT ZLIBNG_ZLIB_COMPAT)
|
||||
set (_zlibng_header_file "zlib-ng.h")
|
||||
else ()
|
||||
set (_zlibng_header_file "zlib.h")
|
||||
endif ()
|
||||
|
||||
if (EXISTS "${ZLIBNG_INCLUDE_DIR}/${_zlibng_header_file}")
|
||||
get_zlibng_version ("${ZLIBNG_INCLUDE_DIR}/${_zlibng_header_file}")
|
||||
if (zlibng_version_str)
|
||||
string (REGEX REPLACE "^#define[\t ]+ZLIBNG_VERSION[\t ]+\"([^\"]*)\".*" "\\1" ZLIBNG_VERSION "${zlibng_version_str}")
|
||||
endif ()
|
||||
unset (zlibng_version_str)
|
||||
elseif (PC_ZLIBNG_FOUND)
|
||||
set (ZLIBNG_VERSION ${PC_ZLIBNG_VERSION})
|
||||
endif ()
|
||||
# If applicable, determine zlib version from zlib.h or from pkg-config file
|
||||
if (ZLIBNG_ZLIB_COMPAT AND EXISTS "${ZLIBNG_INCLUDE_DIR}/zlib.h")
|
||||
file (STRINGS "${ZLIBNG_INCLUDE_DIR}/zlib.h" zlib_version_str REGEX "^#define[\t ]+ZLIB_VERSION[\t ]+\".*\"")
|
||||
if (zlib_version_str)
|
||||
string (REGEX REPLACE "^#define[\t ]+ZLIB_VERSION[\t ]+\"([^\"]*)\".*" "\\1" ZLIB_VERSION "${zlib_version_str}")
|
||||
endif ()
|
||||
unset (zlib_version_str)
|
||||
elseif (PC_ZLIBNG_FOUND)
|
||||
set (ZLIB_VERSION ${PC_ZLIBNG_VERSION})
|
||||
endif ()
|
||||
|
||||
unset (_zlibng_header_file)
|
||||
endif ()
|
||||
|
||||
if (ZLIBNG_LIBRARY)
|
||||
if (ZLIBNG_USE_STATIC_LIBS)
|
||||
set (ZLIBNG_static_FOUND TRUE)
|
||||
else ()
|
||||
set (ZLIBNG_shared_FOUND TRUE)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# Set variables for whether zlib-ng was found
|
||||
find_package_handle_standard_args (ZLIBNG
|
||||
REQUIRED_VARS ZLIBNG_LIBRARY ZLIBNG_INCLUDE_DIR
|
||||
VERSION_VAR ZLIBNG_VERSION
|
||||
HANDLE_COMPONENTS
|
||||
)
|
||||
|
||||
# Created imported targets and set remaining variables for module
|
||||
if (ZLIBNG_FOUND)
|
||||
unset (ZLIBNG_shared_FOUND)
|
||||
unset (ZLIBNG_static_FOUND)
|
||||
|
||||
if (NOT ZLIBNG_ZLIB_COMPAT)
|
||||
if (ZLIBNG_USE_STATIC_LIBS)
|
||||
set (_zlibng_target_name "zlib-ng::zlibstatic")
|
||||
else ()
|
||||
set (_zlibng_target_name "zlib-ng::zlib")
|
||||
endif ()
|
||||
else ()
|
||||
if (ZLIBNG_USE_STATIC_LIBS)
|
||||
set (_zlibng_target_name "ZLIB::zlibstatic")
|
||||
else ()
|
||||
set (_zlibng_target_name "ZLIB::ZLIB")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (NOT TARGET ${_zlibng_target_name})
|
||||
add_library (${_zlibng_target_name} UNKNOWN IMPORTED)
|
||||
|
||||
set_target_properties(${_zlibng_target_name} PROPERTIES
|
||||
IMPORTED_LOCATION "${ZLIBNG_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${ZLIBNG_INCLUDE_DIR}"
|
||||
)
|
||||
endif ()
|
||||
unset (_zlibng_target_name)
|
||||
|
||||
set (ZLIBNG_INCLUDE_DIRS ${ZLIBNG_INCLUDE_DIR})
|
||||
set (ZLIBNG_LIBRARIES ${ZLIBNG_LIBRARY})
|
||||
endif ()
|
||||
@@ -61,9 +61,8 @@
|
||||
# Hints
|
||||
# ^^^^^
|
||||
#
|
||||
# Set ``libaec_ROOT`` to a directory which contains a libaec installation.
|
||||
# If it is known that the libaec installation contains a libaec-config.cmake
|
||||
# file, instead set ``libaec_DIR`` to the directory which contains that file.
|
||||
# Set ``libaec_ROOT`` or ``SZIP_ROOT`` to a directory which contains a libaec
|
||||
# installation.
|
||||
#
|
||||
|
||||
include (FindPackageHandleStandardArgs)
|
||||
@@ -81,7 +80,11 @@ mark_as_advanced (libaec_DIR)
|
||||
# If a libaec-config.cmake file is available for use, prefer that
|
||||
if (libaec_FOUND)
|
||||
find_package_handle_standard_args (libaec HANDLE_COMPONENTS CONFIG_MODE)
|
||||
message (VERBOSE "Found existing libaec CMake configuration file at ${libaec_DIR}")
|
||||
if (DEFINED libaec_DIR AND NOT libaec_DIR STREQUAL "libaec_DIR-NOTFOUND")
|
||||
message (VERBOSE "Found existing libaec CMake configuration file at ${libaec_DIR}")
|
||||
else ()
|
||||
message (VERBOSE "Found existing libaec CMake configuration file")
|
||||
endif ()
|
||||
|
||||
# Set variables that this module returns
|
||||
if (TARGET libaec::aec)
|
||||
@@ -130,7 +133,7 @@ endif ()
|
||||
# Find the libaec.h header file
|
||||
find_path (libaec_INCLUDE_DIR
|
||||
NAMES libaec.h
|
||||
HINTS ${libaec_ROOT} ${PC_LIBAEC_INCLUDE_DIRS}
|
||||
HINTS ${libaec_ROOT} ${SZIP_ROOT} ${PC_LIBAEC_INCLUDE_DIRS}
|
||||
DOC "Path to the libaec.h header file"
|
||||
)
|
||||
mark_as_advanced (libaec_INCLUDE_DIR)
|
||||
@@ -138,7 +141,7 @@ mark_as_advanced (libaec_INCLUDE_DIR)
|
||||
# Find the szlib.h header file
|
||||
find_path (libsz_INCLUDE_DIR
|
||||
NAMES szlib.h
|
||||
HINTS ${libaec_ROOT} ${PC_LIBAEC_INCLUDE_DIRS}
|
||||
HINTS ${libaec_ROOT} ${SZIP_ROOT} ${PC_LIBAEC_INCLUDE_DIRS}
|
||||
DOC "Path to the szlib.h header file"
|
||||
)
|
||||
mark_as_advanced (libsz_INCLUDE_DIR)
|
||||
@@ -146,7 +149,7 @@ mark_as_advanced (libsz_INCLUDE_DIR)
|
||||
# Find the libaec library
|
||||
find_library (libaec_LIBRARY
|
||||
NAMES aec libaec libaec.a
|
||||
HINTS ${libaec_ROOT} ${PC_LIBAEC_LIBRARY_DIRS}
|
||||
HINTS ${libaec_ROOT} ${SZIP_ROOT} ${PC_LIBAEC_LIBRARY_DIRS}
|
||||
PATH_SUFFIXES lib lib64
|
||||
DOC "Path to the libaec library file"
|
||||
)
|
||||
@@ -155,7 +158,7 @@ mark_as_advanced (libaec_LIBRARY)
|
||||
# Find the libsz library
|
||||
find_library (libsz_LIBRARY
|
||||
NAMES sz libsz libsz.a
|
||||
HINTS ${libaec_ROOT} ${PC_LIBAEC_LIBRARY_DIRS}
|
||||
HINTS ${libaec_ROOT} ${SZIP_ROOT} ${PC_LIBAEC_LIBRARY_DIRS}
|
||||
PATH_SUFFIXES lib lib64
|
||||
DOC "Path to the libsz library file"
|
||||
)
|
||||
|
||||
@@ -34,15 +34,7 @@ set (H5PL_HDF5_REPACK_EXECUTABLE $<TARGET_FILE:h5repack> CACHE STRING "HDF5 h5re
|
||||
|
||||
# Allow external support for plugins (e.g., GIT or TGZ), defaulting to HDF5 setting if not defined
|
||||
if (NOT DEFINED H5PL_ALLOW_EXTERNAL_SUPPORT)
|
||||
set (H5PL_ALLOW_EXTERNAL_SUPPORT "${HDF5_ALLOW_EXTERNAL_SUPPORT}" CACHE STRING "Allow External Library Building (NO GIT TGZ)" FORCE)
|
||||
endif ()
|
||||
|
||||
# If using GIT for external support, disable certain plugins (BitGroom, JPEG, LZF)
|
||||
if (H5PL_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT")
|
||||
set (ENABLE_BITGROOM OFF CACHE BOOL "" FORCE)
|
||||
set (ENABLE_BITROUND OFF CACHE BOOL "" FORCE)
|
||||
set (ENABLE_JPEG OFF CACHE BOOL "" FORCE)
|
||||
set (ENABLE_LZF OFF CACHE BOOL "" FORCE)
|
||||
set (H5PL_ALLOW_EXTERNAL_SUPPORT "${HDF5_ALLOW_EXTERNAL_SUPPORT}" CACHE STRING "If not set to NO, specifies where to obtain sources when building or using external libraries (NO GIT TGZ)" FORCE)
|
||||
endif ()
|
||||
|
||||
# On Windows with Intel compilers, disable ZFP plugin (not supported)
|
||||
@@ -57,15 +49,35 @@ if (NOT DEFINED H5PL_TGZPATH)
|
||||
endif ()
|
||||
|
||||
# Set GIT and TGZ plugin source variables from parent project
|
||||
set (H5PL_GIT_URL "${PLUGIN_GIT_URL}" CACHE STRING "Use plugins from HDF Group repository" FORCE)
|
||||
set (H5PL_GIT_BRANCH "${PLUGIN_GIT_BRANCH}" CACHE STRING "" FORCE)
|
||||
if (DEFINED PLUGIN_GIT_URL)
|
||||
# PLUGIN_GIT_URL is deprecated, but still available
|
||||
set (H5PL_GIT_URL "${PLUGIN_GIT_URL}" CACHE STRING "Use plugins from HDF Group repository" FORCE)
|
||||
else ()
|
||||
set (H5PL_GIT_URL "${HDF5_FILTER_PLUGINS_GIT_URL}" CACHE STRING "Use plugins from HDF Group repository" FORCE)
|
||||
endif ()
|
||||
if (DEFINED )
|
||||
# PLUGIN_GIT_BRANCH is deprecated, but still available
|
||||
set (H5PL_GIT_BRANCH "${PLUGIN_GIT_BRANCH}" CACHE STRING "" FORCE)
|
||||
else ()
|
||||
set (H5PL_GIT_BRANCH "${HDF5_FILTER_PLUGINS_GIT_TAG}" CACHE STRING "" FORCE)
|
||||
endif ()
|
||||
mark_as_advanced (H5PL_GIT_URL)
|
||||
mark_as_advanced (H5PL_GIT_BRANCH)
|
||||
set (H5PL_TGZ_NAME "${PLUGIN_TGZ_NAME}" CACHE STRING "Use plugins from compressed file" FORCE)
|
||||
if (DEFINED PLUGIN_TGZ_NAME)
|
||||
# PLUGIN_TGZ_NAME is deprecated, but still available
|
||||
set (H5PL_TGZ_NAME "${PLUGIN_TGZ_NAME}" CACHE STRING "Use plugins from compressed file" FORCE)
|
||||
else ()
|
||||
set (H5PL_TGZ_NAME "${HDF5_FILTER_PLUGINS_TGZ_NAME}" CACHE STRING "Use plugins from compressed file" FORCE)
|
||||
endif ()
|
||||
mark_as_advanced (H5PL_TGZ_NAME)
|
||||
|
||||
# Set plugin package name and CPack option
|
||||
set (PL_PACKAGE_NAME "${PLUGIN_PACKAGE_NAME}" CACHE STRING "Name of plugins package" FORCE)
|
||||
if (DEFINED PLUGIN_PACKAGE_NAME)
|
||||
# PLUGIN_PACKAGE_NAME is deprecated, but still available
|
||||
set (PL_PACKAGE_NAME "${PLUGIN_PACKAGE_NAME}" CACHE STRING "Name of plugins package" FORCE)
|
||||
else ()
|
||||
set (PL_PACKAGE_NAME "${HDF5_FILTER_PLUGINS_PACKAGE_NAME}" CACHE STRING "Name of plugins package" FORCE)
|
||||
endif ()
|
||||
mark_as_advanced (PL_PACKAGE_NAME)
|
||||
set (H5PL_CPACK_ENABLE OFF CACHE BOOL "Enable CPack include and components" FORCE)
|
||||
|
||||
|
||||
@@ -1,84 +0,0 @@
|
||||
#
|
||||
# Copyright by The HDF Group.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of HDF5. The full HDF5 copyright notice, including
|
||||
# terms governing use, modification, and redistribution, is contained in
|
||||
# the LICENSE file, which can be found at the root of the source code
|
||||
# distribution tree, or in https://www.hdfgroup.org/licenses.
|
||||
# If you do not have access to either file, you may request a copy from
|
||||
# help@hdfgroup.org.
|
||||
#
|
||||
# HDF5PluginMacros.cmake - Macros for building and configuring HDF5 filter plugins
|
||||
#
|
||||
# This file provides macros to automate the configuration, fetching, and build
|
||||
# of external HDF5 filter plugins, supporting both GIT and TGZ sources. It also
|
||||
# provides options for enabling/disabling plugins and packaging logic.
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Plugins must be built SHARED
|
||||
#-------------------------------------------------------------------------------
|
||||
# Macro to fetch and make available an external plugin library, either from GIT or TGZ
|
||||
macro (EXTERNAL_PLUGIN_LIBRARY compress_type)
|
||||
if (${compress_type} MATCHES "GIT")
|
||||
# Fetch plugin from a GIT repository
|
||||
FetchContent_Declare (PLUGIN
|
||||
GIT_REPOSITORY ${PLUGIN_URL}
|
||||
GIT_TAG ${PLUGIN_BRANCH}
|
||||
)
|
||||
elseif (${compress_type} MATCHES "TGZ")
|
||||
# Fetch plugin from a TGZ archive
|
||||
FetchContent_Declare (PLUGIN
|
||||
URL ${PLUGIN_URL}
|
||||
URL_HASH ""
|
||||
)
|
||||
endif ()
|
||||
# Include plugin cache configuration
|
||||
include (${HDF_RESOURCES_DIR}/HDF5PluginCache.cmake)
|
||||
set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
|
||||
# Make the plugin available for the build
|
||||
FetchContent_MakeAvailable(PLUGIN)
|
||||
# Set plugin directory and status variables
|
||||
set (PLUGIN_BINARY_DIR "${plugin_BINARY_DIR}")
|
||||
set (PLUGIN_SOURCE_DIR "${plugin_SOURCE_DIR}")
|
||||
set (PLUGIN_LIBRARY "PLUGIN")
|
||||
set (PLUGIN_FOUND 1)
|
||||
endmacro ()
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Macro to define options and add subdirectory for a filter plugin
|
||||
macro (FILTER_OPTION plname)
|
||||
string(TOLOWER ${plname} PLUGIN_NAME)
|
||||
# Option to enable/disable this plugin
|
||||
option (ENABLE_${plname} "Enable Library Building for ${plname} plugin" ON)
|
||||
if (ENABLE_${plname})
|
||||
# Option to use external build for this plugin
|
||||
option (HDF_${plname}_USE_EXTERNAL "Use External Library Building for ${PLUGIN_NAME} plugin else search" OFF)
|
||||
mark_as_advanced (HDF_${plname}_USE_EXTERNAL)
|
||||
# If external support is enabled, set up URLs and branches for GIT/TGZ
|
||||
if (H5PL_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR H5PL_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ")
|
||||
set (HDF_${plname}_USE_EXTERNAL ON CACHE BOOL "Use External Library Building for ${PLUGIN_NAME} plugin" FORCE)
|
||||
if (H5PL_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT")
|
||||
set (HDF_${plname}_URL ${HDF_${plname}_GIT_URL})
|
||||
set (HDF_${plname}_BRANCH ${HDF_${plname}_GIT_BRANCH})
|
||||
elseif (H5PL_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ")
|
||||
if (NOT H5PL_COMP_TGZPATH)
|
||||
set (H5PL_COMP_TGZPATH ${H5PL_SOURCE_DIR}/libs)
|
||||
endif ()
|
||||
set (HDF_${plname}_URL ${H5PL_COMP_TGZPATH}/${HDF_${plname}_TGZ_NAME})
|
||||
endif ()
|
||||
endif ()
|
||||
# Add the plugin subdirectory to the build
|
||||
add_subdirectory (${plname})
|
||||
# Register the plugin's exported libraries for later use
|
||||
set_global_variable (H5PL_LIBRARIES_TO_EXPORT "${H5PL_LIBRARIES_TO_EXPORT};${H5${plname}_LIBRARIES_TO_EXPORT}")
|
||||
endif ()
|
||||
endmacro ()
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Macro for packaging logic for a plugin (currently just a placeholder)
|
||||
macro (PACKAGE_PLUGIN_LIBRARY compress_type)
|
||||
if (${compress_type} MATCHES "GIT" OR ${compress_type} MATCHES "TGZ")
|
||||
message (VERBOSE "Filter PLUGIN is to be packaged")
|
||||
endif ()
|
||||
endmacro ()
|
||||
@@ -1,123 +0,0 @@
|
||||
#
|
||||
# Copyright by The HDF Group.
|
||||
# All rights reserved.
|
||||
#
|
||||
# This file is part of HDF5. The full HDF5 copyright notice, including
|
||||
# terms governing use, modification, and redistribution, is contained in
|
||||
# the LICENSE file, which can be found at the root of the source code
|
||||
# distribution tree, or in https://www.hdfgroup.org/licenses.
|
||||
# If you do not have access to either file, you may request a copy from
|
||||
# help@hdfgroup.org.
|
||||
#
|
||||
# HDFLibMacros.cmake - Macros for configuring external ZLIB and SZIP libraries for HDF5
|
||||
#
|
||||
# This file provides macros to automate the configuration, fetching, and build
|
||||
# of external ZLIB and SZIP (libaec) libraries for HDF5, supporting both GIT and TGZ sources.
|
||||
# It sets up include directories, library variables, and handles patching of CMakeLists.txt
|
||||
# for custom build requirements. These macros are used to ensure consistent integration
|
||||
# of compression libraries in HDF5 builds.
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
macro (EXTERNAL_ZLIB_LIBRARY compress_type)
|
||||
# Select the correct folder for ZLIB or ZLIB-NG
|
||||
if (HDF5_USE_ZLIB_NG)
|
||||
set (zlib_folder "ZLIBNG")
|
||||
else ()
|
||||
set (zlib_folder "ZLIB")
|
||||
endif ()
|
||||
# Handle GIT or TGZ source for ZLIB
|
||||
if (${compress_type} MATCHES "GIT")
|
||||
# Use a different CMakeLists for 'develop' branch
|
||||
if (${ZLIB_BRANCH} MATCHES "develop")
|
||||
set (ZLIB_FILE "devCMakeLists")
|
||||
else ()
|
||||
set (ZLIB_FILE "CMakeLists")
|
||||
endif ()
|
||||
message (STATUS "Filter ZLIB file ${ZLIB_URL}")
|
||||
# Fetch ZLIB from GIT and patch CMakeLists.txt
|
||||
FetchContent_Declare (HDF5_ZLIB
|
||||
GIT_REPOSITORY ${ZLIB_URL}
|
||||
GIT_TAG ${ZLIB_BRANCH}
|
||||
PATCH_COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${HDF_RESOURCES_DIR}/${zlib_folder}/${ZLIB_FILE}.txt
|
||||
<SOURCE_DIR>/CMakeLists.txt
|
||||
)
|
||||
elseif (${compress_type} MATCHES "TGZ")
|
||||
message (VERBOSE "Filter ZLIB file ${ZLIB_URL}")
|
||||
# Fetch ZLIB from TGZ and patch CMakeLists.txt
|
||||
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 ()
|
||||
|
||||
# Make ZLIB available for the build
|
||||
FetchContent_MakeAvailable(HDF5_ZLIB)
|
||||
|
||||
# Optionally add namespace alias for static zlib
|
||||
if (HDF_PACKAGE_NAMESPACE)
|
||||
add_library(${HDF_PACKAGE_NAMESPACE}zlib-static ALIAS zlib-static)
|
||||
endif ()
|
||||
set (H5_ZLIB_STATIC_LIBRARY "${HDF_PACKAGE_NAMESPACE}zlib-static")
|
||||
set (H5_ZLIB_LIBRARIES ${H5_ZLIB_STATIC_LIBRARY})
|
||||
# Set the correct header for zlib-ng compatibility
|
||||
if (HDF5_USE_ZLIB_NG)
|
||||
if (ZLIB_COMPAT)
|
||||
set (H5_ZLIB_HEADER "zlib.h")
|
||||
else ()
|
||||
set (H5_ZLIB_HEADER "zlib-ng.h")
|
||||
endif ()
|
||||
else ()
|
||||
set (H5_ZLIB_HEADER "zlib.h")
|
||||
endif ()
|
||||
|
||||
# Set include directories for generated and source headers
|
||||
set (H5_ZLIB_INCLUDE_DIR_GEN "${hdf5_zlib_BINARY_DIR}")
|
||||
set (H5_ZLIB_INCLUDE_DIR "${hdf5_zlib_SOURCE_DIR}")
|
||||
set (H5_ZLIB_FOUND 1)
|
||||
set (H5_ZLIB_INCLUDE_DIRS ${H5_ZLIB_INCLUDE_DIR_GEN} ${H5_ZLIB_INCLUDE_DIR})
|
||||
endmacro ()
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
macro (EXTERNAL_SZIP_LIBRARY compress_type encoding)
|
||||
# Only libaec library is usable for SZIP
|
||||
if (${compress_type} MATCHES "GIT")
|
||||
# Fetch libaec from GIT and patch CMakeLists.txt
|
||||
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}")
|
||||
# Fetch libaec from TGZ and patch CMakeLists.txt
|
||||
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 ()
|
||||
# Make SZIP (libaec) available for the build
|
||||
FetchContent_MakeAvailable(SZIP)
|
||||
|
||||
# Optionally add namespace aliases for static szaec and aec
|
||||
if (HDF_PACKAGE_NAMESPACE)
|
||||
add_library (${HDF_PACKAGE_NAMESPACE}szaec-static ALIAS szaec-static)
|
||||
add_library (${HDF_PACKAGE_NAMESPACE}aec-static ALIAS aec-static)
|
||||
endif ()
|
||||
set (H5_SZIP_STATIC_LIBRARY "${HDF_PACKAGE_NAMESPACE}szaec-static;${HDF_PACKAGE_NAMESPACE}aec-static")
|
||||
set (H5_SZIP_LIBRARIES ${H5_SZIP_STATIC_LIBRARY})
|
||||
|
||||
# Set include directories for generated and source headers
|
||||
set (H5_SZIP_INCLUDE_DIR_GEN "${szip_BINARY_DIR}")
|
||||
set (H5_SZIP_INCLUDE_DIR "${szip_SOURCE_DIR}/include")
|
||||
set (H5_SZIP_FOUND 1)
|
||||
set (H5_SZIP_INCLUDE_DIRS ${H5_SZIP_INCLUDE_DIR_GEN} ${H5_SZIP_INCLUDE_DIR})
|
||||
endmacro ()
|
||||
@@ -1,302 +0,0 @@
|
||||
cmake_minimum_required (VERSION 3.26)
|
||||
project (LIBAEC C)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Basic LIBAEC stuff here
|
||||
#-----------------------------------------------------------------------------
|
||||
set (CMAKE_C_STANDARD 99)
|
||||
set (CMAKE_C_VISIBILITY_PRESET hidden)
|
||||
set (CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
set (LIBAEC_PACKAGE_EXT ${HDF_PACKAGE_EXT})
|
||||
set (HDF_USE_GNU_DIRS ${HDF5_USE_GNU_DIRS})
|
||||
set (CMAKE_OSX_ARCHITECTURES ${CMAKE_OSX_ARCHITECTURES})
|
||||
set (CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE})
|
||||
set (PACKAGE_NAMESPACE ${HDF_PACKAGE_NAMESPACE})
|
||||
if (MINGW)
|
||||
set (WINDOWS 1) # MinGW tries to imitate Windows
|
||||
endif ()
|
||||
if (WINDOWS)
|
||||
set (HAVE_SYS_STAT_H 1)
|
||||
set (HAVE_SYS_TYPES_H 1)
|
||||
endif ()
|
||||
|
||||
if (NOT WINDOWS)
|
||||
include (TestBigEndian)
|
||||
test_big_endian (WORDS_BIGENDIAN)
|
||||
endif ()
|
||||
|
||||
# Check for __builtin_clzll for faster decoding
|
||||
include (CheckCSourceCompiles)
|
||||
check_c_source_compiles(
|
||||
"int main(void)\n{return __builtin_clzll(1LL);}"
|
||||
HAVE_DECL___BUILTIN_CLZLL)
|
||||
|
||||
if (NOT HAVE_DECL___BUILTIN_CLZLL)
|
||||
# With MSVC we can use _BitScanReverse64
|
||||
check_c_source_compiles (
|
||||
"int main(void){unsigned long foo; unsigned __int64 bar=1LL;
|
||||
return _BitScanReverse64(&foo, bar);}"
|
||||
HAVE_BSR64)
|
||||
endif ()
|
||||
|
||||
include (CheckSymbolExists)
|
||||
check_symbol_exists (snprintf "stdio.h" HAVE_SNPRINTF)
|
||||
if (NOT HAVE_SNPRINTF)
|
||||
check_symbol_exists (_snprintf "stdio.h" HAVE__SNPRINTF)
|
||||
check_symbol_exists (_snprintf_s "stdio.h" HAVE__SNPRINTF_S)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Define some CMake variables for use later in the project
|
||||
#-----------------------------------------------------------------------------
|
||||
set (LIBAEC_RESOURCES_DIR ${HDF_RESOURCES_DIR}/LIBAEC)
|
||||
set (LIBAEC_SRC_DIR ${LIBAEC_SOURCE_DIR}/src)
|
||||
set (LIBAEC_INC_DIR ${LIBAEC_SOURCE_DIR}/include)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Set the core names of all the libraries
|
||||
#-----------------------------------------------------------------------------
|
||||
set (LIBAEC_LIB_CORENAME "aec")
|
||||
set (SZIP_LIB_CORENAME "szaec")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Set the true names of all the libraries if customized by external project
|
||||
#-----------------------------------------------------------------------------
|
||||
set (LIBAEC_LIB_NAME "${LIBAEC_EXTERNAL_LIB_PREFIX}${LIBAEC_LIB_CORENAME}")
|
||||
set (SZIP_LIB_NAME "${LIBAEC_EXTERNAL_LIB_PREFIX}${SZIP_LIB_CORENAME}")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Set the target names of all the libraries
|
||||
#-----------------------------------------------------------------------------
|
||||
set (LIBAEC_LIB_TARGET "${LIBAEC_LIB_CORENAME}-static")
|
||||
set (SZIP_LIB_TARGET "${SZIP_LIB_CORENAME}-static")
|
||||
|
||||
set (libaec_VERS_MAJOR 1)
|
||||
set (libaec_VERS_MINOR 1)
|
||||
set (libaec_VERS_RELEASE 3)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
set (LIBAEC_PACKAGE "libaec")
|
||||
set (LIBAEC_PACKAGE_NAME "LIBAEC")
|
||||
set (LIBAEC_PACKAGE_VERSION "${libaec_VERS_MAJOR}.${libaec_VERS_MINOR}")
|
||||
set (LIBAEC_PACKAGE_VERSION_MAJOR "${libaec_VERS_MAJOR}.${libaec_VERS_MINOR}")
|
||||
set (LIBAEC_PACKAGE_VERSION_MINOR "${libaec_VERS_RELEASE}")
|
||||
set (LIBAEC_PACKAGE_STRING "${LIBAEC_PACKAGE_NAME} ${LIBAEC_PACKAGE_VERSION}")
|
||||
set (LIBAEC_PACKAGE_TARNAME "${LIBAEC_PACKAGE_NAME}${LIBAEC_PACKAGE_EXT}")
|
||||
set (LIBAEC_PACKAGE_URL "http://www.hdfgroup.org")
|
||||
set (LIBAEC_PACKAGE_BUGREPORT "help@hdfgroup.org")
|
||||
set (LIBAEC_PACKAGE_SOVERSION "${libaec_VERS_MAJOR}.${libaec_VERS_MINOR}.${libaec_VERS_RELEASE}")
|
||||
set (LIBAEC_PACKAGE_SOVERSION_MAJOR "${libaec_VERS_MAJOR}")
|
||||
|
||||
HDF_DIR_PATHS(${LIBAEC_PACKAGE_NAME})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Targets built within this project are exported at Install time for use
|
||||
# by other projects
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT LIBAEC_EXPORTED_TARGETS)
|
||||
set (LIBAEC_EXPORTED_TARGETS "libaec-targets")
|
||||
endif ()
|
||||
|
||||
set_global_variable (LIBAEC_LIBRARIES_TO_EXPORT "")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# All libs/tests/examples need the main include directories
|
||||
#-----------------------------------------------------------------------------
|
||||
set_directory_properties (PROPERTIES INCLUDE_DIRECTORIES
|
||||
"${LIBAEC_BINARY_DIR};${LIBAEC_SOURCE_DIR}/src;${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
set (CMAKE_MFC_FLAG 0)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
endif ()
|
||||
|
||||
set (EXE_EXT "")
|
||||
if (WIN32)
|
||||
set (EXE_EXT ".exe")
|
||||
add_compile_definitions (_BIND_TO_CURRENT_VCLIBS_VERSION=1)
|
||||
add_compile_definitions (_CRT_SECURE_NO_WARNINGS)
|
||||
add_compile_definitions (_CONSOLE)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Generate the aec_config.h file containing user settings needed by compilation
|
||||
#-----------------------------------------------------------------------------
|
||||
configure_file (${LIBAEC_RESOURCES_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
# Create libaec.h with current version information
|
||||
configure_file(
|
||||
"include/libaec.h.in"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/libaec.h")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Define LIBAEC Library
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
set (LIBAEC_PUBLIC_HEADERS
|
||||
${CMAKE_CURRENT_BINARY_DIR}/libaec.h
|
||||
)
|
||||
|
||||
set(LIBAEC_SRCS
|
||||
${LIBAEC_SRC_DIR}/encode.c
|
||||
${LIBAEC_SRC_DIR}/encode_accessors.c
|
||||
${LIBAEC_SRC_DIR}/decode.c
|
||||
${LIBAEC_SRC_DIR}/vector.c
|
||||
)
|
||||
|
||||
add_library (${LIBAEC_LIB_TARGET} STATIC ${LIBAEC_SRCS} ${LIBAEC_PUBLIC_HEADERS})
|
||||
target_include_directories (${LIBAEC_LIB_TARGET} PUBLIC
|
||||
"$<BUILD_INTERFACE:${LIBAEC_SOURCE_DIR}>"
|
||||
"$<BUILD_INTERFACE:${LIBAEC_SOURCE_DIR}/include>"
|
||||
"$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>"
|
||||
"$<INSTALL_INTERFACE:include>")
|
||||
if (CMAKE_C_COMPILER_ID MATCHES "IntelLLVM" OR (CMAKE_C_COMPILER_ID MATCHES "[Cc]lang" AND NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 15.0))
|
||||
target_compile_options(${LIBAEC_LIB_TARGET} PRIVATE -Wno-deprecated-non-prototype)
|
||||
endif ()
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_compile_options(${LIBAEC_LIB_TARGET} PRIVATE -fmessage-length=0)
|
||||
endif ()
|
||||
TARGET_C_PROPERTIES (${LIBAEC_LIB_TARGET} STATIC)
|
||||
H5_SET_LIB_OPTIONS (${LIBAEC_LIB_TARGET} ${LIBAEC_LIB_NAME} STATIC 0)
|
||||
set_target_properties (${LIBAEC_LIB_TARGET} PROPERTIES
|
||||
VERSION 0.0.12 SOVERSION 0
|
||||
PUBLIC_HEADER ""
|
||||
LINKER_LANGUAGE C
|
||||
INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
|
||||
)
|
||||
set_global_variable (LIBAEC_LIBRARIES_TO_EXPORT ${LIBAEC_LIB_TARGET})
|
||||
set (install_targets ${LIBAEC_LIB_TARGET})
|
||||
|
||||
set(SZIP_SRCS
|
||||
${LIBAEC_SRC_DIR}/sz_compat.c
|
||||
)
|
||||
|
||||
set (SZIP_PUBLIC_HEADERS
|
||||
${LIBAEC_INC_DIR}/szlib.h
|
||||
)
|
||||
|
||||
add_library (${SZIP_LIB_TARGET} STATIC ${SZIP_SRCS} ${SZIP_PUBLIC_HEADERS})
|
||||
target_include_directories (${SZIP_LIB_TARGET} PUBLIC "${LIBAEC_SOURCE_DIR};${LIBAEC_SOURCE_DIR}/include;${CMAKE_BINARY_DIR}")
|
||||
TARGET_C_PROPERTIES (${SZIP_LIB_TARGET} STATIC)
|
||||
target_link_libraries (${SZIP_LIB_TARGET} PRIVATE ${LIBAEC_LIB_TARGET})
|
||||
H5_SET_LIB_OPTIONS (${SZIP_LIB_TARGET} ${SZIP_LIB_NAME} STATIC 0)
|
||||
set_target_properties (${SZIP_LIB_TARGET} PROPERTIES
|
||||
VERSION 2.0.1 SOVERSION 2
|
||||
PUBLIC_HEADER ""
|
||||
LINKER_LANGUAGE C
|
||||
INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
|
||||
)
|
||||
|
||||
set_global_variable (LIBAEC_LIBRARIES_TO_EXPORT "${LIBAEC_LIBRARIES_TO_EXPORT};${SZIP_LIB_TARGET}")
|
||||
set (install_targets ${install_targets} ${SZIP_LIB_TARGET})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add Target(s) to CMake Install for import into other projects
|
||||
#-----------------------------------------------------------------------------
|
||||
if (LIBAEC_EXPORTED_TARGETS)
|
||||
INSTALL_TARGET_PDB (${LIBAEC_LIB_TARGET} ${LIBAEC_INSTALL_BIN_DIR} libraries)
|
||||
|
||||
install (
|
||||
TARGETS
|
||||
${install_targets}
|
||||
EXPORT
|
||||
${LIBAEC_EXPORTED_TARGETS}
|
||||
LIBRARY DESTINATION ${LIBAEC_INSTALL_LIB_DIR} COMPONENT libraries
|
||||
ARCHIVE DESTINATION ${LIBAEC_INSTALL_LIB_DIR} COMPONENT libraries
|
||||
RUNTIME DESTINATION ${LIBAEC_INSTALL_BIN_DIR} COMPONENT libraries
|
||||
FRAMEWORK DESTINATION ${LIBAEC_INSTALL_FWRK_DIR} COMPONENT libraries
|
||||
PUBLIC_HEADER DESTINATION ${LIBAEC_INSTALL_INCLUDE_DIR} COMPONENT headers
|
||||
)
|
||||
endif ()
|
||||
|
||||
include (CMakePackageConfigHelpers)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Set includes needed for build
|
||||
#-----------------------------------------------------------------------------
|
||||
set (LIBAEC_INCLUDES_BUILD_TIME
|
||||
${LIBAEC_SRC_DIR} ${LIBAEC_INC_DIR} ${LIBAEC_BINARY_DIR}
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Set variables needed for installation
|
||||
#-----------------------------------------------------------------------------
|
||||
set (LIBAEC_VERSION_STRING ${LIBAEC_PACKAGE_VERSION})
|
||||
set (LIBAEC_VERSION_MAJOR ${LIBAEC_PACKAGE_VERSION_MAJOR})
|
||||
set (LIBAEC_VERSION_MINOR ${LIBAEC_PACKAGE_VERSION_MINOR})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure the libaec-config.cmake file for the build directory
|
||||
#-----------------------------------------------------------------------------
|
||||
set (INCLUDE_INSTALL_DIR ${LIBAEC_INSTALL_INCLUDE_DIR})
|
||||
set (SHARE_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/${LIBAEC_INSTALL_CMAKE_DIR}" )
|
||||
set (CURRENT_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}" )
|
||||
configure_package_config_file (
|
||||
${LIBAEC_RESOURCES_DIR}/libaec-config.cmake.in
|
||||
"${LIBAEC_BINARY_DIR}/${LIBAEC_PACKAGE}${LIBAEC_PACKAGE_EXT}-config.cmake"
|
||||
INSTALL_DESTINATION "${LIBAEC_INSTALL_CMAKE_DIR}"
|
||||
PATH_VARS INCLUDE_INSTALL_DIR SHARE_INSTALL_DIR CURRENT_BUILD_DIR
|
||||
INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure the libaec-config.cmake file for the install directory
|
||||
#-----------------------------------------------------------------------------
|
||||
set (INCLUDE_INSTALL_DIR ${LIBAEC_INSTALL_INCLUDE_DIR})
|
||||
set (SHARE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${LIBAEC_INSTALL_CMAKE_DIR}" )
|
||||
set (CURRENT_BUILD_DIR "${CMAKE_INSTALL_PREFIX}")
|
||||
configure_package_config_file (
|
||||
${LIBAEC_RESOURCES_DIR}/libaec-config.cmake.in
|
||||
"${LIBAEC_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${LIBAEC_PACKAGE}${LIBAEC_PACKAGE_EXT}-config.cmake"
|
||||
INSTALL_DESTINATION "${LIBAEC_INSTALL_CMAKE_DIR}"
|
||||
PATH_VARS INCLUDE_INSTALL_DIR SHARE_INSTALL_DIR CURRENT_BUILD_DIR
|
||||
)
|
||||
if (NOT LIBAEC_EXTERNALLY_CONFIGURED)
|
||||
install (
|
||||
FILES ${LIBAEC_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${LIBAEC_PACKAGE}${LIBAEC_PACKAGE_EXT}-config.cmake
|
||||
DESTINATION ${LIBAEC_INSTALL_CMAKE_DIR}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure the libaec-config-version.cmake file for the install directory
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT LIBAEC_EXTERNALLY_CONFIGURED)
|
||||
configure_file (
|
||||
${LIBAEC_RESOURCES_DIR}/libaec-config-version.cmake.in
|
||||
${LIBAEC_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${LIBAEC_PACKAGE}${LIBAEC_PACKAGE_EXT}-config-version.cmake @ONLY
|
||||
)
|
||||
install (
|
||||
FILES ${LIBAEC_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/${LIBAEC_PACKAGE}${LIBAEC_PACKAGE_EXT}-config-version.cmake
|
||||
DESTINATION ${LIBAEC_INSTALL_CMAKE_DIR}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add Target(s) to CMake Install for import into other projects
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT LIBAEC_EXTERNALLY_CONFIGURED)
|
||||
install (
|
||||
EXPORT ${LIBAEC_EXPORTED_TARGETS}
|
||||
DESTINATION ${LIBAEC_INSTALL_CMAKE_DIR}
|
||||
FILE ${LIBAEC_PACKAGE}${LIBAEC_PACKAGE_EXT}-targets.cmake
|
||||
NAMESPACE ${PACKAGE_NAMESPACE}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Export all exported targets to the build tree for use by parent project
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT LIBAEC_EXTERNALLY_CONFIGURED)
|
||||
export (
|
||||
TARGETS ${LIBAEC_LIBRARIES_TO_EXPORT} ${LIBAEC_LIB_DEPENDENCIES}
|
||||
FILE ${LIBAEC_PACKAGE}${LIBAEC_PACKAGE_EXT}-targets.cmake
|
||||
NAMESPACE ${PACKAGE_NAMESPACE}
|
||||
)
|
||||
export (PACKAGE ${LIBAEC_PACKAGE}${LIBAEC_PACKAGE_EXT})
|
||||
endif ()
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>@CPACK_PACKAGE_FILE_NAME@</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>@CPACK_BUNDLE_ICON@</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.@CPACK_PACKAGE_VENDOR@.@CPACK_PACKAGE_NAME@@CPACK_MODULE_VERSION_SUFFIX@</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>@CPACK_PACKAGE_VERSION@</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>@CPACK_SHORT_VERSION_STRING@</string>
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,6 +0,0 @@
|
||||
#cmakedefine WORDS_BIGENDIAN
|
||||
#cmakedefine01 HAVE_DECL___BUILTIN_CLZLL
|
||||
#cmakedefine HAVE_BSR64
|
||||
#cmakedefine HAVE_SNPRINTF
|
||||
#cmakedefine HAVE__SNPRINTF
|
||||
#cmakedefine HAVE__SNPRINTF_S
|
||||
@@ -1,15 +0,0 @@
|
||||
set(PACKAGE_VERSION_MAJOR @PROJECT_VERSION_MAJOR@)
|
||||
set(PACKAGE_VERSION_MINOR @PROJECT_VERSION_MINOR@)
|
||||
set(PACKAGE_VERSION_PATCH @PROJECT_VERSION_PATCH@)
|
||||
set(PACKAGE_VERSION @PROJECT_VERSION@)
|
||||
|
||||
# Check whether the requested PACKAGE_FIND_VERSION is compatible
|
||||
if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION OR
|
||||
PACKAGE_VERSION_MAJOR GREATER PACKAGE_FIND_VERSION_MAJOR)
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
set(PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
if(PACKAGE_VERSION VERSION_EQUAL PACKAGE_FIND_VERSION)
|
||||
set(PACKAGE_VERSION_EXACT TRUE)
|
||||
endif()
|
||||
endif()
|
||||
@@ -1,101 +0,0 @@
|
||||
# libaec-config.cmake
|
||||
# ----------------
|
||||
#
|
||||
# Finds the AEC library, specify the starting search path in libaec_ROOT.
|
||||
#
|
||||
# Static vs. shared
|
||||
# -----------------
|
||||
# To make use of the static library instead of the shared one, one needs
|
||||
# to set the variable libaec_USE_STATIC_LIBS to ON before calling find_package.
|
||||
# Example:
|
||||
# set(libaec_USE_STATIC_LIBS ON)
|
||||
# find_package(libaec CONFIG)
|
||||
#
|
||||
# This will define the following variables:
|
||||
#
|
||||
# libaec_FOUND - True if the system has the AEC library.
|
||||
# libaec_VERSION - The version of the AEC library which was found.
|
||||
# SZIP_FOUND - True if the system has the SZIP library.
|
||||
# SZIP_VERSION - The version of the SZIP library which was found.
|
||||
# SZIP_LIBRARIES - All the required libraries to make use of SZIP.
|
||||
#
|
||||
# and the following imported targets:
|
||||
#
|
||||
# libaec::aec - The AEC library.
|
||||
# libaec::sz - The SZIP compatible version of the AEC library.
|
||||
|
||||
find_path(libaec_INCLUDE_DIR NAMES libaec.h DOC "AEC include directory")
|
||||
find_path(SZIP_INCLUDE_DIR NAMES szlib.h DOC "SZIP include directory")
|
||||
if (libaec_USE_STATIC_LIBS)
|
||||
if (MSVC)
|
||||
find_library(libaec_LIBRARY NAMES aec-static.lib DOC "AEC library")
|
||||
find_library(SZIP_LIBRARY NAMES szip-static.lib DOC "SZIP compatible version of the AEC library")
|
||||
else ()
|
||||
find_library(libaec_LIBRARY NAMES libaec.a DOC "AEC library")
|
||||
find_library(SZIP_LIBRARY NAMES libsz.a DOC "SZIP compatible version of the AEC library")
|
||||
endif ()
|
||||
else ()
|
||||
find_library(libaec_LIBRARY NAMES aec DOC "AEC library")
|
||||
find_library(SZIP_LIBRARY NAMES sz szip DOC "SZIP compatible version of the AEC library")
|
||||
endif ()
|
||||
|
||||
# Check version here
|
||||
if (libaec_INCLUDE_DIR AND libaec_LIBRARY)
|
||||
set(libaec_VERSION "@PROJECT_VERSION@")
|
||||
set(SZIP_VERSION "2.0.1")
|
||||
endif ()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
set(${CMAKE_FIND_PACKAGE_NAME}_CONFIG "${CMAKE_CURRENT_LIST_FILE}")
|
||||
find_package_handle_standard_args(libaec
|
||||
FOUND_VAR libaec_FOUND
|
||||
REQUIRED_VARS libaec_LIBRARY libaec_INCLUDE_DIR SZIP_LIBRARY SZIP_INCLUDE_DIR
|
||||
VERSION_VAR libaec_VERSION
|
||||
CONFIG_MODE
|
||||
)
|
||||
|
||||
if (libaec_FOUND)
|
||||
if (libaec_USE_STATIC_LIBS)
|
||||
add_library(libaec::aec STATIC IMPORTED)
|
||||
else ()
|
||||
add_library(libaec::aec SHARED IMPORTED)
|
||||
target_compile_definitions(libaec::aec INTERFACE LIBAEC_SHARED)
|
||||
if (MSVC)
|
||||
set_target_properties(libaec::aec PROPERTIES
|
||||
IMPORTED_IMPLIB "${libaec_LIBRARY}"
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
set_target_properties(libaec::aec PROPERTIES
|
||||
IMPORTED_LOCATION "${libaec_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${libaec_INCLUDE_DIR}"
|
||||
)
|
||||
|
||||
# SZIP
|
||||
if (libaec_USE_STATIC_LIBS)
|
||||
add_library(libaec::sz STATIC IMPORTED)
|
||||
else ()
|
||||
add_library(libaec::sz SHARED IMPORTED)
|
||||
target_compile_definitions(libaec::sz INTERFACE LIBAEC_SHARED)
|
||||
if (MSVC)
|
||||
set_target_properties(libaec::sz PROPERTIES
|
||||
IMPORTED_IMPLIB "${SZIP_LIBRARY}"
|
||||
)
|
||||
endif ()
|
||||
endif ()
|
||||
set_target_properties(libaec::sz PROPERTIES
|
||||
IMPORTED_LOCATION "${SZIP_LIBRARY}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${SZIP_INCLUDE_DIR}"
|
||||
)
|
||||
|
||||
# Set SZIP variables.
|
||||
set(SZIP_FOUND TRUE)
|
||||
set(SZIP_LIBRARIES "${SZIP_LIBRARY}")
|
||||
endif ()
|
||||
|
||||
mark_as_advanced(
|
||||
libaec_LIBRARY
|
||||
libaec_INCLUDE_DIR
|
||||
SZIP_LIBRARY
|
||||
SZIP_INCLUDE_DIR
|
||||
)
|
||||
@@ -9,7 +9,8 @@
|
||||
# If you do not have access to either file, you may request a copy from
|
||||
# help@hdfgroup.org.
|
||||
#
|
||||
# This is the CMakeCache file.
|
||||
# This file is used to initialize the CMake cache for memory checking
|
||||
# builds of HDF5.
|
||||
|
||||
#########################
|
||||
# EXTERNAL cache entries
|
||||
@@ -47,31 +48,13 @@ set (HDF_TEST_EXPRESS "2" CACHE STRING "Control testing framework (0-3)" FORCE)
|
||||
|
||||
set (HDF5_MINGW_STATIC_GCC_LIBS ON CACHE BOOL "Statically link libgcc/libstdc++" FORCE)
|
||||
|
||||
set (HDF5_ALLOW_EXTERNAL_SUPPORT "TGZ" CACHE STRING "Allow External Library Building (NO GIT TGZ)" FORCE)
|
||||
set_property (CACHE HDF5_ALLOW_EXTERNAL_SUPPORT PROPERTY STRINGS NO GIT TGZ)
|
||||
set (HDF5_ALLOW_EXTERNAL_SUPPORT "TGZ" CACHE STRING "If not set to NO, specifies where to obtain sources when building or using external libraries (NO GIT TGZ)" FORCE)
|
||||
|
||||
########################
|
||||
# compression options
|
||||
########################
|
||||
set (ZLIB_PACKAGE_NAME "zlib" CACHE STRING "Name of ZLIB package" FORCE)
|
||||
set (ZLIB_TGZ_NAME "zlib-1.3.1.tar.gz" CACHE STRING "Use HDF5_ZLib from compressed file" FORCE)
|
||||
set (ZLIB_TGZ_ORIGPATH "https://github.com/madler/zlib/releases/download/v1.3.1" CACHE STRING "Use ZLIB from original location" FORCE)
|
||||
set (ZLIB_USE_LOCALCONTENT ON CACHE BOOL "Use local file for ZLIB FetchContent" FORCE)
|
||||
set (ZLIB_GIT_URL "https://github.com/madler/zlib.git" CACHE STRING "Use ZLIB from GitHub repository" FORCE)
|
||||
set (ZLIB_GIT_BRANCH "develop" CACHE STRING "" FORCE)
|
||||
|
||||
set (ZLIBNG_PACKAGE_NAME "zlib-ng" CACHE STRING "Name of ZLIBNG package" FORCE)
|
||||
set (ZLIBNG_TGZ_NAME "2.2.4.tar.gz" CACHE STRING "Use HDF5_ZLib from compressed file" FORCE)
|
||||
set (ZLIBNG_TGZ_ORIGPATH "https://github.com/zlib-ng/zlib-ng/archive/refs/tags" CACHE STRING "Use ZLIBNG from original location" FORCE)
|
||||
set (ZLIBNG_GIT_URL "https://github.com/zlib-ng/zlib-ng.git" CACHE STRING "Use ZLIBNG from GitHub repository" FORCE)
|
||||
set (ZLIBNG_GIT_BRANCH "develop" CACHE STRING "" FORCE)
|
||||
|
||||
set (LIBAEC_PACKAGE_NAME "libaec" CACHE STRING "Name of AEC SZIP package" FORCE)
|
||||
set (LIBAEC_TGZ_NAME "libaec-1.1.3.tar.gz" CACHE STRING "Use SZip AEC from compressed file" FORCE)
|
||||
set (LIBAEC_TGZ_ORIGPATH "https://github.com/MathisRosenhauer/libaec/releases/download/v1.1.3" CACHE STRING "Use LIBAEC from original location" FORCE)
|
||||
set (LIBAEC_USE_LOCALCONTENT ON CACHE BOOL "Use local file for LIBAEC FetchContent" FORCE)
|
||||
set (LIBAEC_GIT_URL "https://github.com/MathisRosenhauer/libaec.git" CACHE STRING "Use LIBAEC from GitHub repository" FORCE)
|
||||
set (LIBAEC_GIT_BRANCH "v1.1.3" CACHE STRING "" FORCE)
|
||||
|
||||
set (CMAKE_BUILD_TYPE "Debug" CACHE STRING "Build Debug" FORCE)
|
||||
|
||||
@@ -1,307 +0,0 @@
|
||||
cmake_minimum_required (VERSION 3.26)
|
||||
set (CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
|
||||
project (ZLIB C)
|
||||
|
||||
set(VERSION "1.3.1")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Basic ZLIB stuff here
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_PACKAGE_EXT ${HDF_PACKAGE_EXT})
|
||||
set (HDF_USE_GNU_DIRS ${HDF5_USE_GNU_DIRS})
|
||||
set (CMAKE_OSX_ARCHITECTURES ${CMAKE_OSX_ARCHITECTURES})
|
||||
set (CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE})
|
||||
set (PACKAGE_NAMESPACE ${HDF_PACKAGE_NAMESPACE})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Define some CMake variables for use later in the project
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_RESOURCES_DIR ${HDF_RESOURCES_DIR}/ZLIB)
|
||||
set (ZLIB_SRC_DIR ${ZLIB_SOURCE_DIR})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Set the core names of all the libraries
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_LIB_CORENAME "zlib-static")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Set the target names of all the libraries
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_LIB_TARGET "zlib-static")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_PACKAGE "zlib")
|
||||
set (ZLIB_PACKAGE_NAME "ZLIB")
|
||||
|
||||
set (CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
HDF_DIR_PATHS(${ZLIB_PACKAGE_NAME})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Targets built within this project are exported at Install time for use
|
||||
# by other projects
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT ZLIB_EXPORTED_TARGETS)
|
||||
set (ZLIB_EXPORTED_TARGETS "zlib-targets")
|
||||
endif ()
|
||||
|
||||
set_global_variable (ZLIB_LIBRARIES_TO_EXPORT "")
|
||||
|
||||
if (MINGW)
|
||||
set (WINDOWS 1) # MinGW tries to imitate Windows
|
||||
endif ()
|
||||
if (WINDOWS)
|
||||
set (HAVE_STDDEF_H 1)
|
||||
set (HAVE_SYS_TYPES_H 1)
|
||||
endif ()
|
||||
|
||||
include (CheckTypeSize)
|
||||
include (CheckFunctionExists)
|
||||
include (CheckIncludeFile)
|
||||
include (CheckCSourceCompiles)
|
||||
|
||||
check_include_file (sys/types.h HAVE_SYS_TYPES_H)
|
||||
check_include_file (stdint.h HAVE_STDINT_H)
|
||||
check_include_file (stddef.h HAVE_STDDEF_H)
|
||||
|
||||
#
|
||||
# Check to see if we have large file support
|
||||
#
|
||||
set (CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
|
||||
# We add these other definitions here because CheckTypeSize.cmake
|
||||
# in CMake 2.4.x does not automatically do so and we want
|
||||
# compatibility with CMake 2.4.x.
|
||||
if (HAVE_SYS_TYPES_H)
|
||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
|
||||
endif ()
|
||||
if (HAVE_STDINT_H)
|
||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
|
||||
endif ()
|
||||
if (HAVE_STDDEF_H)
|
||||
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
|
||||
endif ()
|
||||
check_type_size (off64_t OFF64_T)
|
||||
if (HAVE_OFF64_T)
|
||||
add_definitions(-D_LARGEFILE64_SOURCE=1)
|
||||
endif ()
|
||||
set (CMAKE_REQUIRED_DEFINITIONS) # clear variable
|
||||
|
||||
#
|
||||
# Check for fseeko
|
||||
#
|
||||
check_function_exists (fseeko HAVE_FSEEKO)
|
||||
if (NOT HAVE_FSEEKO)
|
||||
add_definitions (-DNO_FSEEKO)
|
||||
endif ()
|
||||
|
||||
#
|
||||
# Check for unistd.h
|
||||
#
|
||||
check_include_file (unistd.h Z_HAVE_UNISTD_H)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# All libs/tests/examples need the main include directories
|
||||
#-----------------------------------------------------------------------------
|
||||
set_directory_properties (PROPERTIES INCLUDE_DIRECTORIES
|
||||
"${ZLIB_BINARY_DIR};${ZLIB_SOURCE_DIR};${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
add_definitions (-D_BIND_TO_CURRENT_VCLIBS_VERSION=1)
|
||||
add_definitions (-D_CRT_SECURE_NO_DEPRECATE)
|
||||
add_definitions (-D_CRT_SECURE_NO_WARNINGS)
|
||||
add_definitions (-D_CONSOLE)
|
||||
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endif ()
|
||||
|
||||
#============================================================================
|
||||
# zconf.h
|
||||
#============================================================================
|
||||
|
||||
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
||||
# If we're doing an out of source build and the user has a zconf.h
|
||||
# in their source tree...
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
|
||||
message(VERBOSE "Renaming")
|
||||
message(VERBOSE " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h")
|
||||
message(VERBOSE "to 'zconf.h.included' because this file is included with zlib")
|
||||
message(VERBOSE "but CMake generates it automatically in the build directory.")
|
||||
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included)
|
||||
endif()
|
||||
endif()
|
||||
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Define ZLIB Library
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
set(ZLIB_PUBLIC_HDRS
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zconf.h
|
||||
zlib.h
|
||||
)
|
||||
set(ZLIB_PRIVATE_HDRS
|
||||
crc32.h
|
||||
deflate.h
|
||||
gzguts.h
|
||||
inffast.h
|
||||
inffixed.h
|
||||
inflate.h
|
||||
inftrees.h
|
||||
trees.h
|
||||
zutil.h
|
||||
)
|
||||
set(ZLIB_SRCS
|
||||
adler32.c
|
||||
compress.c
|
||||
crc32.c
|
||||
deflate.c
|
||||
gzclose.c
|
||||
gzlib.c
|
||||
gzread.c
|
||||
gzwrite.c
|
||||
inflate.c
|
||||
infback.c
|
||||
inftrees.c
|
||||
inffast.c
|
||||
trees.c
|
||||
uncompr.c
|
||||
zutil.c
|
||||
)
|
||||
|
||||
### Define library
|
||||
add_library(${ZLIB_LIB_TARGET} STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
target_include_directories(${ZLIB_LIB_TARGET}
|
||||
PRIVATE "${CMAKE_BINARY_DIR}"
|
||||
PUBLIC "${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
)
|
||||
if (MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
if (CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM64")
|
||||
set_target_properties(${ZLIB_LIB_TARGET} PROPERTIES STATIC_LIBRARY_FLAGS "/machine:ARM64")
|
||||
else()
|
||||
set_target_properties(${ZLIB_LIB_TARGET} PROPERTIES STATIC_LIBRARY_FLAGS "/machine:x64")
|
||||
endif()
|
||||
endif()
|
||||
set_target_properties(${ZLIB_LIB_TARGET} PROPERTIES
|
||||
PUBLIC_HEADER ""
|
||||
LINKER_LANGUAGE C
|
||||
INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Compiler specific flags
|
||||
#-----------------------------------------------------------------------------
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_compile_options(${ZLIB_LIB_TARGET} PRIVATE -Wno-strict-prototypes -Wno-implicit-function-declaration)
|
||||
endif ()
|
||||
if (CMAKE_C_COMPILER_ID MATCHES "IntelLLVM" OR CMAKE_C_COMPILER_ID MATCHES "[Cc]lang")
|
||||
target_compile_options(${ZLIB_LIB_TARGET} PRIVATE -Wno-implicit-function-declaration)
|
||||
endif ()
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_compile_options(${ZLIB_LIB_TARGET} PRIVATE -fmessage-length=0)
|
||||
endif ()
|
||||
|
||||
set_target_properties(${ZLIB_LIB_TARGET} PROPERTIES OUTPUT_NAME zlib-static)
|
||||
|
||||
set_global_variable (ZLIB_LIBRARIES_TO_EXPORT "${ZLIB_LIB_TARGET}")
|
||||
set (install_targets ${ZLIB_LIB_TARGET})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add Target(s) to CMake Install for import into other projects
|
||||
#-----------------------------------------------------------------------------
|
||||
if (ZLIB_EXPORTED_TARGETS)
|
||||
INSTALL_TARGET_PDB (${ZLIB_LIB_TARGET} ${ZLIB_INSTALL_BIN_DIR} libraries)
|
||||
|
||||
install (
|
||||
TARGETS
|
||||
${install_targets}
|
||||
EXPORT
|
||||
${ZLIB_EXPORTED_TARGETS}
|
||||
LIBRARY DESTINATION ${ZLIB_INSTALL_LIB_DIR} COMPONENT libraries
|
||||
ARCHIVE DESTINATION ${ZLIB_INSTALL_LIB_DIR} COMPONENT libraries
|
||||
RUNTIME DESTINATION ${ZLIB_INSTALL_BIN_DIR} COMPONENT libraries
|
||||
FRAMEWORK DESTINATION ${ZLIB_INSTALL_FWRK_DIR} COMPONENT libraries
|
||||
PUBLIC_HEADER DESTINATION ${ZLIB_INSTALL_INCLUDE_DIR} COMPONENT headers
|
||||
)
|
||||
endif ()
|
||||
|
||||
include (CMakePackageConfigHelpers)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure the zlib-config.cmake file for the build directory
|
||||
#-----------------------------------------------------------------------------
|
||||
set (INCLUDE_INSTALL_DIR ${ZLIB_INSTALL_INCLUDE_DIR})
|
||||
set (SHARE_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/${ZLIB_INSTALL_CMAKE_DIR}" )
|
||||
set (CURRENT_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}" )
|
||||
configure_package_config_file (
|
||||
${ZLIB_RESOURCES_DIR}/zlib-config.cmake.in
|
||||
"${ZLIB_BINARY_DIR}/zlib-config.cmake"
|
||||
INSTALL_DESTINATION "${ZLIB_INSTALL_CMAKE_DIR}"
|
||||
PATH_VARS INCLUDE_INSTALL_DIR SHARE_INSTALL_DIR CURRENT_BUILD_DIR
|
||||
INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure the zlib-config.cmake file for the install directory
|
||||
#-----------------------------------------------------------------------------
|
||||
set (INCLUDE_INSTALL_DIR ${ZLIB_INSTALL_INCLUDE_DIR})
|
||||
set (SHARE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${ZLIB_INSTALL_CMAKE_DIR}" )
|
||||
set (CURRENT_BUILD_DIR "${CMAKE_INSTALL_PREFIX}")
|
||||
configure_package_config_file (
|
||||
${ZLIB_RESOURCES_DIR}/zlib-config.cmake.in
|
||||
"${ZLIB_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/zlib-config.cmake"
|
||||
INSTALL_DESTINATION "${ZLIB_INSTALL_CMAKE_DIR}"
|
||||
PATH_VARS INCLUDE_INSTALL_DIR SHARE_INSTALL_DIR CURRENT_BUILD_DIR
|
||||
)
|
||||
if (NOT ZLIB_EXTERNALLY_CONFIGURED)
|
||||
install (
|
||||
FILES ${ZLIB_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/zlib-config.cmake
|
||||
DESTINATION ${ZLIB_INSTALL_CMAKE_DIR}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure the ZLIB-config-version.cmake file for the install directory
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT ZLIB_EXTERNALLY_CONFIGURED)
|
||||
configure_file (
|
||||
${ZLIB_RESOURCES_DIR}/zlib-config-version.cmake.in
|
||||
${ZLIB_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/zlib-config-version.cmake @ONLY
|
||||
)
|
||||
install (
|
||||
FILES ${ZLIB_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/zlib-config-version.cmake
|
||||
DESTINATION ${ZLIB_INSTALL_CMAKE_DIR}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add Target(s) to CMake Install for import into other projects
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT ZLIB_EXTERNALLY_CONFIGURED)
|
||||
install (
|
||||
EXPORT ${ZLIB_EXPORTED_TARGETS}
|
||||
DESTINATION ${ZLIB_INSTALL_CMAKE_DIR}
|
||||
FILE zlib-targets.cmake
|
||||
NAMESPACE ${PACKAGE_NAMESPACE}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Export all exported targets to the build tree for use by parent project
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT ZLIB_EXTERNALLY_CONFIGURED)
|
||||
export (
|
||||
TARGETS ${ZLIB_LIBRARIES_TO_EXPORT}
|
||||
FILE zlib-targets.cmake
|
||||
NAMESPACE ${PACKAGE_NAMESPACE}
|
||||
)
|
||||
export (PACKAGE zlib)
|
||||
endif ()
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>@CPACK_PACKAGE_FILE_NAME@</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>@CPACK_BUNDLE_ICON@</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.@CPACK_PACKAGE_VENDOR@.@CPACK_PACKAGE_NAME@@CPACK_MODULE_VERSION_SUFFIX@</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>@CPACK_PACKAGE_VERSIO@</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>@CPACK_SHORT_VERSION_STRING@</string>
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,372 +0,0 @@
|
||||
cmake_minimum_required (VERSION 3.26)
|
||||
|
||||
project(
|
||||
ZLIB
|
||||
LANGUAGES C
|
||||
VERSION 1.4.1.1
|
||||
HOMEPAGE_URL "https://zlib.net/"
|
||||
DESCRIPTION "a general-purpose lossless data-compression library")
|
||||
set (CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Basic ZLIB stuff here
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_PACKAGE_EXT ${HDF_PACKAGE_EXT})
|
||||
set (HDF_USE_GNU_DIRS ${HDF5_USE_GNU_DIRS})
|
||||
set (CMAKE_OSX_ARCHITECTURES ${CMAKE_OSX_ARCHITECTURES})
|
||||
set (CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE})
|
||||
set (PACKAGE_NAMESPACE ${HDF_PACKAGE_NAMESPACE})
|
||||
if (MINGW)
|
||||
set (WINDOWS 1) # MinGW tries to imitate Windows
|
||||
endif ()
|
||||
if (WINDOWS)
|
||||
set (HAVE_STDDEF_H 1)
|
||||
set (HAVE_SYS_TYPES_H 1)
|
||||
endif ()
|
||||
# ============================================================================
|
||||
# configuration
|
||||
# ============================================================================
|
||||
|
||||
option(ZLIB_BUILD_TESTING "Enable Zlib Examples as tests" OFF)
|
||||
option(ZLIB_BUILD_SHARED "Enable building zlib shared library" OFF)
|
||||
option(ZLIB_BUILD_STATIC "Enable building zlib static library" ON)
|
||||
option(ZLIB_BUILD_MINIZIP "Enable building libminizip contrib library" OFF)
|
||||
option(ZLIB_INSTALL "Enable installation of zlib" OFF)
|
||||
option(ZLIB_PREFIX "prefix for all types and library functions, see zconf.h.in"
|
||||
OFF)
|
||||
mark_as_advanced(ZLIB_PREFIX)
|
||||
|
||||
if(WIN32)
|
||||
option(ZLIB_INSTALL_COMPAT_DLL "Install a copy as zlib1.dll" ON)
|
||||
endif(WIN32)
|
||||
|
||||
get_property(IS_MULTI GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
|
||||
if(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI)
|
||||
message(STATUS "No CMAKE_BUILD_TYPE set -- using Release")
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
endif(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI)
|
||||
|
||||
include(CheckCSourceCompiles)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckIncludeFile)
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(CheckTypeSize)
|
||||
include(CPack)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
set(CPACK_INCLUDED FALSE)
|
||||
|
||||
if(NOT ZLIB_CONF_WRITTEN)
|
||||
set(Z_PREFIX ${ZLIB_PREFIX})
|
||||
set(CONF_OUT_FILE ${ZLIB_BINARY_DIR}/zconf.h.cmakein)
|
||||
file(READ ${ZLIB_SOURCE_DIR}/zconf.h ZCONF_CONTENT LIMIT 245)
|
||||
file(WRITE ${CONF_OUT_FILE} ${ZCONF_CONTENT})
|
||||
file(APPEND ${CONF_OUT_FILE} "#cmakedefine Z_PREFIX 1\n")
|
||||
file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_STDARG_H 1\n")
|
||||
file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_UNISTD_H 1\n")
|
||||
file(READ ${ZLIB_SOURCE_DIR}/zconf.h ZCONF_CONTENT OFFSET 244)
|
||||
set(FIRST_ITEM TRUE)
|
||||
|
||||
foreach(item IN LISTS ZCONF_CONTENT)
|
||||
if(FIRST_ITEM)
|
||||
string(APPEND OUT_CONTENT ${item})
|
||||
set(FIRST_ITEM FALSE)
|
||||
else(FIRST_ITEM)
|
||||
string(APPEND OUT_CONTENT "\;" ${item})
|
||||
endif(FIRST_ITEM)
|
||||
endforeach(item IN LISTS ${ZCONF_CONTENT})
|
||||
|
||||
file(APPEND ${CONF_OUT_FILE} ${OUT_CONTENT})
|
||||
set(ZLIB_CONF_WRITTEN
|
||||
TRUE
|
||||
CACHE BOOL "zconf.h.cmakein was created")
|
||||
mark_as_advanced(ZLIB_CONF_WRITTEN)
|
||||
endif(NOT ZLIB_CONF_WRITTEN)
|
||||
|
||||
#
|
||||
# Check to see if we have large file support
|
||||
#
|
||||
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
|
||||
check_type_size(off64_t OFF64_T)
|
||||
unset(CMAKE_REQUIRED_DEFINITIONS) # clear variable
|
||||
|
||||
#
|
||||
# Check for fseeko
|
||||
#
|
||||
check_function_exists(fseeko HAVE_FSEEKO)
|
||||
|
||||
#
|
||||
# Check for stdarg.h
|
||||
#
|
||||
check_include_file(stdarg.h HAVE_STDARG_H)
|
||||
|
||||
#
|
||||
# Check for unistd.h
|
||||
#
|
||||
check_include_file(unistd.h HAVE_UNISTD_H)
|
||||
|
||||
#
|
||||
# Check visibility attribute is supported
|
||||
#
|
||||
if(MSVC)
|
||||
set(CMAKE_REQUIRED_FLAGS "-WX")
|
||||
else(MSVC)
|
||||
set(CMAKE_REQUIRED_FLAGS "-WError")
|
||||
endif(MSVC)
|
||||
|
||||
check_c_source_compiles(
|
||||
"
|
||||
#include <stdlib.h>
|
||||
static void f(void) __attribute__ ((visibility(\"hidden\")));
|
||||
int main(void) {return 0;}
|
||||
"
|
||||
HAVE___ATTR__VIS_HIDDEN)
|
||||
|
||||
unset(CMAKE_COMPILE_FLAGS)
|
||||
set(ZLIB_PC ${ZLIB_BINARY_DIR}/zlib.pc)
|
||||
configure_file(${ZLIB_SOURCE_DIR}/zlib.pc.cmakein ${ZLIB_PC} @ONLY)
|
||||
configure_file(${ZLIB_BINARY_DIR}/zconf.h.cmakein ${ZLIB_BINARY_DIR}/zconf.h)
|
||||
include_directories(${ZLIB_BINARY_DIR} ${ZLIB_SOURCE_DIR})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Define some CMake variables for use later in the project
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_RESOURCES_DIR ${HDF_RESOURCES_DIR}/ZLIB)
|
||||
set (ZLIB_SRC_DIR ${ZLIB_SOURCE_DIR})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Set the core names of all the libraries
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_LIB_CORENAME "zlib-static")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Set the target names of all the libraries
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_LIB_TARGET "zlib-static")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_PACKAGE "zlib")
|
||||
set (ZLIB_PACKAGE_NAME "ZLIB")
|
||||
|
||||
set (CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
HDF_DIR_PATHS(${ZLIB_PACKAGE_NAME})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Targets built within this project are exported at Install time for use
|
||||
# by other projects
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT ZLIB_EXPORTED_TARGETS)
|
||||
set (ZLIB_EXPORTED_TARGETS "zlib-targets")
|
||||
endif ()
|
||||
|
||||
set_global_variable (ZLIB_LIBRARIES_TO_EXPORT "")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# All libs/tests/examples need the main include directories
|
||||
#-----------------------------------------------------------------------------
|
||||
set_directory_properties (PROPERTIES INCLUDE_DIRECTORIES
|
||||
"${ZLIB_BINARY_DIR};${ZLIB_SOURCE_DIR};${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
add_definitions (-D_BIND_TO_CURRENT_VCLIBS_VERSION=1)
|
||||
add_definitions (-D_CRT_SECURE_NO_WARNINGS)
|
||||
add_definitions (-D_CONSOLE)
|
||||
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
|
||||
endif ()
|
||||
|
||||
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
||||
# If we're doing an out of source build and the user has a zconf.h
|
||||
# in their source tree...
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
|
||||
message(VERBOSE "Renaming")
|
||||
message(VERBOSE " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h")
|
||||
message(VERBOSE "to 'zconf.h.included' because this file is included with zlib")
|
||||
message(VERBOSE "but CMake generates it automatically in the build directory.")
|
||||
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included)
|
||||
endif()
|
||||
endif()
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
|
||||
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Define ZLIB Library
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
set(ZLIB_PUBLIC_HDRS ${ZLIB_BINARY_DIR}/zconf.h zlib.h)
|
||||
|
||||
set(ZLIB_PRIVATE_HDRS
|
||||
crc32.h
|
||||
deflate.h
|
||||
gzguts.h
|
||||
inffast.h
|
||||
inffixed.h
|
||||
inflate.h
|
||||
inftrees.h
|
||||
trees.h
|
||||
zutil.h)
|
||||
|
||||
set(ZLIB_SRCS
|
||||
adler32.c
|
||||
compress.c
|
||||
crc32.c
|
||||
deflate.c
|
||||
gzclose.c
|
||||
gzlib.c
|
||||
gzread.c
|
||||
gzwrite.c
|
||||
inflate.c
|
||||
infback.c
|
||||
inftrees.c
|
||||
inffast.c
|
||||
trees.c
|
||||
uncompr.c
|
||||
zutil.c)
|
||||
|
||||
add_library(${ZLIB_LIB_TARGET} STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
target_include_directories(
|
||||
${ZLIB_LIB_TARGET}
|
||||
PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
|
||||
target_compile_definitions(
|
||||
${ZLIB_LIB_TARGET}
|
||||
PRIVATE $<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
|
||||
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
|
||||
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
|
||||
$<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
|
||||
$<$<BOOL:${MSVC}>:_BIND_TO_CURRENT_VCLIBS_VERSION=1>
|
||||
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_WARNINGS>
|
||||
$<$<BOOL:${MSVC}>:_CONSOLE>
|
||||
PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
|
||||
target_include_directories(${ZLIB_LIB_TARGET}
|
||||
PRIVATE "${CMAKE_BINARY_DIR}"
|
||||
PUBLIC "${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_CURRENT_SOURCE_DIR}"
|
||||
)
|
||||
if (MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
if (CMAKE_C_COMPILER_ARCHITECTURE_ID MATCHES "ARM64")
|
||||
set_target_properties(${ZLIB_LIB_TARGET} PROPERTIES STATIC_LIBRARY_FLAGS "/machine:ARM64")
|
||||
else()
|
||||
set_target_properties(${ZLIB_LIB_TARGET} PROPERTIES STATIC_LIBRARY_FLAGS "/machine:x64")
|
||||
endif()
|
||||
endif()
|
||||
set_target_properties(${ZLIB_LIB_TARGET} PROPERTIES
|
||||
PUBLIC_HEADER ""
|
||||
LINKER_LANGUAGE C
|
||||
INTERFACE_INCLUDE_DIRECTORIES "$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include>"
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Compiler specific flags
|
||||
#-----------------------------------------------------------------------------
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_compile_options(${ZLIB_LIB_TARGET} PRIVATE -Wno-strict-prototypes -Wno-implicit-function-declaration)
|
||||
endif ()
|
||||
if (CMAKE_C_COMPILER_ID MATCHES "IntelLLVM" OR CMAKE_C_COMPILER_ID MATCHES "[Cc]lang")
|
||||
target_compile_options(${ZLIB_LIB_TARGET} PRIVATE -Wno-implicit-function-declaration)
|
||||
endif ()
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_compile_options(${ZLIB_LIB_TARGET} PRIVATE -fmessage-length=0)
|
||||
endif ()
|
||||
|
||||
set_target_properties(${ZLIB_LIB_TARGET} PROPERTIES OUTPUT_NAME zlib-static)
|
||||
|
||||
set_global_variable (ZLIB_LIBRARIES_TO_EXPORT "${ZLIB_LIB_TARGET}")
|
||||
set (install_targets ${ZLIB_LIB_TARGET})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add Target(s) to CMake Install for import into other projects
|
||||
#-----------------------------------------------------------------------------
|
||||
if (ZLIB_EXPORTED_TARGETS)
|
||||
install (
|
||||
TARGETS
|
||||
${install_targets}
|
||||
EXPORT
|
||||
${ZLIB_EXPORTED_TARGETS}
|
||||
LIBRARY DESTINATION ${ZLIB_INSTALL_LIB_DIR} COMPONENT libraries
|
||||
ARCHIVE DESTINATION ${ZLIB_INSTALL_LIB_DIR} COMPONENT libraries
|
||||
RUNTIME DESTINATION ${ZLIB_INSTALL_BIN_DIR} COMPONENT libraries
|
||||
FRAMEWORK DESTINATION ${ZLIB_INSTALL_FWRK_DIR} COMPONENT libraries
|
||||
PUBLIC_HEADER DESTINATION ${ZLIB_INSTALL_INCLUDE_DIR} COMPONENT headers
|
||||
)
|
||||
endif ()
|
||||
|
||||
include (CMakePackageConfigHelpers)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure the zlib-config.cmake file for the build directory
|
||||
#-----------------------------------------------------------------------------
|
||||
set (INCLUDE_INSTALL_DIR ${ZLIB_INSTALL_INCLUDE_DIR})
|
||||
set (SHARE_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/${ZLIB_INSTALL_CMAKE_DIR}" )
|
||||
set (CURRENT_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}" )
|
||||
configure_package_config_file (
|
||||
${ZLIB_RESOURCES_DIR}/zlib-config.cmake.in
|
||||
"${ZLIB_BINARY_DIR}/zlib-config.cmake"
|
||||
INSTALL_DESTINATION "${ZLIB_INSTALL_CMAKE_DIR}"
|
||||
PATH_VARS INCLUDE_INSTALL_DIR SHARE_INSTALL_DIR CURRENT_BUILD_DIR
|
||||
INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure the zlib-config.cmake file for the install directory
|
||||
#-----------------------------------------------------------------------------
|
||||
set (INCLUDE_INSTALL_DIR ${ZLIB_INSTALL_INCLUDE_DIR})
|
||||
set (SHARE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${ZLIB_INSTALL_CMAKE_DIR}" )
|
||||
set (CURRENT_BUILD_DIR "${CMAKE_INSTALL_PREFIX}")
|
||||
configure_package_config_file (
|
||||
${ZLIB_RESOURCES_DIR}/zlib-config.cmake.in
|
||||
"${ZLIB_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/zlib-config.cmake"
|
||||
INSTALL_DESTINATION "${ZLIB_INSTALL_CMAKE_DIR}"
|
||||
PATH_VARS INCLUDE_INSTALL_DIR SHARE_INSTALL_DIR CURRENT_BUILD_DIR
|
||||
)
|
||||
if (NOT ZLIB_EXTERNALLY_CONFIGURED)
|
||||
install (
|
||||
FILES ${ZLIB_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/zlib-config.cmake
|
||||
DESTINATION ${ZLIB_INSTALL_CMAKE_DIR}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure the ZLIB-config-version.cmake file for the install directory
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT ZLIB_EXTERNALLY_CONFIGURED)
|
||||
configure_file (
|
||||
${ZLIB_RESOURCES_DIR}/zlib-config-version.cmake.in
|
||||
${ZLIB_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/zlib-config-version.cmake @ONLY
|
||||
)
|
||||
install (
|
||||
FILES ${ZLIB_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/zlib-config-version.cmake
|
||||
DESTINATION ${ZLIB_INSTALL_CMAKE_DIR}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add Target(s) to CMake Install for import into other projects
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT ZLIB_EXTERNALLY_CONFIGURED)
|
||||
install (
|
||||
EXPORT ${ZLIB_EXPORTED_TARGETS}
|
||||
DESTINATION ${ZLIB_INSTALL_CMAKE_DIR}
|
||||
FILE zlib-targets.cmake
|
||||
NAMESPACE ${PACKAGE_NAMESPACE}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Export all exported targets to the build tree for use by parent project
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT ZLIB_EXTERNALLY_CONFIGURED)
|
||||
export (
|
||||
TARGETS ${ZLIB_LIBRARIES_TO_EXPORT}
|
||||
FILE zlib-targets.cmake
|
||||
NAMESPACE ${PACKAGE_NAMESPACE}
|
||||
)
|
||||
export (PACKAGE zlib)
|
||||
endif ()
|
||||
|
||||
@@ -1,553 +0,0 @@
|
||||
/* zconf.h -- configuration of the zlib compression library
|
||||
* Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#ifndef ZCONF_H
|
||||
#define ZCONF_H
|
||||
#cmakedefine Z_PREFIX
|
||||
#cmakedefine Z_HAVE_UNISTD_H
|
||||
|
||||
/*
|
||||
* If you *really* need a unique prefix for all types and library functions,
|
||||
* compile with -DZ_PREFIX. The "standard" zlib should be compiled without it.
|
||||
* Even better than compiling with -DZ_PREFIX would be to use configure to set
|
||||
* this permanently in zconf.h using "./configure --zprefix".
|
||||
*/
|
||||
#ifdef Z_PREFIX /* may be set to #if 1 by ./configure */
|
||||
# define Z_PREFIX_SET
|
||||
|
||||
/* all linked symbols and init macros */
|
||||
# define _dist_code z__dist_code
|
||||
# define _length_code z__length_code
|
||||
# define _tr_align z__tr_align
|
||||
# define _tr_flush_bits z__tr_flush_bits
|
||||
# define _tr_flush_block z__tr_flush_block
|
||||
# define _tr_init z__tr_init
|
||||
# define _tr_stored_block z__tr_stored_block
|
||||
# define _tr_tally z__tr_tally
|
||||
# define adler32 z_adler32
|
||||
# define adler32_combine z_adler32_combine
|
||||
# define adler32_combine64 z_adler32_combine64
|
||||
# define adler32_z z_adler32_z
|
||||
# ifndef Z_SOLO
|
||||
# define compress z_compress
|
||||
# define compress2 z_compress2
|
||||
# define compressBound z_compressBound
|
||||
# endif
|
||||
# define crc32 z_crc32
|
||||
# define crc32_combine z_crc32_combine
|
||||
# define crc32_combine64 z_crc32_combine64
|
||||
# define crc32_combine_gen z_crc32_combine_gen
|
||||
# define crc32_combine_gen64 z_crc32_combine_gen64
|
||||
# define crc32_combine_op z_crc32_combine_op
|
||||
# define crc32_z z_crc32_z
|
||||
# define deflate z_deflate
|
||||
# define deflateBound z_deflateBound
|
||||
# define deflateCopy z_deflateCopy
|
||||
# define deflateEnd z_deflateEnd
|
||||
# define deflateGetDictionary z_deflateGetDictionary
|
||||
# define deflateInit z_deflateInit
|
||||
# define deflateInit2 z_deflateInit2
|
||||
# define deflateInit2_ z_deflateInit2_
|
||||
# define deflateInit_ z_deflateInit_
|
||||
# define deflateParams z_deflateParams
|
||||
# define deflatePending z_deflatePending
|
||||
# define deflatePrime z_deflatePrime
|
||||
# define deflateReset z_deflateReset
|
||||
# define deflateResetKeep z_deflateResetKeep
|
||||
# define deflateSetDictionary z_deflateSetDictionary
|
||||
# define deflateSetHeader z_deflateSetHeader
|
||||
# define deflateTune z_deflateTune
|
||||
# define deflate_copyright z_deflate_copyright
|
||||
# define get_crc_table z_get_crc_table
|
||||
# ifndef Z_SOLO
|
||||
# define gz_error z_gz_error
|
||||
# define gz_intmax z_gz_intmax
|
||||
# define gz_strwinerror z_gz_strwinerror
|
||||
# define gzbuffer z_gzbuffer
|
||||
# define gzclearerr z_gzclearerr
|
||||
# define gzclose z_gzclose
|
||||
# define gzclose_r z_gzclose_r
|
||||
# define gzclose_w z_gzclose_w
|
||||
# define gzdirect z_gzdirect
|
||||
# define gzdopen z_gzdopen
|
||||
# define gzeof z_gzeof
|
||||
# define gzerror z_gzerror
|
||||
# define gzflush z_gzflush
|
||||
# define gzfread z_gzfread
|
||||
# define gzfwrite z_gzfwrite
|
||||
# define gzgetc z_gzgetc
|
||||
# define gzgetc_ z_gzgetc_
|
||||
# define gzgets z_gzgets
|
||||
# define gzoffset z_gzoffset
|
||||
# define gzoffset64 z_gzoffset64
|
||||
# define gzopen z_gzopen
|
||||
# define gzopen64 z_gzopen64
|
||||
# ifdef _WIN32
|
||||
# define gzopen_w z_gzopen_w
|
||||
# endif
|
||||
# define gzprintf z_gzprintf
|
||||
# define gzputc z_gzputc
|
||||
# define gzputs z_gzputs
|
||||
# define gzread z_gzread
|
||||
# define gzrewind z_gzrewind
|
||||
# define gzseek z_gzseek
|
||||
# define gzseek64 z_gzseek64
|
||||
# define gzsetparams z_gzsetparams
|
||||
# define gztell z_gztell
|
||||
# define gztell64 z_gztell64
|
||||
# define gzungetc z_gzungetc
|
||||
# define gzvprintf z_gzvprintf
|
||||
# define gzwrite z_gzwrite
|
||||
# endif
|
||||
# define inflate z_inflate
|
||||
# define inflateBack z_inflateBack
|
||||
# define inflateBackEnd z_inflateBackEnd
|
||||
# define inflateBackInit z_inflateBackInit
|
||||
# define inflateBackInit_ z_inflateBackInit_
|
||||
# define inflateCodesUsed z_inflateCodesUsed
|
||||
# define inflateCopy z_inflateCopy
|
||||
# define inflateEnd z_inflateEnd
|
||||
# define inflateGetDictionary z_inflateGetDictionary
|
||||
# define inflateGetHeader z_inflateGetHeader
|
||||
# define inflateInit z_inflateInit
|
||||
# define inflateInit2 z_inflateInit2
|
||||
# define inflateInit2_ z_inflateInit2_
|
||||
# define inflateInit_ z_inflateInit_
|
||||
# define inflateMark z_inflateMark
|
||||
# define inflatePrime z_inflatePrime
|
||||
# define inflateReset z_inflateReset
|
||||
# define inflateReset2 z_inflateReset2
|
||||
# define inflateResetKeep z_inflateResetKeep
|
||||
# define inflateSetDictionary z_inflateSetDictionary
|
||||
# define inflateSync z_inflateSync
|
||||
# define inflateSyncPoint z_inflateSyncPoint
|
||||
# define inflateUndermine z_inflateUndermine
|
||||
# define inflateValidate z_inflateValidate
|
||||
# define inflate_copyright z_inflate_copyright
|
||||
# define inflate_fast z_inflate_fast
|
||||
# define inflate_table z_inflate_table
|
||||
# ifndef Z_SOLO
|
||||
# define uncompress z_uncompress
|
||||
# define uncompress2 z_uncompress2
|
||||
# endif
|
||||
# define zError z_zError
|
||||
# ifndef Z_SOLO
|
||||
# define zcalloc z_zcalloc
|
||||
# define zcfree z_zcfree
|
||||
# endif
|
||||
# define zlibCompileFlags z_zlibCompileFlags
|
||||
# define zlibVersion z_zlibVersion
|
||||
|
||||
/* all zlib typedefs in zlib.h and zconf.h */
|
||||
# define Byte z_Byte
|
||||
# define Bytef z_Bytef
|
||||
# define alloc_func z_alloc_func
|
||||
# define charf z_charf
|
||||
# define free_func z_free_func
|
||||
# ifndef Z_SOLO
|
||||
# define gzFile z_gzFile
|
||||
# endif
|
||||
# define gz_header z_gz_header
|
||||
# define gz_headerp z_gz_headerp
|
||||
# define in_func z_in_func
|
||||
# define intf z_intf
|
||||
# define out_func z_out_func
|
||||
# define uInt z_uInt
|
||||
# define uIntf z_uIntf
|
||||
# define uLong z_uLong
|
||||
# define uLongf z_uLongf
|
||||
# define voidp z_voidp
|
||||
# define voidpc z_voidpc
|
||||
# define voidpf z_voidpf
|
||||
|
||||
/* all zlib structs in zlib.h and zconf.h */
|
||||
# define gz_header_s z_gz_header_s
|
||||
# define internal_state z_internal_state
|
||||
|
||||
#endif
|
||||
|
||||
#if defined(__MSDOS__) && !defined(MSDOS)
|
||||
# define MSDOS
|
||||
#endif
|
||||
#if (defined(OS_2) || defined(__OS2__)) && !defined(OS2)
|
||||
# define OS2
|
||||
#endif
|
||||
#if defined(_WINDOWS) && !defined(WINDOWS)
|
||||
# define WINDOWS
|
||||
#endif
|
||||
#if defined(_WIN32) || defined(_WIN32_WCE) || defined(__WIN32__)
|
||||
# ifndef WIN32
|
||||
# define WIN32
|
||||
# endif
|
||||
#endif
|
||||
#if (defined(MSDOS) || defined(OS2) || defined(WINDOWS)) && !defined(WIN32)
|
||||
# if !defined(__GNUC__) && !defined(__FLAT__) && !defined(__386__)
|
||||
# ifndef SYS16BIT
|
||||
# define SYS16BIT
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Compile with -DMAXSEG_64K if the alloc function cannot allocate more
|
||||
* than 64k bytes at a time (needed on systems with 16-bit int).
|
||||
*/
|
||||
#ifdef SYS16BIT
|
||||
# define MAXSEG_64K
|
||||
#endif
|
||||
#ifdef MSDOS
|
||||
# define UNALIGNED_OK
|
||||
#endif
|
||||
|
||||
#ifdef __STDC_VERSION__
|
||||
# ifndef STDC
|
||||
# define STDC
|
||||
# endif
|
||||
# if __STDC_VERSION__ >= 199901L
|
||||
# ifndef STDC99
|
||||
# define STDC99
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(__STDC__) || defined(__cplusplus))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(__GNUC__) || defined(__BORLANDC__))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(MSDOS) || defined(WINDOWS) || defined(WIN32))
|
||||
# define STDC
|
||||
#endif
|
||||
#if !defined(STDC) && (defined(OS2) || defined(__HOS_AIX__))
|
||||
# define STDC
|
||||
#endif
|
||||
|
||||
#if defined(__OS400__) && !defined(STDC) /* iSeries (formerly AS/400). */
|
||||
# define STDC
|
||||
#endif
|
||||
|
||||
#ifndef STDC
|
||||
# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */
|
||||
# define const /* note: need a more gentle solution here */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(ZLIB_CONST) && !defined(z_const)
|
||||
# define z_const const
|
||||
#else
|
||||
# define z_const
|
||||
#endif
|
||||
|
||||
#ifdef Z_SOLO
|
||||
# ifdef _WIN64
|
||||
typedef unsigned long long z_size_t;
|
||||
# else
|
||||
typedef unsigned long z_size_t;
|
||||
# endif
|
||||
#else
|
||||
# define z_longlong long long
|
||||
# if defined(NO_SIZE_T)
|
||||
typedef unsigned NO_SIZE_T z_size_t;
|
||||
# elif defined(STDC)
|
||||
# include <stddef.h>
|
||||
typedef size_t z_size_t;
|
||||
# else
|
||||
typedef unsigned long z_size_t;
|
||||
# endif
|
||||
# undef z_longlong
|
||||
#endif
|
||||
|
||||
/* Maximum value for memLevel in deflateInit2 */
|
||||
#ifndef MAX_MEM_LEVEL
|
||||
# ifdef MAXSEG_64K
|
||||
# define MAX_MEM_LEVEL 8
|
||||
# else
|
||||
# define MAX_MEM_LEVEL 9
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
|
||||
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
|
||||
* created by gzip. (Files created by minigzip can still be extracted by
|
||||
* gzip.)
|
||||
*/
|
||||
#ifndef MAX_WBITS
|
||||
# define MAX_WBITS 15 /* 32K LZ77 window */
|
||||
#endif
|
||||
|
||||
/* The memory requirements for deflate are (in bytes):
|
||||
(1 << (windowBits+2)) + (1 << (memLevel+9))
|
||||
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
|
||||
plus a few kilobytes for small objects. For example, if you want to reduce
|
||||
the default memory requirements from 256K to 128K, compile with
|
||||
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
|
||||
Of course this will generally degrade compression (there's no free lunch).
|
||||
|
||||
The memory requirements for inflate are (in bytes) 1 << windowBits
|
||||
that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
|
||||
for small objects.
|
||||
*/
|
||||
|
||||
/* Type declarations */
|
||||
|
||||
#ifndef OF /* function prototypes */
|
||||
# ifdef STDC
|
||||
# define OF(args) args
|
||||
# else
|
||||
# define OF(args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef Z_ARG /* function prototypes for stdarg */
|
||||
# if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||
# define Z_ARG(args) args
|
||||
# else
|
||||
# define Z_ARG(args) ()
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The following definitions for FAR are needed only for MSDOS mixed
|
||||
* model programming (small or medium model with some far allocations).
|
||||
* This was tested only with MSC; for other MSDOS compilers you may have
|
||||
* to define NO_MEMCPY in zutil.h. If you don't need the mixed model,
|
||||
* just define FAR to be empty.
|
||||
*/
|
||||
#ifdef SYS16BIT
|
||||
# if defined(M_I86SM) || defined(M_I86MM)
|
||||
/* MSC small or medium model */
|
||||
# define SMALL_MEDIUM
|
||||
# ifdef _MSC_VER
|
||||
# define FAR _far
|
||||
# else
|
||||
# define FAR far
|
||||
# endif
|
||||
# endif
|
||||
# if (defined(__SMALL__) || defined(__MEDIUM__))
|
||||
/* Turbo C small or medium model */
|
||||
# define SMALL_MEDIUM
|
||||
# ifdef __BORLANDC__
|
||||
# define FAR _far
|
||||
# else
|
||||
# define FAR far
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(WINDOWS) || defined(WIN32)
|
||||
/* If building or using zlib as a DLL, define ZLIB_DLL.
|
||||
* This is not mandatory, but it offers a little performance increase.
|
||||
*/
|
||||
# ifdef ZLIB_DLL
|
||||
# if defined(WIN32) && (!defined(__BORLANDC__) || (__BORLANDC__ >= 0x500))
|
||||
# ifdef ZLIB_INTERNAL
|
||||
# define ZEXTERN extern __declspec(dllexport)
|
||||
# else
|
||||
# define ZEXTERN extern __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
# endif /* ZLIB_DLL */
|
||||
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
|
||||
* define ZLIB_WINAPI.
|
||||
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
|
||||
*/
|
||||
# ifdef ZLIB_WINAPI
|
||||
# ifdef FAR
|
||||
# undef FAR
|
||||
# endif
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# endif
|
||||
# include <windows.h>
|
||||
/* No need for _export, use ZLIB.DEF instead. */
|
||||
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
||||
# define ZEXPORT WINAPI
|
||||
# ifdef WIN32
|
||||
# define ZEXPORTVA WINAPIV
|
||||
# else
|
||||
# define ZEXPORTVA FAR CDECL
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined (__BEOS__)
|
||||
# ifdef ZLIB_DLL
|
||||
# ifdef ZLIB_INTERNAL
|
||||
# define ZEXPORT __declspec(dllexport)
|
||||
# define ZEXPORTVA __declspec(dllexport)
|
||||
# else
|
||||
# define ZEXPORT __declspec(dllimport)
|
||||
# define ZEXPORTVA __declspec(dllimport)
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef ZEXTERN
|
||||
# define ZEXTERN extern
|
||||
#endif
|
||||
#ifndef ZEXPORT
|
||||
# define ZEXPORT
|
||||
#endif
|
||||
#ifndef ZEXPORTVA
|
||||
# define ZEXPORTVA
|
||||
#endif
|
||||
|
||||
#ifndef FAR
|
||||
# define FAR
|
||||
#endif
|
||||
|
||||
#if !defined(__MACTYPES__)
|
||||
typedef unsigned char Byte; /* 8 bits */
|
||||
#endif
|
||||
typedef unsigned int uInt; /* 16 bits or more */
|
||||
typedef unsigned long uLong; /* 32 bits or more */
|
||||
|
||||
#ifdef SMALL_MEDIUM
|
||||
/* Borland C/C++ and some old MSC versions ignore FAR inside typedef */
|
||||
# define Bytef Byte FAR
|
||||
#else
|
||||
typedef Byte FAR Bytef;
|
||||
#endif
|
||||
typedef char FAR charf;
|
||||
typedef int FAR intf;
|
||||
typedef uInt FAR uIntf;
|
||||
typedef uLong FAR uLongf;
|
||||
|
||||
#ifdef STDC
|
||||
typedef void const *voidpc;
|
||||
typedef void FAR *voidpf;
|
||||
typedef void *voidp;
|
||||
#else
|
||||
typedef Byte const *voidpc;
|
||||
typedef Byte FAR *voidpf;
|
||||
typedef Byte *voidp;
|
||||
#endif
|
||||
|
||||
#if !defined(Z_U4) && !defined(Z_SOLO) && defined(STDC)
|
||||
# include <limits.h>
|
||||
# if (UINT_MAX == 0xffffffffUL)
|
||||
# define Z_U4 unsigned
|
||||
# elif (ULONG_MAX == 0xffffffffUL)
|
||||
# define Z_U4 unsigned long
|
||||
# elif (USHRT_MAX == 0xffffffffUL)
|
||||
# define Z_U4 unsigned short
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef Z_U4
|
||||
typedef Z_U4 z_crc_t;
|
||||
#else
|
||||
typedef unsigned long z_crc_t;
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by ./configure */
|
||||
# define Z_HAVE_UNISTD_H
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_STDARG_H /* may be set to #if 1 by ./configure */
|
||||
# define Z_HAVE_STDARG_H
|
||||
#endif
|
||||
|
||||
#ifdef STDC
|
||||
# ifndef Z_SOLO
|
||||
# include <sys/types.h> /* for off_t */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||
# ifndef Z_SOLO
|
||||
# include <stdarg.h> /* for va_list */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
# ifndef Z_SOLO
|
||||
# include <stddef.h> /* for wchar_t */
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
|
||||
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
|
||||
* though the former does not conform to the LFS document), but considering
|
||||
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
|
||||
* equivalently requesting no 64-bit operations
|
||||
*/
|
||||
#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
|
||||
# undef _LARGEFILE64_SOURCE
|
||||
#endif
|
||||
|
||||
#ifndef Z_HAVE_UNISTD_H
|
||||
# ifdef __WATCOMC__
|
||||
# define Z_HAVE_UNISTD_H
|
||||
# endif
|
||||
#endif
|
||||
#ifndef Z_HAVE_UNISTD_H
|
||||
# if defined(_LARGEFILE64_SOURCE) && !defined(_WIN32)
|
||||
# define Z_HAVE_UNISTD_H
|
||||
# endif
|
||||
#endif
|
||||
#ifndef Z_SOLO
|
||||
# if defined(Z_HAVE_UNISTD_H)
|
||||
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
||||
# ifdef VMS
|
||||
# include <unixio.h> /* for off_t */
|
||||
# endif
|
||||
# ifndef z_off_t
|
||||
# define z_off_t off_t
|
||||
# endif
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
|
||||
# define Z_LFS64
|
||||
#endif
|
||||
|
||||
#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
|
||||
# define Z_LARGE64
|
||||
#endif
|
||||
|
||||
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
|
||||
# define Z_WANT64
|
||||
#endif
|
||||
|
||||
#if !defined(SEEK_SET) && !defined(Z_SOLO)
|
||||
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||
# define SEEK_CUR 1 /* Seek from current position. */
|
||||
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||
#endif
|
||||
|
||||
#ifndef z_off_t
|
||||
# define z_off_t long
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && defined(Z_LARGE64)
|
||||
# define z_off64_t off64_t
|
||||
#else
|
||||
# if defined(_WIN32) && !defined(__GNUC__)
|
||||
# define z_off64_t __int64
|
||||
# else
|
||||
# define z_off64_t z_off_t
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* MVS linker does not support external names larger than 8 bytes */
|
||||
#if defined(__MVS__)
|
||||
#pragma map(deflateInit_,"DEIN")
|
||||
#pragma map(deflateInit2_,"DEIN2")
|
||||
#pragma map(deflateEnd,"DEEND")
|
||||
#pragma map(deflateBound,"DEBND")
|
||||
#pragma map(inflateInit_,"ININ")
|
||||
#pragma map(inflateInit2_,"ININ2")
|
||||
#pragma map(inflateEnd,"INEND")
|
||||
#pragma map(inflateSync,"INSY")
|
||||
#pragma map(inflateSetDictionary,"INSEDI")
|
||||
#pragma map(compressBound,"CMBND")
|
||||
#pragma map(inflate_table,"INTABL")
|
||||
#pragma map(inflate_fast,"INFA")
|
||||
#pragma map(inflate_copyright,"INCOPY")
|
||||
#endif
|
||||
|
||||
#endif /* ZCONF_H */
|
||||
@@ -1,42 +0,0 @@
|
||||
#-----------------------------------------------------------------------------
|
||||
# ZLIB Version file for install directory
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
set (PACKAGE_VERSION "@ZLIB_VERSION_STRING@")
|
||||
|
||||
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
if ("${PACKAGE_FIND_VERSION_MAJOR}" STREQUAL "@ZLIB_VERSION_MAJOR@")
|
||||
|
||||
# exact match for version @ZLIB_VERSION_MAJOR@.@ZLIB_VERSION_MINOR@
|
||||
if ("${PACKAGE_FIND_VERSION_MINOR}" STREQUAL "@ZLIB_VERSION_MINOR@")
|
||||
|
||||
# compatible with any version @ZLIB_VERSION_MAJOR@.@ZLIB_VERSION_MINOR@.x
|
||||
set (PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
|
||||
if ("${PACKAGE_FIND_VERSION_PATCH}" STREQUAL "@ZLIB_VERSION_RELEASE@")
|
||||
set (PACKAGE_VERSION_EXACT TRUE)
|
||||
|
||||
if ("${PACKAGE_FIND_VERSION_TWEAK}" STREQUAL "@ZLIB_VERSION_SUBRELEASE@")
|
||||
# not using this yet
|
||||
endif ()
|
||||
endif ()
|
||||
else ()
|
||||
set (PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
|
||||
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
|
||||
if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "@CMAKE_SIZEOF_VOID_P@")
|
||||
math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8")
|
||||
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
|
||||
set(PACKAGE_VERSION_UNSUITABLE TRUE)
|
||||
endif()
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
#-----------------------------------------------------------------------------
|
||||
# ZLIB Config file for compiling against ZLIB build directory
|
||||
#-----------------------------------------------------------------------------
|
||||
@PACKAGE_INIT@
|
||||
|
||||
string(TOUPPER @ZLIB_PACKAGE@ ZLIB_PACKAGE_NAME)
|
||||
|
||||
set (${ZLIB_PACKAGE_NAME}_VALID_COMPONENTS static shared)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# User Options
|
||||
#-----------------------------------------------------------------------------
|
||||
set (${ZLIB_PACKAGE_NAME}_EXPORT_LIBRARIES @ZLIB_LIBRARIES_TO_EXPORT@)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Directories
|
||||
#-----------------------------------------------------------------------------
|
||||
set (${ZLIB_PACKAGE_NAME}_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
|
||||
|
||||
set (${ZLIB_PACKAGE_NAME}_SHARE_DIR "@PACKAGE_SHARE_INSTALL_DIR@")
|
||||
set_and_check (${ZLIB_PACKAGE_NAME}_BUILD_DIR "@PACKAGE_CURRENT_BUILD_DIR@")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Version Strings
|
||||
#-----------------------------------------------------------------------------
|
||||
set (${ZLIB_PACKAGE_NAME}_VERSION_STRING @ZLIB_VERSION_STRING@)
|
||||
set (${ZLIB_PACKAGE_NAME}_VERSION_MAJOR @ZLIB_VERSION_MAJOR@)
|
||||
set (${ZLIB_PACKAGE_NAME}_VERSION_MINOR @ZLIB_VERSION_MINOR@)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Don't include targets if this file is being picked up by another
|
||||
# project which has already built ZLIB as a subproject
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT TARGET "@ZLIB_PACKAGE@")
|
||||
include (@PACKAGE_SHARE_INSTALL_DIR@/@ZLIB_PACKAGE@@ZLIB_PACKAGE_EXT@-targets.cmake)
|
||||
endif ()
|
||||
|
||||
# Handle default component(static) :
|
||||
if (NOT ${ZLIB_PACKAGE_NAME}_FIND_COMPONENTS)
|
||||
set (${ZLIB_PACKAGE_NAME}_FIND_COMPONENTS static)
|
||||
set (${ZLIB_PACKAGE_NAME}_FIND_REQUIRED_static true)
|
||||
endif ()
|
||||
|
||||
# Handle requested components:
|
||||
list (REMOVE_DUPLICATES ${ZLIB_PACKAGE_NAME}_FIND_COMPONENTS)
|
||||
foreach (comp IN LISTS ${ZLIB_PACKAGE_NAME}_FIND_COMPONENTS)
|
||||
list (FIND ${ZLIB_PACKAGE_NAME}_EXPORT_LIBRARIES "@ZLIB_LIB_CORENAME@-${comp}" HAVE_COMP)
|
||||
if (${HAVE_COMP} LESS 0)
|
||||
set (${ZLIB_PACKAGE_NAME}_${comp}_FOUND 0)
|
||||
else ()
|
||||
set (${ZLIB_PACKAGE_NAME}_${comp}_FOUND 1)
|
||||
string(TOUPPER ${ZLIB_PACKAGE_NAME}_${comp}_LIBRARY COMP_LIBRARY)
|
||||
set (${COMP_LIBRARY} ${${COMP_LIBRARY}} @ZLIB_LIB_CORENAME@-${comp})
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
check_required_components (${ZLIB_PACKAGE_NAME})
|
||||
@@ -1,1388 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.5.1...3.29.0)
|
||||
project(ZLIB LANGUAGES C)
|
||||
message(STATUS "Using CMake version ${CMAKE_VERSION}")
|
||||
|
||||
if(POLICY CMP0169)
|
||||
cmake_policy(SET CMP0169 OLD) # CMake 3.30: call FetchContent_Populate() with just the name of a dependency
|
||||
endif()
|
||||
|
||||
# If not specified on the command line, enable C11 as the default
|
||||
# Configuration items that affect the global compiler environment standards
|
||||
# should be issued before the "project" command.
|
||||
if(NOT DEFINED CMAKE_C_STANDARD)
|
||||
set(CMAKE_C_STANDARD 11) # The C standard whose features are requested to build this target
|
||||
endif()
|
||||
if(NOT DEFINED CMAKE_C_STANDARD_REQUIRED)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON) # Boolean describing whether the value of C_STANDARD is a requirement
|
||||
endif()
|
||||
if(NOT DEFINED CMAKE_C_EXTENSIONS)
|
||||
set(CMAKE_C_EXTENSIONS OFF) # Boolean specifying whether compiler specific extensions are requested
|
||||
endif()
|
||||
set(VALID_C_STANDARDS "99" "11")
|
||||
if(NOT CMAKE_C_STANDARD IN_LIST VALID_C_STANDARDS)
|
||||
MESSAGE(FATAL_ERROR "CMAKE_C_STANDARD:STRING=${CMAKE_C_STANDARD} not in known standards list\n ${VALID_C_STANDARDS}")
|
||||
endif()
|
||||
|
||||
# Parse the full version number from zlib.h.in and include in ZLIB_FULL_VERSION
|
||||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h.in _zlib_h_contents)
|
||||
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([0-9]+.[0-9]+.[0-9]+).*\".*"
|
||||
"\\1" ZLIB_HEADER_VERSION ${_zlib_h_contents})
|
||||
string(REGEX REPLACE ".*#define[ \t]+ZLIBNG_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
|
||||
"\\1" ZLIBNG_HEADER_VERSION ${_zlib_h_contents})
|
||||
message(STATUS "ZLIB_HEADER_VERSION: ${ZLIB_HEADER_VERSION}")
|
||||
message(STATUS "ZLIBNG_HEADER_VERSION: ${ZLIBNG_HEADER_VERSION}")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Basic ZLIB stuff here
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_PACKAGE_EXT ${HDF_PACKAGE_EXT})
|
||||
set (HDF_USE_GNU_DIRS ${HDF5_USE_GNU_DIRS})
|
||||
set (CMAKE_OSX_ARCHITECTURES ${CMAKE_OSX_ARCHITECTURES})
|
||||
set (CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE})
|
||||
set (PACKAGE_NAMESPACE ${HDF_PACKAGE_NAMESPACE})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Define some CMake variables for use later in the project
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_RESOURCES_DIR ${HDF_RESOURCES_DIR}/ZLIB)
|
||||
set (ZLIB_SRC_DIR ${ZLIB_SOURCE_DIR})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Set the core names of all the libraries
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_LIB_CORENAME "zlib-static")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Set the target names of all the libraries
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_LIB_TARGET "zlib-static")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_PACKAGE "zlib")
|
||||
set (ZLIB_PACKAGE_NAME "ZLIB")
|
||||
|
||||
set (CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
HDF_DIR_PATHS(${ZLIB_PACKAGE_NAME})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Targets built within this project are exported at Install time for use
|
||||
# by other projects
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT ZLIB_EXPORTED_TARGETS)
|
||||
set (ZLIB_EXPORTED_TARGETS "zlib-targets")
|
||||
endif ()
|
||||
|
||||
set_global_variable (ZLIB_LIBRARIES_TO_EXPORT "")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# All libs/tests/examples need the main include directories
|
||||
#-----------------------------------------------------------------------------
|
||||
set_directory_properties(PROPERTIES INCLUDE_DIRECTORIES
|
||||
"${ZLIB_BINARY_DIR};${ZLIB_SOURCE_DIR};${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
|
||||
)
|
||||
|
||||
include(CheckTypeSize)
|
||||
include(CheckSymbolExists)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckIncludeFile)
|
||||
include(CheckCSourceCompiles)
|
||||
include(CheckCSourceRuns)
|
||||
include(CheckCCompilerFlag)
|
||||
include(CMakeDependentOption)
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(FeatureSummary)
|
||||
|
||||
include(cmake/detect-arch.cmake)
|
||||
include(cmake/detect-install-dirs.cmake)
|
||||
include(cmake/detect-coverage.cmake)
|
||||
include(cmake/detect-intrinsics.cmake)
|
||||
include(cmake/detect-sanitizer.cmake)
|
||||
include(cmake/fallback-macros.cmake)
|
||||
|
||||
if(CMAKE_TOOLCHAIN_FILE)
|
||||
message(STATUS "Using CMake toolchain: ${CMAKE_TOOLCHAIN_FILE}")
|
||||
endif()
|
||||
|
||||
# Make sure we use an appropriate BUILD_TYPE by default, "Release" to be exact
|
||||
# this should select the maximum generic optimisation on the current platform (i.e. -O3 for gcc/clang)
|
||||
get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
if(NOT GENERATOR_IS_MULTI_CONFIG)
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
|
||||
"Choose the type of build, standard options are: Debug Release RelWithDebInfo MinSizeRel."
|
||||
FORCE)
|
||||
add_feature_info(CMAKE_BUILD_TYPE 1 "Build type: ${CMAKE_BUILD_TYPE} (default)")
|
||||
else()
|
||||
add_feature_info(CMAKE_BUILD_TYPE 1 "Build type: ${CMAKE_BUILD_TYPE} (selected)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#
|
||||
# Options parsing
|
||||
#
|
||||
option(WITH_GZFILEOP "Compile with support for gzFile related functions" ON)
|
||||
option(ZLIB_COMPAT "Compile with zlib compatible API" OFF)
|
||||
option(ZLIB_ENABLE_TESTS "Build test binaries" OFF)
|
||||
option(ZLIBNG_ENABLE_TESTS "Test zlib-ng specific API" OFF)
|
||||
option(WITH_GTEST "Build gtest_zlib" OFF)
|
||||
option(WITH_FUZZERS "Build test/fuzz" OFF)
|
||||
option(WITH_BENCHMARKS "Build test/benchmarks" OFF)
|
||||
option(WITH_BENCHMARK_APPS "Build application benchmarks" OFF)
|
||||
option(WITH_OPTIM "Build with optimisation" ON)
|
||||
option(WITH_REDUCED_MEM "Reduced memory usage for special cases (reduces performance)" OFF)
|
||||
option(WITH_NEW_STRATEGIES "Use new strategies" ON)
|
||||
option(WITH_NATIVE_INSTRUCTIONS
|
||||
"Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native)" OFF)
|
||||
option(WITH_RUNTIME_CPU_DETECTION "Build with runtime detection of CPU architecture" ON)
|
||||
option(WITH_MAINTAINER_WARNINGS "Build with project maintainer warnings" OFF)
|
||||
option(WITH_CODE_COVERAGE "Enable code coverage reporting" OFF)
|
||||
option(WITH_INFLATE_STRICT "Build with strict inflate distance checking" OFF)
|
||||
option(WITH_INFLATE_ALLOW_INVALID_DIST "Build with zero fill for inflate invalid distances" OFF)
|
||||
|
||||
set(ZLIB_SYMBOL_PREFIX "" CACHE STRING "Give this prefix to all publicly exported symbols.
|
||||
Useful when embedding into a larger library.
|
||||
Default is no prefix (empty prefix).")
|
||||
|
||||
if(BASEARCH_ARM_FOUND)
|
||||
option(WITH_ACLE "Build with ACLE" ON)
|
||||
option(WITH_NEON "Build with NEON intrinsics" ON)
|
||||
cmake_dependent_option(WITH_ARMV6 "Build with ARMv6 SIMD" ON "NOT ARCH MATCHES \"aarch64\"" OFF)
|
||||
elseif(BASEARCH_PPC_FOUND)
|
||||
option(WITH_ALTIVEC "Build with AltiVec (VMX) optimisations for PowerPC" ON)
|
||||
option(WITH_POWER8 "Build with optimisations for POWER8" ON)
|
||||
option(WITH_POWER9 "Build with optimisations for POWER9" ON)
|
||||
elseif(BASEARCH_RISCV_FOUND)
|
||||
option(WITH_RVV "Build with RVV intrinsics" ON)
|
||||
elseif(BASEARCH_S360_FOUND)
|
||||
option(WITH_DFLTCC_DEFLATE "Build with DFLTCC intrinsics for compression on IBM Z" OFF)
|
||||
option(WITH_DFLTCC_INFLATE "Build with DFLTCC intrinsics for decompression on IBM Z" OFF)
|
||||
option(WITH_CRC32_VX "Build with vectorized CRC32 on IBM Z" ON)
|
||||
elseif(BASEARCH_X86_FOUND)
|
||||
option(WITH_SSE2 "Build with SSE2" ON)
|
||||
cmake_dependent_option(WITH_SSSE3 "Build with SSSE3" ON "WITH_SSE2" OFF)
|
||||
cmake_dependent_option(WITH_SSE42 "Build with SSE42" ON "WITH_SSSE3" OFF)
|
||||
cmake_dependent_option(WITH_PCLMULQDQ "Build with PCLMULQDQ" ON "WITH_SSE42" OFF)
|
||||
cmake_dependent_option(WITH_AVX2 "Build with AVX2" ON "WITH_SSE42" OFF)
|
||||
cmake_dependent_option(WITH_AVX512 "Build with AVX512" ON "WITH_AVX2" OFF)
|
||||
cmake_dependent_option(WITH_AVX512VNNI "Build with AVX512 VNNI extensions" ON "WITH_AVX512" OFF)
|
||||
cmake_dependent_option(WITH_VPCLMULQDQ "Build with VPCLMULQDQ" ON "WITH_PCLMULQDQ;WITH_AVX512" OFF)
|
||||
endif()
|
||||
|
||||
option(INSTALL_UTILS "Copy minigzip and minideflate during install" OFF)
|
||||
|
||||
mark_as_advanced(FORCE
|
||||
ZLIB_SYMBOL_PREFIX
|
||||
WITH_REDUCED_MEM
|
||||
WITH_ACLE WITH_NEON
|
||||
WITH_ARMV6
|
||||
WITH_DFLTCC_DEFLATE
|
||||
WITH_DFLTCC_INFLATE
|
||||
WITH_CRC32_VX
|
||||
WITH_AVX2 WITH_SSE2
|
||||
WITH_SSSE3 WITH_SSE42
|
||||
WITH_PCLMULQDQ
|
||||
WITH_ALTIVEC
|
||||
WITH_POWER8
|
||||
WITH_POWER9
|
||||
WITH_RVV
|
||||
WITH_INFLATE_STRICT
|
||||
WITH_INFLATE_ALLOW_INVALID_DIST
|
||||
INSTALL_UTILS
|
||||
)
|
||||
|
||||
if(ZLIB_COMPAT)
|
||||
add_definitions(-DZLIB_COMPAT)
|
||||
set(WITH_GZFILEOP ON)
|
||||
set(SUFFIX "")
|
||||
set(ZLIB_FULL_VERSION ${ZLIB_HEADER_VERSION}.zlib-ng)
|
||||
set(EXPORT_NAME ZLIB)
|
||||
else()
|
||||
set(SUFFIX "-ng")
|
||||
set(ZLIB_FULL_VERSION ${ZLIBNG_HEADER_VERSION})
|
||||
set(EXPORT_NAME zlib-ng)
|
||||
endif()
|
||||
|
||||
if(WITH_GZFILEOP)
|
||||
add_definitions(-DWITH_GZFILEOP)
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "^Intel")
|
||||
if(CMAKE_HOST_UNIX)
|
||||
set(WARNFLAGS -Wall)
|
||||
set(WARNFLAGS_MAINTAINER -Wall -Wcheck -Wremarks)
|
||||
set(WARNFLAGS_DISABLE)
|
||||
else()
|
||||
set(WARNFLAGS /Wall)
|
||||
set(WARNFLAGS_MAINTAINER /W5)
|
||||
set(WARNFLAGS_DISABLE)
|
||||
endif()
|
||||
check_c_compiler_flag(-diag-disable=10441 HAVE_DIAG_10441)
|
||||
if(HAVE_DIAG_10441)
|
||||
list(APPEND WARNFLAGS_DISABLE "-diag-disable=10441")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -diag-disable=10441")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -diag-disable=10441")
|
||||
endif()
|
||||
elseif(MSVC)
|
||||
# Minimum supported MSVC version is 1800 = Visual Studio 12.0/2013
|
||||
# See also https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
|
||||
if(MSVC_VERSION VERSION_LESS 1800)
|
||||
message(SEND_ERROR "Unsupported Visual Studio compiler version (requires 2013 or later).")
|
||||
endif()
|
||||
# TODO. ICC can be used through MSVC. I'm not sure if we'd ever see that combination
|
||||
# (who'd use cmake from an IDE...) but checking for ICC before checking for MSVC should
|
||||
# avoid mistakes.
|
||||
# /Oi ?
|
||||
set(WARNFLAGS /W3 /w34242 /WX)
|
||||
set(WARNFLAGS_MAINTAINER /W4)
|
||||
set(WARNFLAGS_DISABLE /wd4206 /wd4054 /wd4324)
|
||||
if(BASEARCH_ARM_FOUND)
|
||||
add_definitions(-D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE)
|
||||
if(NOT "${ARCH}" MATCHES "aarch64")
|
||||
set(NEONFLAG "/arch:VFPv4")
|
||||
endif()
|
||||
endif()
|
||||
elseif(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
# Enable warnings in GCC and Clang
|
||||
set(WARNFLAGS -Wall)
|
||||
set(WARNFLAGS_MAINTAINER -Wextra)
|
||||
set(WARNFLAGS_DISABLE)
|
||||
# Check whether -fno-lto is available
|
||||
set(CMAKE_REQUIRED_FLAGS "-fno-lto")
|
||||
check_c_source_compiles(
|
||||
"int main() { return 0; }"
|
||||
FNO_LTO_AVAILABLE FAIL_REGEX "not supported")
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
if(FNO_LTO_AVAILABLE)
|
||||
set(ZNOLTOFLAG "-fno-lto")
|
||||
endif()
|
||||
if(NOT WITH_NATIVE_INSTRUCTIONS)
|
||||
if(BASEARCH_ARM_FOUND)
|
||||
if("${ARCH}" MATCHES "arm" AND NOT CMAKE_C_FLAGS MATCHES "-mfloat-abi")
|
||||
# Auto-detect support for ARM floating point ABI
|
||||
check_include_file(features.h HAVE_FEATURES_H)
|
||||
if(HAVE_FEATURES_H)
|
||||
set(CMAKE_REQUIRED_FLAGS -mfloat-abi=softfp)
|
||||
check_c_source_compiles(
|
||||
"#include <features.h>
|
||||
int main() { return 0; }"
|
||||
HAVE_FLOATABI_SOFTFP)
|
||||
if(HAVE_FLOATABI_SOFTFP)
|
||||
set(FLOATABI -mfloat-abi=softfp)
|
||||
else()
|
||||
set(CMAKE_REQUIRED_FLAGS -mfloat-abi=hard)
|
||||
check_c_source_compiles(
|
||||
"#include <features.h>
|
||||
int main() { return 0; }"
|
||||
HAVE_FLOATABI_HARD)
|
||||
if(HAVE_FLOATABI_HARD)
|
||||
set(FLOATABI -mfloat-abi=hard)
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
endif()
|
||||
if(FLOATABI)
|
||||
message(STATUS "ARM floating point arch: ${FLOATABI}")
|
||||
add_compile_options(${FLOATABI})
|
||||
else()
|
||||
message(STATUS "ARM floating point arch not auto-detected")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
# Disable LTO unless Native Instructions are enabled
|
||||
if(FNO_LTO_AVAILABLE)
|
||||
set(NOLTOFLAG ${ZNOLTOFLAG})
|
||||
endif()
|
||||
endif()
|
||||
if(MINGW)
|
||||
# Add `-Wno-pedantic-ms-format` only if the toolchain supports it
|
||||
check_c_compiler_flag(-Wno-pedantic-ms-format HAVE_NO_PEDANTIC_MS_FORMAT)
|
||||
if(HAVE_NO_PEDANTIC_MS_FORMAT)
|
||||
list(APPEND WARNFLAGS_DISABLE -Wno-pedantic-ms-format)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Set native march/mcpu
|
||||
if(WITH_NATIVE_INSTRUCTIONS)
|
||||
if(NATIVE_ARCH_OVERRIDE)
|
||||
message(STATUS "WARNING: WITH_NATIVE_INSTRUCTIONS enabled, but running with NATIVE_ARCH_OVERRIDE: ${NATIVE_ARCH_OVERRIDE}")
|
||||
set(NATIVEFLAG "${NATIVE_ARCH_OVERRIDE}")
|
||||
else()
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
check_c_compiler_flag(-march=native HAVE_MARCH_NATIVE)
|
||||
if(HAVE_MARCH_NATIVE)
|
||||
set(NATIVEFLAG "-march=native")
|
||||
else()
|
||||
check_c_compiler_flag(-mcpu=native HAVE_MCPU_NATIVE)
|
||||
if(HAVE_MCPU_NATIVE)
|
||||
set(NATIVEFLAG "-mcpu=native")
|
||||
endif()
|
||||
endif()
|
||||
# Fall through
|
||||
endif()
|
||||
endif()
|
||||
if(NATIVEFLAG)
|
||||
# Apply flags to all source files and compilation checks
|
||||
if(WIN32)
|
||||
separate_arguments(NATIVEOPTIONS WINDOWS_COMMAND "${NATIVEFLAG}")
|
||||
else()
|
||||
separate_arguments(NATIVEOPTIONS UNIX_COMMAND "${NATIVEFLAG}")
|
||||
endif()
|
||||
add_compile_options(${NATIVEOPTIONS})
|
||||
set(WITH_RUNTIME_CPU_DETECTION OFF)
|
||||
else()
|
||||
message(STATUS "Ignoring WITH_NATIVE_INSTRUCTIONS; not implemented yet on this configuration")
|
||||
set(WITH_NATIVE_INSTRUCTIONS OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Compile without functable or CPU detection
|
||||
if(NOT WITH_RUNTIME_CPU_DETECTION)
|
||||
if(MSVC AND BASEARCH_X86_FOUND)
|
||||
message(STATUS "WARNING: Microsoft Visual Studio does not support compile time detection of CPU features for \"/arch\" before \"AVX\"")
|
||||
# Workaround for MSVC. By default MSVC does not define the __SSE*__ macros.
|
||||
# Fix it if AVX is enabled.
|
||||
set(CMAKE_REQUIRED_FLAGS "${NATIVEFLAG} ${ZNOLTOFLAG}")
|
||||
check_c_source_compiles(
|
||||
"#ifndef __AVX__
|
||||
# error \"AVX is not enabled.\"
|
||||
#endif
|
||||
int main(void) { return 0; }"
|
||||
MSVC_IS_ENABLED_AVX
|
||||
)
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
if(MSVC_IS_ENABLED_AVX)
|
||||
add_definitions(
|
||||
-D__SSE__=1
|
||||
-D__SSE2__=1
|
||||
-D__SSE3__=1
|
||||
-D__SSSE3__=1
|
||||
-D__SSE4_1__=1
|
||||
-D__SSE4_2__=1
|
||||
-D__PCLMUL__=1
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
add_definitions(-DDISABLE_RUNTIME_CPU_DETECTION)
|
||||
endif()
|
||||
|
||||
# Force disable LTO if WITH_NATIVE_INSTRUCTIONS is not active
|
||||
if(NOT WITH_NATIVE_INSTRUCTIONS)
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)
|
||||
foreach(_cfg_name IN LISTS CMAKE_CONFIGURATION_TYPES)
|
||||
string(TOUPPER "${_cfg_name}" _cfg_name_uc)
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_${_cfg_name_uc} OFF)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Apply warning compiler flags
|
||||
if(WITH_MAINTAINER_WARNINGS)
|
||||
add_compile_options(${WARNFLAGS} ${WARNFLAGS_MAINTAINER} ${WARNFLAGS_DISABLE})
|
||||
else()
|
||||
add_compile_options(${WARNFLAGS} ${WARNFLAGS_DISABLE})
|
||||
endif()
|
||||
|
||||
# Replace optimization level 3 added by default with level 2
|
||||
if(NOT WITH_CODE_COVERAGE AND NOT MSVC AND NOT CMAKE_C_FLAGS MATCHES "([\\/\\-]O)3")
|
||||
string(REGEX REPLACE "([\\/\\-]O)3" "\\12"
|
||||
CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
|
||||
endif()
|
||||
|
||||
# Force Visual C++ to use UTF-8
|
||||
if(MSVC)
|
||||
if (NOT CMAKE_C_FLAGS MATCHES "[\\/\\-]utf-8")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /utf-8")
|
||||
endif()
|
||||
if (NOT CMAKE_CXX_FLAGS MATCHES "[\\/\\-]utf-8")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#
|
||||
# Check for standard/system includes
|
||||
#
|
||||
check_include_file(arm_acle.h HAVE_ARM_ACLE_H)
|
||||
if(HAVE_ARM_ACLE_H)
|
||||
add_definitions(-DHAVE_ARM_ACLE_H)
|
||||
endif()
|
||||
check_include_file(sys/auxv.h HAVE_SYS_AUXV_H)
|
||||
if(HAVE_SYS_AUXV_H)
|
||||
add_definitions(-DHAVE_SYS_AUXV_H)
|
||||
endif()
|
||||
check_include_file(sys/sdt.h HAVE_SYS_SDT_H)
|
||||
if(HAVE_SYS_SDT_H)
|
||||
add_definitions(-DHAVE_SYS_SDT_H)
|
||||
endif()
|
||||
check_include_file(unistd.h HAVE_UNISTD_H)
|
||||
|
||||
#
|
||||
# Check for Linux includes
|
||||
#
|
||||
check_include_file(linux/auxvec.h HAVE_LINUX_AUXVEC_H)
|
||||
if(HAVE_LINUX_AUXVEC_H)
|
||||
add_definitions(-DHAVE_LINUX_AUXVEC_H)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Check to see if we have large file support
|
||||
#
|
||||
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1 -D__USE_LARGEFILE64)
|
||||
check_type_size(off64_t OFF64_T)
|
||||
if(HAVE_OFF64_T)
|
||||
add_definitions(-D_LARGEFILE64_SOURCE=1 -D__USE_LARGEFILE64)
|
||||
else()
|
||||
check_type_size(_off64_t _OFF64_T)
|
||||
if(HAVE__OFF64_T)
|
||||
add_definitions(-D_LARGEFILE64_SOURCE=1 -D__USE_LARGEFILE64)
|
||||
else()
|
||||
check_type_size(__off64_t __OFF64_T)
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
|
||||
|
||||
#
|
||||
# Check for fseeko and other optional functions
|
||||
#
|
||||
check_function_exists(fseeko HAVE_FSEEKO)
|
||||
if(NOT HAVE_FSEEKO)
|
||||
add_definitions(-DNO_FSEEKO)
|
||||
endif()
|
||||
|
||||
check_function_exists(strerror HAVE_STRERROR)
|
||||
if(NOT HAVE_STRERROR)
|
||||
add_definitions(-DNO_STRERROR)
|
||||
endif()
|
||||
|
||||
set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200112L)
|
||||
check_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
|
||||
if(HAVE_POSIX_MEMALIGN)
|
||||
add_definitions(-DHAVE_POSIX_MEMALIGN)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_DEFINITIONS)
|
||||
|
||||
set(CMAKE_REQUIRED_DEFINITIONS -D_ISOC11_SOURCE=1)
|
||||
check_symbol_exists(aligned_alloc stdlib.h HAVE_ALIGNED_ALLOC)
|
||||
if(HAVE_ALIGNED_ALLOC)
|
||||
add_definitions(-DHAVE_ALIGNED_ALLOC)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_DEFINITIONS)
|
||||
|
||||
#
|
||||
# Check whether compiler supports -fno-semantic-interposition parameter
|
||||
#
|
||||
check_c_compiler_flag(-fno-semantic-interposition HAVE_NO_INTERPOSITION)
|
||||
|
||||
#
|
||||
# Check if we can hide zlib internal symbols that are linked between separate source files using hidden
|
||||
#
|
||||
check_c_source_compiles(
|
||||
"#define Z_INTERNAL __attribute__((visibility (\"hidden\")))
|
||||
int Z_INTERNAL foo;
|
||||
int main() {
|
||||
return 0;
|
||||
}"
|
||||
HAVE_ATTRIBUTE_VISIBILITY_HIDDEN FAIL_REGEX "visibility")
|
||||
if(HAVE_ATTRIBUTE_VISIBILITY_HIDDEN)
|
||||
add_definitions(-DHAVE_VISIBILITY_HIDDEN)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Check if we can hide zlib internal symbols that are linked between separate source files using internal
|
||||
#
|
||||
check_c_source_compiles(
|
||||
"#define Z_INTERNAL __attribute__((visibility (\"internal\")))
|
||||
int Z_INTERNAL foo;
|
||||
int main() {
|
||||
return 0;
|
||||
}"
|
||||
HAVE_ATTRIBUTE_VISIBILITY_INTERNAL FAIL_REGEX "visibility")
|
||||
if(HAVE_ATTRIBUTE_VISIBILITY_INTERNAL)
|
||||
add_definitions(-DHAVE_VISIBILITY_INTERNAL)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Check for __attribute__((aligned(x))) support in the compiler
|
||||
#
|
||||
check_c_source_compiles(
|
||||
"int main(void) {
|
||||
__attribute__((aligned(8))) int test = 0;
|
||||
(void)test;
|
||||
return 0;
|
||||
}"
|
||||
HAVE_ATTRIBUTE_ALIGNED FAIL_REGEX "aligned")
|
||||
if(HAVE_ATTRIBUTE_ALIGNED)
|
||||
add_definitions(-DHAVE_ATTRIBUTE_ALIGNED)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Check for __builtin_assume_aligned(x,n) support in the compiler
|
||||
#
|
||||
set(CMAKE_REQUIRED_FLAGS ${ZNOLTOFLAG})
|
||||
check_c_source_compiles(
|
||||
"char *test(char *buffer) {
|
||||
char *abuffer = __builtin_assume_aligned(buffer,64);
|
||||
return abuffer;
|
||||
}
|
||||
int main() {
|
||||
return 0;
|
||||
}"
|
||||
HAVE_BUILTIN_ASSUME_ALIGNED)
|
||||
if(HAVE_BUILTIN_ASSUME_ALIGNED)
|
||||
add_definitions(-DHAVE_BUILTIN_ASSUME_ALIGNED)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
|
||||
#
|
||||
# check for __builtin_ctz() support in the compiler
|
||||
#
|
||||
set(CMAKE_REQUIRED_FLAGS ${ZNOLTOFLAG})
|
||||
check_c_source_compiles(
|
||||
"int main(void) {
|
||||
unsigned int zero = 0;
|
||||
long test = __builtin_ctz(zero);
|
||||
(void)test;
|
||||
return 0;
|
||||
}"
|
||||
HAVE_BUILTIN_CTZ
|
||||
)
|
||||
if(HAVE_BUILTIN_CTZ)
|
||||
add_definitions(-DHAVE_BUILTIN_CTZ)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
|
||||
#
|
||||
# check for __builtin_ctzll() support in the compiler
|
||||
#
|
||||
set(CMAKE_REQUIRED_FLAGS ${ZNOLTOFLAG})
|
||||
check_c_source_compiles(
|
||||
"int main(void) {
|
||||
unsigned int zero = 0;
|
||||
long test = __builtin_ctzll(zero);
|
||||
(void)test;
|
||||
return 0;
|
||||
}"
|
||||
HAVE_BUILTIN_CTZLL
|
||||
)
|
||||
if(HAVE_BUILTIN_CTZLL)
|
||||
add_definitions(-DHAVE_BUILTIN_CTZLL)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
|
||||
#
|
||||
# check for ptrdiff_t support
|
||||
#
|
||||
check_c_source_compiles(
|
||||
"#include <stddef.h>
|
||||
int main() {
|
||||
ptrdiff_t *a;
|
||||
(void)a;
|
||||
return 0;
|
||||
}"
|
||||
HAVE_PTRDIFF_T
|
||||
)
|
||||
if(NOT HAVE_PTRDIFF_T)
|
||||
set(NEED_PTRDIFF_T 1)
|
||||
|
||||
check_type_size("void *" SIZEOF_DATA_PTR)
|
||||
message(STATUS "sizeof(void *) is ${SIZEOF_DATA_PTR} bytes")
|
||||
|
||||
if(${SIZEOF_DATA_PTR} MATCHES "4")
|
||||
set(PTRDIFF_TYPE "uint32_t")
|
||||
elseif(${SIZEOF_DATA_PTR} MATCHES "8")
|
||||
set(PTRDIFF_TYPE "uint64_t")
|
||||
else()
|
||||
message(FATAL_ERROR "sizeof(void *) is neither 32 nor 64 bit")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_compile_options($<$<CONFIG:Debug>:-DZLIB_DEBUG>)
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
endif()
|
||||
|
||||
if(BASEARCH_X86_FOUND)
|
||||
# FORCE_SSE2 option will only be shown if HAVE_SSE2_INTRIN is true
|
||||
if("${ARCH}" MATCHES "i[3-6]86")
|
||||
cmake_dependent_option(FORCE_SSE2 "Always assume CPU is SSE2 capable" OFF "HAVE_SSE2_INTRIN" OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#
|
||||
# Enable deflate_quick at level 1
|
||||
#
|
||||
if(NOT WITH_NEW_STRATEGIES)
|
||||
add_definitions(-DNO_QUICK_STRATEGY)
|
||||
endif()
|
||||
#
|
||||
# Enable deflate_medium at level 4-6
|
||||
#
|
||||
if(NOT WITH_NEW_STRATEGIES)
|
||||
add_definitions(-DNO_MEDIUM_STRATEGY)
|
||||
endif()
|
||||
#
|
||||
# Enable inflate compilation options
|
||||
#
|
||||
if(WITH_INFLATE_STRICT)
|
||||
add_definitions(-DINFLATE_STRICT)
|
||||
message(STATUS "Inflate strict distance checking enabled")
|
||||
endif()
|
||||
if(WITH_INFLATE_ALLOW_INVALID_DIST)
|
||||
add_definitions(-DINFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR)
|
||||
message(STATUS "Inflate zero data for invalid distances enabled")
|
||||
endif()
|
||||
#
|
||||
# Enable reduced memory configuration
|
||||
#
|
||||
if(WITH_REDUCED_MEM)
|
||||
add_definitions(-DHASH_SIZE=32768u -DGZBUFSIZE=8192 -DNO_LIT_MEM)
|
||||
message(STATUS "Configured for reduced memory environment")
|
||||
endif()
|
||||
|
||||
set(GENERIC_ARCHDIR "arch/generic")
|
||||
|
||||
set(ZLIB_ARCH_SRCS)
|
||||
set(ZLIB_ARCH_HDRS ${GENERIC_ARCHDIR}/generic_functions.h)
|
||||
|
||||
if(BASEARCH_ARM_FOUND)
|
||||
set(ARCHDIR "arch/arm")
|
||||
elseif(BASEARCH_PPC_FOUND)
|
||||
set(ARCHDIR "arch/power")
|
||||
elseif(BASEARCH_RISCV_FOUND)
|
||||
set(ARCHDIR "arch/riscv")
|
||||
elseif(BASEARCH_S360_FOUND)
|
||||
set(ARCHDIR "arch/s390")
|
||||
elseif(BASEARCH_X86_FOUND)
|
||||
set(ARCHDIR "arch/x86")
|
||||
if(NOT ${ARCH} MATCHES "x86_64")
|
||||
add_feature_info(SSE2 1 "Support the SSE2 instruction set, using \"${SSE2FLAG}\"")
|
||||
endif()
|
||||
else()
|
||||
set(ARCHDIR ${GENERIC_ARCHDIR})
|
||||
message(STATUS "No optimized architecture: using ${ARCHDIR}")
|
||||
endif()
|
||||
|
||||
if(WITH_OPTIM)
|
||||
if(BASEARCH_ARM_FOUND)
|
||||
add_definitions(-DARM_FEATURES)
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
if("${ARCH}" MATCHES "aarch64")
|
||||
check_c_source_compiles(
|
||||
"#include <sys/auxv.h>
|
||||
int main() {
|
||||
return (getauxval(AT_HWCAP) & HWCAP_CRC32);
|
||||
}"
|
||||
ARM_AUXV_HAS_CRC32
|
||||
)
|
||||
if(ARM_AUXV_HAS_CRC32)
|
||||
add_definitions(-DARM_AUXV_HAS_CRC32)
|
||||
else()
|
||||
message(STATUS "HWCAP_CRC32 not present in sys/auxv.h; cannot detect support at runtime.")
|
||||
endif()
|
||||
else()
|
||||
check_c_source_compiles(
|
||||
"#include <sys/auxv.h>
|
||||
int main() {
|
||||
return (getauxval(AT_HWCAP2) & HWCAP2_CRC32);
|
||||
}"
|
||||
ARM_AUXV_HAS_CRC32
|
||||
)
|
||||
if(ARM_AUXV_HAS_CRC32)
|
||||
add_definitions(-DARM_AUXV_HAS_CRC32)
|
||||
else()
|
||||
check_c_source_compiles(
|
||||
"#include <sys/auxv.h>
|
||||
#include <asm/hwcap.h>
|
||||
int main() {
|
||||
return (getauxval(AT_HWCAP2) & HWCAP2_CRC32);
|
||||
}"
|
||||
ARM_HWCAP_HAS_CRC32
|
||||
)
|
||||
if (ARM_HWCAP_HAS_CRC32)
|
||||
add_definitions(-DARM_AUXV_HAS_CRC32 -DARM_ASM_HWCAP)
|
||||
else()
|
||||
message(STATUS "HWCAP2_CRC32 not present in sys/auxv.h; cannot detect support at runtime.")
|
||||
endif()
|
||||
endif()
|
||||
check_c_source_compiles(
|
||||
"#include <sys/auxv.h>
|
||||
int main() {
|
||||
return (getauxval(AT_HWCAP) & HWCAP_ARM_NEON);
|
||||
}"
|
||||
ARM_AUXV_HAS_NEON
|
||||
)
|
||||
if(ARM_AUXV_HAS_NEON)
|
||||
add_definitions(-DARM_AUXV_HAS_NEON)
|
||||
else()
|
||||
check_c_source_compiles(
|
||||
"#include <sys/auxv.h>
|
||||
int main() {
|
||||
return (getauxval(AT_HWCAP) & HWCAP_NEON);
|
||||
}"
|
||||
ARM_AUXV_HAS_NEON
|
||||
)
|
||||
if (ARM_AUXV_HAS_NEON)
|
||||
add_definitions(-DARM_AUXV_HAS_NEON)
|
||||
else()
|
||||
message(STATUS "Neither HWCAP_ARM_NEON or HWCAP_NEON present in sys/auxv.h; cannot detect support at runtime.")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/arm_functions.h)
|
||||
if(WITH_RUNTIME_CPU_DETECTION)
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/arm_features.h)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/arm_features.c)
|
||||
endif()
|
||||
|
||||
if(WITH_ACLE)
|
||||
check_acle_compiler_flag()
|
||||
if(HAVE_ACLE_FLAG)
|
||||
add_definitions(-DARM_ACLE)
|
||||
set(ACLE_SRCS ${ARCHDIR}/crc32_acle.c)
|
||||
set_property(SOURCE ${ACLE_SRCS} PROPERTY COMPILE_FLAGS "${ACLEFLAG} ${NOLTOFLAG}")
|
||||
list(APPEND ZLIB_ARCH_SRCS ${ACLE_SRCS})
|
||||
add_feature_info(ACLE_CRC 1 "Support ACLE optimized CRC hash generation, using \"${ACLEFLAG}\"")
|
||||
else()
|
||||
set(WITH_ACLE OFF)
|
||||
endif()
|
||||
else()
|
||||
set(WITH_ACLE OFF)
|
||||
endif()
|
||||
if(WITH_NEON)
|
||||
check_neon_compiler_flag()
|
||||
if(NEON_AVAILABLE)
|
||||
add_definitions(-DARM_NEON)
|
||||
set(NEON_SRCS ${ARCHDIR}/adler32_neon.c ${ARCHDIR}/chunkset_neon.c
|
||||
${ARCHDIR}/compare256_neon.c ${ARCHDIR}/slide_hash_neon.c)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${NEON_SRCS})
|
||||
set_property(SOURCE ${NEON_SRCS} PROPERTY COMPILE_FLAGS "${NEONFLAG} ${NOLTOFLAG}")
|
||||
if(MSVC)
|
||||
add_definitions(-D__ARM_NEON__)
|
||||
endif()
|
||||
add_feature_info(NEON_ADLER32 1 "Support NEON instructions in adler32, using \"${NEONFLAG}\"")
|
||||
add_feature_info(NEON_SLIDEHASH 1 "Support NEON instructions in slide_hash, using \"${NEONFLAG}\"")
|
||||
check_neon_ld4_intrinsics()
|
||||
if(NEON_HAS_LD4)
|
||||
add_definitions(-DARM_NEON_HASLD4)
|
||||
endif()
|
||||
else()
|
||||
set(WITH_NEON OFF)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_ARMV6)
|
||||
check_armv6_compiler_flag()
|
||||
if(HAVE_ARMV6_INLINE_ASM OR HAVE_ARMV6_INTRIN)
|
||||
add_definitions(-DARM_SIMD)
|
||||
set(ARMV6_SRCS ${ARCHDIR}/slide_hash_armv6.c)
|
||||
set_property(SOURCE ${ARMV6_SRCS} PROPERTY COMPILE_FLAGS "${ARMV6FLAG} ${NOLTOFLAG}")
|
||||
list(APPEND ZLIB_ARCH_SRCS ${ARMV6_SRCS})
|
||||
add_feature_info(ARMV6 1 "Support ARMv6 SIMD instructions in slide_hash, using \"${ARMV6FLAG}\"")
|
||||
if(HAVE_ARMV6_INTRIN)
|
||||
add_definitions(-DARM_SIMD_INTRIN)
|
||||
endif()
|
||||
else()
|
||||
set(WITH_ARMV6 OFF)
|
||||
endif()
|
||||
else()
|
||||
set(WITH_ARMV6 OFF)
|
||||
endif()
|
||||
elseif(BASEARCH_PPC_FOUND)
|
||||
# Common arch detection code
|
||||
if(WITH_ALTIVEC)
|
||||
check_ppc_intrinsics()
|
||||
endif()
|
||||
if(WITH_POWER8)
|
||||
check_power8_intrinsics()
|
||||
endif()
|
||||
if(WITH_POWER9)
|
||||
check_power9_intrinsics()
|
||||
endif()
|
||||
if(POWER8_NEED_AUXVEC_H OR POWER9_NEED_AUXVEC_H)
|
||||
add_definitions(-DPOWER_NEED_AUXVEC_H)
|
||||
endif()
|
||||
if(HAVE_POWER8_INTRIN OR HAVE_POWER9_INTRIN)
|
||||
add_definitions(-DPOWER_FEATURES)
|
||||
endif()
|
||||
if(HAVE_VMX OR HAVE_POWER8_INTRIN OR HAVE_POWER9_INTRIN)
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/power_functions.h)
|
||||
if(WITH_RUNTIME_CPU_DETECTION)
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/power_features.h)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/power_features.c)
|
||||
endif()
|
||||
endif()
|
||||
# VMX specific options and files
|
||||
if(WITH_ALTIVEC)
|
||||
if(HAVE_VMX)
|
||||
add_definitions(-DPPC_FEATURES)
|
||||
if(HAVE_ALTIVEC)
|
||||
add_definitions(-DPPC_VMX)
|
||||
set(PPC_SRCS ${ARCHDIR}/adler32_vmx.c ${ARCHDIR}/slide_hash_vmx.c)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${PPC_SRCS})
|
||||
add_feature_info(ALTIVEC 1 "Support the AltiVec instruction set, using \"-maltivec\"")
|
||||
set_property(SOURCE ${PPC_SRCS} PROPERTY COMPILE_FLAGS "${PPCFLAGS}")
|
||||
else()
|
||||
set(WITH_ALTIVEC OFF)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
# Power8 specific options and files
|
||||
if(WITH_POWER8)
|
||||
if(HAVE_POWER8_INTRIN)
|
||||
add_definitions(-DPOWER8_VSX)
|
||||
set(POWER8_SRCS ${ARCHDIR}/adler32_power8.c ${ARCHDIR}/chunkset_power8.c ${ARCHDIR}/slide_hash_power8.c)
|
||||
if("${ARCH}" MATCHES "powerpc64(le)?")
|
||||
add_definitions(-DPOWER8_VSX_CRC32)
|
||||
list(APPEND POWER8_SRCS ${ARCHDIR}/crc32_power8.c)
|
||||
endif()
|
||||
list(APPEND ZLIB_ARCH_SRCS ${POWER8_SRCS})
|
||||
set_property(SOURCE ${POWER8_SRCS} PROPERTY COMPILE_FLAGS "${POWER8FLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_POWER8 OFF)
|
||||
endif()
|
||||
endif()
|
||||
# Power9 specific options and files
|
||||
if(WITH_POWER9)
|
||||
if(HAVE_POWER9_INTRIN)
|
||||
add_definitions(-DPOWER9)
|
||||
set(POWER9_SRCS ${ARCHDIR}/compare256_power9.c)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${POWER9_SRCS})
|
||||
set_property(SOURCE ${POWER9_SRCS} PROPERTY COMPILE_FLAGS "${POWER9FLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_POWER9 OFF)
|
||||
endif()
|
||||
endif()
|
||||
elseif(BASEARCH_RISCV_FOUND)
|
||||
if(WITH_RVV)
|
||||
check_rvv_intrinsics()
|
||||
if(HAVE_RVV_INTRIN)
|
||||
add_definitions(-DRISCV_FEATURES)
|
||||
add_definitions(-DRISCV_RVV)
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/riscv_functions.h)
|
||||
if(WITH_RUNTIME_CPU_DETECTION)
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/riscv_features.h)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/riscv_features.c)
|
||||
endif()
|
||||
# FIXME: we will not set compile flags for riscv_features.c when
|
||||
# the kernels update hwcap or hwprobe for riscv
|
||||
set(RVV_SRCS ${ARCHDIR}/adler32_rvv.c ${ARCHDIR}/chunkset_rvv.c ${ARCHDIR}/compare256_rvv.c ${ARCHDIR}/slide_hash_rvv.c)
|
||||
if(WITH_RUNTIME_CPU_DETECTION)
|
||||
list(APPEND RVV_SRCS ${ARCHDIR}/riscv_features.c)
|
||||
endif()
|
||||
list(APPEND ZLIB_ARCH_SRCS ${RVV_SRCS})
|
||||
set_property(SOURCE ${RVV_SRCS} PROPERTY COMPILE_FLAGS "${RISCVFLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_RVV OFF)
|
||||
endif()
|
||||
endif()
|
||||
elseif(BASEARCH_S360_FOUND)
|
||||
check_s390_intrinsics()
|
||||
if(HAVE_S390_INTRIN)
|
||||
add_definitions(-DS390_FEATURES)
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/s390_functions.h)
|
||||
if(WITH_RUNTIME_CPU_DETECTION)
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/s390_features.h)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/s390_features.c)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_DFLTCC_DEFLATE)
|
||||
add_definitions(-DS390_DFLTCC_DEFLATE)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/dfltcc_deflate.c)
|
||||
endif()
|
||||
if(WITH_DFLTCC_INFLATE)
|
||||
add_definitions(-DS390_DFLTCC_INFLATE)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/dfltcc_inflate.c)
|
||||
endif()
|
||||
if(WITH_CRC32_VX)
|
||||
check_vgfma_intrinsics()
|
||||
if(HAVE_VGFMA_INTRIN)
|
||||
add_definitions(-DS390_CRC32_VX)
|
||||
set(CRC32_VX_SRCS ${ARCHDIR}/crc32-vx.c)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${CRC32_VX_SRCS})
|
||||
set_property(SOURCE ${CRC32_VX_SRCS} PROPERTY COMPILE_FLAGS "${VGFMAFLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_CRC32_VX OFF)
|
||||
endif()
|
||||
endif()
|
||||
elseif(BASEARCH_X86_FOUND)
|
||||
add_definitions(-DX86_FEATURES)
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/x86_functions.h)
|
||||
if(WITH_RUNTIME_CPU_DETECTION)
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/x86_features.h)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/x86_features.c)
|
||||
endif()
|
||||
if(MSVC)
|
||||
list(APPEND ZLIB_ARCH_HDRS fallback_builtins.h)
|
||||
endif()
|
||||
check_xsave_intrinsics()
|
||||
if(HAVE_XSAVE_INTRIN)
|
||||
add_feature_info(XSAVE 1 "Support XSAVE intrinsics using \"${XSAVEFLAG}\"")
|
||||
if(WITH_RUNTIME_CPU_DETECTION)
|
||||
set_property(SOURCE ${ARCHDIR}/x86_features.c PROPERTY COMPILE_FLAGS "${XSAVEFLAG}")
|
||||
endif()
|
||||
if(NOT (CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 8.2))
|
||||
add_definitions(-DX86_HAVE_XSAVE_INTRIN)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_SSE2)
|
||||
check_sse2_intrinsics()
|
||||
if(HAVE_SSE2_INTRIN)
|
||||
add_definitions(-DX86_SSE2)
|
||||
set(SSE2_SRCS ${ARCHDIR}/chunkset_sse2.c ${ARCHDIR}/compare256_sse2.c ${ARCHDIR}/slide_hash_sse2.c)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${SSE2_SRCS})
|
||||
if(NOT ${ARCH} MATCHES "x86_64")
|
||||
set_property(SOURCE ${SSE2_SRCS} PROPERTY COMPILE_FLAGS "${SSE2FLAG} ${NOLTOFLAG}")
|
||||
add_feature_info(FORCE_SSE2 FORCE_SSE2 "Assume CPU is SSE2 capable")
|
||||
if(FORCE_SSE2)
|
||||
add_definitions(-DX86_NOCHECK_SSE2)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
set(WITH_SSE2 OFF)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_SSSE3)
|
||||
check_ssse3_intrinsics()
|
||||
if(HAVE_SSSE3_INTRIN AND WITH_SSE2)
|
||||
add_definitions(-DX86_SSSE3)
|
||||
set(SSSE3_SRCS ${ARCHDIR}/adler32_ssse3.c ${ARCHDIR}/chunkset_ssse3.c)
|
||||
add_feature_info(SSSE3_ADLER32 1 "Support SSSE3-accelerated adler32, using \"${SSSE3FLAG}\"")
|
||||
list(APPEND ZLIB_ARCH_SRCS ${SSSE3_SRCS})
|
||||
set_property(SOURCE ${SSSE3_SRCS} PROPERTY COMPILE_FLAGS "${SSSE3FLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_SSSE3 OFF)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_SSE42)
|
||||
check_sse42_intrinsics()
|
||||
if(HAVE_SSE42_INTRIN AND WITH_SSSE3)
|
||||
add_definitions(-DX86_SSE42)
|
||||
set(SSE42_SRCS ${ARCHDIR}/adler32_sse42.c)
|
||||
add_feature_info(SSE42_CRC 1 "Support SSE4.2 optimized adler32 hash generation, using \"${SSE42FLAG}\"")
|
||||
list(APPEND ZLIB_ARCH_SRCS ${SSE42_SRCS})
|
||||
set_property(SOURCE ${SSE42_SRCS} PROPERTY COMPILE_FLAGS "${SSE42FLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_SSE42 OFF)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_PCLMULQDQ)
|
||||
check_pclmulqdq_intrinsics()
|
||||
if(HAVE_PCLMULQDQ_INTRIN AND WITH_SSE42)
|
||||
add_definitions(-DX86_PCLMULQDQ_CRC)
|
||||
set(PCLMULQDQ_SRCS ${ARCHDIR}/crc32_pclmulqdq.c)
|
||||
add_feature_info(PCLMUL_CRC 1 "Support CRC hash generation using PCLMULQDQ, using \"${SSE42FLAG} ${PCLMULFLAG}\"")
|
||||
list(APPEND ZLIB_ARCH_SRCS ${PCLMULQDQ_SRCS})
|
||||
set_property(SOURCE ${PCLMULQDQ_SRCS} PROPERTY COMPILE_FLAGS "${SSE42FLAG} ${PCLMULFLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_PCLMULQDQ OFF)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_AVX2)
|
||||
check_avx2_intrinsics()
|
||||
if(HAVE_AVX2_INTRIN AND WITH_SSE42)
|
||||
add_definitions(-DX86_AVX2)
|
||||
set(AVX2_SRCS ${ARCHDIR}/slide_hash_avx2.c)
|
||||
add_feature_info(AVX2_SLIDEHASH 1 "Support AVX2 optimized slide_hash, using \"${AVX2FLAG}\"")
|
||||
list(APPEND AVX2_SRCS ${ARCHDIR}/chunkset_avx2.c)
|
||||
add_feature_info(AVX2_CHUNKSET 1 "Support AVX2 optimized chunkset, using \"${AVX2FLAG}\"")
|
||||
list(APPEND AVX2_SRCS ${ARCHDIR}/compare256_avx2.c)
|
||||
add_feature_info(AVX2_COMPARE256 1 "Support AVX2 optimized compare256, using \"${AVX2FLAG}\"")
|
||||
list(APPEND AVX2_SRCS ${ARCHDIR}/adler32_avx2.c)
|
||||
add_feature_info(AVX2_ADLER32 1 "Support AVX2-accelerated adler32, using \"${AVX2FLAG}\"")
|
||||
list(APPEND ZLIB_ARCH_SRCS ${AVX2_SRCS})
|
||||
set_property(SOURCE ${AVX2_SRCS} PROPERTY COMPILE_FLAGS "${AVX2FLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_AVX2 OFF)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_AVX512)
|
||||
check_avx512_intrinsics()
|
||||
if(HAVE_AVX512_INTRIN AND WITH_AVX2)
|
||||
add_definitions(-DX86_AVX512)
|
||||
list(APPEND AVX512_SRCS ${ARCHDIR}/adler32_avx512.c)
|
||||
add_feature_info(AVX512_ADLER32 1 "Support AVX512-accelerated adler32, using \"${AVX512FLAG}\"")
|
||||
list(APPEND AVX512_SRCS ${ARCHDIR}/chunkset_avx512.c)
|
||||
add_feature_info(AVX512_CHUNKSET 1 "Support AVX512 optimized chunkset, using \"${AVX512FLAG}\"")
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/adler32_avx512_p.h)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${AVX512_SRCS})
|
||||
set_property(SOURCE ${AVX512_SRCS} PROPERTY COMPILE_FLAGS "${AVX512FLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_AVX512 OFF)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_AVX512VNNI)
|
||||
check_avx512vnni_intrinsics()
|
||||
if(HAVE_AVX512VNNI_INTRIN AND WITH_AVX2)
|
||||
add_definitions(-DX86_AVX512VNNI)
|
||||
add_feature_info(AVX512VNNI_ADLER32 1 "Support AVX512VNNI adler32, using \"${AVX512VNNIFLAG}\"")
|
||||
list(APPEND AVX512VNNI_SRCS ${ARCHDIR}/adler32_avx512_vnni.c)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${AVX512VNNI_SRCS})
|
||||
set_property(SOURCE ${AVX512VNNI_SRCS} PROPERTY COMPILE_FLAGS "${AVX512VNNIFLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_AVX512VNNI OFF)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_VPCLMULQDQ)
|
||||
check_vpclmulqdq_intrinsics()
|
||||
if(HAVE_VPCLMULQDQ_INTRIN AND WITH_PCLMULQDQ AND WITH_AVX512)
|
||||
add_definitions(-DX86_VPCLMULQDQ_CRC)
|
||||
set(VPCLMULQDQ_SRCS ${ARCHDIR}/crc32_vpclmulqdq.c)
|
||||
add_feature_info(VPCLMUL_CRC 1 "Support CRC hash generation using VPCLMULQDQ, using \"${PCLMULFLAG} ${VPCLMULFLAG} ${AVX512FLAG}\"")
|
||||
list(APPEND ZLIB_ARCH_SRCS ${VPCLMULQDQ_SRCS})
|
||||
set_property(SOURCE ${VPCLMULQDQ_SRCS} PROPERTY COMPILE_FLAGS "${PCLMULFLAG} ${VPCLMULFLAG} ${AVX512FLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_VPCLMULQDQ OFF)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message(STATUS "Architecture-specific source files: ${ZLIB_ARCH_SRCS}")
|
||||
|
||||
#============================================================================
|
||||
# zconf.h
|
||||
#============================================================================
|
||||
|
||||
macro(generate_cmakein input output)
|
||||
file(REMOVE ${output})
|
||||
file(STRINGS ${input} _lines)
|
||||
foreach(_line IN LISTS _lines)
|
||||
string(REGEX REPLACE "#ifdef HAVE_UNISTD_H.*" "@ZCONF_UNISTD_LINE@" _line "${_line}")
|
||||
string(REGEX REPLACE "#ifdef NEED_PTRDIFF_T.*" "@ZCONF_PTRDIFF_LINE@" _line "${_line}")
|
||||
if(NEED_PTRDIFF_T)
|
||||
string(REGEX REPLACE "typedef PTRDIFF_TYPE" "typedef @PTRDIFF_TYPE@" _line "${_line}")
|
||||
endif()
|
||||
file(APPEND ${output} "${_line}\n")
|
||||
endforeach()
|
||||
endmacro(generate_cmakein)
|
||||
|
||||
generate_cmakein( ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h.in ${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h.cmakein )
|
||||
|
||||
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
||||
# If we're doing an out of source build and the user has a zconf.h
|
||||
# in their source tree...
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h)
|
||||
message(STATUS "Renaming")
|
||||
message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h")
|
||||
message(STATUS "to 'zconf${SUFFIX}.h.included' because this file is included with zlib")
|
||||
message(STATUS "but CMake generates it automatically in the build directory.")
|
||||
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h.included)
|
||||
endif()
|
||||
|
||||
# If we're doing an out of source build and the user has a zconf.h.cmakein
|
||||
# in their source tree...
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h.cmakein)
|
||||
message(STATUS "Renaming")
|
||||
message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h.cmakein")
|
||||
message(STATUS "to 'zconf${SUFFIX}.h.cmakeincluded' because this file is included with zlib")
|
||||
message(STATUS "but CMake generates it automatically in the build directory.")
|
||||
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h.cmakein ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h.cmakeincluded)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# The user is allowed (but discouraged) to set absolute CMAKE_INSTALL_*DIR paths.
|
||||
# If they do, we copy these non-relocatable paths into the pkg-config file.
|
||||
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
set(PC_INC_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
else()
|
||||
set(PC_INC_INSTALL_DIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
endif()
|
||||
|
||||
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
|
||||
set(PC_LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
|
||||
else()
|
||||
set(PC_LIB_INSTALL_DIR "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Define ZLIB Library
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
set(ZLIB_PUBLIC_HDRS
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zlib_name_mangling${SUFFIX}.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zlib${SUFFIX}.h
|
||||
)
|
||||
set(ZLIB_PRIVATE_HDRS
|
||||
arch/generic/chunk_permute_table.h
|
||||
arch/generic/compare256_p.h
|
||||
arch/generic/generic_functions.h
|
||||
adler32_p.h
|
||||
chunkset_tpl.h
|
||||
compare256_rle.h
|
||||
arch_functions.h
|
||||
crc32_braid_p.h
|
||||
crc32_braid_comb_p.h
|
||||
crc32_braid_tbl.h
|
||||
deflate.h
|
||||
deflate_p.h
|
||||
functable.h
|
||||
inffast_tpl.h
|
||||
inffixed_tbl.h
|
||||
inflate.h
|
||||
inflate_p.h
|
||||
inftrees.h
|
||||
insert_string_tpl.h
|
||||
match_tpl.h
|
||||
trees.h
|
||||
trees_emit.h
|
||||
trees_tbl.h
|
||||
zbuild.h
|
||||
zendian.h
|
||||
zutil.h
|
||||
)
|
||||
set(ZLIB_SRCS
|
||||
arch/generic/adler32_c.c
|
||||
arch/generic/adler32_fold_c.c
|
||||
arch/generic/chunkset_c.c
|
||||
arch/generic/compare256_c.c
|
||||
arch/generic/crc32_braid_c.c
|
||||
arch/generic/crc32_fold_c.c
|
||||
arch/generic/slide_hash_c.c
|
||||
adler32.c
|
||||
compress.c
|
||||
crc32.c
|
||||
crc32_braid_comb.c
|
||||
deflate.c
|
||||
deflate_fast.c
|
||||
deflate_huff.c
|
||||
deflate_medium.c
|
||||
deflate_quick.c
|
||||
deflate_rle.c
|
||||
deflate_slow.c
|
||||
deflate_stored.c
|
||||
functable.c
|
||||
infback.c
|
||||
inflate.c
|
||||
inftrees.c
|
||||
insert_string.c
|
||||
insert_string_roll.c
|
||||
trees.c
|
||||
uncompr.c
|
||||
zutil.c
|
||||
)
|
||||
|
||||
if(WITH_RUNTIME_CPU_DETECTION)
|
||||
list(APPEND ZLIB_PRIVATE_HDRS cpu_features.h)
|
||||
list(APPEND ZLIB_SRCS cpu_features.c)
|
||||
endif()
|
||||
|
||||
set(ZLIB_GZFILE_PRIVATE_HDRS
|
||||
gzguts.h
|
||||
)
|
||||
set(ZLIB_GZFILE_SRCS
|
||||
gzlib.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gzread.c
|
||||
gzwrite.c
|
||||
)
|
||||
|
||||
set(ZLIB_ALL_SRCS ${ZLIB_SRCS} ${ZLIB_ARCH_HDRS} ${ZLIB_ARCH_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
if(WITH_GZFILEOP)
|
||||
list(APPEND ZLIB_ALL_SRCS ${ZLIB_GZFILE_PRIVATE_HDRS} ${ZLIB_GZFILE_SRCS})
|
||||
endif()
|
||||
|
||||
### Define library
|
||||
add_library(${ZLIB_LIB_TARGET} STATIC ${ZLIB_ALL_SRCS})
|
||||
set_global_variable (ZLIB_LIBRARIES_TO_EXPORT "zlib-static")
|
||||
set (install_targets zlib-static)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Compiler specific flags
|
||||
#-----------------------------------------------------------------------------
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_compile_options(${ZLIB_LIB_TARGET} PRIVATE -Wno-strict-prototypes -Wno-implicit-function-declaration)
|
||||
endif ()
|
||||
if (CMAKE_C_COMPILER_ID MATCHES "IntelLLVM" OR CMAKE_C_COMPILER_ID MATCHES "[Cc]lang")
|
||||
target_compile_options(${ZLIB_LIB_TARGET} PRIVATE -Wno-implicit-function-declaration)
|
||||
endif ()
|
||||
|
||||
if(NOT ZLIB_COMPAT)
|
||||
target_compile_definitions(${ZLIB_LIB_TARGET} PUBLIC ZLIBNG_NATIVE_API)
|
||||
endif()
|
||||
target_include_directories(${ZLIB_LIB_TARGET} PUBLIC
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}$<SEMICOLON>${CMAKE_CURRENT_SOURCE_DIR}>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||
|
||||
set_target_properties(${ZLIB_LIB_TARGET} PROPERTIES OUTPUT_NAME zlib-static)
|
||||
|
||||
if(HAVE_UNISTD_H)
|
||||
SET(ZCONF_UNISTD_LINE "#if 1 /* was set to #if 1 by configure/cmake/etc */")
|
||||
else()
|
||||
SET(ZCONF_UNISTD_LINE "#if 0 /* was set to #if 0 by configure/cmake/etc */")
|
||||
endif()
|
||||
if(NEED_PTRDIFF_T)
|
||||
SET(ZCONF_PTRDIFF_LINE "#if 1 /* was set to #if 1 by configure/cmake/etc */")
|
||||
else()
|
||||
SET(ZCONF_PTRDIFF_LINE "#ifdef NEED_PTRDIFF_T /* may be set to #if 1 by configure/cmake/etc */")
|
||||
endif()
|
||||
|
||||
set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib${SUFFIX}.pc)
|
||||
if(WITH_GZFILEOP)
|
||||
set(PKG_CONFIG_CFLAGS "-DWITH_GZFILEOP")
|
||||
endif()
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
|
||||
${ZLIB_PC} @ONLY)
|
||||
configure_file(${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h.cmakein
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h @ONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlib${SUFFIX}.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zlib${SUFFIX}.h @ONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/gzread.c.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gzread.c @ONLY)
|
||||
|
||||
if (NOT ZLIB_SYMBOL_PREFIX STREQUAL "")
|
||||
add_feature_info(ZLIB_SYMBOL_PREFIX ON "Publicly exported symbols have a custom prefix")
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlib_name_mangling${SUFFIX}.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zlib_name_mangling${SUFFIX}.h @ONLY)
|
||||
else()
|
||||
add_feature_info(ZLIB_SYMBOL_PREFIX OFF "Publicly exported symbols DO NOT have a custom prefix")
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlib_name_mangling.h.empty
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zlib_name_mangling${SUFFIX}.h COPYONLY)
|
||||
endif()
|
||||
# add_definitions(-DZLIB_SYMBOL_PREFIX=${ZLIB_SYMBOL_PREFIX}) # not needed
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add Target(s) to CMake Install for import into other projects
|
||||
#-----------------------------------------------------------------------------
|
||||
if (ZLIB_EXPORTED_TARGETS)
|
||||
INSTALL_TARGET_PDB (${ZLIB_LIB_TARGET} ${ZLIB_INSTALL_BIN_DIR} libraries)
|
||||
|
||||
install (
|
||||
TARGETS
|
||||
${install_targets}
|
||||
EXPORT
|
||||
${ZLIB_EXPORTED_TARGETS}
|
||||
LIBRARY DESTINATION ${ZLIB_INSTALL_LIB_DIR} COMPONENT libraries
|
||||
ARCHIVE DESTINATION ${ZLIB_INSTALL_LIB_DIR} COMPONENT libraries
|
||||
RUNTIME DESTINATION ${ZLIB_INSTALL_BIN_DIR} COMPONENT libraries
|
||||
FRAMEWORK DESTINATION ${ZLIB_INSTALL_FWRK_DIR} COMPONENT libraries
|
||||
PUBLIC_HEADER DESTINATION ${ZLIB_INSTALL_INCLUDE_DIR} COMPONENT headers
|
||||
)
|
||||
endif ()
|
||||
|
||||
include (CMakePackageConfigHelpers)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure the zlib-config.cmake file for the build directory
|
||||
#-----------------------------------------------------------------------------
|
||||
set (INCLUDE_INSTALL_DIR ${ZLIB_INSTALL_INCLUDE_DIR})
|
||||
set (SHARE_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/${ZLIB_INSTALL_CMAKE_DIR}" )
|
||||
set (CURRENT_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}" )
|
||||
configure_package_config_file (
|
||||
${ZLIB_RESOURCES_DIR}/zlib-config.cmake.in
|
||||
"${ZLIB_BINARY_DIR}/zlib-config.cmake"
|
||||
INSTALL_DESTINATION "${ZLIB_INSTALL_CMAKE_DIR}"
|
||||
PATH_VARS INCLUDE_INSTALL_DIR SHARE_INSTALL_DIR CURRENT_BUILD_DIR
|
||||
INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure the zlib-config.cmake file for the install directory
|
||||
#-----------------------------------------------------------------------------
|
||||
set (INCLUDE_INSTALL_DIR ${ZLIB_INSTALL_INCLUDE_DIR})
|
||||
set (SHARE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${ZLIB_INSTALL_CMAKE_DIR}" )
|
||||
set (CURRENT_BUILD_DIR "${CMAKE_INSTALL_PREFIX}")
|
||||
configure_package_config_file (
|
||||
${ZLIB_RESOURCES_DIR}/zlib-config.cmake.in
|
||||
"${ZLIB_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/zlib-config.cmake"
|
||||
INSTALL_DESTINATION "${ZLIB_INSTALL_CMAKE_DIR}"
|
||||
PATH_VARS INCLUDE_INSTALL_DIR SHARE_INSTALL_DIR CURRENT_BUILD_DIR
|
||||
)
|
||||
if (NOT ZLIB_EXTERNALLY_CONFIGURED)
|
||||
install (
|
||||
FILES ${ZLIB_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/zlib-config.cmake
|
||||
DESTINATION ${ZLIB_INSTALL_CMAKE_DIR}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure the ZLIB-config-version.cmake file for the install directory
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT ZLIB_EXTERNALLY_CONFIGURED)
|
||||
configure_file (
|
||||
${ZLIB_RESOURCES_DIR}/zlib-config-version.cmake.in
|
||||
${ZLIB_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/zlib-config-version.cmake @ONLY
|
||||
)
|
||||
install (
|
||||
FILES ${ZLIB_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/zlib-config-version.cmake
|
||||
DESTINATION ${ZLIB_INSTALL_CMAKE_DIR}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add Target(s) to CMake Install for import into other projects
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT ZLIB_EXTERNALLY_CONFIGURED)
|
||||
install (
|
||||
EXPORT ${ZLIB_EXPORTED_TARGETS}
|
||||
DESTINATION ${ZLIB_INSTALL_CMAKE_DIR}
|
||||
FILE zlib-targets.cmake
|
||||
NAMESPACE ${PACKAGE_NAMESPACE}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Export all exported targets to the build tree for use by parent project
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT ZLIB_EXTERNALLY_CONFIGURED)
|
||||
export (
|
||||
TARGETS ${ZLIB_LIBRARIES_TO_EXPORT}
|
||||
FILE zlib-targets.cmake
|
||||
NAMESPACE ${PACKAGE_NAMESPACE}
|
||||
)
|
||||
export (PACKAGE zlib)
|
||||
endif ()
|
||||
|
||||
add_feature_info(WITH_GZFILEOP WITH_GZFILEOP "Compile with support for gzFile related functions")
|
||||
add_feature_info(ZLIB_COMPAT ZLIB_COMPAT "Compile with zlib compatible API")
|
||||
add_feature_info(ZLIB_ENABLE_TESTS ZLIB_ENABLE_TESTS "Build test binaries")
|
||||
add_feature_info(ZLIBNG_ENABLE_TESTS ZLIBNG_ENABLE_TESTS "Test zlib-ng specific API")
|
||||
add_feature_info(WITH_SANITIZER WITH_SANITIZER "Enable sanitizer support")
|
||||
add_feature_info(WITH_GTEST WITH_GTEST "Build gtest_zlib")
|
||||
add_feature_info(WITH_FUZZERS WITH_FUZZERS "Build test/fuzz")
|
||||
add_feature_info(WITH_BENCHMARKS WITH_BENCHMARKS "Build test/benchmarks")
|
||||
add_feature_info(WITH_BENCHMARK_APPS WITH_BENCHMARK_APPS "Build application benchmarks")
|
||||
add_feature_info(WITH_OPTIM WITH_OPTIM "Build with optimisation")
|
||||
add_feature_info(WITH_NEW_STRATEGIES WITH_NEW_STRATEGIES "Use new strategies")
|
||||
add_feature_info(WITH_NATIVE_INSTRUCTIONS WITH_NATIVE_INSTRUCTIONS
|
||||
"Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native)")
|
||||
add_feature_info(WITH_RUNTIME_CPU_DETECTION WITH_RUNTIME_CPU_DETECTION "Build with runtime CPU detection")
|
||||
add_feature_info(WITH_MAINTAINER_WARNINGS WITH_MAINTAINER_WARNINGS "Build with project maintainer warnings")
|
||||
add_feature_info(WITH_CODE_COVERAGE WITH_CODE_COVERAGE "Enable code coverage reporting")
|
||||
add_feature_info(WITH_INFLATE_STRICT WITH_INFLATE_STRICT "Build with strict inflate distance checking")
|
||||
add_feature_info(WITH_INFLATE_ALLOW_INVALID_DIST WITH_INFLATE_ALLOW_INVALID_DIST "Build with zero fill for inflate invalid distances")
|
||||
|
||||
if(BASEARCH_ARM_FOUND)
|
||||
add_feature_info(WITH_ACLE WITH_ACLE "Build with ACLE")
|
||||
add_feature_info(WITH_NEON WITH_NEON "Build with NEON intrinsics")
|
||||
add_feature_info(WITH_ARMV6 WITH_ARMV6 "Build with ARMv6 SIMD")
|
||||
elseif(BASEARCH_PPC_FOUND)
|
||||
add_feature_info(WITH_ALTIVEC WITH_ALTIVEC "Build with AltiVec optimisations")
|
||||
add_feature_info(WITH_POWER8 WITH_POWER8 "Build with optimisations for POWER8")
|
||||
add_feature_info(WITH_POWER9 WITH_POWER9 "Build with optimisations for POWER9")
|
||||
elseif(BASEARCH_RISCV_FOUND)
|
||||
add_feature_info(WITH_RVV WITH_RVV "Build with RVV intrinsics")
|
||||
elseif(BASEARCH_S360_FOUND)
|
||||
add_feature_info(WITH_DFLTCC_DEFLATE WITH_DFLTCC_DEFLATE "Build with DFLTCC intrinsics for compression on IBM Z")
|
||||
add_feature_info(WITH_DFLTCC_INFLATE WITH_DFLTCC_INFLATE "Build with DFLTCC intrinsics for decompression on IBM Z")
|
||||
add_feature_info(WITH_CRC32_VX WITH_CRC32_VX "Build with vectorized CRC32 on IBM Z")
|
||||
elseif(BASEARCH_X86_FOUND)
|
||||
add_feature_info(WITH_AVX2 WITH_AVX2 "Build with AVX2")
|
||||
add_feature_info(WITH_AVX512 WITH_AVX512 "Build with AVX512")
|
||||
add_feature_info(WITH_AVX512VNNI WITH_AVX512VNNI "Build with AVX512 VNNI")
|
||||
add_feature_info(WITH_SSE2 WITH_SSE2 "Build with SSE2")
|
||||
add_feature_info(WITH_SSSE3 WITH_SSSE3 "Build with SSSE3")
|
||||
add_feature_info(WITH_SSE42 WITH_SSE42 "Build with SSE42")
|
||||
add_feature_info(WITH_PCLMULQDQ WITH_PCLMULQDQ "Build with PCLMULQDQ")
|
||||
add_feature_info(WITH_VPCLMULQDQ WITH_VPCLMULQDQ "Build with VPCLMULQDQ")
|
||||
endif()
|
||||
|
||||
add_feature_info(INSTALL_UTILS INSTALL_UTILS "Copy minigzip and minideflate during install")
|
||||
|
||||
FEATURE_SUMMARY(WHAT ALL INCLUDE_QUIET_PACKAGES)
|
||||
|
||||
@@ -1,26 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>English</string>
|
||||
<key>CFBundleExecutable</key>
|
||||
<string>@CPACK_PACKAGE_FILE_NAME@</string>
|
||||
<key>CFBundleIconFile</key>
|
||||
<string>@CPACK_BUNDLE_ICON@</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>org.@CPACK_PACKAGE_VENDOR@.@CPACK_PACKAGE_NAME@@CPACK_MODULE_VERSION_SUFFIX@</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>FMWK</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>@CPACK_PACKAGE_VERSIO@</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>@CPACK_SHORT_VERSION_STRING@</string>
|
||||
<key>CSResourcesFileMapped</key>
|
||||
<true/>
|
||||
</dict>
|
||||
</plist>
|
||||
@@ -1,1532 +0,0 @@
|
||||
cmake_minimum_required(VERSION 3.5.1...3.29.0)
|
||||
project(ZLIB LANGUAGES C)
|
||||
message(STATUS "Using CMake version ${CMAKE_VERSION}")
|
||||
|
||||
if(POLICY CMP0169)
|
||||
cmake_policy(SET CMP0169 OLD) # CMake 3.30: call FetchContent_Populate() with just the name of a dependency
|
||||
endif()
|
||||
|
||||
# If not specified on the command line, enable C11 as the default
|
||||
# Configuration items that affect the global compiler environment standards
|
||||
# should be issued before the "project" command.
|
||||
if(NOT DEFINED CMAKE_C_STANDARD)
|
||||
set(CMAKE_C_STANDARD 11) # The C standard whose features are requested to build this target
|
||||
endif()
|
||||
if(NOT DEFINED CMAKE_C_STANDARD_REQUIRED)
|
||||
set(CMAKE_C_STANDARD_REQUIRED ON) # Boolean describing whether the value of C_STANDARD is a requirement
|
||||
endif()
|
||||
if(NOT DEFINED CMAKE_C_EXTENSIONS)
|
||||
set(CMAKE_C_EXTENSIONS OFF) # Boolean specifying whether compiler specific extensions are requested
|
||||
endif()
|
||||
set(VALID_C_STANDARDS "99" "11")
|
||||
if(NOT CMAKE_C_STANDARD IN_LIST VALID_C_STANDARDS)
|
||||
MESSAGE(FATAL_ERROR "CMAKE_C_STANDARD:STRING=${CMAKE_C_STANDARD} not in known standards list\n ${VALID_C_STANDARDS}")
|
||||
endif()
|
||||
|
||||
# Parse the full version number from zlib.h.in and include in ZLIB_FULL_VERSION
|
||||
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h.in _zlib_h_contents)
|
||||
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([0-9]+.[0-9]+.[0-9]+).*\".*"
|
||||
"\\1" ZLIB_HEADER_VERSION ${_zlib_h_contents})
|
||||
string(REGEX REPLACE ".*#define[ \t]+ZLIBNG_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
|
||||
"\\1" ZLIBNG_HEADER_VERSION ${_zlib_h_contents})
|
||||
message(STATUS "ZLIB_HEADER_VERSION: ${ZLIB_HEADER_VERSION}")
|
||||
message(STATUS "ZLIBNG_HEADER_VERSION: ${ZLIBNG_HEADER_VERSION}")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Basic ZLIB stuff here
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_PACKAGE_EXT ${HDF_PACKAGE_EXT})
|
||||
set (HDF_USE_GNU_DIRS ${HDF5_USE_GNU_DIRS})
|
||||
set (CMAKE_OSX_ARCHITECTURES ${CMAKE_OSX_ARCHITECTURES})
|
||||
set (CMAKE_TOOLCHAIN_FILE ${CMAKE_TOOLCHAIN_FILE})
|
||||
set (PACKAGE_NAMESPACE ${HDF_PACKAGE_NAMESPACE})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Define some CMake variables for use later in the project
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_RESOURCES_DIR ${HDF_RESOURCES_DIR}/ZLIB)
|
||||
set (ZLIB_SRC_DIR ${ZLIB_SOURCE_DIR})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Set the core names of all the libraries
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_LIB_CORENAME "zlib-static")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Set the target names of all the libraries
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_LIB_TARGET "zlib-static")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
set (ZLIB_PACKAGE "zlib")
|
||||
set (ZLIB_PACKAGE_NAME "ZLIB")
|
||||
|
||||
set (CMAKE_POSITION_INDEPENDENT_CODE ON)
|
||||
|
||||
HDF_DIR_PATHS(${ZLIB_PACKAGE_NAME})
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Targets built within this project are exported at Install time for use
|
||||
# by other projects
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT ZLIB_EXPORTED_TARGETS)
|
||||
set (ZLIB_EXPORTED_TARGETS "zlib-targets")
|
||||
endif ()
|
||||
|
||||
set_global_variable (ZLIB_LIBRARIES_TO_EXPORT "")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# All libs/tests/examples need the main include directories
|
||||
#-----------------------------------------------------------------------------
|
||||
set_directory_properties(PROPERTIES INCLUDE_DIRECTORIES
|
||||
"${ZLIB_BINARY_DIR};${ZLIB_SOURCE_DIR};${CMAKE_RUNTIME_OUTPUT_DIRECTORY}"
|
||||
)
|
||||
|
||||
include(CheckTypeSize)
|
||||
include(CheckSymbolExists)
|
||||
include(CheckFunctionExists)
|
||||
include(CheckIncludeFile)
|
||||
include(CheckCSourceCompiles)
|
||||
include(CheckCSourceRuns)
|
||||
include(CheckCCompilerFlag)
|
||||
include(CMakeDependentOption)
|
||||
include(CMakePackageConfigHelpers)
|
||||
include(FeatureSummary)
|
||||
|
||||
include(cmake/detect-arch.cmake)
|
||||
include(cmake/detect-install-dirs.cmake)
|
||||
include(cmake/detect-coverage.cmake)
|
||||
include(cmake/detect-intrinsics.cmake)
|
||||
include(cmake/detect-sanitizer.cmake)
|
||||
include(cmake/fallback-macros.cmake)
|
||||
|
||||
if(CMAKE_TOOLCHAIN_FILE)
|
||||
message(STATUS "Using CMake toolchain: ${CMAKE_TOOLCHAIN_FILE}")
|
||||
endif()
|
||||
|
||||
# Make sure we use an appropriate BUILD_TYPE by default, "Release" to be exact
|
||||
# this should select the maximum generic optimisation on the current platform (i.e. -O3 for gcc/clang)
|
||||
get_property(GENERATOR_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
|
||||
if(NOT GENERATOR_IS_MULTI_CONFIG)
|
||||
if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE "Release" CACHE STRING
|
||||
"Choose the type of build, standard options are: Debug Release RelWithDebInfo MinSizeRel."
|
||||
FORCE)
|
||||
add_feature_info(CMAKE_BUILD_TYPE 1 "Build type: ${CMAKE_BUILD_TYPE} (default)")
|
||||
else()
|
||||
add_feature_info(CMAKE_BUILD_TYPE 1 "Build type: ${CMAKE_BUILD_TYPE} (selected)")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#
|
||||
# Options parsing
|
||||
#
|
||||
option(WITH_GZFILEOP "Compile with support for gzFile related functions" ON)
|
||||
option(ZLIB_COMPAT "Compile with zlib compatible API" OFF)
|
||||
option(ZLIB_ENABLE_TESTS "Build test binaries" OFF)
|
||||
option(ZLIBNG_ENABLE_TESTS "Test zlib-ng specific API" OFF)
|
||||
option(WITH_GTEST "Build gtest_zlib" OFF)
|
||||
option(WITH_FUZZERS "Build test/fuzz" OFF)
|
||||
option(WITH_BENCHMARKS "Build test/benchmarks" OFF)
|
||||
option(WITH_BENCHMARK_APPS "Build application benchmarks" OFF)
|
||||
option(WITH_OPTIM "Build with optimisation" ON)
|
||||
option(WITH_REDUCED_MEM "Reduced memory usage for special cases (reduces performance)" OFF)
|
||||
option(WITH_NEW_STRATEGIES "Use new strategies" ON)
|
||||
option(WITH_CRC32_CHORBA "Enable optimized CRC32 algorithm Chorba" ON)
|
||||
option(WITH_NATIVE_INSTRUCTIONS
|
||||
"Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native)" OFF)
|
||||
option(WITH_RUNTIME_CPU_DETECTION "Build with runtime detection of CPU architecture" ON)
|
||||
option(WITH_MAINTAINER_WARNINGS "Build with project maintainer warnings" OFF)
|
||||
option(WITH_CODE_COVERAGE "Enable code coverage reporting" OFF)
|
||||
option(WITH_INFLATE_STRICT "Build with strict inflate distance checking" OFF)
|
||||
option(WITH_INFLATE_ALLOW_INVALID_DIST "Build with zero fill for inflate invalid distances" OFF)
|
||||
|
||||
set(ZLIB_SYMBOL_PREFIX "" CACHE STRING "Give this prefix to all publicly exported symbols.
|
||||
Useful when embedding into a larger library.
|
||||
Default is no prefix (empty prefix).")
|
||||
|
||||
if(BASEARCH_ARM_FOUND)
|
||||
option(WITH_ARMV8 "Build with ARMv8 CRC32 intrinsics" ON)
|
||||
option(WITH_NEON "Build with NEON intrinsics" ON)
|
||||
cmake_dependent_option(WITH_ARMV6 "Build with ARMv6 SIMD" ON "NOT ARCH MATCHES \"aarch64\"" OFF)
|
||||
|
||||
# Provided for backward compatibility
|
||||
if(DEFINED WITH_ACLE)
|
||||
set(WITH_ARMV8 ${WITH_ACLE})
|
||||
endif()
|
||||
elseif(BASEARCH_PPC_FOUND)
|
||||
option(WITH_ALTIVEC "Build with AltiVec (VMX) optimisations for PowerPC" ON)
|
||||
option(WITH_POWER8 "Build with optimisations for POWER8" ON)
|
||||
option(WITH_POWER9 "Build with optimisations for POWER9" ON)
|
||||
elseif(BASEARCH_RISCV_FOUND)
|
||||
option(WITH_RVV "Build with RVV intrinsics" ON)
|
||||
option(WITH_RISCV_ZBC "Build with RISCV ZBC" ON)
|
||||
elseif(BASEARCH_S360_FOUND)
|
||||
option(WITH_DFLTCC_DEFLATE "Build with DFLTCC intrinsics for compression on IBM Z" OFF)
|
||||
option(WITH_DFLTCC_INFLATE "Build with DFLTCC intrinsics for decompression on IBM Z" OFF)
|
||||
option(WITH_CRC32_VX "Build with vectorized CRC32 on IBM Z" ON)
|
||||
elseif(BASEARCH_X86_FOUND)
|
||||
option(WITH_SSE2 "Build with SSE2" ON)
|
||||
cmake_dependent_option(WITH_SSSE3 "Build with SSSE3" ON "WITH_SSE2" OFF)
|
||||
cmake_dependent_option(WITH_SSE41 "Build with SSE41" ON "WITH_SSSE3" OFF)
|
||||
cmake_dependent_option(WITH_SSE42 "Build with SSE42" ON "WITH_SSE41" OFF)
|
||||
cmake_dependent_option(WITH_PCLMULQDQ "Build with PCLMULQDQ" ON "WITH_SSE42" OFF)
|
||||
cmake_dependent_option(WITH_AVX2 "Build with AVX2" ON "WITH_SSE42" OFF)
|
||||
cmake_dependent_option(WITH_AVX512 "Build with AVX512" ON "WITH_AVX2" OFF)
|
||||
cmake_dependent_option(WITH_AVX512VNNI "Build with AVX512 VNNI extensions" ON "WITH_AVX512" OFF)
|
||||
cmake_dependent_option(WITH_VPCLMULQDQ "Build with VPCLMULQDQ" ON "WITH_PCLMULQDQ;WITH_AVX512" OFF)
|
||||
endif()
|
||||
|
||||
option(INSTALL_UTILS "Copy minigzip and minideflate during install" OFF)
|
||||
|
||||
mark_as_advanced(FORCE
|
||||
ZLIB_SYMBOL_PREFIX
|
||||
WITH_REDUCED_MEM
|
||||
WITH_CRC32_CHORBA
|
||||
WITH_ARMV8 WITH_NEON
|
||||
WITH_ARMV6
|
||||
WITH_DFLTCC_DEFLATE
|
||||
WITH_DFLTCC_INFLATE
|
||||
WITH_CRC32_VX
|
||||
WITH_AVX2 WITH_SSE2
|
||||
WITH_SSSE3 WITH_SSE41 WITH_SSE42
|
||||
WITH_PCLMULQDQ
|
||||
WITH_ALTIVEC
|
||||
WITH_POWER8
|
||||
WITH_POWER9
|
||||
WITH_RVV
|
||||
WITH_RISCV_ZBC
|
||||
WITH_INFLATE_STRICT
|
||||
WITH_INFLATE_ALLOW_INVALID_DIST
|
||||
INSTALL_UTILS
|
||||
)
|
||||
|
||||
if(ZLIB_COMPAT)
|
||||
add_definitions(-DZLIB_COMPAT)
|
||||
set(WITH_GZFILEOP ON)
|
||||
set(SUFFIX "")
|
||||
set(ZLIB_FULL_VERSION ${ZLIB_HEADER_VERSION}.zlib-ng)
|
||||
set(EXPORT_NAME ZLIB)
|
||||
else()
|
||||
set(SUFFIX "-ng")
|
||||
set(ZLIB_FULL_VERSION ${ZLIBNG_HEADER_VERSION})
|
||||
set(EXPORT_NAME zlib-ng)
|
||||
endif()
|
||||
|
||||
if(WITH_GZFILEOP)
|
||||
add_definitions(-DWITH_GZFILEOP)
|
||||
endif()
|
||||
|
||||
if(NOT WITH_CRC32_CHORBA)
|
||||
add_definitions(-DWITHOUT_CHORBA)
|
||||
endif()
|
||||
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "^Intel")
|
||||
if(CMAKE_HOST_UNIX)
|
||||
set(WARNFLAGS -Wall)
|
||||
set(WARNFLAGS_MAINTAINER -Wall -Wcheck -Wremarks)
|
||||
set(WARNFLAGS_DISABLE)
|
||||
else()
|
||||
set(WARNFLAGS /Wall)
|
||||
set(WARNFLAGS_MAINTAINER /W5)
|
||||
set(WARNFLAGS_DISABLE)
|
||||
endif()
|
||||
check_c_compiler_flag(-diag-disable=10441 HAVE_DIAG_10441)
|
||||
if(HAVE_DIAG_10441)
|
||||
list(APPEND WARNFLAGS_DISABLE "-diag-disable=10441")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -diag-disable=10441")
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -diag-disable=10441")
|
||||
endif()
|
||||
elseif(MSVC)
|
||||
# Minimum supported MSVC version is 1800 = Visual Studio 12.0/2013
|
||||
# See also https://cmake.org/cmake/help/latest/variable/MSVC_VERSION.html
|
||||
if(MSVC_VERSION VERSION_LESS 1800)
|
||||
message(SEND_ERROR "Unsupported Visual Studio compiler version (requires 2013 or later).")
|
||||
endif()
|
||||
# TODO. ICC can be used through MSVC. I'm not sure if we'd ever see that combination
|
||||
# (who'd use cmake from an IDE...) but checking for ICC before checking for MSVC should
|
||||
# avoid mistakes.
|
||||
# /Oi ?
|
||||
set(WARNFLAGS /W3 /w34242 /WX)
|
||||
set(WARNFLAGS_MAINTAINER /W4)
|
||||
set(WARNFLAGS_DISABLE /wd4206 /wd4054 /wd4324)
|
||||
if(BASEARCH_ARM_FOUND)
|
||||
add_definitions(-D_ARM_WINAPI_PARTITION_DESKTOP_SDK_AVAILABLE)
|
||||
if(NOT "${ARCH}" MATCHES "aarch64")
|
||||
set(NEONFLAG "/arch:VFPv4")
|
||||
endif()
|
||||
endif()
|
||||
elseif(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
# Enable warnings in GCC and Clang
|
||||
set(WARNFLAGS -Wall)
|
||||
set(WARNFLAGS_MAINTAINER -Wextra)
|
||||
set(WARNFLAGS_DISABLE)
|
||||
# Check whether -fno-lto is available
|
||||
set(CMAKE_REQUIRED_FLAGS "-fno-lto")
|
||||
check_c_source_compiles(
|
||||
"int main() { return 0; }"
|
||||
FNO_LTO_AVAILABLE FAIL_REGEX "not supported")
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
if(FNO_LTO_AVAILABLE)
|
||||
set(ZNOLTOFLAG "-fno-lto")
|
||||
endif()
|
||||
if(NOT WITH_NATIVE_INSTRUCTIONS)
|
||||
if(BASEARCH_ARM_FOUND)
|
||||
if("${ARCH}" MATCHES "arm" AND NOT CMAKE_C_FLAGS MATCHES "-mfloat-abi")
|
||||
# Auto-detect support for ARM floating point ABI
|
||||
check_include_file(features.h HAVE_FEATURES_H)
|
||||
if(HAVE_FEATURES_H)
|
||||
set(CMAKE_REQUIRED_FLAGS -mfloat-abi=softfp)
|
||||
check_c_source_compiles(
|
||||
"#include <features.h>
|
||||
int main() { return 0; }"
|
||||
HAVE_FLOATABI_SOFTFP)
|
||||
if(HAVE_FLOATABI_SOFTFP)
|
||||
set(FLOATABI -mfloat-abi=softfp)
|
||||
else()
|
||||
set(CMAKE_REQUIRED_FLAGS -mfloat-abi=hard)
|
||||
check_c_source_compiles(
|
||||
"#include <features.h>
|
||||
int main() { return 0; }"
|
||||
HAVE_FLOATABI_HARD)
|
||||
if(HAVE_FLOATABI_HARD)
|
||||
set(FLOATABI -mfloat-abi=hard)
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
endif()
|
||||
if(FLOATABI)
|
||||
message(STATUS "ARM floating point arch: ${FLOATABI}")
|
||||
add_compile_options(${FLOATABI})
|
||||
else()
|
||||
message(STATUS "ARM floating point arch not auto-detected")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
# Disable LTO unless Native Instructions are enabled
|
||||
if(FNO_LTO_AVAILABLE)
|
||||
set(NOLTOFLAG ${ZNOLTOFLAG})
|
||||
endif()
|
||||
endif()
|
||||
if(MINGW)
|
||||
# Add `-Wno-pedantic-ms-format` only if the toolchain supports it
|
||||
check_c_compiler_flag(-Wno-pedantic-ms-format HAVE_NO_PEDANTIC_MS_FORMAT)
|
||||
if(HAVE_NO_PEDANTIC_MS_FORMAT)
|
||||
list(APPEND WARNFLAGS_DISABLE -Wno-pedantic-ms-format)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Set native march/mcpu
|
||||
if(WITH_NATIVE_INSTRUCTIONS)
|
||||
if(NATIVE_ARCH_OVERRIDE)
|
||||
message(STATUS "WARNING: WITH_NATIVE_INSTRUCTIONS enabled, but running with NATIVE_ARCH_OVERRIDE: ${NATIVE_ARCH_OVERRIDE}")
|
||||
set(NATIVEFLAG "${NATIVE_ARCH_OVERRIDE}")
|
||||
else()
|
||||
if(CMAKE_C_COMPILER_ID MATCHES "GNU" OR CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
check_c_compiler_flag(-march=native HAVE_MARCH_NATIVE)
|
||||
if(HAVE_MARCH_NATIVE)
|
||||
set(NATIVEFLAG "-march=native")
|
||||
else()
|
||||
check_c_compiler_flag(-mcpu=native HAVE_MCPU_NATIVE)
|
||||
if(HAVE_MCPU_NATIVE)
|
||||
set(NATIVEFLAG "-mcpu=native")
|
||||
endif()
|
||||
endif()
|
||||
# Fall through
|
||||
endif()
|
||||
endif()
|
||||
if(NATIVEFLAG)
|
||||
# Apply flags to all source files and compilation checks
|
||||
if(WIN32)
|
||||
separate_arguments(NATIVEOPTIONS WINDOWS_COMMAND "${NATIVEFLAG}")
|
||||
else()
|
||||
separate_arguments(NATIVEOPTIONS UNIX_COMMAND "${NATIVEFLAG}")
|
||||
endif()
|
||||
add_compile_options(${NATIVEOPTIONS})
|
||||
set(WITH_RUNTIME_CPU_DETECTION OFF)
|
||||
else()
|
||||
message(STATUS "Ignoring WITH_NATIVE_INSTRUCTIONS; not implemented yet on this configuration")
|
||||
set(WITH_NATIVE_INSTRUCTIONS OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Compile without functable or CPU detection
|
||||
if(NOT WITH_RUNTIME_CPU_DETECTION)
|
||||
if(MSVC AND BASEARCH_X86_FOUND)
|
||||
message(STATUS "WARNING: Microsoft Visual Studio does not support compile time detection of CPU features for \"/arch\" before \"AVX\"")
|
||||
# Workaround for MSVC. By default MSVC does not define the __SSE*__ macros.
|
||||
# Fix it if AVX is enabled.
|
||||
set(CMAKE_REQUIRED_FLAGS "${NATIVEFLAG} ${ZNOLTOFLAG}")
|
||||
check_c_source_compiles(
|
||||
"#ifndef __AVX__
|
||||
# error \"AVX is not enabled.\"
|
||||
#endif
|
||||
int main(void) { return 0; }"
|
||||
MSVC_IS_ENABLED_AVX
|
||||
)
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
if(MSVC_IS_ENABLED_AVX)
|
||||
add_definitions(
|
||||
-D__SSE__=1
|
||||
-D__SSE2__=1
|
||||
-D__SSE3__=1
|
||||
-D__SSSE3__=1
|
||||
-D__SSE4_1__=1
|
||||
-D__SSE4_2__=1
|
||||
-D__PCLMUL__=1
|
||||
)
|
||||
endif()
|
||||
endif()
|
||||
add_definitions(-DDISABLE_RUNTIME_CPU_DETECTION)
|
||||
endif()
|
||||
|
||||
# Force disable LTO if WITH_NATIVE_INSTRUCTIONS is not active
|
||||
if(NOT WITH_NATIVE_INSTRUCTIONS)
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION OFF)
|
||||
foreach(_cfg_name IN LISTS CMAKE_CONFIGURATION_TYPES)
|
||||
string(TOUPPER "${_cfg_name}" _cfg_name_uc)
|
||||
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION_${_cfg_name_uc} OFF)
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
# Apply warning compiler flags
|
||||
if(WITH_MAINTAINER_WARNINGS)
|
||||
add_compile_options(${WARNFLAGS} ${WARNFLAGS_MAINTAINER} ${WARNFLAGS_DISABLE})
|
||||
else()
|
||||
add_compile_options(${WARNFLAGS} ${WARNFLAGS_DISABLE})
|
||||
endif()
|
||||
|
||||
# Replace optimization level 3 added by default with level 2
|
||||
if(NOT WITH_CODE_COVERAGE AND NOT MSVC AND NOT CMAKE_C_FLAGS MATCHES "([\\/\\-]O)3")
|
||||
string(REGEX REPLACE "([\\/\\-]O)3" "\\12"
|
||||
CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
|
||||
endif()
|
||||
|
||||
# Force Visual C++ to use UTF-8
|
||||
if(MSVC)
|
||||
if (NOT CMAKE_C_FLAGS MATCHES "[\\/\\-]utf-8")
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /utf-8")
|
||||
endif()
|
||||
if (NOT CMAKE_CXX_FLAGS MATCHES "[\\/\\-]utf-8")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /utf-8")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#
|
||||
# Additional flags for features checking
|
||||
#
|
||||
set(ADDITIONAL_CHECK_FLAGS )
|
||||
if(APPLE)
|
||||
check_c_compiler_flag(-Werror=unguarded-availability HAVE_W_ERROR_UNGUARDED_AVAILABILITY)
|
||||
if(HAVE_W_ERROR_UNGUARDED_AVAILABILITY)
|
||||
set(ADDITIONAL_CHECK_FLAGS "${ADDITIONAL_CHECK_FLAGS} -Werror=unguarded-availability")
|
||||
endif()
|
||||
check_c_compiler_flag(-Werror=unguarded-availability-new HAVE_W_ERROR_UNGUARDED_AVAILABILITY_NEW)
|
||||
if(HAVE_W_ERROR_UNGUARDED_AVAILABILITY_NEW)
|
||||
set(ADDITIONAL_CHECK_FLAGS "${ADDITIONAL_CHECK_FLAGS} -Werror=unguarded-availability-new")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
#
|
||||
# Check for standard/system includes
|
||||
#
|
||||
check_include_file(arm_acle.h HAVE_ARM_ACLE_H)
|
||||
if(HAVE_ARM_ACLE_H)
|
||||
add_definitions(-DHAVE_ARM_ACLE_H)
|
||||
endif()
|
||||
check_include_file(sys/auxv.h HAVE_SYS_AUXV_H)
|
||||
if(HAVE_SYS_AUXV_H)
|
||||
add_definitions(-DHAVE_SYS_AUXV_H)
|
||||
endif()
|
||||
check_include_file(sys/sdt.h HAVE_SYS_SDT_H)
|
||||
if(HAVE_SYS_SDT_H)
|
||||
add_definitions(-DHAVE_SYS_SDT_H)
|
||||
endif()
|
||||
check_include_file(unistd.h HAVE_UNISTD_H)
|
||||
|
||||
#
|
||||
# Check for Linux includes
|
||||
#
|
||||
check_include_file(linux/auxvec.h HAVE_LINUX_AUXVEC_H)
|
||||
if(HAVE_LINUX_AUXVEC_H)
|
||||
add_definitions(-DHAVE_LINUX_AUXVEC_H)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Check to see if we have large file support
|
||||
#
|
||||
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1 -D__USE_LARGEFILE64)
|
||||
check_type_size(off64_t OFF64_T)
|
||||
if(HAVE_OFF64_T)
|
||||
add_definitions(-D_LARGEFILE64_SOURCE=1 -D__USE_LARGEFILE64)
|
||||
else()
|
||||
check_type_size(_off64_t _OFF64_T)
|
||||
if(HAVE__OFF64_T)
|
||||
add_definitions(-D_LARGEFILE64_SOURCE=1 -D__USE_LARGEFILE64)
|
||||
else()
|
||||
check_type_size(__off64_t __OFF64_T)
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
|
||||
|
||||
#
|
||||
# Check for fseeko and other optional functions
|
||||
#
|
||||
set(CMAKE_REQUIRED_FLAGS "${ADDITIONAL_CHECK_FLAGS}")
|
||||
check_function_exists(fseeko HAVE_FSEEKO)
|
||||
if(NOT HAVE_FSEEKO)
|
||||
add_definitions(-DNO_FSEEKO)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
|
||||
set(CMAKE_REQUIRED_FLAGS "${ADDITIONAL_CHECK_FLAGS}")
|
||||
check_function_exists(strerror HAVE_STRERROR)
|
||||
if(NOT HAVE_STRERROR)
|
||||
add_definitions(-DNO_STRERROR)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
|
||||
#
|
||||
# Check for aligned memory allocation support: POSIX
|
||||
#
|
||||
set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200112L -D_ISOC11_SOURCE=1)
|
||||
set(CMAKE_REQUIRED_FLAGS "${ADDITIONAL_CHECK_FLAGS}")
|
||||
check_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN)
|
||||
if(HAVE_POSIX_MEMALIGN)
|
||||
add_definitions(-DHAVE_POSIX_MEMALIGN)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
set(CMAKE_REQUIRED_DEFINITIONS)
|
||||
|
||||
#
|
||||
# Check for aligned memory allocation support: C11
|
||||
#
|
||||
set(CMAKE_REQUIRED_DEFINITIONS -D_POSIX_C_SOURCE=200112L -D_ISOC11_SOURCE=1)
|
||||
set(CMAKE_REQUIRED_FLAGS "${ADDITIONAL_CHECK_FLAGS}")
|
||||
check_symbol_exists(aligned_alloc stdlib.h HAVE_ALIGNED_ALLOC)
|
||||
if(HAVE_ALIGNED_ALLOC)
|
||||
add_definitions(-DHAVE_ALIGNED_ALLOC)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
set(CMAKE_REQUIRED_DEFINITIONS)
|
||||
|
||||
#
|
||||
# Check for aligned memory allocation support: GNU extension
|
||||
# Note: memalign() is deprecated in glibc
|
||||
#
|
||||
check_symbol_exists(memalign malloc.h HAVE_MEMALIGN)
|
||||
if(HAVE_MEMALIGN)
|
||||
add_definitions(-DHAVE_MEMALIGN)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_DEFINITIONS)
|
||||
|
||||
#
|
||||
# Check for aligned memory allocation support: MSVC extensions
|
||||
#
|
||||
check_symbol_exists(_aligned_malloc malloc.h HAVE__ALIGNED_MALLOC)
|
||||
if(HAVE__ALIGNED_MALLOC)
|
||||
add_definitions(-DHAVE__ALIGNED_MALLOC)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_DEFINITIONS)
|
||||
|
||||
#
|
||||
# Check for x86 __cpuid / __cpuid_count support: GNU extensions
|
||||
# gcc/clang and MSVC have __cpuid, so check __cpuid_count instead
|
||||
check_symbol_exists(__cpuid_count cpuid.h HAVE_CPUID_GNU)
|
||||
if(HAVE_CPUID_GNU)
|
||||
add_definitions(-DHAVE_CPUID_GNU)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_DEFINITIONS)
|
||||
|
||||
#
|
||||
# Check for x86 __cpuid / __cpuidex support: MSVC extensions
|
||||
# gcc/clang and MSVC have __cpuid, so check __cpuidex instead
|
||||
# check_symbol_exists() does not work for intrinsics
|
||||
|
||||
check_c_source_compiles(
|
||||
"
|
||||
#include <intrin.h>
|
||||
static inline void cpuid_ms(int info, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx) {
|
||||
unsigned int registers[4];
|
||||
__cpuid((int *)registers, info);
|
||||
*eax = registers[0];
|
||||
*ebx = registers[1];
|
||||
*ecx = registers[2];
|
||||
*edx = registers[3];
|
||||
}
|
||||
|
||||
int main(void) {
|
||||
unsigned int eax, ebx, ecx, edx;
|
||||
cpuid_ms(0, &eax, &ebx, &ecx, &edx);
|
||||
return eax;
|
||||
}"
|
||||
HAVE_CPUID_MS)
|
||||
|
||||
if(HAVE_CPUID_MS)
|
||||
add_definitions(-DHAVE_CPUID_MS)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_DEFINITIONS)
|
||||
|
||||
#
|
||||
# Check whether compiler supports -fno-semantic-interposition parameter
|
||||
#
|
||||
check_c_compiler_flag(-fno-semantic-interposition HAVE_NO_INTERPOSITION)
|
||||
|
||||
#
|
||||
# Check if we can hide zlib internal symbols that are linked between separate source files using hidden
|
||||
#
|
||||
check_c_source_compiles(
|
||||
"#define Z_INTERNAL __attribute__((visibility (\"hidden\")))
|
||||
int Z_INTERNAL foo;
|
||||
int main() {
|
||||
return 0;
|
||||
}"
|
||||
HAVE_ATTRIBUTE_VISIBILITY_HIDDEN FAIL_REGEX "visibility")
|
||||
if(HAVE_ATTRIBUTE_VISIBILITY_HIDDEN)
|
||||
add_definitions(-DHAVE_VISIBILITY_HIDDEN)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Check if we can hide zlib internal symbols that are linked between separate source files using internal
|
||||
#
|
||||
check_c_source_compiles(
|
||||
"#define Z_INTERNAL __attribute__((visibility (\"internal\")))
|
||||
int Z_INTERNAL foo;
|
||||
int main() {
|
||||
return 0;
|
||||
}"
|
||||
HAVE_ATTRIBUTE_VISIBILITY_INTERNAL FAIL_REGEX "visibility")
|
||||
if(HAVE_ATTRIBUTE_VISIBILITY_INTERNAL)
|
||||
add_definitions(-DHAVE_VISIBILITY_INTERNAL)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Check for __attribute__((aligned(x))) support in the compiler
|
||||
#
|
||||
check_c_source_compiles(
|
||||
"int main(void) {
|
||||
__attribute__((aligned(8))) int test = 0;
|
||||
(void)test;
|
||||
return 0;
|
||||
}"
|
||||
HAVE_ATTRIBUTE_ALIGNED FAIL_REGEX "aligned")
|
||||
if(HAVE_ATTRIBUTE_ALIGNED)
|
||||
add_definitions(-DHAVE_ATTRIBUTE_ALIGNED)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Check for __builtin_assume_aligned(x,n) support in the compiler
|
||||
#
|
||||
set(CMAKE_REQUIRED_FLAGS ${ZNOLTOFLAG})
|
||||
check_c_source_compiles(
|
||||
"char *test(char *buffer) {
|
||||
char *abuffer = __builtin_assume_aligned(buffer,64);
|
||||
return abuffer;
|
||||
}
|
||||
int main() {
|
||||
return 0;
|
||||
}"
|
||||
HAVE_BUILTIN_ASSUME_ALIGNED)
|
||||
if(HAVE_BUILTIN_ASSUME_ALIGNED)
|
||||
add_definitions(-DHAVE_BUILTIN_ASSUME_ALIGNED)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
|
||||
#
|
||||
# check for __builtin_ctz() support in the compiler
|
||||
#
|
||||
set(CMAKE_REQUIRED_FLAGS ${ZNOLTOFLAG})
|
||||
check_c_source_compiles(
|
||||
"int main(void) {
|
||||
unsigned int zero = 0;
|
||||
long test = __builtin_ctz(zero);
|
||||
(void)test;
|
||||
return 0;
|
||||
}"
|
||||
HAVE_BUILTIN_CTZ
|
||||
)
|
||||
if(HAVE_BUILTIN_CTZ)
|
||||
add_definitions(-DHAVE_BUILTIN_CTZ)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
|
||||
#
|
||||
# check for __builtin_ctzll() support in the compiler
|
||||
#
|
||||
set(CMAKE_REQUIRED_FLAGS ${ZNOLTOFLAG})
|
||||
check_c_source_compiles(
|
||||
"int main(void) {
|
||||
unsigned int zero = 0;
|
||||
long test = __builtin_ctzll(zero);
|
||||
(void)test;
|
||||
return 0;
|
||||
}"
|
||||
HAVE_BUILTIN_CTZLL
|
||||
)
|
||||
if(HAVE_BUILTIN_CTZLL)
|
||||
add_definitions(-DHAVE_BUILTIN_CTZLL)
|
||||
endif()
|
||||
set(CMAKE_REQUIRED_FLAGS)
|
||||
|
||||
#
|
||||
# check for ptrdiff_t support
|
||||
#
|
||||
check_c_source_compiles(
|
||||
"#include <stddef.h>
|
||||
int main() {
|
||||
ptrdiff_t *a;
|
||||
(void)a;
|
||||
return 0;
|
||||
}"
|
||||
HAVE_PTRDIFF_T
|
||||
)
|
||||
if(NOT HAVE_PTRDIFF_T)
|
||||
set(NEED_PTRDIFF_T 1)
|
||||
|
||||
check_type_size("void *" SIZEOF_DATA_PTR)
|
||||
message(STATUS "sizeof(void *) is ${SIZEOF_DATA_PTR} bytes")
|
||||
|
||||
if(${SIZEOF_DATA_PTR} MATCHES "4")
|
||||
set(PTRDIFF_TYPE "uint32_t")
|
||||
elseif(${SIZEOF_DATA_PTR} MATCHES "8")
|
||||
set(PTRDIFF_TYPE "uint64_t")
|
||||
else()
|
||||
message(FATAL_ERROR "sizeof(void *) is neither 32 nor 64 bit")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_compile_options($<$<CONFIG:Debug>:-DZLIB_DEBUG>)
|
||||
|
||||
if(MSVC)
|
||||
set(CMAKE_DEBUG_POSTFIX "d")
|
||||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
|
||||
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
|
||||
endif()
|
||||
|
||||
#
|
||||
# Enable deflate_quick at level 1
|
||||
#
|
||||
if(NOT WITH_NEW_STRATEGIES)
|
||||
add_definitions(-DNO_QUICK_STRATEGY)
|
||||
endif()
|
||||
#
|
||||
# Enable deflate_medium at level 4-6
|
||||
#
|
||||
if(NOT WITH_NEW_STRATEGIES)
|
||||
add_definitions(-DNO_MEDIUM_STRATEGY)
|
||||
endif()
|
||||
#
|
||||
# Enable inflate compilation options
|
||||
#
|
||||
if(WITH_INFLATE_STRICT)
|
||||
add_definitions(-DINFLATE_STRICT)
|
||||
message(STATUS "Inflate strict distance checking enabled")
|
||||
endif()
|
||||
if(WITH_INFLATE_ALLOW_INVALID_DIST)
|
||||
add_definitions(-DINFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR)
|
||||
message(STATUS "Inflate zero data for invalid distances enabled")
|
||||
endif()
|
||||
#
|
||||
# Enable reduced memory configuration
|
||||
#
|
||||
if(WITH_REDUCED_MEM)
|
||||
add_definitions(-DHASH_SIZE=32768u -DGZBUFSIZE=8192 -DNO_LIT_MEM)
|
||||
message(STATUS "Configured for reduced memory environment")
|
||||
endif()
|
||||
|
||||
set(GENERIC_ARCHDIR "arch/generic")
|
||||
|
||||
set(ZLIB_ARCH_SRCS)
|
||||
set(ZLIB_ARCH_HDRS ${GENERIC_ARCHDIR}/generic_functions.h)
|
||||
|
||||
if(BASEARCH_ARM_FOUND)
|
||||
set(ARCHDIR "arch/arm")
|
||||
elseif(BASEARCH_PPC_FOUND)
|
||||
set(ARCHDIR "arch/power")
|
||||
elseif(BASEARCH_RISCV_FOUND)
|
||||
set(ARCHDIR "arch/riscv")
|
||||
elseif(BASEARCH_S360_FOUND)
|
||||
set(ARCHDIR "arch/s390")
|
||||
elseif(BASEARCH_X86_FOUND)
|
||||
set(ARCHDIR "arch/x86")
|
||||
if(NOT ${ARCH} MATCHES "x86_64")
|
||||
add_feature_info(SSE2 1 "Support the SSE2 instruction set, using \"${SSE2FLAG}\"")
|
||||
endif()
|
||||
else()
|
||||
set(ARCHDIR ${GENERIC_ARCHDIR})
|
||||
message(STATUS "No optimized architecture: using ${ARCHDIR}")
|
||||
endif()
|
||||
|
||||
if(WITH_OPTIM)
|
||||
if(BASEARCH_ARM_FOUND)
|
||||
add_definitions(-DARM_FEATURES)
|
||||
if(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
if("${ARCH}" MATCHES "aarch64")
|
||||
check_c_source_compiles(
|
||||
"#include <sys/auxv.h>
|
||||
int main() {
|
||||
return (getauxval(AT_HWCAP) & HWCAP_CRC32);
|
||||
}"
|
||||
ARM_AUXV_HAS_CRC32
|
||||
)
|
||||
if(ARM_AUXV_HAS_CRC32)
|
||||
add_definitions(-DARM_AUXV_HAS_CRC32)
|
||||
else()
|
||||
message(STATUS "HWCAP_CRC32 not present in sys/auxv.h; cannot detect support at runtime.")
|
||||
endif()
|
||||
else()
|
||||
check_c_source_compiles(
|
||||
"#include <sys/auxv.h>
|
||||
int main() {
|
||||
return (getauxval(AT_HWCAP2) & HWCAP2_CRC32);
|
||||
}"
|
||||
ARM_AUXV_HAS_CRC32
|
||||
)
|
||||
if(ARM_AUXV_HAS_CRC32)
|
||||
add_definitions(-DARM_AUXV_HAS_CRC32)
|
||||
else()
|
||||
check_c_source_compiles(
|
||||
"#include <sys/auxv.h>
|
||||
#include <asm/hwcap.h>
|
||||
int main() {
|
||||
return (getauxval(AT_HWCAP2) & HWCAP2_CRC32);
|
||||
}"
|
||||
ARM_HWCAP_HAS_CRC32
|
||||
)
|
||||
if (ARM_HWCAP_HAS_CRC32)
|
||||
add_definitions(-DARM_AUXV_HAS_CRC32 -DARM_ASM_HWCAP)
|
||||
else()
|
||||
message(STATUS "HWCAP2_CRC32 not present in sys/auxv.h; cannot detect support at runtime.")
|
||||
endif()
|
||||
endif()
|
||||
check_c_source_compiles(
|
||||
"#include <sys/auxv.h>
|
||||
int main() {
|
||||
return (getauxval(AT_HWCAP) & HWCAP_ARM_NEON);
|
||||
}"
|
||||
ARM_AUXV_HAS_NEON
|
||||
)
|
||||
if(ARM_AUXV_HAS_NEON)
|
||||
add_definitions(-DARM_AUXV_HAS_NEON)
|
||||
else()
|
||||
check_c_source_compiles(
|
||||
"#include <sys/auxv.h>
|
||||
int main() {
|
||||
return (getauxval(AT_HWCAP) & HWCAP_NEON);
|
||||
}"
|
||||
ARM_AUXV_HAS_NEON
|
||||
)
|
||||
if (ARM_AUXV_HAS_NEON)
|
||||
add_definitions(-DARM_AUXV_HAS_NEON)
|
||||
else()
|
||||
message(STATUS "Neither HWCAP_ARM_NEON or HWCAP_NEON present in sys/auxv.h; cannot detect support at runtime.")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/arm_functions.h)
|
||||
if(WITH_RUNTIME_CPU_DETECTION)
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/arm_features.h)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/arm_features.c)
|
||||
endif()
|
||||
|
||||
if(WITH_ARMV8)
|
||||
check_armv8_compiler_flag()
|
||||
if(HAVE_ARMV8_INLINE_ASM OR HAVE_ARMV8_INTRIN)
|
||||
add_definitions(-DARM_CRC32)
|
||||
set(ARMV8_SRCS ${ARCHDIR}/crc32_armv8.c)
|
||||
set_property(SOURCE ${ARMV8_SRCS} PROPERTY COMPILE_FLAGS "${ARMV8FLAG} ${NOLTOFLAG}")
|
||||
list(APPEND ZLIB_ARCH_SRCS ${ARMV8_SRCS})
|
||||
add_feature_info(ARMV8_CRC 1 "Support ARMv8 optimized CRC hash generation, using \"${ARMV8FLAG}\"")
|
||||
if(HAVE_ARMV8_INTRIN)
|
||||
add_definitions(-DARM_CRC32_INTRIN)
|
||||
endif()
|
||||
else()
|
||||
set(WITH_ARMV8 OFF)
|
||||
endif()
|
||||
else()
|
||||
set(WITH_ARMV8 OFF)
|
||||
endif()
|
||||
if(WITH_NEON)
|
||||
check_neon_compiler_flag()
|
||||
if(NEON_AVAILABLE)
|
||||
add_definitions(-DARM_NEON)
|
||||
set(NEON_SRCS ${ARCHDIR}/adler32_neon.c ${ARCHDIR}/chunkset_neon.c
|
||||
${ARCHDIR}/compare256_neon.c ${ARCHDIR}/slide_hash_neon.c)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${NEON_SRCS})
|
||||
set_property(SOURCE ${NEON_SRCS} PROPERTY COMPILE_FLAGS "${NEONFLAG} ${NOLTOFLAG}")
|
||||
if(MSVC)
|
||||
add_definitions(-D__ARM_NEON__)
|
||||
endif()
|
||||
add_feature_info(NEON_ADLER32 1 "Support NEON instructions in adler32, using \"${NEONFLAG}\"")
|
||||
add_feature_info(NEON_SLIDEHASH 1 "Support NEON instructions in slide_hash, using \"${NEONFLAG}\"")
|
||||
check_neon_ld4_intrinsics()
|
||||
if(NEON_HAS_LD4)
|
||||
add_definitions(-DARM_NEON_HASLD4)
|
||||
endif()
|
||||
else()
|
||||
set(WITH_NEON OFF)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_ARMV6)
|
||||
check_armv6_compiler_flag()
|
||||
if(HAVE_ARMV6_INLINE_ASM OR HAVE_ARMV6_INTRIN)
|
||||
add_definitions(-DARM_SIMD)
|
||||
set(ARMV6_SRCS ${ARCHDIR}/slide_hash_armv6.c)
|
||||
set_property(SOURCE ${ARMV6_SRCS} PROPERTY COMPILE_FLAGS "${ARMV6FLAG} ${NOLTOFLAG}")
|
||||
list(APPEND ZLIB_ARCH_SRCS ${ARMV6_SRCS})
|
||||
add_feature_info(ARMV6 1 "Support ARMv6 SIMD instructions in slide_hash, using \"${ARMV6FLAG}\"")
|
||||
if(HAVE_ARMV6_INTRIN)
|
||||
add_definitions(-DARM_SIMD_INTRIN)
|
||||
endif()
|
||||
else()
|
||||
set(WITH_ARMV6 OFF)
|
||||
endif()
|
||||
else()
|
||||
set(WITH_ARMV6 OFF)
|
||||
endif()
|
||||
elseif(BASEARCH_PPC_FOUND)
|
||||
# Common arch detection code
|
||||
if(WITH_ALTIVEC)
|
||||
check_ppc_intrinsics()
|
||||
endif()
|
||||
if(WITH_POWER8)
|
||||
check_power8_intrinsics()
|
||||
endif()
|
||||
if(WITH_POWER9)
|
||||
check_power9_intrinsics()
|
||||
endif()
|
||||
if(POWER8_NEED_AUXVEC_H OR POWER9_NEED_AUXVEC_H)
|
||||
add_definitions(-DPOWER_NEED_AUXVEC_H)
|
||||
endif()
|
||||
if(HAVE_POWER8_INTRIN OR HAVE_POWER9_INTRIN)
|
||||
add_definitions(-DPOWER_FEATURES)
|
||||
endif()
|
||||
if(HAVE_VMX OR HAVE_POWER8_INTRIN OR HAVE_POWER9_INTRIN)
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/power_functions.h)
|
||||
if(WITH_RUNTIME_CPU_DETECTION)
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/power_features.h)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/power_features.c)
|
||||
endif()
|
||||
endif()
|
||||
# VMX specific options and files
|
||||
if(WITH_ALTIVEC)
|
||||
if(HAVE_VMX)
|
||||
add_definitions(-DPPC_FEATURES)
|
||||
if(HAVE_ALTIVEC)
|
||||
add_definitions(-DPPC_VMX)
|
||||
set(PPC_SRCS ${ARCHDIR}/adler32_vmx.c ${ARCHDIR}/slide_hash_vmx.c)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${PPC_SRCS})
|
||||
add_feature_info(ALTIVEC 1 "Support the AltiVec instruction set, using \"-maltivec\"")
|
||||
set_property(SOURCE ${PPC_SRCS} PROPERTY COMPILE_FLAGS "${PPCFLAGS}")
|
||||
else()
|
||||
set(WITH_ALTIVEC OFF)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
# Power8 specific options and files
|
||||
if(WITH_POWER8)
|
||||
if(HAVE_POWER8_INTRIN)
|
||||
add_definitions(-DPOWER8_VSX)
|
||||
set(POWER8_SRCS ${ARCHDIR}/adler32_power8.c ${ARCHDIR}/chunkset_power8.c ${ARCHDIR}/slide_hash_power8.c)
|
||||
if("${ARCH}" MATCHES "powerpc64(le)?")
|
||||
add_definitions(-DPOWER8_VSX_CRC32)
|
||||
list(APPEND POWER8_SRCS ${ARCHDIR}/crc32_power8.c)
|
||||
endif()
|
||||
list(APPEND ZLIB_ARCH_SRCS ${POWER8_SRCS})
|
||||
set_property(SOURCE ${POWER8_SRCS} PROPERTY COMPILE_FLAGS "${POWER8FLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_POWER8 OFF)
|
||||
endif()
|
||||
endif()
|
||||
# Power9 specific options and files
|
||||
if(WITH_POWER9)
|
||||
if(HAVE_POWER9_INTRIN)
|
||||
add_definitions(-DPOWER9)
|
||||
set(POWER9_SRCS ${ARCHDIR}/compare256_power9.c)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${POWER9_SRCS})
|
||||
set_property(SOURCE ${POWER9_SRCS} PROPERTY COMPILE_FLAGS "${POWER9FLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_POWER9 OFF)
|
||||
endif()
|
||||
endif()
|
||||
elseif(BASEARCH_RISCV_FOUND)
|
||||
if(WITH_RVV)
|
||||
check_rvv_intrinsics()
|
||||
if(HAVE_RVV_INTRIN)
|
||||
add_definitions(-DRISCV_FEATURES)
|
||||
add_definitions(-DRISCV_RVV)
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/riscv_functions.h)
|
||||
if(WITH_RUNTIME_CPU_DETECTION)
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/riscv_features.h)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/riscv_features.c)
|
||||
endif()
|
||||
# FIXME: we will not set compile flags for riscv_features.c when
|
||||
# the kernels update hwcap or hwprobe for riscv
|
||||
set(RVV_SRCS ${ARCHDIR}/adler32_rvv.c ${ARCHDIR}/chunkset_rvv.c ${ARCHDIR}/compare256_rvv.c ${ARCHDIR}/slide_hash_rvv.c)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${RVV_SRCS})
|
||||
set_property(SOURCE ${RVV_SRCS} PROPERTY COMPILE_FLAGS "${RISCVFLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_RVV OFF)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_RISCV_ZBC)
|
||||
check_riscv_zbc_ext()
|
||||
if(HAVE_RISCV_ZBC)
|
||||
add_definitions(-DRISCV_CRC32_ZBC)
|
||||
set(ZBC_SRCS ${ARCHDIR}/crc32_zbc.c)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${ZBC_SRCS})
|
||||
set_property(SOURCE ${ZBC_SRCS} PROPERTY COMPILE_FLAGS "-march=rv64gc_zbc ${NOLTOFLAG}")
|
||||
add_feature_info(RISCV_ZBC 1 "Support RISC-V Zbc extension for CRC32")
|
||||
else()
|
||||
set(WITH_RISCV_ZBC OFF)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(WITH_RUNTIME_CPU_DETECTION AND BASEARCH_RISCV_FOUND)
|
||||
if(WITH_RVV AND WITH_RISCV_ZBC AND HAVE_RVV_INTRIN AND HAVE_RISCV_ZBC)
|
||||
set_property(SOURCE ${ARCHDIR}/riscv_features.c PROPERTY COMPILE_FLAGS "${RISCVFLAG}_zbc ${NOLTOFLAG}")
|
||||
elseif(WITH_RVV AND HAVE_RVV_INTRIN)
|
||||
set_property(SOURCE ${ARCHDIR}/riscv_features.c PROPERTY COMPILE_FLAGS "${RISCVFLAG} ${NOLTOFLAG}")
|
||||
elseif(WITH_RISCV_ZBC AND HAVE_RISCV_ZBC)
|
||||
set_property(SOURCE ${ARCHDIR}/riscv_features.c PROPERTY COMPILE_FLAGS "${RISCVZBCFLAG} ${NOLTOFLAG}")
|
||||
endif()
|
||||
endif()
|
||||
elseif(BASEARCH_S360_FOUND)
|
||||
check_s390_intrinsics()
|
||||
if(HAVE_S390_INTRIN)
|
||||
add_definitions(-DS390_FEATURES)
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/s390_functions.h)
|
||||
if(WITH_RUNTIME_CPU_DETECTION)
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/s390_features.h)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/s390_features.c)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_DFLTCC_DEFLATE)
|
||||
add_definitions(-DS390_DFLTCC_DEFLATE)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/dfltcc_deflate.c)
|
||||
endif()
|
||||
if(WITH_DFLTCC_INFLATE)
|
||||
add_definitions(-DS390_DFLTCC_INFLATE)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/dfltcc_inflate.c)
|
||||
endif()
|
||||
if(WITH_CRC32_VX)
|
||||
check_vgfma_intrinsics()
|
||||
if(HAVE_VGFMA_INTRIN)
|
||||
add_definitions(-DS390_CRC32_VX)
|
||||
set(CRC32_VX_SRCS ${ARCHDIR}/crc32-vx.c)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${CRC32_VX_SRCS})
|
||||
set_property(SOURCE ${CRC32_VX_SRCS} PROPERTY COMPILE_FLAGS "${VGFMAFLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_CRC32_VX OFF)
|
||||
endif()
|
||||
endif()
|
||||
elseif(BASEARCH_X86_FOUND)
|
||||
add_definitions(-DX86_FEATURES)
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/x86_functions.h)
|
||||
if(WITH_RUNTIME_CPU_DETECTION)
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/x86_features.h)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${ARCHDIR}/x86_features.c)
|
||||
endif()
|
||||
if(MSVC)
|
||||
list(APPEND ZLIB_ARCH_HDRS fallback_builtins.h)
|
||||
endif()
|
||||
check_xsave_intrinsics()
|
||||
if(HAVE_XSAVE_INTRIN)
|
||||
add_feature_info(XSAVE 1 "Support XSAVE intrinsics using \"${XSAVEFLAG}\"")
|
||||
if(WITH_RUNTIME_CPU_DETECTION)
|
||||
set_property(SOURCE ${ARCHDIR}/x86_features.c PROPERTY COMPILE_FLAGS "${XSAVEFLAG}")
|
||||
endif()
|
||||
if(NOT (CMAKE_C_COMPILER_ID MATCHES "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS 8.2))
|
||||
add_definitions(-DX86_HAVE_XSAVE_INTRIN)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_SSE2)
|
||||
check_sse2_intrinsics()
|
||||
# FORCE_SSE2 option will only be shown if HAVE_SSE2_INTRIN is true
|
||||
if("${ARCH}" MATCHES "i[3-6]86")
|
||||
cmake_dependent_option(FORCE_SSE2 "Always assume CPU is SSE2 capable" OFF "HAVE_SSE2_INTRIN" OFF)
|
||||
endif()
|
||||
if(HAVE_SSE2_INTRIN)
|
||||
add_definitions(-DX86_SSE2)
|
||||
set(SSE2_SRCS ${ARCHDIR}/chunkset_sse2.c ${ARCHDIR}/chorba_sse2.c ${ARCHDIR}/compare256_sse2.c ${ARCHDIR}/slide_hash_sse2.c)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${SSE2_SRCS})
|
||||
if(NOT ${ARCH} MATCHES "x86_64")
|
||||
set_property(SOURCE ${SSE2_SRCS} PROPERTY COMPILE_FLAGS "${SSE2FLAG} ${NOLTOFLAG}")
|
||||
add_feature_info(FORCE_SSE2 FORCE_SSE2 "Assume CPU is SSE2 capable")
|
||||
if(FORCE_SSE2)
|
||||
add_definitions(-DX86_NOCHECK_SSE2)
|
||||
endif()
|
||||
endif()
|
||||
else()
|
||||
set(WITH_SSE2 OFF)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_SSSE3)
|
||||
check_ssse3_intrinsics()
|
||||
if(HAVE_SSSE3_INTRIN AND WITH_SSE2)
|
||||
add_definitions(-DX86_SSSE3)
|
||||
set(SSSE3_SRCS ${ARCHDIR}/adler32_ssse3.c ${ARCHDIR}/chunkset_ssse3.c)
|
||||
add_feature_info(SSSE3_ADLER32 1 "Support SSSE3-accelerated adler32, using \"${SSSE3FLAG}\"")
|
||||
list(APPEND ZLIB_ARCH_SRCS ${SSSE3_SRCS})
|
||||
set_property(SOURCE ${SSSE3_SRCS} PROPERTY COMPILE_FLAGS "${SSSE3FLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_SSSE3 OFF)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_SSE41)
|
||||
check_sse41_intrinsics()
|
||||
if(HAVE_SSE41_INTRIN AND WITH_SSSE3)
|
||||
add_definitions(-DX86_SSE41)
|
||||
set(SSE41_SRCS ${ARCHDIR}/chorba_sse41.c)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${SSE41_SRCS})
|
||||
set_property(SOURCE ${SSE41_SRCS} PROPERTY COMPILE_FLAGS "${SSE41FLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_SSE41 OFF)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_SSE42)
|
||||
check_sse42_intrinsics()
|
||||
if(HAVE_SSE42_INTRIN AND WITH_SSE41)
|
||||
add_definitions(-DX86_SSE42)
|
||||
set(SSE42_SRCS ${ARCHDIR}/adler32_sse42.c)
|
||||
add_feature_info(SSE42_CRC 1 "Support SSE4.2 optimized adler32 hash generation, using \"${SSE42FLAG}\"")
|
||||
list(APPEND ZLIB_ARCH_SRCS ${SSE42_SRCS})
|
||||
set_property(SOURCE ${SSE42_SRCS} PROPERTY COMPILE_FLAGS "${SSE42FLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_SSE42 OFF)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_PCLMULQDQ)
|
||||
check_pclmulqdq_intrinsics()
|
||||
if(HAVE_PCLMULQDQ_INTRIN AND WITH_SSE42)
|
||||
add_definitions(-DX86_PCLMULQDQ_CRC)
|
||||
set(PCLMULQDQ_SRCS ${ARCHDIR}/crc32_pclmulqdq.c)
|
||||
add_feature_info(PCLMUL_CRC 1 "Support CRC hash generation using PCLMULQDQ, using \"${SSE42FLAG} ${PCLMULFLAG}\"")
|
||||
list(APPEND ZLIB_ARCH_SRCS ${PCLMULQDQ_SRCS})
|
||||
set_property(SOURCE ${PCLMULQDQ_SRCS} PROPERTY COMPILE_FLAGS "${SSE42FLAG} ${PCLMULFLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_PCLMULQDQ OFF)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_AVX2)
|
||||
check_avx2_intrinsics()
|
||||
if(HAVE_AVX2_INTRIN AND WITH_SSE42)
|
||||
add_definitions(-DX86_AVX2)
|
||||
set(AVX2_SRCS ${ARCHDIR}/slide_hash_avx2.c)
|
||||
add_feature_info(AVX2_SLIDEHASH 1 "Support AVX2 optimized slide_hash, using \"${AVX2FLAG}\"")
|
||||
list(APPEND AVX2_SRCS ${ARCHDIR}/chunkset_avx2.c)
|
||||
add_feature_info(AVX2_CHUNKSET 1 "Support AVX2 optimized chunkset, using \"${AVX2FLAG}\"")
|
||||
list(APPEND AVX2_SRCS ${ARCHDIR}/compare256_avx2.c)
|
||||
add_feature_info(AVX2_COMPARE256 1 "Support AVX2 optimized compare256, using \"${AVX2FLAG}\"")
|
||||
list(APPEND AVX2_SRCS ${ARCHDIR}/adler32_avx2.c)
|
||||
add_feature_info(AVX2_ADLER32 1 "Support AVX2-accelerated adler32, using \"${AVX2FLAG}\"")
|
||||
list(APPEND ZLIB_ARCH_SRCS ${AVX2_SRCS})
|
||||
set_property(SOURCE ${AVX2_SRCS} PROPERTY COMPILE_FLAGS "${AVX2FLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_AVX2 OFF)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_AVX512)
|
||||
check_avx512_intrinsics()
|
||||
if(HAVE_AVX512_INTRIN AND WITH_AVX2)
|
||||
add_definitions(-DX86_AVX512)
|
||||
list(APPEND AVX512_SRCS ${ARCHDIR}/adler32_avx512.c)
|
||||
add_feature_info(AVX512_ADLER32 1 "Support AVX512-accelerated adler32, using \"${AVX512FLAG}\"")
|
||||
list(APPEND AVX512_SRCS ${ARCHDIR}/chunkset_avx512.c)
|
||||
add_feature_info(AVX512_CHUNKSET 1 "Support AVX512 optimized chunkset, using \"${AVX512FLAG}\"")
|
||||
list(APPEND AVX512_SRCS ${ARCHDIR}/compare256_avx512.c)
|
||||
add_feature_info(AVX512_COMPARE256 1 "Support AVX512 optimized compare256, using \"${AVX512FLAG}\"")
|
||||
list(APPEND ZLIB_ARCH_HDRS ${ARCHDIR}/adler32_avx512_p.h)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${AVX512_SRCS})
|
||||
set_property(SOURCE ${AVX512_SRCS} PROPERTY COMPILE_FLAGS "${AVX512FLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_AVX512 OFF)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_AVX512VNNI)
|
||||
check_avx512vnni_intrinsics()
|
||||
if(HAVE_AVX512VNNI_INTRIN AND WITH_AVX2)
|
||||
add_definitions(-DX86_AVX512VNNI)
|
||||
add_feature_info(AVX512VNNI_ADLER32 1 "Support AVX512VNNI adler32, using \"${AVX512VNNIFLAG}\"")
|
||||
list(APPEND AVX512VNNI_SRCS ${ARCHDIR}/adler32_avx512_vnni.c)
|
||||
list(APPEND ZLIB_ARCH_SRCS ${AVX512VNNI_SRCS})
|
||||
set_property(SOURCE ${AVX512VNNI_SRCS} PROPERTY COMPILE_FLAGS "${AVX512VNNIFLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_AVX512VNNI OFF)
|
||||
endif()
|
||||
endif()
|
||||
if(WITH_VPCLMULQDQ)
|
||||
check_vpclmulqdq_intrinsics()
|
||||
if(HAVE_VPCLMULQDQ_INTRIN AND WITH_PCLMULQDQ AND WITH_AVX512)
|
||||
add_definitions(-DX86_VPCLMULQDQ_CRC)
|
||||
set(VPCLMULQDQ_SRCS ${ARCHDIR}/crc32_vpclmulqdq.c)
|
||||
add_feature_info(VPCLMUL_CRC 1 "Support CRC hash generation using VPCLMULQDQ, using \"${PCLMULFLAG} ${VPCLMULFLAG} ${AVX512FLAG}\"")
|
||||
list(APPEND ZLIB_ARCH_SRCS ${VPCLMULQDQ_SRCS})
|
||||
set_property(SOURCE ${VPCLMULQDQ_SRCS} PROPERTY COMPILE_FLAGS "${PCLMULFLAG} ${VPCLMULFLAG} ${AVX512FLAG} ${NOLTOFLAG}")
|
||||
else()
|
||||
set(WITH_VPCLMULQDQ OFF)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
message(STATUS "Architecture-specific source files: ${ZLIB_ARCH_SRCS}")
|
||||
|
||||
#============================================================================
|
||||
# zconf.h
|
||||
#============================================================================
|
||||
|
||||
macro(generate_cmakein input output)
|
||||
file(REMOVE ${output})
|
||||
file(STRINGS ${input} _lines)
|
||||
foreach(_line IN LISTS _lines)
|
||||
string(REGEX REPLACE "#ifdef HAVE_UNISTD_H.*" "@ZCONF_UNISTD_LINE@" _line "${_line}")
|
||||
string(REGEX REPLACE "#ifdef NEED_PTRDIFF_T.*" "@ZCONF_PTRDIFF_LINE@" _line "${_line}")
|
||||
if(NEED_PTRDIFF_T)
|
||||
string(REGEX REPLACE "typedef PTRDIFF_TYPE" "typedef @PTRDIFF_TYPE@" _line "${_line}")
|
||||
endif()
|
||||
file(APPEND ${output} "${_line}\n")
|
||||
endforeach()
|
||||
endmacro(generate_cmakein)
|
||||
|
||||
generate_cmakein( ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h.in ${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h.cmakein )
|
||||
|
||||
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
|
||||
# If we're doing an out of source build and the user has a zconf.h
|
||||
# in their source tree...
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h)
|
||||
message(STATUS "Renaming")
|
||||
message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h")
|
||||
message(STATUS "to 'zconf${SUFFIX}.h.included' because this file is included with zlib")
|
||||
message(STATUS "but CMake generates it automatically in the build directory.")
|
||||
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h.included)
|
||||
endif()
|
||||
|
||||
# If we're doing an out of source build and the user has a zconf.h.cmakein
|
||||
# in their source tree...
|
||||
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h.cmakein)
|
||||
message(STATUS "Renaming")
|
||||
message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h.cmakein")
|
||||
message(STATUS "to 'zconf${SUFFIX}.h.cmakeincluded' because this file is included with zlib")
|
||||
message(STATUS "but CMake generates it automatically in the build directory.")
|
||||
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h.cmakein ${CMAKE_CURRENT_SOURCE_DIR}/zconf${SUFFIX}.h.cmakeincluded)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# The user is allowed (but discouraged) to set absolute CMAKE_INSTALL_*DIR paths.
|
||||
# If they do, we copy these non-relocatable paths into the pkg-config file.
|
||||
if(IS_ABSOLUTE "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
set(PC_INC_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
else()
|
||||
set(PC_INC_INSTALL_DIR "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
|
||||
endif()
|
||||
|
||||
if(IS_ABSOLUTE "${CMAKE_INSTALL_LIBDIR}")
|
||||
set(PC_LIB_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
|
||||
else()
|
||||
set(PC_LIB_INSTALL_DIR "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
|
||||
endif()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Define ZLIB Library
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
set(ZLIB_PUBLIC_HDRS
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zlib_name_mangling${SUFFIX}.h
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zlib${SUFFIX}.h
|
||||
)
|
||||
set(ZLIB_PRIVATE_HDRS
|
||||
arch/generic/chunk_permute_table.h
|
||||
arch/generic/compare256_p.h
|
||||
arch/generic/generic_functions.h
|
||||
adler32_p.h
|
||||
arch_functions.h
|
||||
chunkset_tpl.h
|
||||
compare256_rle.h
|
||||
crc32.h
|
||||
crc32_braid_p.h
|
||||
crc32_braid_comb_p.h
|
||||
crc32_braid_tbl.h
|
||||
deflate.h
|
||||
deflate_p.h
|
||||
fallback_builtins.h
|
||||
functable.h
|
||||
inffast_tpl.h
|
||||
inffixed_tbl.h
|
||||
inflate.h
|
||||
inflate_p.h
|
||||
inftrees.h
|
||||
insert_string_tpl.h
|
||||
match_tpl.h
|
||||
trees.h
|
||||
trees_emit.h
|
||||
trees_tbl.h
|
||||
zbuild.h
|
||||
zendian.h
|
||||
zmemory.h
|
||||
zutil.h
|
||||
zutil_p.h
|
||||
)
|
||||
set(ZLIB_SRCS
|
||||
arch/generic/adler32_c.c
|
||||
arch/generic/adler32_fold_c.c
|
||||
arch/generic/chunkset_c.c
|
||||
arch/generic/compare256_c.c
|
||||
arch/generic/crc32_braid_c.c
|
||||
arch/generic/crc32_c.c
|
||||
arch/generic/crc32_fold_c.c
|
||||
arch/generic/slide_hash_c.c
|
||||
adler32.c
|
||||
compress.c
|
||||
crc32.c
|
||||
crc32_braid_comb.c
|
||||
deflate.c
|
||||
deflate_fast.c
|
||||
deflate_huff.c
|
||||
deflate_medium.c
|
||||
deflate_quick.c
|
||||
deflate_rle.c
|
||||
deflate_slow.c
|
||||
deflate_stored.c
|
||||
functable.c
|
||||
infback.c
|
||||
inflate.c
|
||||
inftrees.c
|
||||
insert_string.c
|
||||
insert_string_roll.c
|
||||
trees.c
|
||||
uncompr.c
|
||||
zutil.c
|
||||
)
|
||||
|
||||
if(WITH_CRC32_CHORBA)
|
||||
list(APPEND ZLIB_SRCS arch/generic/crc32_chorba_c.c)
|
||||
endif()
|
||||
|
||||
if(WITH_RUNTIME_CPU_DETECTION)
|
||||
list(APPEND ZLIB_PRIVATE_HDRS cpu_features.h)
|
||||
list(APPEND ZLIB_SRCS cpu_features.c)
|
||||
endif()
|
||||
|
||||
set(ZLIB_GZFILE_PRIVATE_HDRS
|
||||
gzguts.h
|
||||
)
|
||||
set(ZLIB_GZFILE_SRCS
|
||||
gzlib.c
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gzread.c
|
||||
gzwrite.c
|
||||
)
|
||||
|
||||
set(ZLIB_ALL_SRCS ${ZLIB_SRCS} ${ZLIB_ARCH_HDRS} ${ZLIB_ARCH_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
|
||||
if(WITH_GZFILEOP)
|
||||
list(APPEND ZLIB_ALL_SRCS ${ZLIB_GZFILE_PRIVATE_HDRS} ${ZLIB_GZFILE_SRCS})
|
||||
endif()
|
||||
|
||||
### Define library
|
||||
add_library(${ZLIB_LIB_TARGET} STATIC ${ZLIB_ALL_SRCS})
|
||||
set_global_variable (ZLIB_LIBRARIES_TO_EXPORT "zlib-static")
|
||||
set (install_targets zlib-static)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Compiler specific flags
|
||||
#-----------------------------------------------------------------------------
|
||||
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
|
||||
target_compile_options(${ZLIB_LIB_TARGET} PRIVATE -Wno-strict-prototypes -Wno-implicit-function-declaration)
|
||||
endif ()
|
||||
if (CMAKE_C_COMPILER_ID MATCHES "IntelLLVM" OR CMAKE_C_COMPILER_ID MATCHES "[Cc]lang")
|
||||
target_compile_options(${ZLIB_LIB_TARGET} PRIVATE -Wno-implicit-function-declaration)
|
||||
endif ()
|
||||
|
||||
if(NOT ZLIB_COMPAT)
|
||||
target_compile_definitions(${ZLIB_LIB_TARGET} PUBLIC ZLIBNG_NATIVE_API)
|
||||
endif()
|
||||
target_include_directories(${ZLIB_LIB_TARGET} PUBLIC
|
||||
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}$<SEMICOLON>${CMAKE_CURRENT_SOURCE_DIR}>"
|
||||
"$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>")
|
||||
|
||||
set_target_properties(${ZLIB_LIB_TARGET} PROPERTIES OUTPUT_NAME zlib-static)
|
||||
|
||||
if(HAVE_UNISTD_H)
|
||||
SET(ZCONF_UNISTD_LINE "#if 1 /* was set to #if 1 by configure/cmake/etc */")
|
||||
else()
|
||||
SET(ZCONF_UNISTD_LINE "#if 0 /* was set to #if 0 by configure/cmake/etc */")
|
||||
endif()
|
||||
if(NEED_PTRDIFF_T)
|
||||
SET(ZCONF_PTRDIFF_LINE "#if 1 /* was set to #if 1 by configure/cmake/etc */")
|
||||
else()
|
||||
SET(ZCONF_PTRDIFF_LINE "#ifdef NEED_PTRDIFF_T /* may be set to #if 1 by configure/cmake/etc */")
|
||||
endif()
|
||||
|
||||
set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib${SUFFIX}.pc)
|
||||
if(WITH_GZFILEOP)
|
||||
set(PKG_CONFIG_CFLAGS "-DWITH_GZFILEOP")
|
||||
endif()
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
|
||||
${ZLIB_PC} @ONLY)
|
||||
configure_file(${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h.cmakein
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zconf${SUFFIX}.h @ONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlib${SUFFIX}.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zlib${SUFFIX}.h @ONLY)
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/gzread.c.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/gzread.c @ONLY)
|
||||
|
||||
if (NOT ZLIB_SYMBOL_PREFIX STREQUAL "")
|
||||
add_feature_info(ZLIB_SYMBOL_PREFIX ON "Publicly exported symbols have a custom prefix")
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlib_name_mangling${SUFFIX}.h.in
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zlib_name_mangling${SUFFIX}.h @ONLY)
|
||||
else()
|
||||
add_feature_info(ZLIB_SYMBOL_PREFIX OFF "Publicly exported symbols DO NOT have a custom prefix")
|
||||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/zlib_name_mangling.h.empty
|
||||
${CMAKE_CURRENT_BINARY_DIR}/zlib_name_mangling${SUFFIX}.h COPYONLY)
|
||||
endif()
|
||||
# add_definitions(-DZLIB_SYMBOL_PREFIX=${ZLIB_SYMBOL_PREFIX}) # not needed
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add Target(s) to CMake Install for import into other projects
|
||||
#-----------------------------------------------------------------------------
|
||||
if (ZLIB_EXPORTED_TARGETS)
|
||||
INSTALL_TARGET_PDB (${ZLIB_LIB_TARGET} ${ZLIB_INSTALL_BIN_DIR} libraries)
|
||||
|
||||
install (
|
||||
TARGETS
|
||||
${install_targets}
|
||||
EXPORT
|
||||
${ZLIB_EXPORTED_TARGETS}
|
||||
LIBRARY DESTINATION ${ZLIB_INSTALL_LIB_DIR} COMPONENT libraries
|
||||
ARCHIVE DESTINATION ${ZLIB_INSTALL_LIB_DIR} COMPONENT libraries
|
||||
RUNTIME DESTINATION ${ZLIB_INSTALL_BIN_DIR} COMPONENT libraries
|
||||
FRAMEWORK DESTINATION ${ZLIB_INSTALL_FWRK_DIR} COMPONENT libraries
|
||||
PUBLIC_HEADER DESTINATION ${ZLIB_INSTALL_INCLUDE_DIR} COMPONENT headers
|
||||
)
|
||||
endif ()
|
||||
|
||||
include (CMakePackageConfigHelpers)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure the zlib-config.cmake file for the build directory
|
||||
#-----------------------------------------------------------------------------
|
||||
set (INCLUDE_INSTALL_DIR ${ZLIB_INSTALL_INCLUDE_DIR})
|
||||
set (SHARE_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/${ZLIB_INSTALL_CMAKE_DIR}" )
|
||||
set (CURRENT_BUILD_DIR "${CMAKE_CURRENT_BINARY_DIR}" )
|
||||
configure_package_config_file (
|
||||
${ZLIB_RESOURCES_DIR}/zlib-config.cmake.in
|
||||
"${ZLIB_BINARY_DIR}/zlib-config.cmake"
|
||||
INSTALL_DESTINATION "${ZLIB_INSTALL_CMAKE_DIR}"
|
||||
PATH_VARS INCLUDE_INSTALL_DIR SHARE_INSTALL_DIR CURRENT_BUILD_DIR
|
||||
INSTALL_PREFIX "${CMAKE_CURRENT_BINARY_DIR}"
|
||||
)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure the zlib-config.cmake file for the install directory
|
||||
#-----------------------------------------------------------------------------
|
||||
set (INCLUDE_INSTALL_DIR ${ZLIB_INSTALL_INCLUDE_DIR})
|
||||
set (SHARE_INSTALL_DIR "${CMAKE_INSTALL_PREFIX}/${ZLIB_INSTALL_CMAKE_DIR}" )
|
||||
set (CURRENT_BUILD_DIR "${CMAKE_INSTALL_PREFIX}")
|
||||
configure_package_config_file (
|
||||
${ZLIB_RESOURCES_DIR}/zlib-config.cmake.in
|
||||
"${ZLIB_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/zlib-config.cmake"
|
||||
INSTALL_DESTINATION "${ZLIB_INSTALL_CMAKE_DIR}"
|
||||
PATH_VARS INCLUDE_INSTALL_DIR SHARE_INSTALL_DIR CURRENT_BUILD_DIR
|
||||
)
|
||||
if (NOT ZLIB_EXTERNALLY_CONFIGURED)
|
||||
install (
|
||||
FILES ${ZLIB_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/zlib-config.cmake
|
||||
DESTINATION ${ZLIB_INSTALL_CMAKE_DIR}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Configure the ZLIB-config-version.cmake file for the install directory
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT ZLIB_EXTERNALLY_CONFIGURED)
|
||||
configure_file (
|
||||
${ZLIB_RESOURCES_DIR}/zlib-config-version.cmake.in
|
||||
${ZLIB_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/zlib-config-version.cmake @ONLY
|
||||
)
|
||||
install (
|
||||
FILES ${ZLIB_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/zlib-config-version.cmake
|
||||
DESTINATION ${ZLIB_INSTALL_CMAKE_DIR}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Add Target(s) to CMake Install for import into other projects
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT ZLIB_EXTERNALLY_CONFIGURED)
|
||||
install (
|
||||
EXPORT ${ZLIB_EXPORTED_TARGETS}
|
||||
DESTINATION ${ZLIB_INSTALL_CMAKE_DIR}
|
||||
FILE zlib-targets.cmake
|
||||
NAMESPACE ${PACKAGE_NAMESPACE}
|
||||
COMPONENT configinstall
|
||||
)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Export all exported targets to the build tree for use by parent project
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT ZLIB_EXTERNALLY_CONFIGURED)
|
||||
export (
|
||||
TARGETS ${ZLIB_LIBRARIES_TO_EXPORT}
|
||||
FILE zlib-targets.cmake
|
||||
NAMESPACE ${PACKAGE_NAMESPACE}
|
||||
)
|
||||
export (PACKAGE zlib)
|
||||
endif ()
|
||||
|
||||
add_feature_info(WITH_GZFILEOP WITH_GZFILEOP "Compile with support for gzFile related functions")
|
||||
add_feature_info(ZLIB_COMPAT ZLIB_COMPAT "Compile with zlib compatible API")
|
||||
add_feature_info(ZLIB_ENABLE_TESTS ZLIB_ENABLE_TESTS "Build test binaries")
|
||||
add_feature_info(ZLIBNG_ENABLE_TESTS ZLIBNG_ENABLE_TESTS "Test zlib-ng specific API")
|
||||
add_feature_info(WITH_SANITIZER WITH_SANITIZER "Enable sanitizer support")
|
||||
add_feature_info(WITH_GTEST WITH_GTEST "Build gtest_zlib")
|
||||
add_feature_info(WITH_FUZZERS WITH_FUZZERS "Build test/fuzz")
|
||||
add_feature_info(WITH_BENCHMARKS WITH_BENCHMARKS "Build test/benchmarks")
|
||||
add_feature_info(WITH_BENCHMARK_APPS WITH_BENCHMARK_APPS "Build application benchmarks")
|
||||
add_feature_info(WITH_OPTIM WITH_OPTIM "Build with optimisation")
|
||||
add_feature_info(WITH_NEW_STRATEGIES WITH_NEW_STRATEGIES "Use new strategies")
|
||||
add_feature_info(WITH_CRC32_CHORBA WITH_CRC32_CHORBA "Use optimized CRC32 algorithm Chorba")
|
||||
add_feature_info(WITH_NATIVE_INSTRUCTIONS WITH_NATIVE_INSTRUCTIONS
|
||||
"Instruct the compiler to use the full instruction set on this host (gcc/clang -march=native)")
|
||||
add_feature_info(WITH_RUNTIME_CPU_DETECTION WITH_RUNTIME_CPU_DETECTION "Build with runtime CPU detection")
|
||||
add_feature_info(WITH_MAINTAINER_WARNINGS WITH_MAINTAINER_WARNINGS "Build with project maintainer warnings")
|
||||
add_feature_info(WITH_CODE_COVERAGE WITH_CODE_COVERAGE "Enable code coverage reporting")
|
||||
add_feature_info(WITH_INFLATE_STRICT WITH_INFLATE_STRICT "Build with strict inflate distance checking")
|
||||
add_feature_info(WITH_INFLATE_ALLOW_INVALID_DIST WITH_INFLATE_ALLOW_INVALID_DIST "Build with zero fill for inflate invalid distances")
|
||||
|
||||
if(BASEARCH_ARM_FOUND)
|
||||
add_feature_info(WITH_ARMV8 WITH_ARMV8 "Build with ARMv8 CRC32 intrinsics")
|
||||
add_feature_info(WITH_NEON WITH_NEON "Build with NEON intrinsics")
|
||||
add_feature_info(WITH_ARMV6 WITH_ARMV6 "Build with ARMv6 SIMD")
|
||||
elseif(BASEARCH_PPC_FOUND)
|
||||
add_feature_info(WITH_ALTIVEC WITH_ALTIVEC "Build with AltiVec optimisations")
|
||||
add_feature_info(WITH_POWER8 WITH_POWER8 "Build with optimisations for POWER8")
|
||||
add_feature_info(WITH_POWER9 WITH_POWER9 "Build with optimisations for POWER9")
|
||||
elseif(BASEARCH_RISCV_FOUND)
|
||||
add_feature_info(WITH_RVV WITH_RVV "Build with RVV intrinsics")
|
||||
add_feature_info(WITH_RISCV_ZBC WITH_RISCV_ZBC "Build with RISCV ZBC")
|
||||
elseif(BASEARCH_S360_FOUND)
|
||||
add_feature_info(WITH_DFLTCC_DEFLATE WITH_DFLTCC_DEFLATE "Build with DFLTCC intrinsics for compression on IBM Z")
|
||||
add_feature_info(WITH_DFLTCC_INFLATE WITH_DFLTCC_INFLATE "Build with DFLTCC intrinsics for decompression on IBM Z")
|
||||
add_feature_info(WITH_CRC32_VX WITH_CRC32_VX "Build with vectorized CRC32 on IBM Z")
|
||||
elseif(BASEARCH_X86_FOUND)
|
||||
add_feature_info(WITH_AVX2 WITH_AVX2 "Build with AVX2")
|
||||
add_feature_info(WITH_AVX512 WITH_AVX512 "Build with AVX512")
|
||||
add_feature_info(WITH_AVX512VNNI WITH_AVX512VNNI "Build with AVX512 VNNI")
|
||||
add_feature_info(WITH_SSE2 WITH_SSE2 "Build with SSE2")
|
||||
add_feature_info(WITH_SSSE3 WITH_SSSE3 "Build with SSSE3")
|
||||
add_feature_info(WITH_SSE41 WITH_SSE41 "Build with SSE41")
|
||||
add_feature_info(WITH_SSE42 WITH_SSE42 "Build with SSE42")
|
||||
add_feature_info(WITH_PCLMULQDQ WITH_PCLMULQDQ "Build with PCLMULQDQ")
|
||||
add_feature_info(WITH_VPCLMULQDQ WITH_VPCLMULQDQ "Build with VPCLMULQDQ")
|
||||
endif()
|
||||
|
||||
add_feature_info(INSTALL_UTILS INSTALL_UTILS "Copy minigzip and minideflate during install")
|
||||
|
||||
FEATURE_SUMMARY(WHAT ALL INCLUDE_QUIET_PACKAGES)
|
||||
|
||||
@@ -1,206 +0,0 @@
|
||||
/* zconf.h -- configuration of the zlib compression library
|
||||
* Copyright (C) 1995-2016 Jean-loup Gailly, Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#ifndef ZCONF_H
|
||||
#define ZCONF_H
|
||||
|
||||
#include "zlib_name_mangling.h"
|
||||
|
||||
#if !defined(_WIN32) && defined(__WIN32__)
|
||||
# define _WIN32
|
||||
#endif
|
||||
|
||||
/* Clang macro for detecting declspec support
|
||||
* https://clang.llvm.org/docs/LanguageExtensions.html#has-declspec-attribute
|
||||
*/
|
||||
#ifndef __has_declspec_attribute
|
||||
# define __has_declspec_attribute(x) 0
|
||||
#endif
|
||||
|
||||
#if defined(ZLIB_CONST) && !defined(z_const)
|
||||
# define z_const const
|
||||
#else
|
||||
# define z_const
|
||||
#endif
|
||||
|
||||
/* Maximum value for memLevel in deflateInit2 */
|
||||
#ifndef MAX_MEM_LEVEL
|
||||
# define MAX_MEM_LEVEL 9
|
||||
#endif
|
||||
|
||||
/* Maximum value for windowBits in deflateInit2 and inflateInit2.
|
||||
* WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files
|
||||
* created by gzip. (Files created by minigzip can still be extracted by
|
||||
* gzip.)
|
||||
*/
|
||||
#ifndef MIN_WBITS
|
||||
# define MIN_WBITS 8 /* 256 LZ77 window */
|
||||
#endif
|
||||
#ifndef MAX_WBITS
|
||||
# define MAX_WBITS 15 /* 32K LZ77 window */
|
||||
#endif
|
||||
|
||||
/* The memory requirements for deflate are (in bytes):
|
||||
(1 << (windowBits+2)) + (1 << (memLevel+9))
|
||||
that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values)
|
||||
plus a few kilobytes for small objects. For example, if you want to reduce
|
||||
the default memory requirements from 256K to 128K, compile with
|
||||
make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7"
|
||||
Of course this will generally degrade compression (there's no free lunch).
|
||||
|
||||
The memory requirements for inflate are (in bytes) 1 << windowBits
|
||||
that is, 32K for windowBits=15 (default value) plus about 7 kilobytes
|
||||
for small objects.
|
||||
*/
|
||||
|
||||
/* Type declarations */
|
||||
|
||||
|
||||
#ifndef OF /* function prototypes */
|
||||
# define OF(args) args
|
||||
#endif
|
||||
|
||||
#ifdef ZLIB_INTERNAL
|
||||
# define Z_INTERNAL ZLIB_INTERNAL
|
||||
#endif
|
||||
|
||||
/* If building or using zlib as a DLL, define ZLIB_DLL.
|
||||
* This is not mandatory, but it offers a little performance increase.
|
||||
*/
|
||||
#if defined(ZLIB_DLL) && (defined(_WIN32) || (__has_declspec_attribute(dllexport) && __has_declspec_attribute(dllimport)))
|
||||
# ifdef Z_INTERNAL
|
||||
# define Z_EXTERN extern __declspec(dllexport)
|
||||
# else
|
||||
# define Z_EXTERN extern __declspec(dllimport)
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* If building or using zlib with the WINAPI/WINAPIV calling convention,
|
||||
* define ZLIB_WINAPI.
|
||||
* Caution: the standard ZLIB1.DLL is NOT compiled using ZLIB_WINAPI.
|
||||
*/
|
||||
#if defined(ZLIB_WINAPI) && defined(_WIN32)
|
||||
# ifndef WIN32_LEAN_AND_MEAN
|
||||
# define WIN32_LEAN_AND_MEAN
|
||||
# endif
|
||||
# include <windows.h>
|
||||
/* No need for _export, use ZLIB.DEF instead. */
|
||||
/* For complete Windows compatibility, use WINAPI, not __stdcall. */
|
||||
# define Z_EXPORT WINAPI
|
||||
# define Z_EXPORTVA WINAPIV
|
||||
#endif
|
||||
|
||||
#ifndef Z_EXTERN
|
||||
# define Z_EXTERN extern
|
||||
#endif
|
||||
#ifndef Z_EXPORT
|
||||
# define Z_EXPORT
|
||||
#endif
|
||||
#ifndef Z_EXPORTVA
|
||||
# define Z_EXPORTVA
|
||||
#endif
|
||||
|
||||
/* Conditional exports */
|
||||
#define ZNG_CONDEXPORT Z_INTERNAL
|
||||
|
||||
/* For backwards compatibility */
|
||||
|
||||
#ifndef ZEXTERN
|
||||
# define ZEXTERN Z_EXTERN
|
||||
#endif
|
||||
#ifndef ZEXPORT
|
||||
# define ZEXPORT Z_EXPORT
|
||||
#endif
|
||||
#ifndef ZEXPORTVA
|
||||
# define ZEXPORTVA Z_EXPORTVA
|
||||
#endif
|
||||
#ifndef FAR
|
||||
# define FAR
|
||||
#endif
|
||||
|
||||
/* Legacy zlib typedefs for backwards compatibility. Don't assume stdint.h is defined. */
|
||||
typedef unsigned char Byte;
|
||||
typedef Byte Bytef;
|
||||
|
||||
typedef unsigned int uInt; /* 16 bits or more */
|
||||
typedef unsigned long uLong; /* 32 bits or more */
|
||||
|
||||
typedef char charf;
|
||||
typedef int intf;
|
||||
typedef uInt uIntf;
|
||||
typedef uLong uLongf;
|
||||
|
||||
typedef void const *voidpc;
|
||||
typedef void *voidpf;
|
||||
typedef void *voidp;
|
||||
|
||||
typedef unsigned int z_crc_t;
|
||||
|
||||
#ifdef HAVE_UNISTD_H /* may be set to #if 1 by configure/cmake/etc */
|
||||
# define Z_HAVE_UNISTD_H
|
||||
#endif
|
||||
|
||||
#ifdef NEED_PTRDIFF_T /* may be set to #if 1 by configure/cmake/etc */
|
||||
typedef PTRDIFF_TYPE ptrdiff_t;
|
||||
#endif
|
||||
|
||||
#include <sys/types.h> /* for off_t */
|
||||
|
||||
#include <stddef.h> /* for wchar_t and NULL */
|
||||
|
||||
/* a little trick to accommodate both "#define _LARGEFILE64_SOURCE" and
|
||||
* "#define _LARGEFILE64_SOURCE 1" as requesting 64-bit operations, (even
|
||||
* though the former does not conform to the LFS document), but considering
|
||||
* both "#undef _LARGEFILE64_SOURCE" and "#define _LARGEFILE64_SOURCE 0" as
|
||||
* equivalently requesting no 64-bit operations
|
||||
*/
|
||||
#if defined(_LARGEFILE64_SOURCE) && -_LARGEFILE64_SOURCE - -1 == 1
|
||||
# undef _LARGEFILE64_SOURCE
|
||||
#endif
|
||||
|
||||
#if defined(Z_HAVE_UNISTD_H) || defined(_LARGEFILE64_SOURCE)
|
||||
# include <unistd.h> /* for SEEK_*, off_t, and _LFS64_LARGEFILE */
|
||||
# ifndef z_off_t
|
||||
# define z_off_t off_t
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(_LFS64_LARGEFILE) && _LFS64_LARGEFILE-0
|
||||
# define Z_LFS64
|
||||
#endif
|
||||
|
||||
#if defined(_LARGEFILE64_SOURCE) && defined(Z_LFS64)
|
||||
# define Z_LARGE64
|
||||
#endif
|
||||
|
||||
#if defined(_FILE_OFFSET_BITS) && _FILE_OFFSET_BITS-0 == 64 && defined(Z_LFS64)
|
||||
# define Z_WANT64
|
||||
#endif
|
||||
|
||||
#if !defined(SEEK_SET)
|
||||
# define SEEK_SET 0 /* Seek from beginning of file. */
|
||||
# define SEEK_CUR 1 /* Seek from current position. */
|
||||
# define SEEK_END 2 /* Set file pointer to EOF plus "offset" */
|
||||
#endif
|
||||
|
||||
#ifndef z_off_t
|
||||
# define z_off_t long
|
||||
#endif
|
||||
|
||||
#if !defined(_WIN32) && defined(Z_LARGE64)
|
||||
# define z_off64_t off64_t
|
||||
#else
|
||||
# if defined(__MSYS__)
|
||||
# define z_off64_t _off64_t
|
||||
# elif defined(_WIN32) && !defined(__GNUC__)
|
||||
# define z_off64_t __int64
|
||||
# else
|
||||
# define z_off64_t z_off_t
|
||||
# endif
|
||||
#endif
|
||||
|
||||
typedef size_t z_size_t;
|
||||
|
||||
#endif /* ZCONF_H */
|
||||
@@ -1,42 +0,0 @@
|
||||
#-----------------------------------------------------------------------------
|
||||
# ZLIB Version file for install directory
|
||||
#-----------------------------------------------------------------------------
|
||||
|
||||
set (PACKAGE_VERSION "@ZLIB_VERSION_STRING@")
|
||||
|
||||
if("${PACKAGE_VERSION}" VERSION_LESS "${PACKAGE_FIND_VERSION}" )
|
||||
set(PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
else()
|
||||
if ("${PACKAGE_FIND_VERSION_MAJOR}" STREQUAL "@ZLIB_VERSION_MAJOR@")
|
||||
|
||||
# exact match for version @ZLIB_VERSION_MAJOR@.@ZLIB_VERSION_MINOR@
|
||||
if ("${PACKAGE_FIND_VERSION_MINOR}" STREQUAL "@ZLIB_VERSION_MINOR@")
|
||||
|
||||
# compatible with any version @ZLIB_VERSION_MAJOR@.@ZLIB_VERSION_MINOR@.x
|
||||
set (PACKAGE_VERSION_COMPATIBLE TRUE)
|
||||
|
||||
if ("${PACKAGE_FIND_VERSION_PATCH}" STREQUAL "@ZLIB_VERSION_RELEASE@")
|
||||
set (PACKAGE_VERSION_EXACT TRUE)
|
||||
|
||||
if ("${PACKAGE_FIND_VERSION_TWEAK}" STREQUAL "@ZLIB_VERSION_SUBRELEASE@")
|
||||
# not using this yet
|
||||
endif ()
|
||||
endif ()
|
||||
else ()
|
||||
set (PACKAGE_VERSION_COMPATIBLE FALSE)
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# if the installed or the using project don't have CMAKE_SIZEOF_VOID_P set, ignore it:
|
||||
if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "" OR "@CMAKE_SIZEOF_VOID_P@" STREQUAL "")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# check that the installed version has the same 32/64bit-ness as the one which is currently searching:
|
||||
if(NOT "${CMAKE_SIZEOF_VOID_P}" STREQUAL "@CMAKE_SIZEOF_VOID_P@")
|
||||
math(EXPR installedBits "@CMAKE_SIZEOF_VOID_P@ * 8")
|
||||
set(PACKAGE_VERSION "${PACKAGE_VERSION} (${installedBits}bit)")
|
||||
set(PACKAGE_VERSION_UNSUITABLE TRUE)
|
||||
endif()
|
||||
|
||||
@@ -1,57 +0,0 @@
|
||||
#-----------------------------------------------------------------------------
|
||||
# ZLIB Config file for compiling against ZLIB build directory
|
||||
#-----------------------------------------------------------------------------
|
||||
@PACKAGE_INIT@
|
||||
|
||||
string(TOUPPER @ZLIB_PACKAGE@ ZLIB_PACKAGE_NAME)
|
||||
|
||||
set (${ZLIB_PACKAGE_NAME}_VALID_COMPONENTS static shared)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# User Options
|
||||
#-----------------------------------------------------------------------------
|
||||
set (${ZLIB_PACKAGE_NAME}_EXPORT_LIBRARIES @ZLIB_LIBRARIES_TO_EXPORT@)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Directories
|
||||
#-----------------------------------------------------------------------------
|
||||
set (${ZLIB_PACKAGE_NAME}_INCLUDE_DIR "@PACKAGE_INCLUDE_INSTALL_DIR@")
|
||||
|
||||
set (${ZLIB_PACKAGE_NAME}_SHARE_DIR "@PACKAGE_SHARE_INSTALL_DIR@")
|
||||
set_and_check (${ZLIB_PACKAGE_NAME}_BUILD_DIR "@PACKAGE_CURRENT_BUILD_DIR@")
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Version Strings
|
||||
#-----------------------------------------------------------------------------
|
||||
set (${ZLIB_PACKAGE_NAME}_VERSION_STRING @ZLIB_VERSION_STRING@)
|
||||
set (${ZLIB_PACKAGE_NAME}_VERSION_MAJOR @ZLIB_VERSION_MAJOR@)
|
||||
set (${ZLIB_PACKAGE_NAME}_VERSION_MINOR @ZLIB_VERSION_MINOR@)
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
# Don't include targets if this file is being picked up by another
|
||||
# project which has already built ZLIB as a subproject
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT TARGET "@ZLIB_PACKAGE@")
|
||||
include (@PACKAGE_SHARE_INSTALL_DIR@/@ZLIB_PACKAGE@@ZLIB_PACKAGE_EXT@-targets.cmake)
|
||||
endif ()
|
||||
|
||||
# Handle default component(static) :
|
||||
if (NOT ${ZLIB_PACKAGE_NAME}_FIND_COMPONENTS)
|
||||
set (${ZLIB_PACKAGE_NAME}_FIND_COMPONENTS static)
|
||||
set (${ZLIB_PACKAGE_NAME}_FIND_REQUIRED_static true)
|
||||
endif ()
|
||||
|
||||
# Handle requested components:
|
||||
list (REMOVE_DUPLICATES ${ZLIB_PACKAGE_NAME}_FIND_COMPONENTS)
|
||||
foreach (comp IN LISTS ${ZLIB_PACKAGE_NAME}_FIND_COMPONENTS)
|
||||
list (FIND ${ZLIB_PACKAGE_NAME}_EXPORT_LIBRARIES "@ZLIB_LIB_CORENAME@-${comp}" HAVE_COMP)
|
||||
if (${HAVE_COMP} LESS 0)
|
||||
set (${ZLIB_PACKAGE_NAME}_${comp}_FOUND 0)
|
||||
else ()
|
||||
set (${ZLIB_PACKAGE_NAME}_${comp}_FOUND 1)
|
||||
string(TOUPPER ${ZLIB_PACKAGE_NAME}_${comp}_LIBRARY COMP_LIBRARY)
|
||||
set (${COMP_LIBRARY} ${${COMP_LIBRARY}} @ZLIB_LIB_CORENAME@-${comp})
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
||||
check_required_components (${ZLIB_PACKAGE_NAME})
|
||||
@@ -48,8 +48,7 @@ if (NOT DEFINED CMAKE_DEBUG_POSTFIX)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
set (HDF5_ALLOW_EXTERNAL_SUPPORT "TGZ" CACHE STRING "Allow External Library Building (NO GIT TGZ)" FORCE)
|
||||
set_property (CACHE HDF5_ALLOW_EXTERNAL_SUPPORT PROPERTY STRINGS NO GIT TGZ)
|
||||
set (HDF5_ALLOW_EXTERNAL_SUPPORT "TGZ" CACHE STRING "If not set to NO, specifies where to obtain sources when building or using external libraries (NO GIT TGZ)" FORCE)
|
||||
|
||||
########################
|
||||
# compression options
|
||||
|
||||
@@ -24,7 +24,7 @@ endif ()
|
||||
if (NOT TEST_OUTPUT) # the output file to capture the test program output
|
||||
message (FATAL_ERROR "Require TEST_OUTPUT to be defined")
|
||||
endif ()
|
||||
if (NOT TEST_EXPECT)
|
||||
if (NOT DEFINED TEST_EXPECT)
|
||||
message (VERBOSE "Optional TEST_EXPECT is not defined")
|
||||
endif ()
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ if (LOCAL_MEMCHECK_TEST)
|
||||
find_program(CTEST_MEMORYCHECK_COMMAND NAMES valgrind)
|
||||
endif()
|
||||
set (CTEST_CONFIGURE_COMMAND
|
||||
"${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/mccacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_CONFIGURATION_TYPE} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" ${CTEST_CONFIGURE_ARCHITECTURE} ${CTEST_CONFIGURE_TOOLSET} \"${CTEST_SOURCE_DIRECTORY}\""
|
||||
"${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/MemcheckCacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_CONFIGURATION_TYPE} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" ${CTEST_CONFIGURE_ARCHITECTURE} ${CTEST_CONFIGURE_TOOLSET} \"${CTEST_SOURCE_DIRECTORY}\""
|
||||
)
|
||||
else ()
|
||||
if (LOCAL_COVERAGE_TEST)
|
||||
|
||||
@@ -72,7 +72,6 @@ set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRIN
|
||||
#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_ZLIB_SUPPORT:BOOL=OFF")
|
||||
### enable using ext szip
|
||||
#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON")
|
||||
#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_ENCODING:BOOL=ON")
|
||||
|
||||
#### package examples ####
|
||||
#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_PACK_EXAMPLES:BOOL=ON -DHDF5_EXAMPLES_COMPRESSED:STRING=HDF5Examples-2.0.3-Source.tar.gz -DHDF5_EXAMPLES_COMPRESSED_DIR:PATH=${CTEST_SCRIPT_DIRECTORY}")
|
||||
|
||||
@@ -124,21 +124,23 @@ else ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (${HDF5_PACKAGE_NAME}_PROVIDES_ZLIB_SUPPORT)
|
||||
if (NOT @ZLIB_USE_EXTERNAL@)
|
||||
if (${HDF5_PACKAGE_NAME}_PROVIDES_ZLIB_SUPPORT AND NOT @ZLIB_USE_EXTERNAL@)
|
||||
if (NOT @HDF5_USE_ZLIB_NG@)
|
||||
if (@HDF5_MODULE_MODE_ZLIB@)
|
||||
# Expect that the default shared library is expected with FindZLIB.cmake
|
||||
find_dependency (ZLIB MODULE)
|
||||
else ()
|
||||
find_dependency (ZLIB NAMES @Z_PACKAGE_NAME@ CONFIG OPTIONAL_COMPONENTS @ZLIB_SEARCH_TYPE@)
|
||||
endif ()
|
||||
else ()
|
||||
find_dependency (@ZLIBNG_PACKAGE_NAME@ OPTIONAL_COMPONENTS @ZLIBNG_SEARCH_TYPE@)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (${HDF5_PACKAGE_NAME}_PROVIDES_SZIP_SUPPORT)
|
||||
if (NOT @SZIP_USE_EXTERNAL@)
|
||||
find_dependency (@LIBAEC_PACKAGE_NAME@ OPTIONAL_COMPONENTS @LIBAEC_SEARCH_TYPE@)
|
||||
endif ()
|
||||
# If szip/libaec support was enabled and libaec was found on the system at build
|
||||
# time, locate libaec to propagate the dependency
|
||||
if (${HDF5_PACKAGE_NAME}_PROVIDES_SZIP_SUPPORT AND NOT @SZIP_USE_EXTERNAL@)
|
||||
find_dependency (@LIBAEC_PACKAGE_NAME@ OPTIONAL_COMPONENTS @LIBAEC_SEARCH_TYPE@)
|
||||
endif ()
|
||||
|
||||
#-----------------------------------------------------------------------------
|
||||
@@ -179,15 +181,55 @@ set (${HDF5_PACKAGE_NAME}_VERSION_MINOR @HDF5_VERSION_MINOR@)
|
||||
# project which has already built hdf5 as a subproject
|
||||
#-----------------------------------------------------------------------------
|
||||
if (NOT TARGET "@HDF5_PACKAGE@")
|
||||
if (${HDF5_PACKAGE_NAME}_PROVIDES_ZLIB_SUPPORT)
|
||||
if (${HDF5_PACKAGE_NAME}_PACKAGE_EXTLIBS AND @ZLIB_USE_EXTERNAL@)
|
||||
include ("@PACKAGE_SHARE_INSTALL_DIR@/@ZLIB_PACKAGE_NAME@@HDF_PACKAGE_EXT@-targets.cmake")
|
||||
# If zlib support was enabled and zlib was built from an external source,
|
||||
# include the installed CMake targets file so the targets are available
|
||||
if (${HDF5_PACKAGE_NAME}_PROVIDES_ZLIB_SUPPORT AND @ZLIB_USE_EXTERNAL@)
|
||||
if (@HDF5_USE_ZLIB_NG@)
|
||||
set (_zlib_targets_file_name "${PACKAGE_PREFIX_DIR}/@HDF5_ZLIBNG_INSTALL_CMAKEDIR@/@HDF5_ZLIBNG_INSTALL_NAME@@HDF_PACKAGE_EXT@-targets.cmake")
|
||||
else ()
|
||||
string (TOUPPER "@HDF5_ZLIB_INSTALL_NAME@" ${HDF5_PACKAGE_NAME}_ZLIB_INSTALL_NAME_UPPER)
|
||||
set (_zlib_targets_file_name "${PACKAGE_PREFIX_DIR}/@HDF5_ZLIB_INSTALL_CMAKEDIR@/${${HDF5_PACKAGE_NAME}_ZLIB_INSTALL_NAME_UPPER}@HDF_PACKAGE_EXT@Config.cmake")
|
||||
unset (${HDF5_PACKAGE_NAME}_ZLIB_INSTALL_NAME_UPPER)
|
||||
|
||||
if (@HDF5_USE_ZLIB_STATIC@)
|
||||
set (ZLIB_FIND_COMPONENTS "static")
|
||||
else ()
|
||||
set (ZLIB_FIND_COMPONENTS "shared")
|
||||
endif ()
|
||||
endif ()
|
||||
include ("${_zlib_targets_file_name}" OPTIONAL RESULT_VARIABLE _zlib_loaded)
|
||||
unset (ZLIB_FIND_COMPONENTS)
|
||||
unset (_zlib_targets_file_name)
|
||||
if (NOT _zlib_loaded)
|
||||
if (@HDF5_USE_ZLIB_NG@)
|
||||
set (_zlib_name "zlib-ng")
|
||||
else ()
|
||||
set (_zlib_name "zlib")
|
||||
endif ()
|
||||
set (${HDF5_PACKAGE_NAME}_FOUND FALSE)
|
||||
set (${HDF5_PACKAGE_NAME}_NOT_FOUND_MESSAGE "Couldn't locate ${_zlib_name} targets file ${_zlib_targets_file_name}")
|
||||
unset (_zlib_name)
|
||||
unset (_zlib_loaded)
|
||||
return ()
|
||||
endif ()
|
||||
unset (_zlib_loaded)
|
||||
endif ()
|
||||
if (${HDF5_PACKAGE_NAME}_PROVIDES_SZIP_SUPPORT)
|
||||
if (${HDF5_PACKAGE_NAME}_PACKAGE_EXTLIBS AND @SZIP_USE_EXTERNAL@)
|
||||
include ("@PACKAGE_SHARE_INSTALL_DIR@/@LIBAEC_PACKAGE_NAME@@HDF_PACKAGE_EXT@-targets.cmake")
|
||||
# If szip/libaec support was enabled and libaec was built from an external source,
|
||||
# include the installed CMake targets file so the targets are available
|
||||
if (${HDF5_PACKAGE_NAME}_PROVIDES_SZIP_SUPPORT AND @SZIP_USE_EXTERNAL@)
|
||||
if (@HDF5_USE_LIBAEC_STATIC@)
|
||||
set (_libaec_targets_file_name "@PACKAGE_SHARE_INSTALL_DIR@/@LIBAEC_PACKAGE_NAME@@HDF_PACKAGE_EXT@_static-targets.cmake")
|
||||
else ()
|
||||
set (_libaec_targets_file_name "@PACKAGE_SHARE_INSTALL_DIR@/@LIBAEC_PACKAGE_NAME@@HDF_PACKAGE_EXT@_shared-targets.cmake")
|
||||
endif ()
|
||||
include ("${_libaec_targets_file_name}" OPTIONAL RESULT_VARIABLE _libaec_loaded)
|
||||
if (NOT _libaec_loaded)
|
||||
set (${HDF5_PACKAGE_NAME}_FOUND FALSE)
|
||||
set (${HDF5_PACKAGE_NAME}_NOT_FOUND_MESSAGE "Couldn't locate libaec targets file ${_libaec_targets_file_name}")
|
||||
unset (_libaec_loaded)
|
||||
return ()
|
||||
endif ()
|
||||
unset (_libaec_loaded)
|
||||
endif ()
|
||||
include ("@PACKAGE_SHARE_INSTALL_DIR@/@HDF5_PACKAGE@@HDF_PACKAGE_EXT@-targets.cmake")
|
||||
# OPTIONAL: some packages ship HDF5 in such a way that the static and
|
||||
|
||||
@@ -658,9 +658,9 @@ The ci-StdPlugins preset sets the following cache variables:
|
||||
The ci-PluginsVars preset sets the following cache variables (see the https://\SRCURL/config/CacheURLs.cmake file for the latest versions):
|
||||
\li "HDF5_ENABLE_PLUGIN_SUPPORT": "ON"
|
||||
\li "H5PL_ALLOW_EXTERNAL_SUPPORT": {"type": "STRING", "value": "TGZ"}
|
||||
\li "PLUGIN_PACKAGE_NAME": {"type": "STRING", "value": "pl"}
|
||||
\li "PLUGIN_TGZ_ORIGPATH": {"type": "STRING", "value": "hdf5_plugins download"}
|
||||
\li "PLUGIN_TGZ_NAME": {"type": "STRING", "value": "hdf5_plugins-master.tar.gz"}
|
||||
\li "HDF5_FILTER_PLUGINS_PACKAGE_NAME": {"type": "STRING", "value": "h5pl"}
|
||||
\li "HDF5_FILTER_PLUGINS_TGZ_ORIGPATH": {"type": "STRING", "value": "hdf5_plugins download"}
|
||||
\li "HDF5_FILTER_PLUGINS_TGZ_NAME": {"type": "STRING", "value": "hdf5_plugins-master.tar.gz"}
|
||||
|
||||
The ci-base-plugins preset sets the following cache variables (see the https://\SRCURL/config/CacheURLs.cmake file for the latest versions):
|
||||
\li "BITGROOM_PACKAGE_NAME": {"type": "STRING", "value": "bitgroom"},
|
||||
|
||||
@@ -14,7 +14,6 @@ A comprehensive analysis of the HDF5 CMake-only build system and CI/CD infrastru
|
||||
#### Main Configuration Files
|
||||
- `CMakeLists.txt` - Root build configuration
|
||||
- `CMakeBuildOptions.cmake` - Centralized build option definitions
|
||||
- `CMakeFilters.cmake` - Compression filter support (zlib, szip, libaec)
|
||||
- `CMakeTests.cmake` - Testing infrastructure configuration
|
||||
- `CMakeInstallation.cmake` - Installation and packaging setup
|
||||
- `CMakeVOL.cmake` - Virtual Object Layer connector support
|
||||
|
||||
@@ -15,6 +15,7 @@ For releases prior to version 2.0.0, please see the release.txt file and for mor
|
||||
## 📖 Contents
|
||||
* [Executive Summary](CHANGELOG.md#execsummary)
|
||||
* [Breaking Changes](CHANGELOG.md#%EF%B8%8F-breaking-changes)
|
||||
* [Deprecations](CHANGELOG.md#-deprecations)
|
||||
* [New Features & Improvements](CHANGELOG.md#-new-features--improvements)
|
||||
* [Bug Fixes](CHANGELOG.md#-bug-fixes)
|
||||
* [Support for new platforms and languages](CHANGELOG.md#-support-for-new-platforms-and-languages)
|
||||
@@ -40,6 +41,7 @@ For releases prior to version 2.0.0, please see the release.txt file and for mor
|
||||
|
||||
## Enhanced Features:
|
||||
|
||||
- Made several improvements to the CMake logic for handling filter libraries
|
||||
|
||||
## Java Enhancements:
|
||||
|
||||
@@ -50,11 +52,39 @@ We would like to thank the many HDF5 community members who contributed to this r
|
||||
|
||||
# ⚠️ Breaking Changes
|
||||
|
||||
# 🪦 Deprecations
|
||||
|
||||
- The CMake variable `ZLIB_GIT_BRANCH` has been deprecated in favor of `ZLIB_GIT_TAG`
|
||||
- The CMake variable `ZLIBNG_GIT_BRANCH` has been deprecated in favor of `ZLIBNG_GIT_TAG`
|
||||
- The CMake variable `LIBAEC_GIT_BRANCH` has been deprecated in favor of `LIBAEC_GIT_TAG`
|
||||
- The CMake variable `PLUGIN_GIT_BRANCH` has been deprecated in favor of `HDF5_FILTER_PLUGINS_GIT_TAG`
|
||||
- The CMake variable `PLUGIN_GIT_URL` has been deprecated in favor of `HDF5_FILTER_PLUGINS_GIT_URL`
|
||||
- The CMake variable `PLUGIN_TGZ_NAME` has been deprecated in favor of `HDF5_FILTER_PLUGINS_TGZ_NAME`
|
||||
- The CMake variable `PLUGIN_TGZ_ORIGPATH` has been deprecated in favor of `HDF5_FILTER_PLUGINS_TGZ_ORIGPATH`
|
||||
- The CMake variable `PLUGIN_PACKAGE_NAME` has been deprecated in favor of `HDF5_FILTER_PLUGINS_PACKAGE_NAME`
|
||||
|
||||
# 🚀 New Features & Improvements
|
||||
|
||||
## Configuration
|
||||
|
||||
### Updated external building of zlib, zlib-ng and libaec to not use a patching process
|
||||
|
||||
When building these libraries from external sources while building HDF5, the library previously used a patching process to adapt the libraries to its own build process. The sources for these libraries are no longer patched and build directly from the sources of the latest upstream releases (currently, zlib 1.3.2, zlib-ng 2.3.3 and libaec 1.1.6). This also fixed an issue with the build of zlib-ng failing due to updates that were made since the last version that HDF5 was patching the sources for.
|
||||
|
||||
Fixes GitHub issue #6204
|
||||
|
||||
### Fixed an issue where CMake-built installations of zlib libraries couldn't be located on a system
|
||||
|
||||
An incorrect package name was being supplied to CMake's find_package() function when attempting to locate zlib libraries on the system in Config mode. The package name has been corrected and CMake-built zlib libraries can now be located.
|
||||
|
||||
### Fixed an issue where static zlib libraries couldn't be found on the system
|
||||
|
||||
The value of the HDF5 CMake variable `HDF5_USE_ZLIB_STATIC` was previously used incorrectly when locating zlib libraries on the system with CMake's find_package() function, causing it to have no effect. This has been fixed and static zlib libraries can now be located.
|
||||
|
||||
### Added a CMake module to locate zlib-ng for zlib support
|
||||
|
||||
A new `FindZLIBNG.cmake` CMake module has been added. This module is intended to locate zlib-ng on the system for zlib support in HDF5 when zlib-ng was built with Autotools instead of CMake. When zlib-ng support is enabled in HDF5 with the `HDF5_ENABLE_ZLIB_SUPPORT` and `HDF5_USE_ZLIB_NG` options, this module will first check for an existing CMake-built zlib-ng and use that if it's available. Otherwise, the module will heuristically search for zlib-ng on the system. If necessary, the module can be hinted toward a particular zlib-ng installation by setting the CMake variable `ZLIBNG_ROOT` to point to a directory.
|
||||
|
||||
### Added a CMake module to locate libaec for SZIP support
|
||||
|
||||
A new `Findlibaec.cmake` CMake module has been added. This module is intended to locate libaec on the system for SZIP support in HDF5 when libaec was built with Autotools instead of CMake. When SZIP support is enabled in HDF5 with the `HDF5_ENABLE_SZIP_SUPPORT` option, this module will first check for an existing CMake-built libaec and use that if it's available. Otherwise, the module will heuristically search for libaec on the system. If necessary, the module can be hinted toward a particular libaec installation by setting the CMake variable `libaec_ROOT` to point to a directory. If it is known that a CMake-built libaec installation exists on the system in a non-standard location, the CMake variable `libaec_DIR` can instead be set to a directory containing a `libaec-config.cmake` file to cause the module to prefer that libaec installation.
|
||||
|
||||
+14
-215
@@ -367,109 +367,9 @@ Go through these steps:
|
||||
|
||||
1. We suggest you obtain the latest CMake from the Kitware web site. The HDF5 2."X"."Y" product **requires a minimum CMake version 3.26**.
|
||||
|
||||
2. If you plan to use Zlib or Szip (aka libaec):
|
||||
2. If you plan to use Zlib/Zlib-ng, Szip (aka libaec) and/or HDF5 filter plugins, refer to the instructions in [INSTALL_Filters.md](./INSTALL_Filters.md).
|
||||
|
||||
1. Download the binary packages and install them in a central location. For example on Windows, create a folder `extlibs` and install the packages there. Add the following CMake options:
|
||||
|
||||
```
|
||||
-DZLIB_LIBRARY:FILEPATH=some_location/lib/zlib.lib
|
||||
-DZLIB_INCLUDE_DIR:PATH=some_location/include
|
||||
-DZLIB_USE_EXTERNAL:BOOL=OFF
|
||||
-DSZIP_LIBRARY:FILEPATH=some_location/lib/libszaec.lib
|
||||
-DSZIP_INCLUDE_DIR:PATH=some_location/include
|
||||
-Dlibaec_LIBRARY:FILEPATH=some_location/lib/libaec.lib
|
||||
-Dlibaec_INCLUDE_DIR:PATH=some_location/include
|
||||
-DSZIP_USE_EXTERNAL:BOOL=OFF
|
||||
```
|
||||
where `some_location` is the full path to the `extlibs` folder.
|
||||
Also if the appropriate environment variable is set, the above options are not required:
|
||||
```
|
||||
set(ENV{ZLIB_ROOT} "some_location")
|
||||
set(ENV{SZIP_ROOT} "some_location")
|
||||
set(ENV{libaec_ROOT} "some_location")
|
||||
```
|
||||
|
||||
Note that if there is a problem finding the libraries, try adding the
|
||||
CMake variable `CMAKE_FIND_DEBUG_MODE:BOOL=ON` to the command line.
|
||||
|
||||
2. Use source packages from a GIT server by adding the following CMake
|
||||
options:
|
||||
|
||||
`HDF5_ALLOW_EXTERNAL_SUPPORT:STRING="GIT"`<br/>
|
||||
`ZLIB_GIT_URL:STRING="https://some_location/zlib"` or `ZLIBNG_GIT_URL:STRING="https://some_location/zlibng"`<br/>
|
||||
`ZLIB_GIT_BRANCH="some_branch"` or `ZLIBNG_GIT_BRANCH="some_branch"`<br/>
|
||||
`SZIP_GIT_URL:STRING="https://some_location/szip"`<br/>
|
||||
`SZIP_GIT_BRANCH="some_branch"`<br/>
|
||||
`LIBAEC_GIT_URL:STRING="https://some_location/libaec"`<br/>
|
||||
`LIBAEC_GIT_BRANCH="some_branch"`<br/>
|
||||
|
||||
where `some_location` is the URL to the GIT repository and `some_branch` is a branch in the repository, usually
|
||||
the default. Also set `CMAKE_BUILD_TYPE` to the configuration type.
|
||||
|
||||
3. Use source packages from a compressed file by adding the following
|
||||
CMake options:
|
||||
|
||||
`HDF5_ALLOW_EXTERNAL_SUPPORT:STRING="TGZ"`<br/>
|
||||
`ZLIB_TGZ_NAME:STRING="zlib_src.ext"` or `ZLIBNG_TGZ_NAME:STRING="zlibng_src.ext"`<br/>
|
||||
`LIBAEC_TGZ_NAME:STRING="libaec_src.ext"`<br/>
|
||||
`TGZPATH:STRING="some_location"`<br/>
|
||||
|
||||
where `some_location` is the URL or full path to the compressed
|
||||
file and `ext` is the type of compression file. Also set `CMAKE_BUILD_TYPE`
|
||||
to the configuration type during configuration. See the settings in the
|
||||
`config/cmake/cacheinit.cmake` file used for testing.
|
||||
|
||||
4. Use original source packages from a compressed file by adding the following
|
||||
CMake options:
|
||||
|
||||
`LIBAEC_TGZ_NAME:STRING="szip_src.ext"`<br/>
|
||||
`LIBAEC_TGZ_ORIGPATH:STRING="some_location"`<br/>
|
||||
`ZLIB_TGZ_NAME:STRING="zlib_src.ext"` or `ZLIBNG_TGZ_NAME:STRING="zlibng_src.ext"`<br/>
|
||||
`ZLIB_TGZ_ORIGPATH:STRING="some_location"` or Z`LIBNG_TGZ_ORIGPATH:STRING="some_location"`<br/>
|
||||
`HDF5_ALLOW_EXTERNAL_SUPPORT:STRING="TGZ"`
|
||||
|
||||
where `some_location` is the URL and by setting
|
||||
```
|
||||
ZLIB_USE_LOCALCONTENT:BOOL=OFF
|
||||
LIBAEC_USE_LOCALCONTENT:BOOL=OFF
|
||||
```
|
||||
or full path to the compressed file and `ext` is the type of compression file.
|
||||
Also set `CMAKE_BUILD_TYPE` to the configuration type during configuration.
|
||||
See the settings in the `config/cmake/cacheinit.cmake` used for testing.
|
||||
|
||||
The files can also be retrieved from a local path if necessary `TGZPATH:STRING="some_location"` by setting
|
||||
```
|
||||
ZLIB_USE_LOCALCONTENT:BOOL=ON
|
||||
LIBAEC_USE_LOCALCONTENT:BOOL=ON
|
||||
```
|
||||
|
||||
3. If you plan to use compression plugins:
|
||||
|
||||
1. Use source packages from an GIT server by adding the following CMake
|
||||
options:
|
||||
|
||||
```
|
||||
HDF5_ALLOW_EXTERNAL_SUPPORT:STRING="GIT"
|
||||
PLUGIN_GIT_URL:STRING="http://some_location/plugins"
|
||||
PLUGIN_GIT_BRANCH="some_branch"
|
||||
```
|
||||
|
||||
where `some_location` is the URL to the GIT repository and `some_branch` is
|
||||
a branch in the repository, usually the default. Also set
|
||||
`CMAKE_BUILD_TYPE` to the configuration type.
|
||||
|
||||
2. Use source packages from a compressed file by adding the following CMake options:
|
||||
```
|
||||
HDF5_ALLOW_EXTERNAL_SUPPORT:STRING="TGZ"
|
||||
PLUGIN_TGZ_NAME:STRING="plugin_src.ext"
|
||||
TGZPATH:STRING="some_location"
|
||||
```
|
||||
where `some_location` is the URL or full path to the compressed
|
||||
file and `ext` is the type of compression file. Also set `CMAKE_BUILD_TYPE`
|
||||
to the configuration type during configuration. See the settings in the
|
||||
`config/cmake/cacheinit.cmake` file used for testing.
|
||||
|
||||
4. If you are building on Apple Darwin platforms, you should add the following options:
|
||||
3. If you are building on Apple Darwin platforms, you should add the following options:
|
||||
|
||||
* Compiler choice - use Xcode by setting the `CC` and `CXX` environment variables.
|
||||
|
||||
@@ -480,9 +380,9 @@ Go through these steps:
|
||||
CMAKE_ANSI_CFLAGS:STRING=-fPIC
|
||||
CTEST_USE_LAUNCHERS:BOOL=ON
|
||||
|
||||
5. Windows developers should install NSIS or WiX to create an install image with CPack. Visual Studio Express users will not be able to package HDF5 into an install image executable.
|
||||
4. Windows developers should install NSIS or WiX to create an install image with CPack. Visual Studio Express users will not be able to package HDF5 into an install image executable.
|
||||
|
||||
6. Developers can copy the `config/cmake/cacheinit.cmake` file and alter the settings for the developers' environment. Then the only options needed on the command line are those options that are different. Example using the default cache file:
|
||||
5. Developers can copy the `config/cmake/cacheinit.cmake` file and alter the settings for the developers' environment. Then the only options needed on the command line are those options that are different. Example using the default cache file:
|
||||
|
||||
```cmd
|
||||
cmake -C ../config/cmake/cacheinit.cmake ^
|
||||
@@ -493,7 +393,7 @@ Go through these steps:
|
||||
..
|
||||
```
|
||||
|
||||
7. CMake uses a toolchain of utilities to compile, link libraries,
|
||||
6. CMake uses a toolchain of utilities to compile, link libraries,
|
||||
create archives, and other tasks to drive the build. The toolchain
|
||||
utilities available are determined by the languages enabled. In normal
|
||||
builds, CMake automatically determines the toolchain for host builds
|
||||
@@ -592,7 +492,9 @@ turn specific options on or off for testing using the following command line wit
|
||||
|
||||
cmake -C <sourcepath>/config/cmake/cacheinit.cmake -G "<generator>" [-D<options>] <sourcepath>
|
||||
|
||||
Where `<generator>` is (examples):
|
||||
Where `cacheinit.cmake` is a file used to populate an initial CMake cache with some common option settings,
|
||||
|
||||
`<generator>` is (examples):
|
||||
* MinGW Makefiles
|
||||
* NMake Makefiles
|
||||
* Unix Makefiles
|
||||
@@ -602,74 +504,10 @@ Where `<generator>` is (examples):
|
||||
* Visual Studio 16 2019
|
||||
* Visual Studio 17 2022
|
||||
|
||||
`<options>` is:
|
||||
|
||||
* For installed SZIP/libaec:
|
||||
|
||||
SZIP_INCLUDE_DIR:PATH=<path to szip includes directory>
|
||||
SZIP_LIBRARY:FILEPATH=<path to szip/library file>
|
||||
libaec_INCLUDE_DIR:PATH=<path to libaec includes directory>
|
||||
libaec_LIBRARY:FILEPATH=<path to libaec/library file>
|
||||
|
||||
or
|
||||
|
||||
SZIP_ROOT:PATH=<path to szip root directory>
|
||||
libaec_ROOT:PATH=<path to libaec root directory>
|
||||
|
||||
* For installed ZLIB/ZLIBNG:
|
||||
|
||||
ZLIB_INCLUDE_DIR:PATH=<path to zlib includes directory>
|
||||
ZLIB_LIBRARY:FILEPATH=<path to zlib/library file>
|
||||
|
||||
or
|
||||
|
||||
ZLIB_ROOT:PATH=<path to zlib root directory>
|
||||
and `<options>` are any CMake options to be added to the configuration:
|
||||
|
||||
* `<HDF5OPTION>:BOOL=[ON | OFF]`
|
||||
|
||||
`cacheinit.cmake` highlights are:
|
||||
|
||||
```cmake
|
||||
# This is the CMakeCache file used by HDF Group for daily tests.
|
||||
set (CMAKE_INSTALL_FRAMEWORK_PREFIX "Library/Frameworks" CACHE STRING "Frameworks installation directory" FORCE)
|
||||
set (HDF_PACKAGE_NAMESPACE "hdf5::" CACHE STRING "Name for HDF package namespace (can be empty)" FORCE)
|
||||
set (HDF5_BUILD_CPP_LIB ON CACHE BOOL "Build C++ support" FORCE)
|
||||
set (HDF5_BUILD_FORTRAN ON CACHE BOOL "Build FORTRAN support" FORCE)
|
||||
set (HDF5_BUILD_JAVA ON CACHE BOOL "Build JAVA support" FORCE)
|
||||
set (HDF5_ENABLE_ALL_WARNINGS ON CACHE BOOL "Enable all warnings" FORCE)
|
||||
set (HDF5_ALLOW_EXTERNAL_SUPPORT "TGZ" CACHE STRING "Allow External Library Building (NO GIT TGZ)" FORCE)
|
||||
########################
|
||||
# compression options
|
||||
########################
|
||||
set (ZLIB_PACKAGE_NAME "zlib" CACHE STRING "Name of ZLIB package" FORCE)
|
||||
set (ZLIB_TGZ_NAME "zlib-1.3.1.tar.gz" CACHE STRING "Use HDF5_ZLib from compressed file" FORCE)
|
||||
set (ZLIB_TGZ_ORIGPATH "https://github.com/madler/zlib/releases/download/v1.3.1" CACHE STRING "Use ZLIB from original location" FORCE)
|
||||
set (ZLIB_USE_LOCALCONTENT ON CACHE BOOL "Use local file for ZLIB FetchContent" FORCE)
|
||||
set (ZLIB_GIT_URL "https://github.com/madler/zlib.git" CACHE STRING "Use ZLIB from GitHub repository" FORCE)
|
||||
set (ZLIB_GIT_BRANCH "develop" CACHE STRING "" FORCE)
|
||||
set (HDF5_USE_ZLIB_NG OFF CACHE BOOL "Use zlib-ng library as zlib library" FORCE)
|
||||
set (ZLIBNG_PACKAGE_NAME "zlib-ng" CACHE STRING "Name of ZLIBNG package" FORCE)
|
||||
set (ZLIBNG_TGZ_NAME "2.2.4.tar.gz" CACHE STRING "Use HDF5_ZLib from compressed file" FORCE)
|
||||
set (ZLIBNG_TGZ_ORIGPATH "https://github.com/zlib-ng/zlib-ng/archive/refs/tags" CACHE STRING "Use ZLIBNG from original location" FORCE)
|
||||
set (ZLIBNG_GIT_URL "https://github.com/zlib-ng/zlib-ng.git" CACHE STRING "Use ZLIBNG from GitHub repository" FORCE)
|
||||
set (ZLIBNG_GIT_BRANCH "develop" CACHE STRING "" FORCE)
|
||||
set (LIBAEC_PACKAGE_NAME "libaec" CACHE STRING "Name of AEC SZIP package" FORCE)
|
||||
set (LIBAEC_TGZ_NAME "libaec-1.1.3.tar.gz" CACHE STRING "Use SZip AEC from compressed file" FORCE)
|
||||
set (LIBAEC_TGZ_ORIGPATH "https://github.com/MathisRosenhauer/libaec/releases/download/v1.1.3" CACHE STRING "Use LIBAEC from original location" FORCE)
|
||||
set (LIBAEC_USE_LOCALCONTENT ON CACHE BOOL "Use local file for LIBAEC FetchContent" FORCE)
|
||||
set (LIBAEC_GIT_URL "https://github.com/MathisRosenhauer/libaec.git" CACHE STRING "Use LIBAEC from GitHub repository" FORCE)
|
||||
set (LIBAEC_GIT_BRANCH "v1.1.3" CACHE STRING "" FORCE)
|
||||
########################
|
||||
# filter plugin options
|
||||
########################
|
||||
set (PLUGIN_TGZ_ORIGPATH "https://github.com/HDFGroup/hdf5_plugins/releases/download/snapshot" CACHE STRING "Use PLUGINS from original location" FORCE)
|
||||
set (PLUGIN_TGZ_NAME "hdf5_plugins-master.tar.gz" CACHE STRING "Use PLUGINS from compressed file" FORCE)
|
||||
set (PLUGIN_USE_LOCALCONTENT ON CACHE BOOL "Use local file for PLUGIN FetchContent" FORCE)
|
||||
set (PLUGIN_PACKAGE_NAME "pl" CACHE STRING "Name of PLUGIN package" FORCE)
|
||||
set (PLUGIN_GIT_URL "https://github.com/HDFGroup/hdf5_plugins.git" CACHE STRING "Use plugins from HDF Group repository" FORCE)
|
||||
set (PLUGIN_GIT_BRANCH "master" CACHE STRING "" FORCE)
|
||||
```
|
||||
|
||||
### Step 2: Configure the Cache Settings
|
||||
|
||||
Visual CMake users, click the Configure button. If this is the first time you are running `cmake-gui` in this directory, you will be prompted for the generator you wish to use (for example on Windows, Visual Studio 14). CMake will read in the `CMakeLists.txt` files from the source directory and display options for the HDF5 project. After the first configure you can adjust the cache settings and/or specify the locations of other programs.
|
||||
@@ -715,48 +553,9 @@ If you wish to use the Visual Studio environment, open the solution
|
||||
file in your build directory. Be sure to select either `Debug` or
|
||||
`Release` and build the solution.
|
||||
|
||||
The external libraries (zlib, szip and plugins) can be configured
|
||||
to allow building the libraries by downloading from a GIT repository.
|
||||
The option is `HDF5_ALLOW_EXTERNAL_SUPPORT`; by adding the following
|
||||
configuration option: `-DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING="GIT"`.
|
||||
|
||||
The options to control the GIT parameters (`config/cmake/cacheinit.cmake` file) are:
|
||||
|
||||
```cmake
|
||||
ZLIB_GIT_URL:STRING="https://${git_url}/zlib"
|
||||
ZLIB_GIT_BRANCH="${git_branch}"
|
||||
SZIP_GIT_URL:STRING="https://${git_url}/szip"
|
||||
SZIP_GIT_BRANCH="${git_branch}"
|
||||
LIBAEC_GIT_URL:STRING="https://${git_url}/libaec"
|
||||
LIBAEC_GIT_BRANCH="${git_branch}"
|
||||
PLUGIN_GIT_URL:STRING="https://${git_url}/plugin"
|
||||
PLUGIN_GIT_BRANCH="${git_branch}"
|
||||
```
|
||||
|
||||
`${git_url}` should be changed to your location and `${git_branch}` is
|
||||
your branch in the repository. Also define `CMAKE_BUILD_TYPE`
|
||||
to be the configuration type.
|
||||
|
||||
Alternatively, the external libraries (zlib, szip and plugins) can be configured
|
||||
to allow building the libraries by using a compressed file.
|
||||
The option is `HDF5_ALLOW_EXTERNAL_SUPPORT` and is enabled by
|
||||
adding the following configuration option: `-DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING="TGZ"`.
|
||||
|
||||
The options to control the TGZ URL (`config/cmake/cacheinit.cmake` file) are:
|
||||
|
||||
```cmake
|
||||
ZLIB_TGZ_NAME:STRING="zlib_src.ext"
|
||||
LIBAEC_TGZ_NAME:STRING="libaec_src.ext"
|
||||
PLUGIN_TGZ_NAME:STRING="plugin_src.ext"
|
||||
TGZPATH:STRING="some_location"
|
||||
```
|
||||
|
||||
where `some_location/xxxx_src.ext` is the URL or full path to
|
||||
the compressed file and where `ext` is the type of the compression
|
||||
file such as `.bz2`, `.tar`, `.tar.gz`, `.tgz`, or `.zip`. Also define
|
||||
`CMAKE_BUILD_TYPE` to be the configuration type.
|
||||
|
||||
> **NOTE:** The file named by `LIBAEC_TGZ_NAME` is used to build SZIP.
|
||||
External libraries (zlib, szip and plugins) can be configured to allow
|
||||
building the libraries by downloading from a GIT repository or by using
|
||||
a compressed file. See the instructions in [INSTALL_Filters.md](./INSTALL_Filters.md) to do this.
|
||||
|
||||
### Step 4: Test HDF5
|
||||
|
||||
@@ -1123,8 +922,8 @@ If `BUILD_TESTING` is true:
|
||||
| `LIBAEC_USE_LOCALCONTENT` | Use local file for LIBAEC FetchContent | `OFF` |
|
||||
| `HDF5_USE_LIBAEC_STATIC` | Find static AEC library | `OFF` |
|
||||
| `PLUGIN_USE_EXTERNAL` | `Use External Library Building for PLUGINS else search` | `OFF` |
|
||||
| `PLUGIN_TGZ_ORIGPATH` | Use PLUGIN from original location | `"https://github.com/HDFGroup/hdf5_plugins/releases/download/snapshot"` |
|
||||
| `PLUGIN_TGZ_NAME` | Use PLUGIN from original compressed file | `"hdf5_plugins-master.tar.gz"` |
|
||||
| `HDF5_FILTER_PLUGINS_TGZ_ORIGPATH` | Use PLUGIN from original location | `"https://github.com/HDFGroup/hdf5_plugins/releases/download/snapshot"` |
|
||||
| `HDF5_FILTER_PLUGINS_TGZ_NAME` | Use PLUGIN from original compressed file | `"hdf5_plugins-master.tar.gz"` |
|
||||
| `PLUGIN_USE_LOCALCONTENT` | Use local file for PLUGIN FetchContent | `OFF` |
|
||||
| `H5_DEFAULT_PLUGINDIR` | Default library search folder for filter plugins | `"%ALLUSERSPROFILE%/hdf5/lib/plugin"` (**Windows**)<br/>`"/usr/local/hdf5/lib/plugin"` |
|
||||
|
||||
|
||||
@@ -0,0 +1,173 @@
|
||||
# Build HDF5 with support for data filters
|
||||
|
||||
This file provides instructions for building HDF5 with support for various data filters, including zlib and libaec.
|
||||
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
|
||||
* [CMake options](#cmake-options)
|
||||
* [Zlib options](#zlib-options)
|
||||
* [Zlib-ng options](#zlib-ng-options)
|
||||
* [Libaec (szip) options](#libaec-szip-options)
|
||||
* [HDF5 filter plugins options](#hdf5-filter-plugins-options)
|
||||
* [Using system-installed libraries](#using-system-installed-libraries)
|
||||
* [Using libraries built with CMake FetchContent](#using-libraries-built-with-cmake-fetchcontent)
|
||||
* [CMake options for `HDF5_ALLOW_EXTERNAL_SUPPORT=GIT`](#cmake-options-for-hdf5_allow_external_supportgit)
|
||||
* [CMake options for `HDF5_ALLOW_EXTERNAL_SUPPORT=TGZ`](#cmake-options-for-hdf5_allow_external_supporttgz)
|
||||
* [Troubleshooting](#troubleshooting)
|
||||
|
||||
---
|
||||
|
||||
## CMake options
|
||||
<a name="cmake_options"></a>
|
||||
|
||||
HDF5 currently has built-in support for zlib, zlib-ng and libaec (szip), as well as support for a collection of dynamically-loaded filter libraries from the [HDF5 filter plugins](https://github.com/HDFGroup/hdf5_plugins) repository, which are controlled by the following CMake options:
|
||||
|
||||
- `HDF5_ENABLE_ZLIB_SUPPORT` (`ON`/`OFF` Default: `OFF`) - Enable zlib support
|
||||
- `HDF5_ENABLE_SZIP_SUPPORT` (`ON`/`OFF` Default: `OFF`) - Enable libaec (szip) support
|
||||
- `HDF5_USE_ZLIB_NG` (`ON`/`OFF` Default: `OFF`) - Enable zlib-ng support
|
||||
- `HDF5_ENABLE_PLUGIN_SUPPORT` (`ON`/`OFF` Default: `OFF`) - Enable support for plugins from the HDF5 filter plugins repository
|
||||
- `HDF5_ALLOW_EXTERNAL_SUPPORT` (`NO`/`GIT`/`TGZ` Default: `NO`) - Specify whether support for libraries from external sources should be enabled (see [Using libraries built with CMake FetchContent](#fetchcontent_building))
|
||||
- `TGZPATH` (`<path>` Default: top level of HDF5 source directory) - When `HDF5_ALLOW_EXTERNAL_SUPPORT` is `TGZ` and a filter's `_USE_LOCALCONTENT` variable is `ON` (see below), specifies the directory to look in for a library's source code compressed file.
|
||||
|
||||
By default, setting `HDF5_ENABLE_ZLIB_SUPPORT` to `ON` will enable support for zlib. Setting the additional option `HDF5_USE_ZLIB_NG` to `ON` will cause HDF5 to instead use zlib-ng in place of zlib.
|
||||
|
||||
Additional CMake options for controlling how specific filters are found/used include the following:
|
||||
|
||||
### Zlib options
|
||||
|
||||
- `HDF5_USE_ZLIB_STATIC` (`ON`/`OFF` Default: `OFF`) - Prefer locating and using static zlib libraries (if available) instead of shared libraries
|
||||
- `ZLIB_USE_EXTERNAL` (`ON`/`OFF` Default: `OFF`) - If `ON` and `HDF5_ALLOW_EXTERNAL_SUPPORT` is `GIT` or `TGZ`, instructs HDF5 to build zlib from an external source and use that while building HDF5 itself. If `ON` and `HDF5_ALLOW_EXTERNAL_SUPPORT` is `NO`, causes a configuration error.
|
||||
- `ZLIB_USE_LOCALCONTENT` (`ON`/`OFF` Default: `OFF`) - If `ON`, `HDF5_ALLOW_EXTERNAL_SUPPORT` is `TGZ` and `ZLIB_USE_EXTERNAL` is `ON`, instructs HDF5 to build zlib from a compressed source file on the filesystem, which is pointed to by the path formed from combining `TGZPATH` and `ZLIB_TGZ_NAME`, and use that while building HDF5 itself. If `ON` and `HDF5_ALLOW_EXTERNAL_SUPPORT` is `NO` or `GIT`, causes a configuration error.
|
||||
- `HDF5_MODULE_MODE_ZLIB` (`ON`/`OFF` Default: `ON`) - If `ON`, locates zlib using CMake's [find_package()](https://cmake.org/cmake/help/latest/command/find_package.html) Module mode search, otherwise uses a Config mode search. In most cases this option should be left to the default value, but may need to be modified for specific zlib installations.
|
||||
- `ZLIB_GIT_URL` (`<url>` Default: [zlib](https://github.com/madler/zlib.git)) - Specifies the git URL to retrieve zlib from when `HDF5_ALLOW_EXTERNAL_SUPPORT` is `GIT` and `ZLIB_USE_EXTERNAL` is `ON` (e.g., when building zlib with CMake's FetchContent)
|
||||
- `ZLIB_GIT_TAG` / `ZLIB_GIT_BRANCH` (`<git tag>` Default: `v<zlib_version>`) - Specifies the git tag, commit hash or branch name to use for retrieving zlib when `HDF5_ALLOW_EXTERNAL_SUPPORT` is `GIT` and `ZLIB_USE_EXTERNAL` is `ON` (e.g., when building zlib with CMake's FetchContent). `ZLIB_GIT_BRANCH` is deprecated in favor of `ZLIB_GIT_TAG`.
|
||||
- `ZLIB_TGZ_NAME` (`<filename>` Default: `zlib-<zlib_version>.tar.gz`) - Specifies the base filename of a compressed file containing the zlib source code which will be used when `HDF5_ALLOW_EXTERNAL_SUPPORT` is `TGZ` and `ZLIB_USE_EXTERNAL` is `ON`. Combined with either `TGZPATH` or `ZLIB_TGZ_ORIGPATH`, depending on the value of `ZLIB_USE_LOCALCONTENT`, to form a full path to the compressed file.
|
||||
- `ZLIB_TGZ_ORIGPATH` (`<url>` Default: `https://github.com/madler/zlib/releases/download/v<zlib_version>`) - Specifies the URL to retrieve a compressed file containing the zlib source code from when `HDF5_ALLOW_EXTERNAL_SUPPORT` is `TGZ`, `ZLIB_USE_EXTERNAL` is `ON` and `ZLIB_USE_LOCALCONTENT` is `OFF`. Combined with `ZLIB_TGZ_NAME` to form a full URL for the download.
|
||||
- `ZLIB_PACKAGE_NAME` (`<string>` Default: `zlib`) - The package name to use when locating zlib libraries with CMake's [find_package()](https://cmake.org/cmake/help/latest/command/find_package.html). Usually should be left to the default value but may need to be modified in rare circumstances.
|
||||
|
||||
### Zlib-ng options
|
||||
|
||||
> [!NOTE]
|
||||
> The `HDF5_USE_ZLIB_STATIC`, `ZLIB_USE_EXTERNAL` and `ZLIB_USE_LOCALCONTENT` options also apply to zlib-ng when `HDF5_USE_ZLIB_NG` is set to `ON`.
|
||||
|
||||
- `ZLIBNG_GIT_URL` (`<url>` Default: [zlib-ng](https://github.com/zlib-ng/zlib-ng.git)) - Specifies the git URL to retrieve zlib-ng from when `HDF5_ALLOW_EXTERNAL_SUPPORT` is `GIT`, `ZLIB_USE_EXTERNAL` is `ON` and `HDF5_USE_ZLIB_NG` is `ON` (e.g., when building zlib-ng with CMake's FetchContent)
|
||||
- `ZLIBNG_GIT_TAG` / `ZLIBNG_GIT_BRANCH` (`<git tag>` Default: `<zlibng_version>`) - Specifies the git tag, commit hash or branch name to use for retrieving zlib-ng when `HDF5_ALLOW_EXTERNAL_SUPPORT` is `GIT`, `ZLIB_USE_EXTERNAL` is `ON` and `HDF5_USE_ZLIB_NG` is `ON` (e.g., when building zlib-ng with CMake's FetchContent). `ZLIBNG_GIT_BRANCH` is deprecated in favor of `ZLIBNG_GIT_TAG`.
|
||||
- `ZLIBNG_TGZ_NAME` (`<filename>` Default: `<zlibng_version>.tar.gz`) - Specifies the base filename of a compressed file containing the zlib-ng source code which will be used when `HDF5_ALLOW_EXTERNAL_SUPPORT` is `TGZ`, `ZLIB_USE_EXTERNAL` is `ON` and `HDF5_USE_ZLIB_NG` is `ON`. Combined with either `TGZPATH` or `ZLIBNG_TGZ_ORIGPATH`, depending on the value of `ZLIB_USE_LOCALCONTENT`, to form a full path to the compressed file.
|
||||
- `ZLIBNG_TGZ_ORIGPATH` (`<url>` Default: `https://github.com/zlib-ng/zlib-ng/archive/refs/tags`) - Specifies the URL to retrieve a compressed file containing the zlib-ng source code from when `HDF5_ALLOW_EXTERNAL_SUPPORT` is `TGZ`, `ZLIB_USE_EXTERNAL` is `ON`, `ZLIB_USE_LOCALCONTENT` is `OFF` and `HDF5_USE_ZLIB_NG` is `ON`. Combined with `ZLIBNG_TGZ_NAME` to form a full URL for the download.
|
||||
- `ZLIBNG_PACKAGE_NAME` (`<string>` Default: `ZLIBNG`) - The package name to use when locating zlib-ng libraries with CMake's [find_package()](https://cmake.org/cmake/help/latest/command/find_package.html). Usually should be left to the default value but may need to be modified in rare circumstances.
|
||||
|
||||
### Libaec (szip) options
|
||||
|
||||
- `HDF5_USE_LIBAEC_STATIC` (`ON`/`OFF` Default: `OFF`) - Prefer locating and using static libaec libraries (if available) instead of shared libraries
|
||||
- `SZIP_USE_EXTERNAL` (`ON`/`OFF` Default: `OFF`) - If `ON` and `HDF5_ALLOW_EXTERNAL_SUPPORT` is `GIT` or `TGZ`, instructs HDF5 to build libaec from an external source and use that while building HDF5 itself. If `ON` and `HDF5_ALLOW_EXTERNAL_SUPPORT` is `NO`, causes a configuration error.
|
||||
- `LIBAEC_USE_LOCALCONTENT` (`ON`/`OFF` Default: `OFF`) - If `ON`, `HDF5_ALLOW_EXTERNAL_SUPPORT` is `TGZ` and `SZIP_USE_EXTERNAL` is `ON`, instructs HDF5 to build libaec from a compressed source file on the filesystem, which is pointed to by the path formed from combining `TGZPATH` and `LIBAEC_TGZ_NAME`, and use that while building HDF5 itself. If `ON` and `HDF5_ALLOW_EXTERNAL_SUPPORT` is `NO` or `GIT`, causes a configuration error.
|
||||
- `LIBAEC_GIT_URL` (`<url>` Default: [libaec](https://github.com/MathisRosenhauer/libaec.git)) - Specifies the git URL to retrieve libaec from when `HDF5_ALLOW_EXTERNAL_SUPPORT` is `GIT` and `SZIP_USE_EXTERNAL` is `ON` (e.g., when building libaec with CMake's FetchContent)
|
||||
- `LIBAEC_GIT_TAG` / `LIBAEC_GIT_BRANCH` (`<git tag>` Default: `v<libaec_version>`) - Specifies the git tag, commit hash or branch name to use for retrieving libaec when `HDF5_ALLOW_EXTERNAL_SUPPORT` is `GIT` and `SZIP_USE_EXTERNAL` is `ON` (e.g., when building libaec with CMake's FetchContent). `LIBAEC_GIT_BRANCH` is deprecated in favor of `LIBAEC_GIT_TAG`.
|
||||
- `LIBAEC_TGZ_NAME` (`<filename>` Default: `libaec-<libaec_version>.tar.gz`) - Specifies the base filename of a compressed file containing the libaec source code which will be used when `HDF5_ALLOW_EXTERNAL_SUPPORT` is `TGZ` and `SZIP_USE_EXTERNAL` is `ON`. Combined with either `TGZPATH` or `LIBAEC_TGZ_ORIGPATH`, depending on the value of `LIBAEC_USE_LOCALCONTENT`, to form a full path to the compressed file.
|
||||
- `LIBAEC_TGZ_ORIGPATH` (`<url>` Default: `https://github.com/MathisRosenhauer/libaec/releases/download/v<libaec_version>`) - Specifies the URL to retrieve a compressed file containing the libaec source code from when `HDF5_ALLOW_EXTERNAL_SUPPORT` is `TGZ`, `SZIP_USE_EXTERNAL` is `ON` and `LIBAEC_USE_LOCALCONTENT` is `OFF`. Combined with `LIBAEC_TGZ_NAME` to form a full URL for the download.
|
||||
- `LIBAEC_PACKAGE_NAME` (`<string>` Default: `libaec`) - The package name to use when locating libaec libraries with CMake's [find_package()](https://cmake.org/cmake/help/latest/command/find_package.html). Usually should be left to the default value but may need to be modified in rare circumstances.
|
||||
- `HDF5_ENABLE_SZIP_ENCODING` (`ON`/`OFF` Default: `ON`) - Specifies whether encoding should be enabled for the HDF5 szip filter. Deprecated option that is no longer used.
|
||||
|
||||
### HDF5 filter plugins options
|
||||
|
||||
- `PLUGIN_USE_EXTERNAL` (`ON`/`OFF` Default: `OFF`) - If `ON` and `HDF5_ALLOW_EXTERNAL_SUPPORT` is `GIT` or `TGZ`, instructs HDF5 to build several dynamically-loaded data filter plugins from the [hdf5_plugins](https://github.com/HDFGroup/hdf5_plugins) repository while building HDF5 itself. If `ON` and `HDF5_ALLOW_EXTERNAL_SUPPORT` is `NO`, causes a configuration error.
|
||||
- `PLUGIN_USE_LOCALCONTENT` (`ON`/`OFF` Default: `OFF`) - If `ON`, `HDF5_ALLOW_EXTERNAL_SUPPORT` is `TGZ` and `PLUGIN_USE_EXTERNAL` is `ON`, instructs HDF5 to build several dynamically-loaded data filter plugins from a compressed source file on the filesystem, which is pointed to by the path formed from combining `TGZPATH` and `HDF5_FILTER_PLUGINS_TGZ_NAME` / `PLUGIN_TGZ_NAME`, and use that while building HDF5 itself. If `ON` and `HDF5_ALLOW_EXTERNAL_SUPPORT` is `NO` or `GIT`, causes a configuration error.
|
||||
- `HDF5_FILTER_PLUGINS_GIT_URL` / `PLUGIN_GIT_URL` (`<url>` Default: [hdf5_plugins](https://github.com/HDFGroup/hdf5_plugins.git)) - Specifies the git URL to retrieve HDF5 filter plugins from when `HDF5_ALLOW_EXTERNAL_SUPPORT` is `GIT` and `PLUGIN_USE_EXTERNAL` is `ON` (e.g., when building HDF5 filter plugins with CMake's FetchContent). `PLUGIN_GIT_URL` is deprecated in favor of `HDF5_FILTER_PLUGINS_GIT_URL`.
|
||||
- `HDF5_FILTER_PLUGINS_GIT_TAG` / `PLUGIN_GIT_BRANCH` (`<git tag>` Default: `master`) - Specifies the git tag, commit hash or branch name to use for retrieving HDF5 filter plugins when `HDF5_ALLOW_EXTERNAL_SUPPORT` is `GIT` and `PLUGIN_USE_EXTERNAL` is `ON` (e.g., when building HDF5 filter plugins with CMake's FetchContent). `PLUGIN_GIT_BRANCH` is deprecated in favor of `HDF5_FILTER_PLUGINS_GIT_TAG`.
|
||||
- `HDF5_FILTER_PLUGINS_TGZ_NAME` / `PLUGIN_TGZ_NAME` (`<filename>` Default: `hdf5_plugins-master.tar.gz`) - Specifies the base filename of a compressed file containing the HDF5 filter plugins source code which will be used when `HDF5_ALLOW_EXTERNAL_SUPPORT` is `TGZ` and `PLUGIN_USE_EXTERNAL` is `ON`. Combined with either `TGZPATH` or `HDF5_FILTER_PLUGINS_TGZ_ORIGPATH` / `PLUGIN_TGZ_ORIGPATH`, depending on the value of `PLUGIN_USE_LOCALCONTENT`, to form a full path to the compressed file. `PLUGIN_TGZ_NAME` is deprecated in favor of `HDF5_FILTER_PLUGINS_TGZ_NAME`.
|
||||
- `HDF5_FILTER_PLUGINS_TGZ_ORIGPATH` / `PLUGIN_TGZ_ORIGPATH` (`<url>` Default: `https://github.com/HDFGroup/hdf5_plugins/releases/download/snapshot`) - Specifies the URL to retrieve a compressed file containing the HDF5 filter plugins source code from when `HDF5_ALLOW_EXTERNAL_SUPPORT` is `TGZ`, `PLUGIN_USE_EXTERNAL` is `ON` and `PLUGIN_USE_LOCALCONTENT` is `OFF`. Combined with `HDF5_FILTER_PLUGINS_TGZ_NAME` / `PLUGIN_TGZ_NAME` to form a full URL for the download. `PLUGIN_TGZ_ORIGPATH` is deprecated in favor of `HDF5_FILTER_PLUGINS_TGZ_ORIGPATH`.
|
||||
- `HDF5_FILTER_PLUGINS_PACKAGE_NAME` / `PLUGIN_PACKAGE_NAME` (`<string>` Default: `h5pl`) - The package name to use when locating HDF5 filter plugins libraries with CMake's [find_package()](https://cmake.org/cmake/help/latest/command/find_package.html). Usually should be left to the default value but may need to be modified in rare circumstances. `PLUGIN_PACKAGE_NAME` is deprecated in favor of `HDF5_FILTER_PLUGINS_PACKAGE_NAME`.
|
||||
|
||||
## Using system-installed libraries
|
||||
|
||||
To build HDF5 with data filter support using libraries that are installed on the system, setting the relevant `HDF5_ENABLE_XXX_SUPPORT` [CMake options](#cmake_options) to `ON` should be enough in most cases. However, CMake can be instructed to look for specific libraries if desired or if the needed libraries are installed to directories that aren't in CMake's default search paths:
|
||||
|
||||
- For zlib, set the CMake variable `ZLIB_ROOT` to the top level directory of a zlib installation
|
||||
- For zlib-ng, set the CMake variable `ZLIBNG_ROOT` to the top level directory of a zlib installation
|
||||
- For libaec (szip), set the CMake variable `SZIP_ROOT` or `libaec_ROOT` to the top level directory of a libaec installation
|
||||
|
||||
<b>Example:</b> Configure HDF5 with zlib and libaec support from system libraries
|
||||
|
||||
```bash
|
||||
cmake -DHDF5_ENABLE_ZLIB_SUPPORT=ON -DHDF5_ENABLE_SZIP_SUPPORT=ON <hdf5_source_dir>
|
||||
```
|
||||
|
||||
<b>Example:</b> Configure HDF5 with zlib installed to a non-system directory
|
||||
|
||||
```bash
|
||||
cmake -DHDF5_ENABLE_ZLIB_SUPPORT=ON -DZLIB_ROOT=/path/to/my/zlib/installation <hdf5_source_dir>
|
||||
```
|
||||
|
||||
<b>Example:</b> Configure HDF5 with zlib-ng static libraries installed to a non-system directory
|
||||
|
||||
```bash
|
||||
cmake -DHDF5_ENABLE_ZLIB_SUPPORT=ON -DHDF5_USE_ZLIB_NG=ON -DHDF5_USE_ZLIB_STATIC=ON -DZLIBNG_ROOT=/path/to/my/zlib-ng/installation <hdf5_source_dir>
|
||||
```
|
||||
|
||||
## Using libraries built with CMake FetchContent
|
||||
<a name="fetchcontent_building"></a>
|
||||
|
||||
> [!WARNING]
|
||||
> HDF5 does not currently namespace libraries that are built using CMake's FetchContent functionality. Use caution when installing HDF5 to a system directory if any libraries are built this way, as there is risk of overwriting pre-existing libraries on the system. For this reason, it is recommended to install filter libraries on the system and allow HDF5 to find them at build time instead. This method is only provided as a convenience for building HDF5 binaries and for testing of HDF5.
|
||||
|
||||
When building HDF5, one may choose to build the libraries for data filters alongside HDF5 by using CMake's FetchContent functionality.
|
||||
This will either download the source code for libraries or use compressed source code files from the filesystem and add the source code to the HDF5 build and installation processes. To set up this method, several CMake variables need to be set when configuring HDF5. First, the CMake variable `HDF5_ALLOW_EXTERNAL_SUPPORT` must be set to the value `GIT` or `TGZ`. The value `GIT` will instruct the HDF5 build process to retrieve the source code for libraries from git URLs, whereas the value `TGZ` will instruct the build process to retrieve the source code for libraries from compressed files from either a web URL or a path on the filesystem.
|
||||
|
||||
Next, external support for the desired data filters needs to be configured into HDF5. This simply involves setting the relevant `HDF5_ENABLE_XXX_SUPPORT` and `XXX_USE_EXTERNAL` [CMake options](#cmake_options) to `ON`.
|
||||
|
||||
Finally, any CMake options for how the source code should be retrieved and built must be set. The default values set for most of these options can be found in [CacheURLs.cmake](../config/CacheURLs.cmake) and can be changed by setting values for the CMake variables listed there. Note that the `HDF5_USE_XXX_STATIC` options affect which type of library, shared or static, is built when building external libraries.
|
||||
|
||||
> [!TIP]
|
||||
> CMake options for a library can generally be passed through when building them with FetchContent by defining those options when configuring HDF5 (e.g., add `-DZLIB_BUILD_TESTING=OFF` to the list of HDF5 configuration options), but be aware that HDF5 may override the values for some of these variables.
|
||||
|
||||
### CMake options for `HDF5_ALLOW_EXTERNAL_SUPPORT=GIT`
|
||||
|
||||
When the `HDF5_ALLOW_EXTERNAL_SUPPORT` CMake option is specified as `GIT`, all filter libraries will be downloaded from git URLs using a specified git tag, commit hash or branch name. For example, using the default values for libaec will cause CMake to download the libaec source from `https://github.com/MathisRosenhauer/libaec.git` (`LIBAEC_GIT_URL`) using the git tag `v1.1.6` (`LIBAEC_GIT_TAG` as of the time of writing). Each filter's `_GIT_URL` and `_GIT_TAG` CMake variables may have values specified for them to change where the source code is downloaded from.
|
||||
|
||||
<b>Example:</b> Configure HDF5 with zlib-ng from system libraries and libaec (szip) from the default git repository
|
||||
|
||||
```bash
|
||||
cmake -DHDF5_ALLOW_EXTERNAL_SUPPORT=GIT -DHDF5_ENABLE_ZLIB_SUPPORT=ON -DHDF5_USE_ZLIB_NG=ON -DHDF5_ENABLE_SZIP_SUPPORT=ON -DSZIP_USE_EXTERNAL=ON <hdf5_source_dir>
|
||||
```
|
||||
|
||||
<b>Example:</b> Configure HDF5 with zlib-ng, libaec and the HDF5 filter plugins from the default git repositories
|
||||
|
||||
```bash
|
||||
cmake -DHDF5_ALLOW_EXTERNAL_SUPPORT=GIT -DHDF5_ENABLE_ZLIB_SUPPORT=ON -DHDF5_USE_ZLIB_NG=ON -DZLIB_USE_EXTERNAL=ON -DHDF5_ENABLE_SZIP_SUPPORT=ON -DSZIP_USE_EXTERNAL=ON -DHDF5_ENABLE_PLUGIN_SUPPORT=ON -DPLUGIN_USE_EXTERNAL=ON <hdf5_source_dir>
|
||||
```
|
||||
|
||||
<b>Example:</b> Configure HDF5 with libaec from a custom git repository
|
||||
|
||||
```bash
|
||||
cmake -DHDF5_ALLOW_EXTERNAL_SUPPORT=GIT -DHDF5_ENABLE_SZIP_SUPPORT=ON -DSZIP_USE_EXTERNAL=ON -DLIBAEC_GIT_URL="https://github.com/user/libaec.git" -DLIBAEC_GIT_TAG="my_libaec_tag" <hdf5_source_dir>
|
||||
```
|
||||
|
||||
### CMake options for `HDF5_ALLOW_EXTERNAL_SUPPORT=TGZ`
|
||||
|
||||
When the `HDF5_ALLOW_EXTERNAL_SUPPORT` CMake option is specified as `TGZ`, the way in which filter libraries are retrieved depends on the value for that filter's `_USE_LOCALCONTENT` CMake option. For each filter that has its `_USE_LOCALCONTENT` variable set to `OFF`, CMake will download a compressed file with the relevant library's source code from a URL formed by combining the filter's `_TGZ_ORIGPATH` and `_TGZ_NAME` CMake variables. For example, the default values of `LIBAEC_TGZ_ORIGPATH` and `LIBAEC_TGZ_NAME` are `https://github.com/MathisRosenhauer/libaec/releases/download/v<libaec_version>` and `libaec-<libaec_version>.tar.gz`, respectively. As of the time of writing, the current default version of libaec is 1.1.6, resulting in a URL of https://github.com/MathisRosenhauer/libaec/releases/download/v1.1.6/libaec-1.1.6.tar.gz. CMake will download this file, uncompress it and use the contents as source code when building the library alongside HDF5. Each filter's `_TGZ_ORIGPATH` and `_TGZ_NAME` CMake variables may have values specified for them to change where the file is downloaded from.
|
||||
|
||||
For each filter that has its `_USE_LOCALCONTENT` variable set to `ON`, CMake will search the directory specified by `TGZPATH` for the compressed file with that filter's library source code according to the default names, which can be changed by setting a filter's `_TGZ_NAME` variable. For example, to locate compressed files with zlib and libaec libraries with the names `zlib.tar.gz` and `libaec.tar.gz` in the directory `/home/user/filters`, specify the following CMake options when configuring HDF5:
|
||||
|
||||
- `-DTGZPATH="/home/user/filters"`
|
||||
- `-DZLIB_TGZ_NAME="zlib.tar.gz"`
|
||||
- `-DLIBAEC_TGZ_NAME="libaec.tar.gz"`
|
||||
|
||||
CMake will combine `TGZPATH` with each of `ZLIB_TGZ_NAME` and `LIBAEC_TGZ_NAME` to form full paths to each file.
|
||||
|
||||
<b>Example:</b> Configure HDF5 with zlib-ng and libaec from downloaded tar.gz files with the default names
|
||||
|
||||
```bash
|
||||
cmake -DHDF5_ALLOW_EXTERNAL_SUPPORT=TGZ -DHDF5_ENABLE_ZLIB_SUPPORT=ON -DHDF5_USE_ZLIB_NG=ON -DZLIB_USE_EXTERNAL=ON -DHDF5_ENABLE_SZIP_SUPPORT=ON -DSZIP_USE_EXTERNAL=ON <hdf5_source_dir>
|
||||
```
|
||||
|
||||
<b>Example:</b> Configure HDF5 with zlib-ng and libaec from tar.gz files on the system with custom names
|
||||
|
||||
```bash
|
||||
cmake -DHDF5_ALLOW_EXTERNAL_SUPPORT=TGZ -DTGZPATH="/path/to/files" -DHDF5_ENABLE_ZLIB_SUPPORT=ON -DHDF5_USE_ZLIB_NG=ON -DZLIB_USE_EXTERNAL=ON -DZLIB_USE_LOCALCONTENT=ON -DZLIBNG_TGZ_NAME="zlib-ng-2.3.3.tar.gz" -DHDF5_ENABLE_SZIP_SUPPORT=ON -DSZIP_USE_EXTERNAL=ON -DLIBAEC_USE_LOCALCONTENT=ON -DLIBAEC_TGZ_NAME="libaec-1.1.6.tar.gz" <hdf5_source_dir>
|
||||
```
|
||||
|
||||
## Troubleshooting
|
||||
|
||||
If the HDF5 build process does not properly locate libraries for a data filter on the system, debugging of the process can be enabled when configuring HDF5 by passing the option `-DCMAKE_FIND_DEBUG_MODE=ON`. This option is intended for advanced users, but will give information about what paths on the system are or are not being searched.
|
||||
@@ -0,0 +1,26 @@
|
||||
# HDF5 Library maintainer's notes
|
||||
|
||||
This document is a catch-all file with general notes for HDF5 library maintainers.
|
||||
|
||||
---
|
||||
|
||||
## Table of Contents
|
||||
|
||||
* [Maintaining external libraries built with CMake FetchContent](#maintaining-external-libraries-built-with-cmake-fetchcontent)
|
||||
* [Updating libraries to new versions](#updating-libraries-to-new-versions)
|
||||
|
||||
---
|
||||
|
||||
## Maintaining external libraries built with CMake FetchContent
|
||||
|
||||
### Updating libraries to new versions
|
||||
|
||||
When performing a new release of HDF5, external libraries that can be fetched and built with CMake's FetchContent should be checked and updated as necessary. For filter libraries, this involves the following steps:
|
||||
|
||||
- For each library being updated:
|
||||
- Modify [CacheURLs.cmake](../config/CacheURLs.cmake) and [CMakePresets.json](../CMakePresets.json) to set the new version of the library, git/tgz URL, git tag, etc.
|
||||
- Check the library's source code for any change in CMake logic, including target names and export namespaces, installed configuration files, etc. and make adjustments to the CMake logic in HDF5 that sets up to build that library
|
||||
- If the library's source is being patched by HDF5, check for any adjustments that need to be made to the file(s) being patched and create a new version, ideally with the source version in the file name, to be used by the patching process
|
||||
- Check the library's source code for any new CMake options or settings that should be enabled/disabled or set near the relevant `FetchContent_MakeAvailable()` call in the CMake logic that will fetch and configure the source
|
||||
- Check the library's source code for any new CMake options or settings that should be marked as advanced with `mark_as_advanced()` _after_ the relevant `FetchContent_MakeAvailable()` call in order to hide them from CMake GUI programs and prevent a clutter of build options
|
||||
- Test building and installing HDF5 with the updated libraries being obtained with FetchContent to check for any new issues
|
||||
@@ -1267,6 +1267,14 @@ if (BUILD_STATIC_LIBS)
|
||||
H5_SET_LIB_OPTIONS (${HDF5_LIB_TARGET} ${HDF5_LIB_NAME} STATIC 0)
|
||||
set_target_properties (${HDF5_LIB_TARGET} PROPERTIES FOLDER libraries)
|
||||
|
||||
# If building Zlib or Szip from source, add a dependency on their build process
|
||||
# so they get built before the main library target does
|
||||
if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT|TGZ")
|
||||
if ((ZLIB_USE_EXTERNAL AND H5_ZLIB_FOUND) OR (SZIP_USE_EXTERNAL AND H5_SZIP_FOUND))
|
||||
add_dependencies (${HDF5_LIB_TARGET} ${LINK_COMP_LIBS})
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
set (install_targets_static ${HDF5_LIB_TARGET})
|
||||
endif ()
|
||||
|
||||
@@ -1296,6 +1304,14 @@ if (BUILD_SHARED_LIBS)
|
||||
H5_SET_LIB_OPTIONS (${HDF5_LIBSH_TARGET} ${HDF5_LIB_NAME} SHARED "LIB")
|
||||
set_target_properties (${HDF5_LIBSH_TARGET} PROPERTIES FOLDER libraries)
|
||||
|
||||
# If building Zlib or Szip from source, add a dependency on their build process
|
||||
# so they get built before the main library target does
|
||||
if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT|TGZ")
|
||||
if ((ZLIB_USE_EXTERNAL AND H5_ZLIB_FOUND) OR (SZIP_USE_EXTERNAL AND H5_SZIP_FOUND))
|
||||
add_dependencies (${HDF5_LIBSH_TARGET} ${LINK_COMP_LIBS})
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
set (install_targets_shared ${HDF5_LIBSH_TARGET})
|
||||
endif ()
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ const char H5build_settings[]=
|
||||
" Concurrency: @HDF5_ENABLE_CONCURRENCY@\n"
|
||||
" Default API mapping: @HDF5_DEFAULT_API_VERSION@\n"
|
||||
" With deprecated public symbols: @HDF5_ENABLE_DEPRECATED_SYMBOLS@\n"
|
||||
" I/O filters (external): @EXTERNAL_FILTERS@\n"
|
||||
" I/O filters (external): @SETTINGS_EXTERNAL_FILTERS@\n"
|
||||
" _Float16 support: @HDF5_ENABLE_NONSTANDARD_FEATURE_FLOAT16@\n"
|
||||
" Map (H5M) API: @H5_HAVE_MAP_API@\n"
|
||||
" Direct VFD: @H5_HAVE_DIRECT@\n"
|
||||
|
||||
@@ -78,7 +78,7 @@ Dimension scales w/ new references: @DIMENSION_SCALES_WITH_NEW_REF@
|
||||
Concurrency: @HDF5_ENABLE_CONCURRENCY@
|
||||
Default API mapping: @HDF5_DEFAULT_API_VERSION@
|
||||
With deprecated public symbols: @HDF5_ENABLE_DEPRECATED_SYMBOLS@
|
||||
I/O filters (external): @EXTERNAL_FILTERS@
|
||||
I/O filters (external): @SETTINGS_EXTERNAL_FILTERS@
|
||||
_Float16 support: @HDF5_ENABLE_NONSTANDARD_FEATURE_FLOAT16@
|
||||
Map (H5M) API: @HDF5_ENABLE_MAP_API@
|
||||
Direct VFD: @HDF5_ENABLE_DIRECT_VFD@
|
||||
|
||||
@@ -119,7 +119,7 @@ set (zip_perf_SOURCES
|
||||
)
|
||||
if (H5_ZLIB_HEADER)
|
||||
message (VERBOSE "H5_ZLIB_HEADER for zip_perf=${H5_ZLIB_HEADER}")
|
||||
if (HDF5_USE_ZLIB_NG AND NOT ZLIB_COMPAT)
|
||||
if (HDF5_USE_ZLIB_NG AND NOT ZLIB_COMPAT AND NOT ZLIBNG_ZLIB_COMPAT)
|
||||
add_compile_definitions(H5_HAVE_ZLIBNG_H=1 H5_ZLIB_HEADER="${H5_ZLIB_HEADER}")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
Reference in New Issue
Block a user