diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2010-09-28 18:28:28 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2010-09-28 18:28:28 (GMT) |
commit | 0a00129baeee660977e6421a49c66dc3fee18733 (patch) | |
tree | 81f7e4bf381340313e6f131946477736ce5a4934 /CMakeLists.txt | |
parent | 09384e14e785498ab1843dcba9a5011743d01343 (diff) | |
download | hdf5-0a00129baeee660977e6421a49c66dc3fee18733.zip hdf5-0a00129baeee660977e6421a49c66dc3fee18733.tar.gz hdf5-0a00129baeee660977e6421a49c66dc3fee18733.tar.bz2 |
[svn-r19486] Add ExternalProject support for external libs - option added Defaults to NO. SVN allows downloading project from svn. Future option is to use a tar file.
Tested: Windows, local Linux
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 114 |
1 files changed, 96 insertions, 18 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ce6b757..202909f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -435,20 +435,57 @@ HDF5_SETUP_FILTERS (FLETCHER32) HDF5_SETUP_FILTERS (NBIT) HDF5_SETUP_FILTERS (SCALEOFFSET) +INCLUDE (ExternalProject) +OPTION (HDF5_ALLOW_EXTERNAL_SUPPORT "Allow External Library Building" "NO") + #----------------------------------------------------------------------------- # Option for ZLib support #----------------------------------------------------------------------------- OPTION (HDF5_ENABLE_Z_LIB_SUPPORT "Enable Zlib Filters" OFF) IF (HDF5_ENABLE_Z_LIB_SUPPORT) IF (NOT H5_ZLIB_HEADER) - FIND_PACKAGE (ZLIB REQUIRED) + FIND_PACKAGE (ZLIB) IF (ZLIB_FOUND) SET (H5_HAVE_FILTER_DEFLATE 1) SET (H5_HAVE_ZLIB_H 1) SET (H5_HAVE_LIBZ 1) SET (H5_ZLIB_HEADER "zlib.h") ELSE (ZLIB_FOUND) - MESSAGE (FATAL " ZLib is Required for ZLib support in HDF5") + IF (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN") + EXTERNALPROJECT_ADD (ZLIB + SVN_REPOSITORY http://svn.hdfgroup.uiuc.edu/zlib/trunk + # [SVN_REVISION rev] + INSTALL_COMMAND "" + CMAKE_ARGS + -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + ) + EXTERNALPROJECT_GET_PROPERTY (ZLIB BINARY_DIR SOURCE_DIR) + + IF (BUILD_SHARED_LIBS) + SET (ZLIB_LIBRARY + "${BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}zlib1${CMAKE_IMPORT_LIBRARY_SUFFIX}" + ) + ELSE (BUILD_SHARED_LIBS) + SET (ZLIB_LIBRARY + "${BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}zlib${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) + ENDIF (BUILD_SHARED_LIBS) + SET (ZLIB_INCLUDE_DIR_GEN + "${BINARY_DIR}" + ) + SET (ZLIB_INCLUDE_DIR + "${SOURCE_DIR}/src" + ) + + SET (ZLIB_FOUND 1) + SET (ZLIB_LIBRARIES ${ZLIB_LIBRARY}) + SET (ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR_GEN} ${ZLIB_INCLUDE_DIR}) + SET (H5_HAVE_FILTER_DEFLATE 1) + SET (H5_HAVE_ZLIB_H 1) + SET (H5_HAVE_LIBZ 1) + ELSE (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN") + MESSAGE (FATAL " ZLib is Required for ZLib support in HDF5") + ENDIF (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN") ENDIF (ZLIB_FOUND) ELSE (NOT H5_ZLIB_HEADER) # This project is being called from within another and ZLib is already configured @@ -467,23 +504,57 @@ ENDIF (HDF5_ENABLE_Z_LIB_SUPPORT) SET (CMAKE_MODULE_PATH ${HDF5_RESOURCES_DIR} ${CMAKE_MODULE_PATH}) OPTION (HDF5_ENABLE_SZIP_SUPPORT "Use SZip Filter" OFF) IF (HDF5_ENABLE_SZIP_SUPPORT) - FIND_PACKAGE (SZIP REQUIRED) + OPTION (HDF5_ENABLE_SZIP_ENCODING "Use SZip Encoding" OFF) + FIND_PACKAGE (SZIP) IF (SZIP_FOUND) SET (H5_HAVE_FILTER_SZIP 1) SET (H5_HAVE_SZLIB_H 1) SET (H5_HAVE_LIBSZ 1) - SET (LINK_LIBS ${LINK_LIBS} ${SZIP_LIBRARIES}) - INCLUDE_DIRECTORIES (${SZIP_INCLUDE_DIRS}) -# MESSAGE (STATUS "SZIP_INCLUDE_DIRS: ${SZIP_INCLUDE_DIRS}") -# MESSAGE (STATUS "SZIP_INCLUDE_DIR: ${SZIP_INCLUDE_DIR}") - MESSAGE (STATUS "Filter SZIP is ON") - OPTION (HDF5_ENABLE_SZIP_ENCODING "Use SZip Encoding" OFF) - IF (HDF5_ENABLE_SZIP_ENCODING) - SET (H5_HAVE_SZIP_ENCODER 1) - ENDIF (HDF5_ENABLE_SZIP_ENCODING) ELSE (SZIP_FOUND) + IF (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN") + EXTERNALPROJECT_ADD (SZIP + SVN_REPOSITORY http://svn.hdfgroup.uiuc.edu/szip/trunk + # [SVN_REVISION rev] + INSTALL_COMMAND "" + CMAKE_ARGS + -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DSZIP_ENABLE_ENCODING:BOOL=${HDF5_ENABLE_SZIP_ENCODING} + ) + EXTERNALPROJECT_GET_PROPERTY (SZIP BINARY_DIR SOURCE_DIR) + + + IF (BUILD_SHARED_LIBS) + SET (SZIP_LIBRARY + "${BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/${CMAKE_IMPORT_LIBRARY_PREFIX}szip${CMAKE_IMPORT_LIBRARY_SUFFIX}" + ) + ELSE (BUILD_SHARED_LIBS) + SET (SZIP_LIBRARY + "${BINARY_DIR}/bin/${CMAKE_CFG_INTDIR}/${CMAKE_STATIC_LIBRARY_PREFIX}szip${CMAKE_STATIC_LIBRARY_SUFFIX}" + ) + ENDIF (BUILD_SHARED_LIBS) + SET (SZIP_INCLUDE_DIR_GEN + "${BINARY_DIR}" + ) + SET (SZIP_INCLUDE_DIR + "${SOURCE_DIR}/src" + ) + + SET (SZIP_FOUND 1) + SET (SZIP_LIBRARIES ${SZIP_LIBRARY}) + SET (SZIP_INCLUDE_DIRS ${SZIP_INCLUDE_DIR_GEN} ${SZIP_INCLUDE_DIR}) + SET (H5_HAVE_FILTER_SZIP 1) + SET (H5_HAVE_SZLIB_H 1) + SET (H5_HAVE_LIBSZ 1) + ELSE (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN") MESSAGE (FATAL_ERROR "SZIP is Required for SZIP support in HDF5") + ENDIF (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN") ENDIF (SZIP_FOUND) + SET (LINK_LIBS ${LINK_LIBS} ${SZIP_LIBRARIES}) + INCLUDE_DIRECTORIES (${SZIP_INCLUDE_DIRS}) + MESSAGE (STATUS "Filter SZIP is ON") + IF (HDF5_ENABLE_SZIP_ENCODING) + SET (H5_HAVE_SZIP_ENCODER 1) + ENDIF (HDF5_ENABLE_SZIP_ENCODING) ENDIF (HDF5_ENABLE_SZIP_SUPPORT) #----------------------------------------------------------------------------- @@ -500,7 +571,7 @@ IF (WIN32) GET_FILENAME_COMPONENT(ZLIB_BIN_PATH ${ZLIB_LIBRARY} PATH) # MESSAGE (STATUS "ZLIB_BIN_PATH: ${ZLIB_BIN_PATH}") ADD_CUSTOM_TARGET (ZLIB-Release-Copy ALL - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ZLIB_BIN_PATH}/${ZLIB_DLL_NAME}.dll ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/ + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ZLIB_BIN_PATH}/${ZLIB_DLL_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/ COMMENT "Copying ${ZLIB_BIN_PATH}/${ZLIB_DLL_NAME}.dll to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/" ) ENDIF (HDF5_ENABLE_Z_LIB_SUPPORT AND ZLIB_FOUND) @@ -511,7 +582,7 @@ IF (WIN32) GET_FILENAME_COMPONENT(SZIP_BIN_PATH ${SZIP_LIBRARY} PATH) # MESSAGE (STATUS "SZIP_BIN_PATH: ${SZIP_BIN_PATH}") ADD_CUSTOM_TARGET (SZIP-Release-Copy ALL - COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SZIP_BIN_PATH}/${SZIP_DLL_NAME}.dll ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/ + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SZIP_BIN_PATH}/${SZIP_DLL_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/ COMMENT "Copying ${SZIP_BIN_PATH}/${SZIP_DLL_NAME}.dll to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${CMAKE_CFG_INTDIR}/" ) ENDIF (HDF5_ENABLE_SZIP_SUPPORT AND SZIP_FOUND) @@ -545,6 +616,13 @@ ENDIF (HDF5_USE_H5DUMP_PACKED_BITS) #----------------------------------------------------------------------------- ADD_SUBDIRECTORY (${HDF5_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src) +IF (ZLIB_FOUND) + ADD_DEPENDENCIES (${HDF5_LIB_TARGET} ZLIB) +ENDIF (ZLIB_FOUND) +IF (SZIP_FOUND) + ADD_DEPENDENCIES (${HDF5_LIB_TARGET} SZIP) +ENDIF (SZIP_FOUND) + #----------------------------------------------------------------------------- # Build utility to copy and strip X lines of file #----------------------------------------------------------------------------- @@ -666,7 +744,7 @@ IF (NOT HDF5_EXTERNALLY_CONFIGURED) IF (HDF5_PACKAGE_EXTLIBS) IF (HDF5_ENABLE_Z_LIB_SUPPORT AND ZLIB_FOUND) INSTALL ( - FILES ${ZLIB_INCLUDE_DIR}/zconf.h ${ZLIB_INCLUDE_DIR}/zlib.h + FILES ${ZLIB_INCLUDE_DIR_GEN}/zconf.h ${ZLIB_INCLUDE_DIR}/zlib.h DESTINATION ${HDF5_INSTALL_INCLUDE_DIR} COMPONENT headers ) @@ -681,7 +759,7 @@ IF (NOT HDF5_EXTERNALLY_CONFIGURED) GET_FILENAME_COMPONENT(ZLIB_BIN_PATH ${ZLIB_LIBRARY} PATH) # message(STATUS "ZLIB_BIN_PATH: ${ZLIB_BIN_PATH}") INSTALL( - FILES ${ZLIB_BIN_PATH}/${ZLIB_DLL_NAME}.dll + FILES ${ZLIB_BIN_PATH}/${ZLIB_DLL_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT libraries ) @@ -689,7 +767,7 @@ IF (NOT HDF5_EXTERNALLY_CONFIGURED) ENDIF (HDF5_ENABLE_Z_LIB_SUPPORT AND ZLIB_FOUND) IF (HDF5_ENABLE_SZIP_SUPPORT AND SZIP_FOUND) INSTALL ( - FILES ${SZIP_INCLUDE_DIR}/SZconfig.h ${SZIP_INCLUDE_DIR}/szlib.h ${SZIP_INCLUDE_DIR}/szip_adpt.h ${SZIP_INCLUDE_DIR}/ricehdf.h + FILES ${SZIP_INCLUDE_DIR_GEN}/SZconfig.h ${SZIP_INCLUDE_DIR}/szlib.h ${SZIP_INCLUDE_DIR}/szip_adpt.h ${SZIP_INCLUDE_DIR}/ricehdf.h DESTINATION ${HDF5_INSTALL_INCLUDE_DIR} COMPONENT headers ) @@ -704,7 +782,7 @@ IF (NOT HDF5_EXTERNALLY_CONFIGURED) GET_FILENAME_COMPONENT(SZIP_BIN_PATH ${SZIP_LIBRARY} PATH) # message(STATUS "SZIP_BIN_PATH: ${ZLIB_BIN_PATH}") INSTALL( - FILES ${SZIP_BIN_PATH}/${SZIP_DLL_NAME}.dll + FILES ${SZIP_BIN_PATH}/${SZIP_DLL_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT libraries ) |