diff options
Diffstat (limited to 'CMakeFilters.cmake')
-rw-r--r-- | CMakeFilters.cmake | 88 |
1 files changed, 68 insertions, 20 deletions
diff --git a/CMakeFilters.cmake b/CMakeFilters.cmake index 725390b..953a060 100644 --- a/CMakeFilters.cmake +++ b/CMakeFilters.cmake @@ -11,16 +11,44 @@ # option (USE_LIBAEC "Use AEC library as SZip Filter" OFF) option (USE_LIBAEC_STATIC "Use static AEC library " OFF) +option (ZLIB_USE_EXTERNAL "Use External Library Building for ZLIB" 0) +option (SZIP_USE_EXTERNAL "Use External Library Building for SZIP" 0) -include (ExternalProject) -include (FetchContent) +option (BUILD_ZLIB_WITH_FETCHCONTENT "Use FetchContent to use original source files" OFF) +if (BUILD_ZLIB_WITH_FETCHCONTENT) + set (ZLIB_USE_EXTERNAL "Use External Library Building for ZLIB" 1) + if (NOT ZLIB_USE_LOCALCONTENT) + set (ZLIB_URL ${ZLIB_TGZ_ORIGPATH}/${ZLIB_TGZ_ORIGNAME}) + else () + set (ZLIB_URL ${TGZPATH}/${ZLIB_TGZ_ORIGNAME}) + endif () + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Filter ZLIB file is ${ZLIB_URL}") + endif () +endif () + +option (BUILD_SZIP_WITH_FETCHCONTENT "Use FetchContent to use original source files" OFF) +if (BUILD_SZIP_WITH_FETCHCONTENT) + # Only libaec library is usable + set (USE_LIBAEC ON CACHE BOOL "Use libaec szip replacement" FORCE) + set (SZIP_USE_EXTERNAL "Use External Library Building for SZIP" 1) + if (NOT LIBAEC_USE_LOCALCONTENT) + set (SZIP_URL ${LIBAEC_TGZ_ORIGPATH}/${LIBAEC_TGZ_ORIGNAME}) + else () + set (SZIP_URL ${TGZPATH}/${LIBAEC_TGZ_ORIGNAME}) + endif () + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "Filter SZIP file is ${SZIP_URL}") + endif () +endif () +include (ExternalProject) #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") - option (ZLIB_USE_EXTERNAL "Use External Library Building for HDF5_ZLIB" 1) - option (SZIP_USE_EXTERNAL "Use External Library Building for SZIP" 1) + set (ZLIB_USE_EXTERNAL "Use External Library Building for ZLIB" 1) + set (SZIP_USE_EXTERNAL "Use External Library Building for SZIP" 1) if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT") set (ZLIB_URL ${ZLIB_GIT_URL} CACHE STRING "Path to zlib git repository") set (ZLIB_BRANCH ${ZLIB_GIT_BRANCH}) @@ -30,16 +58,20 @@ if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MAT if (NOT TGZPATH) set (TGZPATH ${HDF5_SOURCE_DIR}) endif () - set (ZLIB_URL ${TGZPATH}/${ZLIB_TGZ_NAME}) + if (NOT BUILD_ZLIB_WITH_FETCHCONTENT) + set (ZLIB_URL ${TGZPATH}/${ZLIB_TGZ_NAME}) + endif () if (NOT EXISTS "${ZLIB_URL}") set (HDF5_ENABLE_Z_LIB_SUPPORT OFF CACHE BOOL "" FORCE) if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") message (VERBOSE "Filter ZLIB file ${ZLIB_URL} not found") endif () endif () - set (SZIP_URL ${TGZPATH}/${SZIP_TGZ_NAME}) - if (USE_LIBAEC) - set (SZIP_URL ${TGZPATH}/${SZAEC_TGZ_NAME}) + if (NOT BUILD_SZIP_WITH_FETCHCONTENT) + set (SZIP_URL ${TGZPATH}/${SZIP_TGZ_NAME}) + if (USE_LIBAEC) + set (SZIP_URL ${TGZPATH}/${SZAEC_TGZ_NAME}) + endif () endif () if (NOT EXISTS "${SZIP_URL}") set (HDF5_ENABLE_SZIP_SUPPORT OFF CACHE BOOL "" FORCE) @@ -63,9 +95,6 @@ if (HDF5_ENABLE_Z_LIB_SUPPORT) find_package (ZLIB NAMES ${ZLIB_PACKAGE_NAME}${HDF_PACKAGE_EXT} COMPONENTS static shared) if (NOT ZLIB_FOUND) find_package (ZLIB) # Legacy find - if (ZLIB_FOUND) - set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${ZLIB_LIBRARIES}) - endif () endif () endif () if (ZLIB_FOUND) @@ -76,7 +105,16 @@ if (HDF5_ENABLE_Z_LIB_SUPPORT) set (ZLIB_INCLUDE_DIR_GEN ${ZLIB_INCLUDE_DIR}) set (ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) else () - if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") + if (BUILD_ZLIB_WITH_FETCHCONTENT) + # Only tgz files available + ORIGINAL_ZLIB_LIBRARY ("TGZ") + set (H5_HAVE_FILTER_DEFLATE 1) + set (H5_HAVE_ZLIB_H 1) + set (H5_HAVE_LIBZ 1) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "HDF5_ZLIB is built from fetch content") + endif () + elseif (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") EXTERNAL_ZLIB_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT}) set (H5_HAVE_FILTER_DEFLATE 1) set (H5_HAVE_ZLIB_H 1) @@ -115,18 +153,11 @@ if (HDF5_ENABLE_SZIP_SUPPORT) if (USE_LIBAEC) set(libaec_USE_STATIC_LIBS ${USE_LIBAEC_STATIC}) find_package (libaec 1.0.5 CONFIG) - if (SZIP_FOUND) - set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_LIBRARIES}) - endif () endif () - if (NOT SZIP_FOUND) find_package (SZIP NAMES ${SZIP_PACKAGE_NAME}${HDF_PACKAGE_EXT} COMPONENTS static shared) if (NOT SZIP_FOUND) find_package (SZIP) # Legacy find - if (SZIP_FOUND) - set (LINK_COMP_LIBS ${LINK_COMP_LIBS} ${SZIP_LIBRARIES}) - endif () endif () endif () endif () @@ -137,7 +168,24 @@ if (HDF5_ENABLE_SZIP_SUPPORT) set (SZIP_INCLUDE_DIR_GEN ${SZIP_INCLUDE_DIR}) set (SZIP_INCLUDE_DIRS ${SZIP_INCLUDE_DIRS} ${SZIP_INCLUDE_DIR}) else () - if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") + if (BUILD_SZIP_WITH_FETCHCONTENT) + # Only tgz files available + ORIGINAL_SZIP_LIBRARY ("TGZ" ${HDF5_ENABLE_SZIP_ENCODING}) + set (H5_HAVE_FILTER_SZIP 1) + set (H5_HAVE_SZLIB_H 1) + set (H5_HAVE_LIBSZ 1) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "SZIP is built from fetch content") + endif () + if (USE_LIBAEC) + if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0") + message (VERBOSE "... with library AEC") + endif () + set (SZIP_PACKAGE_NAME ${LIBAEC_PACKAGE_NAME}) + else () + set (SZIP_PACKAGE_NAME ${SZIP_PACKAGE_NAME}) + endif () + elseif (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "GIT" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") EXTERNAL_SZIP_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT} ${HDF5_ENABLE_SZIP_ENCODING}) set (H5_HAVE_FILTER_SZIP 1) set (H5_HAVE_SZLIB_H 1) |