From 456ebba0fbeff3951764acab396ba161297e99ef Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 20 Aug 2010 10:16:06 -0500 Subject: [svn-r19257] Change Cmake to allow a local zlib header to be used in H5Zdelate module. Corrected use of "SKIP" message in cmake. Corrections to cmake configuration files (for cmake external projects). Community suggested changes. Tested: local linux --- CMakeLists.txt | 105 +++++++++++++++++++++--------- MANIFEST | 2 +- config/cmake/hdf5-config-version.cmake.in | 27 ++++++++ config/cmake/hdf5-config.cmake.build.in | 68 ++++++++++--------- config/cmake/hdf5-config.cmake.install.in | 61 ++++++++++++----- config/cmake/hdf5_zlib.h.in | 1 - src/CMakeLists.txt | 31 +++++---- src/H5Zdeflate.c | 7 +- tools/h5dump/CMakeLists.txt | 5 +- 9 files changed, 211 insertions(+), 96 deletions(-) create mode 100644 config/cmake/hdf5-config-version.cmake.in delete mode 100644 config/cmake/hdf5_zlib.h.in diff --git a/CMakeLists.txt b/CMakeLists.txt index 04c0bfe..ebef2b3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,12 @@ PROJECT (HDF5 C CXX) # name conflicts with system versions, then a prefix may be added # to ensure that the correct versions configured are used. # +# HDF5_INSTALL_BIN_DIR, HDF5_INSTALL_LIB_DIR, HDF5_INSTALL_INCLUDE_DIR : +# Customize the 'bin', 'lib', and 'include' installation directories. +# +# HDF5_INSTALL_NO_DEVELOPMENT : +# Set to true to skip installation of headers and CMake package files. +# # Consider this example from the ParaView project, it builds its own zlib # library and tells HDF5 to add it as a dependency - this ensures that # any project making use of this build of HDF5 will use the correct zlib @@ -128,6 +134,16 @@ SET (HDF5_F90_SOURCE_DIR ${HDF5_SOURCE_DIR}/fortran) # set default prefix location SET (CMAKE_INSTALL_PREFIX "./hdf5" CACHE PATH "Install path prefix, prepended onto install directories") +IF (NOT HDF5_INSTALL_BIN_DIR) + SET(HDF5_INSTALL_BIN_DIR bin) +ENDIF() +IF (NOT HDF5_INSTALL_LIB_DIR) + SET(HDF5_INSTALL_LIB_DIR lib) +ENDIF() +IF (NOT HDF5_INSTALL_INCLUDE_DIR) + SET(HDF5_INSTALL_INCLUDE_DIR include) +ENDIF() + #----------------------------------------------------------------------------- # parse the full version number from H5public.h and include in H5_VERS_INFO #----------------------------------------------------------------------------- @@ -576,36 +592,43 @@ CONFIGURE_FILE (${HDF5_RESOURCES_DIR}/H5pubconf.h.in ${HDF5_BINARY_DIR}/H5pubcon #----------------------------------------------------------------------------- # Add file(s) to CMake Install #----------------------------------------------------------------------------- -INSTALL ( - FILES - ${PROJECT_BINARY_DIR}/H5pubconf.h - DESTINATION - include - COMPONENT - headers -) +IF (NOT HDF5_INSTALL_NO_DEVELOPMENT) + INSTALL ( + FILES + ${PROJECT_BINARY_DIR}/H5pubconf.h + DESTINATION + ${HDF5_INSTALL_INCLUDE_DIR} + COMPONENT + headers + ) +ENDIF () #----------------------------------------------------------------------------- # Add Target(s) to CMake Install for import into other projects #----------------------------------------------------------------------------- -INSTALL ( - EXPORT - ${HDF5_EXPORTED_TARGETS} - DESTINATION - lib/cmake/hdf5-${HDF5_PACKAGE_VERSION} - FILE - hdf5-targets.cmake -) +IF (NOT HDF5_EXTERNALLY_CONFIGURED) + INSTALL ( + EXPORT + ${HDF5_EXPORTED_TARGETS} + DESTINATION + lib/cmake/hdf5-${HDF5_PACKAGE_VERSION} + FILE + hdf5-targets.cmake + ) +ENDIF () #----------------------------------------------------------------------------- # Export all exported targets to the build tree for use by parent project #----------------------------------------------------------------------------- -EXPORT ( - TARGETS - ${HDF5_LIBRARIES_TO_EXPORT} ${HDF5_LIB_DEPENDENCIES} - FILE - hdf5-targets.cmake -) +IF (NOT HDF5_EXTERNALLY_CONFIGURED) + EXPORT ( + TARGETS + ${HDF5_LIBRARIES_TO_EXPORT} ${HDF5_LIB_DEPENDENCIES} + FILE + hdf5-targets.cmake + ) +ENDIF () + #----------------------------------------------------------------------------- # Configure the hdf5-config.cmake file for the build directory #----------------------------------------------------------------------------- @@ -625,16 +648,34 @@ CONFIGURE_FILE ( #----------------------------------------------------------------------------- # Configure the hdf5-config.cmake file for the install directory #----------------------------------------------------------------------------- -CONFIGURE_FILE ( - ${HDF5_RESOURCES_DIR}/hdf5-config.cmake.install.in - ${HDF5_BINARY_DIR}/CMakeFiles/hdf5-config.cmake @ONLY -) -INSTALL ( - FILES - ${HDF5_BINARY_DIR}/CMakeFiles/hdf5-config.cmake - DESTINATION - lib/cmake/hdf5-${HDF5_PACKAGE_VERSION} -) +IF (NOT HDF5_EXTERNALLY_CONFIGURED) + CONFIGURE_FILE ( + ${HDF5_RESOURCES_DIR}/hdf5-config.cmake.install.in + ${HDF5_BINARY_DIR}/CMakeFiles/hdf5-config.cmake @ONLY + ) + INSTALL ( + FILES + ${HDF5_BINARY_DIR}/CMakeFiles/hdf5-config.cmake + DESTINATION + lib/cmake/hdf5-${HDF5_PACKAGE_VERSION} + ) +ENDIF () + +#----------------------------------------------------------------------------- +# Configure the hdf5-config-version .cmake file for the install directory +#----------------------------------------------------------------------------- +IF (NOT HDF5_EXTERNALLY_CONFIGURED) + CONFIGURE_FILE ( + ${HDF5_RESOURCES_DIR}/hdf5-config-version.cmake.in + ${HDF5_BINARY_DIR}/CMakeFiles/hdf5-config-version.cmake @ONLY + ) + INSTALL ( + FILES + ${HDF5_BINARY_DIR}/CMakeFiles/hdf5-config-version.cmake + DESTINATION + lib/cmake/hdf5-${HDF5_PACKAGE_VERSION} + ) +ENDIF () #----------------------------------------------------------------------------- # Set the cpack variables diff --git a/MANIFEST b/MANIFEST index 5c1d799..6e76ba4 100644 --- a/MANIFEST +++ b/MANIFEST @@ -1870,10 +1870,10 @@ ./config/cmake/CheckTypeSize.cmake ./config/cmake/H5cxx_config.h.in ./config/cmake/H5pubconf.h.in -./config/cmake/hdf5_zlib.h.in ./config/cmake/FindHDF5.cmake ./config/cmake/hdf5-config.cmake.build.in ./config/cmake/hdf5-config.cmake.install.in +./config/cmake/hdf5-config-version.cmake.in ./config/cmake/HDF5Macros.cmake ./config/cmake/libhdf5.settings.cmake.in ./config/cmake/cacheinit.cmake diff --git a/config/cmake/hdf5-config-version.cmake.in b/config/cmake/hdf5-config-version.cmake.in new file mode 100644 index 0000000..c1201cc --- /dev/null +++ b/config/cmake/hdf5-config-version.cmake.in @@ -0,0 +1,27 @@ +#----------------------------------------------------------------------------- +# HDF5 Version file for install directory +#----------------------------------------------------------------------------- + +SET (PACKAGE_VERSION @HDF5_VERSION_STRING@) + +IF ("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL @H5_VERS_MAJOR@) + + # exact match for version @H5_VERS_MAJOR@.@H5_VERS_MINOR@ + IF ("${PACKAGE_FIND_VERSION_MINOR}" EQUAL @H5_VERS_MINOR@) + + # compatible with any version @H5_VERS_MAJOR@.@H5_VERS_MINOR@.x + SET (PACKAGE_VERSION_COMPATIBLE 1) + + IF ("${PACKAGE_FIND_VERSION_PATCH}" EQUAL @H5_VERS_RELEASE@) + SET (PACKAGE_VERSION_EXACT 1) + + IF ("${PACKAGE_FIND_VERSION_TWEAK}" EQUAL @H5_VERS_SUBRELEASE@) + # not using this yet + ENDIF ("${PACKAGE_FIND_VERSION_TWEAK}" EQUAL @H5_VERS_SUBRELEASE@) + + ENDIF ("${PACKAGE_FIND_VERSION_PATCH}" EQUAL @H5_VERS_RELEASE@) + + ENDIF ("${PACKAGE_FIND_VERSION_MINOR}" EQUAL @H5_VERS_MINOR@) +ENDIF ("${PACKAGE_FIND_VERSION_MAJOR}" EQUAL @H5_VERS_MAJOR@) + + diff --git a/config/cmake/hdf5-config.cmake.build.in b/config/cmake/hdf5-config.cmake.build.in index 132e8be..ecbde48 100644 --- a/config/cmake/hdf5-config.cmake.build.in +++ b/config/cmake/hdf5-config.cmake.build.in @@ -1,42 +1,50 @@ #----------------------------------------------------------------------------- # HDF5 Config file for compiling against hdf5 build directory #----------------------------------------------------------------------------- - -SET (HDF5_INCLUDE_DIRS "@HDF5_INCLUDES_BUILD_TIME@") +GET_FILENAME_COMPONENT (SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) #----------------------------------------------------------------------------- -# Don't include targets if this file is being picked up by another -# project which has already build hdf5 as a subproject +# User Options #----------------------------------------------------------------------------- -IF (NOT TARGET "hdf5" AND NOT HDF5_INSTALL_SKIP_TARGETS) - GET_FILENAME_COMPONENT (SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) - INCLUDE (${SELF_DIR}/HDF5-targets.cmake) -ENDIF (NOT TARGET "hdf5" AND NOT HDF5_INSTALL_SKIP_TARGETS) - -SET (HDF5_VERSION_STRING @HDF5_VERSION_STRING@) -SET (HDF5_VERSION_MAJOR @HDF5_VERSION_MAJOR@) -SET (HDF5_VERSION_MINOR @HDF5_VERSION_MINOR@) - SET (HDF5_ENABLE_PARALLEL @HDF5_ENABLE_PARALLEL@) SET (HDF5_BUILD_FORTRAN @HDF5_BUILD_FORTRAN@) SET (HDF5_BUILD_CPP_LIB @HDF5_BUILD_CPP_LIB@) SET (HDF5_BUILD_TOOLS @HDF5_BUILD_TOOLS@) SET (HDF5_BUILD_HL_LIB @HDF5_BUILD_HL_LIB@) -# -# To be continued ... -# -# XXX_INCLUDE_DIRS The final set of include directories listed in one variable for use by client code. This should not be a cache entry. -# XXX_LIBRARIES The libraries to link against to use XXX. These should include full paths. This should not be a cache entry. -# XXX_DEFINITIONS Definitions to use when compiling code that uses XXX. This really shouldn't include options such as (-DHAS_JPEG)that a client source-code file uses to decide whether to #include -# XXX_EXECUTABLE Where to find the XXX tool. -# XXX_YYY_EXECUTABLE Where to find the YYY tool that comes with XXX. -# XXX_LIBRARY_DIRS Optionally, the final set of library directories listed in one variable for use by client code. This should not be a cache entry. -# XXX_ROOT_DIR Where to find the base directory of XXX. -# XXX_VERSION_YY Expect Version YY if true. Make sure at most one of these is ever true. -# XXX_WRAP_YY If False, do not try to use the relevent CMake wrapping command. -# XXX_YY_FOUND If False, optional YY part of XXX sytem is not available. -# XXX_FOUND Set to false, or undefined, if we haven't found, or don't want to use XXX. -# XXX_RUNTIME_LIBRARY_DIRS Optionally, the runtime library search path for use when running an executable linked to shared libraries. -# The list should be used by user code to create the PATH on windows or LD_LIBRARY_PATH on unix. -# This should not be a cache entry. +#----------------------------------------------------------------------------- +# Directories +#----------------------------------------------------------------------------- +SET (HDF5_INCLUDE_DIR "@HDF5_INCLUDES_BUILD_TIME@") + +IF (HDF5_BUILD_FORTRAN) + SET (HDF5_INCLUDE_DIR_FORTRAN "@CMAKE_Fortran_MODULE_DIRECTORY@" ) +ENDIF (HDF5_BUILD_FORTRAN) + +IF (HDF5_BUILD_CPP_LIB) + SET (HDF5_INCLUDE_DIR_CPP ${HDF5_INCLUDE_DIR} ) +ENDIF (HDF5_BUILD_CPP_LIB) + +IF (HDF5_BUILD_HL_LIB) + SET (HDF5_INCLUDE_DIR_HL ${HDF5_INCLUDE_DIR} ) +ENDIF (HDF5_BUILD_HL_LIB) + +IF (HDF5_BUILD_TOOLS) + SET (HDF5_INCLUDE_DIR_CPP ${HDF5_INCLUDE_DIR} ) +ENDIF (HDF5_BUILD_TOOLS) + +#----------------------------------------------------------------------------- +# Version Strings +#----------------------------------------------------------------------------- +SET (HDF5_VERSION_STRING @HDF5_VERSION_STRING@) +SET (HDF5_VERSION_MAJOR @HDF5_VERSION_MAJOR@) +SET (HDF5_VERSION_MINOR @HDF5_VERSION_MINOR@) + +#----------------------------------------------------------------------------- +# Don't include targets if this file is being picked up by another +# project which has already build hdf5 as a subproject +#----------------------------------------------------------------------------- +IF (NOT TARGET "hdf5") + GET_FILENAME_COMPONENT (SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) + INCLUDE (${SELF_DIR}/hdf5-targets.cmake) +ENDIF (NOT TARGET "hdf5") diff --git a/config/cmake/hdf5-config.cmake.install.in b/config/cmake/hdf5-config.cmake.install.in index 2c33edf..4fda6e8 100644 --- a/config/cmake/hdf5-config.cmake.install.in +++ b/config/cmake/hdf5-config.cmake.install.in @@ -1,35 +1,62 @@ #----------------------------------------------------------------------------- # HDF5 Config file for compiling against hdf5 install directory #----------------------------------------------------------------------------- - GET_FILENAME_COMPONENT (SELF_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) -GET_FILENAME_COMPONENT (HDF5_INCLUDE_DIRS "${SELF_DIR}/../include" ABSOLUTE) -SET (HDF5_FORTRAN_DIR ${HDF5_INCLUDE_DIRS}/fortran) #----------------------------------------------------------------------------- -# Don't include targets if this file is being picked up by another -# project which has already build hdf5 as a subproject +# User Options #----------------------------------------------------------------------------- -IF (NOT TARGET "hdf5") - INCLUDE (${SELF_DIR}/HDF5-targets.cmake) -ENDIF (NOT TARGET "hdf5") - -SET (HDF5_VERSION_STRING @HDF5_VERSION_STRING@) -SET (HDF5_VERSION_MAJOR @HDF5_VERSION_MAJOR@) -SET (HDF5_VERSION_MINOR @HDF5_VERSION_MINOR@) - SET (HDF5_ENABLE_PARALLEL @HDF5_ENABLE_PARALLEL@) SET (HDF5_BUILD_FORTRAN @HDF5_BUILD_FORTRAN@) SET (HDF5_BUILD_CPP_LIB @HDF5_BUILD_CPP_LIB@) SET (HDF5_BUILD_TOOLS @HDF5_BUILD_TOOLS@) SET (HDF5_BUILD_HL_LIB @HDF5_BUILD_HL_LIB@) +#----------------------------------------------------------------------------- +# Directories +#----------------------------------------------------------------------------- +SET (HDF5_INCLUDE_DIR "@CMAKE_INSTALL_PREFIX@/include" ) + +IF (HDF5_BUILD_FORTRAN) + SET (HDF5_INCLUDE_DIR_FORTRAN "@CMAKE_INSTALL_PREFIX@/include/fortran" ) +ENDIF (HDF5_BUILD_FORTRAN) + +IF (HDF5_BUILD_CPP_LIB) + SET (HDF5_INCLUDE_DIR_CPP "@CMAKE_INSTALL_PREFIX@/include/cpp" ) +ENDIF (HDF5_BUILD_CPP_LIB) + +IF (HDF5_BUILD_HL_LIB) + SET (HDF5_INCLUDE_DIR_HL "@CMAKE_INSTALL_PREFIX@/include/hl" ) +ENDIF (HDF5_BUILD_HL_LIB) + +IF (HDF5_BUILD_TOOLS) + SET (HDF5_INCLUDE_DIR_CPP "@CMAKE_INSTALL_PREFIX@/include/tools" ) +ENDIF (HDF5_BUILD_TOOLS) + +#----------------------------------------------------------------------------- +# Version Strings +#----------------------------------------------------------------------------- +SET (HDF5_VERSION_STRING @HDF5_VERSION_STRING@) +SET (HDF5_VERSION_MAJOR @HDF5_VERSION_MAJOR@) +SET (HDF5_VERSION_MINOR @HDF5_VERSION_MINOR@) + +#----------------------------------------------------------------------------- +# Don't include targets if this file is being picked up by another +# project which has already built hdf5 as a subproject +#----------------------------------------------------------------------------- +IF (NOT TARGET "hdf5") + INCLUDE (${SELF_DIR}/hdf5-targets.cmake) +ENDIF (NOT TARGET "hdf5") + +#----------------------------------------------------------------------------- +# Unfinished +#----------------------------------------------------------------------------- # -# To be continued ... +# To be continued (maybe) ... # -# XXX_INCLUDE_DIRS The final set of include directories listed in one variable for use by client code. This should not be a cache entry. -# XXX_LIBRARIES The libraries to link against to use XXX. These should include full paths. This should not be a cache entry. -# XXX_DEFINITIONS Definitions to use when compiling code that uses XXX. This really shouldn't include options such as (-DHAS_JPEG)that a client source-code file uses to decide whether to #include +# XXX_INCLUDE_DIRS no, use one per library as in HDF5_FORTRAN_INCLUDE_DIR +# XXX_LIBRARIES not needed - see hdf5-targets.cmake +# XXX_DEFINITIONS Definitions to use when compiling code that uses XXX. This really shouldn't include options such as (-DHAS_JPEG) that a client source-code file uses to decide whether to #include # XXX_EXECUTABLE Where to find the XXX tool. # XXX_YYY_EXECUTABLE Where to find the YYY tool that comes with XXX. # XXX_LIBRARY_DIRS Optionally, the final set of library directories listed in one variable for use by client code. This should not be a cache entry. diff --git a/config/cmake/hdf5_zlib.h.in b/config/cmake/hdf5_zlib.h.in deleted file mode 100644 index 104db27..0000000 --- a/config/cmake/hdf5_zlib.h.in +++ /dev/null @@ -1 +0,0 @@ -#include <@H5_ZLIB_HEADER@> diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c64d4f0..bcec81c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -417,6 +417,11 @@ SET (H5Z_SRCS ${HDF5_SRC_DIR}/H5Zszip.c ${HDF5_SRC_DIR}/H5Ztrans.c ) +IF (H5_ZLIB_HEADER) + SET_PROPERTY(SOURCE ${HDF5_SRC_DIR}/H5Zdeflate.c PROPERTY + COMPILE_DEFINITIONS H5_ZLIB_HEADER="${H5_ZLIB_HEADER}") +ENDIF (H5_ZLIB_HEADER) + SET (H5Z_HDRS ${HDF5_SRC_DIR}/H5Zpkg.h @@ -642,15 +647,17 @@ H5_SET_LIB_OPTIONS (${HDF5_LIB_TARGET} ${HDF5_LIB_NAME} ${LIB_TYPE}) #----------------------------------------------------------------------------- # Add file(s) to CMake Install #----------------------------------------------------------------------------- -INSTALL ( - FILES - ${H5_PUBLIC_HEADERS} - ${H5_PRIVATE_HEADERS} - DESTINATION - include - COMPONENT - headers -) +IF (NOT HDF5_INSTALL_NO_DEVELOPMENT) + INSTALL ( + FILES + ${H5_PUBLIC_HEADERS} + ${H5_PRIVATE_HEADERS} + DESTINATION + ${HDF5_INSTALL_INCLUDE_DIR} + COMPONENT + headers + ) +ENDIF () #----------------------------------------------------------------------------- # Add Target(s) to CMake Install for import into other projects @@ -661,8 +668,8 @@ IF (HDF5_EXPORTED_TARGETS) ${HDF5_LIB_TARGET} EXPORT ${HDF5_EXPORTED_TARGETS} - LIBRARY DESTINATION lib COMPONENT libraries - ARCHIVE DESTINATION lib COMPONENT libraries - RUNTIME DESTINATION bin COMPONENT libraries + LIBRARY DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT libraries + ARCHIVE DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT libraries + RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT libraries ) ENDIF (HDF5_EXPORTED_TARGETS) diff --git a/src/H5Zdeflate.c b/src/H5Zdeflate.c index c490720..63e7b9a 100644 --- a/src/H5Zdeflate.c +++ b/src/H5Zdeflate.c @@ -28,8 +28,11 @@ #ifdef H5_HAVE_FILTER_DEFLATE -#ifdef H5_HAVE_ZLIB_H -# include "zlib.h" +#if defined(H5_HAVE_ZLIB_H) && !defined(H5_ZLIB_HEADER) +# define H5_ZLIB_HEADER "zlib.h" +#endif +#if defined(H5_ZLIB_HEADER) +# include H5_ZLIB_HEADER /* "zlib.h" */ #endif /* Local function prototypes */ diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt index 00ff759..04d246c 100644 --- a/tools/h5dump/CMakeLists.txt +++ b/tools/h5dump/CMakeLists.txt @@ -326,7 +326,10 @@ IF (BUILD_TESTING) MACRO (ADD_SKIP_H5_TEST skipresultfile skipresultcode testtype) IF (${testtype} STREQUAL "SKIP") - MESSAGE (STATUS "SKIP ${skipresultfile} ${ARGN}") + ADD_TEST ( + NAME H5REPACK-${testname} + COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${skipresultfile} ${ARGN}" + ) ELSE (${testtype} STREQUAL "SKIP") ADD_H5_TEST (${skipresultfile} ${skipresultcode} ${ARGN}) ENDIF (${testtype} STREQUAL "SKIP") -- cgit v0.12