From 291bf2052931b1f117a9cd43ff707437c8b7dd5b Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 19 Aug 2015 05:54:48 -0500 Subject: [svn-r27522] CMake files match those of the trunk but still need to be updated with changes in this branch. Tested on: NONE (CMake is still broken in this branch) --- CMakeFilters.cmake | 22 +- CMakeInstallation.cmake | 137 ++-- CMakeLists.txt | 78 +- c++/CMakeLists.txt | 9 - c++/examples/CMakeLists.txt | 8 +- c++/src/CMakeLists.txt | 38 +- c++/test/CMakeLists.txt | 4 +- config/cmake/CPack.Info.plist.in | 26 + config/cmake/ConfigureChecks.cmake | 11 + config/cmake/H5pubconf.h.in | 30 +- config/cmake/HDF518_Examples.cmake.in | 3 +- config/cmake/HDF5Macros.cmake | 12 + config/cmake/HDF5UseFortran.cmake | 491 ++++++++++++ config/cmake/HDF5_Examples.cmake.in | 126 +++ config/cmake/HDFCompilerFlags.cmake | 4 +- config/cmake/README.txt.cmake.in | 8 +- config/cmake/cacheinit.cmake | 6 +- config/cmake/hdf5-config.cmake.in | 52 +- config/cmake/libhdf5.settings.cmake.in | 5 +- config/cmake/mccacheinit.cmake | 2 - config/cmake/scripts/CTestScript.cmake | 564 +++++++------- config/cmake/scripts/HDF518config.cmake | 346 ++++----- config/cmake_ext_mod/CTestCustom.cmake | 16 + config/cmake_ext_mod/CheckTypeSize.cmake | 50 ++ config/cmake_ext_mod/ConfigureChecks.cmake | 756 ++++++++++++++++++ config/cmake_ext_mod/FindMPI.cmake | 684 +++++++++++++++++ config/cmake_ext_mod/FindSZIP.cmake | 172 +++++ config/cmake_ext_mod/GetTimeOfDayTest.cpp | 15 + config/cmake_ext_mod/HDFCXXTests.cpp | 56 ++ config/cmake_ext_mod/HDFLibMacros.cmake | 270 +++++++ config/cmake_ext_mod/HDFMacros.cmake | 277 +++++++ config/cmake_ext_mod/HDFTests.c | 466 ++++++++++++ config/cmake_ext_mod/HDFUseFortran.cmake | 176 +++++ config/cmake_ext_mod/NSIS.InstallOptions.ini.in | 37 + config/cmake_ext_mod/NSIS.template.in | 974 ++++++++++++++++++++++++ config/cmake_ext_mod/grepTest.cmake | 64 ++ config/cmake_ext_mod/hdf.bmp | Bin 0 -> 1254 bytes config/cmake_ext_mod/hdf.icns | Bin 0 -> 326012 bytes config/cmake_ext_mod/hdf.ico | Bin 0 -> 23558 bytes config/cmake_ext_mod/prunTest.cmake | 145 ++++ config/cmake_ext_mod/runTest.cmake | 207 +++++ config/cmake_ext_mod/version.plist.in | 17 + examples/CMakeLists.txt | 22 +- examples/CMakeTests.cmake | 67 ++ fortran/examples/CMakeLists.txt | 82 +- fortran/examples/CMakeTests.cmake | 41 + fortran/src/CMakeLists.txt | 321 ++++---- fortran/test/CMakeLists.txt | 299 ++++++-- fortran/test/CMakeTests.cmake | 26 + fortran/testpar/CMakeLists.txt | 6 +- hl/CMakeLists.txt | 8 - hl/c++/examples/CMakeLists.txt | 4 +- hl/c++/src/CMakeLists.txt | 31 +- hl/c++/test/CMakeLists.txt | 4 +- hl/examples/CMakeLists.txt | 4 +- hl/fortran/examples/CMakeLists.txt | 6 +- hl/fortran/src/CMakeLists.txt | 177 ++++- hl/fortran/test/CMakeLists.txt | 80 +- hl/fortran/test/CMakeTests.cmake | 31 + hl/src/CMakeLists.txt | 33 +- hl/test/CMakeLists.txt | 20 +- hl/tools/CMakeLists.txt | 17 +- src/CMakeLists.txt | 59 +- test/CMakeLists.txt | 156 +++- test/CMakeTests.cmake | 570 ++++++++++++-- testpar/CMakeLists.txt | 8 +- tools/h5copy/CMakeLists.txt | 13 +- tools/h5diff/CMakeLists.txt | 22 +- tools/h5dump/CMakeLists.txt | 13 +- tools/h5import/CMakeLists.txt | 13 +- tools/h5jam/CMakeLists.txt | 29 +- tools/h5ls/CMakeLists.txt | 9 +- tools/h5repack/CMakeLists.txt | 69 +- tools/h5repack/CMakeTests.cmake | 8 - tools/h5stat/CMakeLists.txt | 13 +- tools/lib/CMakeLists.txt | 39 +- tools/misc/CMakeLists.txt | 25 +- tools/perform/CMakeLists.txt | 36 +- 78 files changed, 7452 insertions(+), 1273 deletions(-) create mode 100644 config/cmake/CPack.Info.plist.in create mode 100644 config/cmake/HDF5UseFortran.cmake create mode 100644 config/cmake/HDF5_Examples.cmake.in mode change 100755 => 100644 config/cmake/scripts/CTestScript.cmake mode change 100755 => 100644 config/cmake/scripts/HDF518config.cmake create mode 100644 config/cmake_ext_mod/CTestCustom.cmake create mode 100644 config/cmake_ext_mod/CheckTypeSize.cmake create mode 100644 config/cmake_ext_mod/ConfigureChecks.cmake create mode 100644 config/cmake_ext_mod/FindMPI.cmake create mode 100644 config/cmake_ext_mod/FindSZIP.cmake create mode 100644 config/cmake_ext_mod/GetTimeOfDayTest.cpp create mode 100644 config/cmake_ext_mod/HDFCXXTests.cpp create mode 100644 config/cmake_ext_mod/HDFLibMacros.cmake create mode 100644 config/cmake_ext_mod/HDFMacros.cmake create mode 100644 config/cmake_ext_mod/HDFTests.c create mode 100644 config/cmake_ext_mod/HDFUseFortran.cmake create mode 100644 config/cmake_ext_mod/NSIS.InstallOptions.ini.in create mode 100644 config/cmake_ext_mod/NSIS.template.in create mode 100644 config/cmake_ext_mod/grepTest.cmake create mode 100644 config/cmake_ext_mod/hdf.bmp create mode 100644 config/cmake_ext_mod/hdf.icns create mode 100644 config/cmake_ext_mod/hdf.ico create mode 100644 config/cmake_ext_mod/prunTest.cmake create mode 100644 config/cmake_ext_mod/runTest.cmake create mode 100644 config/cmake_ext_mod/version.plist.in diff --git a/CMakeFilters.cmake b/CMakeFilters.cmake index 7050f87..c2b81dc 100644 --- a/CMakeFilters.cmake +++ b/CMakeFilters.cmake @@ -28,11 +28,12 @@ option (HDF5_ENABLE_Z_LIB_SUPPORT "Enable Zlib Filters" OFF) if (HDF5_ENABLE_Z_LIB_SUPPORT) if (NOT H5_ZLIB_HEADER) if (NOT ZLIB_USE_EXTERNAL) - find_package (ZLIB NAMES ${ZLIB_PACKAGE_NAME}${HDF_PACKAGE_EXT}) + 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_LIBS ${LINK_LIBS} ${ZLIB_LIBRARIES}) + set (LINK_SHARED_LIBS ${LINK_SHARED_LIBS} ${ZLIB_LIBRARIES}) endif (ZLIB_FOUND) endif (NOT ZLIB_FOUND) endif (NOT ZLIB_USE_EXTERNAL) @@ -45,7 +46,7 @@ if (HDF5_ENABLE_Z_LIB_SUPPORT) set (ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS} ${ZLIB_INCLUDE_DIR}) else (ZLIB_FOUND) if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") - EXTERNAL_ZLIB_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT} ${LIB_TYPE}) + EXTERNAL_ZLIB_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT}) set (H5_HAVE_FILTER_DEFLATE 1) set (H5_HAVE_ZLIB_H 1) set (H5_HAVE_LIBZ 1) @@ -63,7 +64,10 @@ if (HDF5_ENABLE_Z_LIB_SUPPORT) if (H5_HAVE_FILTER_DEFLATE) set (EXTERNAL_FILTERS "${EXTERNAL_FILTERS} DEFLATE") endif (H5_HAVE_FILTER_DEFLATE) - set (LINK_LIBS ${LINK_LIBS} ${ZLIB_LIBRARIES}) + if (BUILD_SHARED_LIBS) + set (LINK_SHARED_LIBS ${LINK_SHARED_LIBS} ${ZLIB_SHARED_LIBRARY}) + endif (BUILD_SHARED_LIBS) + set (LINK_LIBS ${LINK_LIBS} ${ZLIB_STATIC_LIBRARY}) INCLUDE_DIRECTORIES (${ZLIB_INCLUDE_DIRS}) message (STATUS "Filter ZLIB is ON") endif (HDF5_ENABLE_Z_LIB_SUPPORT) @@ -75,11 +79,12 @@ option (HDF5_ENABLE_SZIP_SUPPORT "Use SZip Filter" OFF) if (HDF5_ENABLE_SZIP_SUPPORT) option (HDF5_ENABLE_SZIP_ENCODING "Use SZip Encoding" OFF) if (NOT SZIP_USE_EXTERNAL) - find_package (SZIP NAMES ${SZIP_PACKAGE_NAME}${HDF_PACKAGE_EXT}) + 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_LIBS ${LINK_LIBS} ${SZIP_LIBRARIES}) + set (LINK_SHARED_LIBS ${LINK_SHARED_LIBS} ${SZIP_LIBRARIES}) endif (SZIP_FOUND) endif (NOT SZIP_FOUND) endif (NOT SZIP_USE_EXTERNAL) @@ -88,10 +93,10 @@ if (HDF5_ENABLE_SZIP_SUPPORT) set (H5_HAVE_SZLIB_H 1) set (H5_HAVE_LIBSZ 1) set (SZIP_INCLUDE_DIR_GEN ${SZIP_INCLUDE_DIR}) - set (SZIP_INCLUDE_DIRS ${SZIP_INCLUDE_DIR}) + set (SZIP_INCLUDE_DIRS ${SZIP_INCLUDE_DIRS} ${SZIP_INCLUDE_DIR}) else (SZIP_FOUND) if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") - EXTERNAL_SZIP_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT} ${LIB_TYPE} ${HDF5_ENABLE_SZIP_ENCODING}) + EXTERNAL_SZIP_LIBRARY (${HDF5_ALLOW_EXTERNAL_SUPPORT} ${HDF5_ENABLE_SZIP_ENCODING}) set (H5_HAVE_FILTER_SZIP 1) set (H5_HAVE_SZLIB_H 1) set (H5_HAVE_LIBSZ 1) @@ -100,7 +105,10 @@ if (HDF5_ENABLE_SZIP_SUPPORT) message (FATAL_ERROR "SZIP is Required for SZIP support in HDF5") endif (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") endif (SZIP_FOUND) - set (LINK_LIBS ${LINK_LIBS} ${SZIP_LIBRARIES}) + if (BUILD_SHARED_LIBS) + set (LINK_SHARED_LIBS ${LINK_SHARED_LIBS} ${SZIP_SHARED_LIBRARY}) + endif (BUILD_SHARED_LIBS) + set (LINK_LIBS ${LINK_LIBS} ${SZIP_STATIC_LIBRARY}) INCLUDE_DIRECTORIES (${SZIP_INCLUDE_DIRS}) message (STATUS "Filter SZIP is ON") if (H5_HAVE_FILTER_SZIP) diff --git a/CMakeInstallation.cmake b/CMakeInstallation.cmake index 74bf85f..f87119e 100644 --- a/CMakeInstallation.cmake +++ b/CMakeInstallation.cmake @@ -79,7 +79,7 @@ configure_package_config_file ( #----------------------------------------------------------------------------- if (NOT HDF5_EXTERNALLY_CONFIGURED) configure_file ( - ${HDF_RESOURCES_DIR}/FindHDF5.cmake.in + ${HDF_RESOURCES_DIR}/FindHDF5.cmake.in ${HDF5_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindHDF5${HDF_PACKAGE_EXT}.cmake @ONLY ) install ( @@ -134,7 +134,7 @@ else (H5_WORDS_BIGENDIAN) set (BYTESEX little-endian) endif (H5_WORDS_BIGENDIAN) configure_file ( - ${HDF_RESOURCES_DIR}/libhdf5.settings.cmake.in + ${HDF_RESOURCES_DIR}/libhdf5.settings.cmake.in ${HDF5_BINARY_DIR}/libhdf5.settings @ONLY ) install ( @@ -167,11 +167,11 @@ install ( option (HDF5_PACK_EXAMPLES "Package the HDF5 Library Examples Compressed File" OFF) if (HDF5_PACK_EXAMPLES) configure_file ( - ${HDF_RESOURCES_DIR}/HDF518_Examples.cmake.in - ${HDF5_BINARY_DIR}/HDF518_Examples.cmake @ONLY + ${HDF_RESOURCES_DIR}/HDF5_Examples.cmake.in + ${HDF5_BINARY_DIR}/HDF5_Examples.cmake @ONLY ) install ( - FILES ${HDF5_BINARY_DIR}/HDF518_Examples.cmake + FILES ${HDF5_BINARY_DIR}/HDF5_Examples.cmake DESTINATION ${HDF5_INSTALL_DATA_DIR} COMPONENT hdfdocuments ) @@ -180,9 +180,9 @@ if (HDF5_PACK_EXAMPLES) COMMAND ${CMAKE_COMMAND} -E tar xzf ${HDF5_EXAMPLES_COMPRESSED_DIR}/${HDF5_EXAMPLES_COMPRESSED} ) install ( - DIRECTORY ${HDF5_BINARY_DIR}/HDF5Examples-0.1.1-Source + DIRECTORY ${HDF5_BINARY_DIR}/HDF5Examples DESTINATION ${HDF5_INSTALL_DATA_DIR} - USE_SOURCE_PERMISSIONS + USE_SOURCE_PERMISSIONS COMPONENT hdfdocuments ) install ( @@ -298,13 +298,13 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) set (CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_VENDOR}/${CPACK_PACKAGE_NAME}/${CPACK_PACKAGE_VERSION}") set (CPACK_PACKAGE_ICON "${HDF_RESOURCES_EXT_DIR}/hdf.bmp") - set (CPACK_GENERATOR "TGZ") + set (CPACK_GENERATOR "TGZ") if (WIN32) - set (CPACK_GENERATOR "ZIP") + set (CPACK_GENERATOR "ZIP") - if (NSIS_EXECUTABLE) - list (APPEND CPACK_GENERATOR "NSIS") - endif (NSIS_EXECUTABLE) + if (NSIS_EXECUTABLE) + list (APPEND CPACK_GENERATOR "NSIS") + endif (NSIS_EXECUTABLE) # Installers for 32- vs. 64-bit CMake: # - Root install directory (displayed to end user at installer-run time) # - "NSIS package/display name" (text used in the installer GUI) @@ -327,10 +327,10 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) set (CPACK_PACKAGE_INSTALL_DIRECTORY "${CPACK_PACKAGE_VENDOR}\\\\${CPACK_PACKAGE_NAME}\\\\${CPACK_PACKAGE_VERSION}") set (CPACK_NSIS_CONTACT "${HDF5_PACKAGE_BUGREPORT}") set (CPACK_NSIS_MODIFY_PATH ON) - - if (WIX_EXECUTABLE) - list (APPEND CPACK_GENERATOR "WIX") - endif (WIX_EXECUTABLE) + + if (WIX_EXECUTABLE) + list (APPEND CPACK_GENERATOR "WIX") + endif (WIX_EXECUTABLE) #WiX variables set (CPACK_WIX_UNINSTALL "1") # .. variable:: CPACK_WIX_LICENSE_RTF @@ -375,30 +375,24 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) set(CPACK_WIX_PATCH_FILE "${HDF_RESOURCES_DIR}/patch.xml") endif (BUILD_SHARED_LIBS) elseif (APPLE) - list (APPEND CPACK_GENERATOR "DragNDrop") + list (APPEND CPACK_GENERATOR "DragNDrop") set (CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE ON) set (CPACK_PACKAGING_INSTALL_PREFIX "/${CPACK_PACKAGE_INSTALL_DIRECTORY}") set (CPACK_PACKAGE_ICON "${HDF_RESOURCES_EXT_DIR}/hdf.icns") - option (HDF5_PACK_MACOSX_BUNDLE "Package the HDF5 Library in a Bundle" OFF) - if (HDF5_PACK_MACOSX_BUNDLE) - list (APPEND CPACK_GENERATOR "Bundle") + option (HDF5_PACK_MACOSX_FRAMEWORK "Package the HDF5 Library in a Frameworks" OFF) + if (HDF5_PACK_MACOSX_FRAMEWORK AND HDF5_BUILD_FRAMEWORKS) set (CPACK_BUNDLE_NAME "${HDF5_PACKAGE_STRING}") set (CPACK_BUNDLE_LOCATION "/") # make sure CMAKE_INSTALL_PREFIX ends in / set (CMAKE_INSTALL_PREFIX "/${CPACK_BUNDLE_NAME}.framework/Versions/${CPACK_PACKAGE_VERSION}/${CPACK_PACKAGE_NAME}/") set (CPACK_BUNDLE_ICON "${HDF_RESOURCES_EXT_DIR}/hdf.icns") set (CPACK_BUNDLE_PLIST "${HDF5_BINARY_DIR}/CMakeFiles/Info.plist") - set (CPACK_APPLE_GUI_INFO_STRING "HDF5 (Hierarchical Data Format 5) Software Library and Utilities") - set (CPACK_APPLE_GUI_COPYRIGHT "Copyright © 2006-2015 by The HDF Group. All rights reserved.") set (CPACK_SHORT_VERSION_STRING "${CPACK_PACKAGE_VERSION}") - set (CPACK_APPLE_GUI_BUNDLE_NAME "${HDF5_PACKAGE_STRING}") - set (CPACK_APPLE_GUI_VERSION_STRING "${CPACK_PACKAGE_VERSION_STRING}") - set (CPACK_APPLE_GUI_SHORT_VERSION_STRING "${CPACK_PACKAGE_VERSION}") #----------------------------------------------------------------------------- # Configure the Info.plist file for the install bundle #----------------------------------------------------------------------------- configure_file ( - ${HDF_RESOURCES_EXT_DIR}/CPack.Info.plist.in + ${HDF_RESOURCES_DIR}/CPack.Info.plist.in ${HDF5_BINARY_DIR}/CMakeFiles/Info.plist @ONLY ) configure_file ( @@ -411,19 +405,18 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) ) install ( FILES ${HDF5_BINARY_DIR}/CMakeFiles/PkgInfo - ${HDF5_BINARY_DIR}/CMakeFiles/version.plist DESTINATION .. ) - endif (HDF5_PACK_MACOSX_BUNDLE) + endif (HDF5_PACK_MACOSX_FRAMEWORK AND HDF5_BUILD_FRAMEWORKS) else (WIN32) - list (APPEND CPACK_GENERATOR "STGZ") + list (APPEND CPACK_GENERATOR "STGZ") set (CPACK_PACKAGING_INSTALL_PREFIX "/${CPACK_PACKAGE_INSTALL_DIRECTORY}") set (CPACK_COMPONENTS_ALL_IN_ONE_PACKAGE ON) set (CPACK_DEBIAN_PACKAGE_SECTION "Libraries") set (CPACK_DEBIAN_PACKAGE_MAINTAINER "${HDF5_PACKAGE_BUGREPORT}") -# list (APPEND CPACK_GENERATOR "RPM") +# list (APPEND CPACK_GENERATOR "RPM") set (CPACK_RPM_PACKAGE_RELEASE "1") set (CPACK_RPM_COMPONENT_INSTALL ON) set (CPACK_RPM_PACKAGE_RELOCATABLE ON) @@ -431,7 +424,7 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) set (CPACK_RPM_PACKAGE_GROUP "Development/Libraries") set (CPACK_RPM_PACKAGE_URL "${HDF5_PACKAGE_URL}") set (CPACK_RPM_PACKAGE_SUMMARY "HDF5 is a unique technology suite that makes possible the management of extremely large and complex data collections.") - set (CPACK_RPM_PACKAGE_DESCRIPTION + set (CPACK_RPM_PACKAGE_DESCRIPTION "The HDF5 technology suite includes: * A versatile data model that can represent very complex data objects and a wide variety of metadata. @@ -447,14 +440,14 @@ if (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) The HDF5 data model, file format, API, library, and tools are open and distributed without charge. " ) - + #----------------------------------------------------------------------------- # Configure the spec file for the install RPM #----------------------------------------------------------------------------- # configure_file ("${HDF5_RESOURCES_DIR}/hdf5.spec.in" "${CMAKE_CURRENT_BINARY_DIR}/${HDF5_PACKAGE_NAME}.spec" @ONLY IMMEDIATE) # set (CPACK_RPM_USER_BINARY_SPECFILE "${CMAKE_CURRENT_BINARY_DIR}/${HDF5_PACKAGE_NAME}.spec") endif (WIN32) - + # By default, do not warn when built on machines using only VS Express: if (NOT DEFINED CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS) set (CMAKE_INSTALL_SYSTEM_RUNTIME_LIBS_NO_WARNINGS ON) @@ -462,7 +455,7 @@ The HDF5 data model, file format, API, library, and tools are open and distribut include (InstallRequiredSystemLibraries) set (CPACK_INSTALL_CMAKE_PROJECTS "${HDF5_BINARY_DIR};HDF5;ALL;/") - + if (HDF5_PACKAGE_EXTLIBS) if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") if (ZLIB_FOUND AND ZLIB_USE_EXTERNAL) @@ -485,7 +478,7 @@ The HDF5 data model, file format, API, library, and tools are open and distribut endif (SZIP_FOUND AND SZIP_USE_EXTERNAL) endif (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") endif (HDF5_PACKAGE_EXTLIBS) - + include (CPack) cpack_add_install_type(Full DISPLAY_NAME "Everything") @@ -511,121 +504,121 @@ The HDF5 data model, file format, API, library, and tools are open and distribut #--------------------------------------------------------------------------- # Now list the cpack commands #--------------------------------------------------------------------------- - CPACK_ADD_COMPONENT (libraries + cpack_add_component (libraries DISPLAY_NAME "HDF5 Libraries" GROUP Runtime INSTALL_TYPES Full Developer User ) - CPACK_ADD_COMPONENT (headers - DISPLAY_NAME "HDF5 Headers" + cpack_add_component (headers + DISPLAY_NAME "HDF5 Headers" DEPENDS libraries GROUP Development INSTALL_TYPES Full Developer ) - CPACK_ADD_COMPONENT (hdfdocuments + cpack_add_component (hdfdocuments DISPLAY_NAME "HDF5 Documents" GROUP Documents INSTALL_TYPES Full Developer ) - CPACK_ADD_COMPONENT (configinstall - DISPLAY_NAME "HDF5 CMake files" + cpack_add_component (configinstall + DISPLAY_NAME "HDF5 CMake files" DEPENDS libraries GROUP Development INSTALL_TYPES Full Developer User ) - + if (HDF5_BUILD_FORTRAN) - CPACK_ADD_COMPONENT (fortlibraries - DISPLAY_NAME "HDF5 Fortran Libraries" + cpack_add_component (fortlibraries + DISPLAY_NAME "HDF5 Fortran Libraries" DEPENDS libraries GROUP Runtime INSTALL_TYPES Full Developer User ) - CPACK_ADD_COMPONENT (fortheaders - DISPLAY_NAME "HDF5 Fortran Headers" + cpack_add_component (fortheaders + DISPLAY_NAME "HDF5 Fortran Headers" DEPENDS fortlibraries GROUP Development INSTALL_TYPES Full Developer ) endif (HDF5_BUILD_FORTRAN) - + if (HDF5_BUILD_CPP_LIB) - CPACK_ADD_COMPONENT (cpplibraries - DISPLAY_NAME "HDF5 C++ Libraries" + cpack_add_component (cpplibraries + DISPLAY_NAME "HDF5 C++ Libraries" DEPENDS libraries GROUP Runtime INSTALL_TYPES Full Developer User ) - CPACK_ADD_COMPONENT (cppheaders - DISPLAY_NAME "HDF5 C++ Headers" + cpack_add_component (cppheaders + DISPLAY_NAME "HDF5 C++ Headers" DEPENDS cpplibraries GROUP Development INSTALL_TYPES Full Developer ) endif (HDF5_BUILD_CPP_LIB) - + if (HDF5_BUILD_TOOLS) - CPACK_ADD_COMPONENT (toolsapplications - DISPLAY_NAME "HDF5 Tools Applications" + cpack_add_component (toolsapplications + DISPLAY_NAME "HDF5 Tools Applications" DEPENDS toolslibraries GROUP Applications INSTALL_TYPES Full Developer User ) - CPACK_ADD_COMPONENT (toolslibraries - DISPLAY_NAME "HDF5 Tools Libraries" + cpack_add_component (toolslibraries + DISPLAY_NAME "HDF5 Tools Libraries" DEPENDS libraries GROUP Runtime INSTALL_TYPES Full Developer User ) - CPACK_ADD_COMPONENT (toolsheaders - DISPLAY_NAME "HDF5 Tools Headers" + cpack_add_component (toolsheaders + DISPLAY_NAME "HDF5 Tools Headers" DEPENDS toolslibraries GROUP Development INSTALL_TYPES Full Developer ) endif (HDF5_BUILD_TOOLS) - + if (HDF5_BUILD_HL_LIB) - CPACK_ADD_COMPONENT (hllibraries - DISPLAY_NAME "HDF5 HL Libraries" + cpack_add_component (hllibraries + DISPLAY_NAME "HDF5 HL Libraries" DEPENDS libraries GROUP Runtime INSTALL_TYPES Full Developer User ) - CPACK_ADD_COMPONENT (hlheaders - DISPLAY_NAME "HDF5 HL Headers" + cpack_add_component (hlheaders + DISPLAY_NAME "HDF5 HL Headers" DEPENDS hllibraries GROUP Development INSTALL_TYPES Full Developer ) - CPACK_ADD_COMPONENT (hltoolsapplications - DISPLAY_NAME "HDF5 HL Tools Applications" + cpack_add_component (hltoolsapplications + DISPLAY_NAME "HDF5 HL Tools Applications" DEPENDS hllibraries GROUP Applications INSTALL_TYPES Full Developer User ) if (HDF5_BUILD_CPP_LIB) - CPACK_ADD_COMPONENT (hlcpplibraries - DISPLAY_NAME "HDF5 HL C++ Libraries" + cpack_add_component (hlcpplibraries + DISPLAY_NAME "HDF5 HL C++ Libraries" DEPENDS hllibraries GROUP Runtime INSTALL_TYPES Full Developer User ) - CPACK_ADD_COMPONENT (hlcppheaders - DISPLAY_NAME "HDF5 HL C++ Headers" + cpack_add_component (hlcppheaders + DISPLAY_NAME "HDF5 HL C++ Headers" DEPENDS hlcpplibraries GROUP Development INSTALL_TYPES Full Developer ) endif (HDF5_BUILD_CPP_LIB) if (HDF5_BUILD_FORTRAN) - CPACK_ADD_COMPONENT (hlfortlibraries - DISPLAY_NAME "HDF5 HL Fortran Libraries" + cpack_add_component (hlfortlibraries + DISPLAY_NAME "HDF5 HL Fortran Libraries" DEPENDS fortlibraries GROUP Runtime INSTALL_TYPES Full Developer User ) endif (HDF5_BUILD_FORTRAN) endif (HDF5_BUILD_HL_LIB) - + endif (NOT HDF5_EXTERNALLY_CONFIGURED AND NOT HDF5_NO_PACKAGES) diff --git a/CMakeLists.txt b/CMakeLists.txt index 33b4bca..799c1da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -87,6 +87,7 @@ endif () # # Add the sub project # add_subdirectory (Utilities/hdf5-1.8) #----------------------------------------------------------------------------- +string(TIMESTAMP CONFIG_DATE "%Y-%m-%d") #----------------------------------------------------------------------------- # Allow Visual Studio solution directories @@ -138,18 +139,30 @@ set (HDF5_HL_F90_C_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_HL_F90_C_LIB_ #----------------------------------------------------------------------------- # Set the target names of all the libraries #----------------------------------------------------------------------------- -set (HDF5_LIB_TARGET ${HDF5_LIB_CORENAME}) -set (HDF5_TEST_LIB_TARGET ${HDF5_TEST_LIB_CORENAME}) -set (HDF5_CPP_LIB_TARGET ${HDF5_CPP_LIB_CORENAME}) -set (HDF5_HL_LIB_TARGET ${HDF5_HL_LIB_CORENAME}) -set (HDF5_HL_CPP_LIB_TARGET ${HDF5_HL_CPP_LIB_CORENAME}) -set (HDF5_TOOLS_LIB_TARGET ${HDF5_TOOLS_LIB_CORENAME}) -set (HDF5_F90_LIB_TARGET ${HDF5_F90_LIB_CORENAME}) -set (HDF5_F90_C_LIB_TARGET ${HDF5_F90_C_LIB_CORENAME}) -set (HDF5_F90_TEST_LIB_TARGET ${HDF5_F90_TEST_LIB_CORENAME}) -set (HDF5_F90_C_TEST_LIB_TARGET ${HDF5_F90_C_TEST_LIB_CORENAME}) -set (HDF5_HL_F90_LIB_TARGET ${HDF5_HL_F90_LIB_CORENAME}) -set (HDF5_HL_F90_C_LIB_TARGET ${HDF5_HL_F90_C_LIB_CORENAME}) +set (HDF5_LIB_TARGET "${HDF5_LIB_CORENAME}-static") +set (HDF5_TEST_LIB_TARGET "${HDF5_TEST_LIB_CORENAME}-static") +set (HDF5_CPP_LIB_TARGET "${HDF5_CPP_LIB_CORENAME}-static") +set (HDF5_HL_LIB_TARGET "${HDF5_HL_LIB_CORENAME}-static") +set (HDF5_HL_CPP_LIB_TARGET "${HDF5_HL_CPP_LIB_CORENAME}-static") +set (HDF5_TOOLS_LIB_TARGET "${HDF5_TOOLS_LIB_CORENAME}-static") +set (HDF5_F90_LIB_TARGET "${HDF5_F90_LIB_CORENAME}-static") +set (HDF5_F90_C_LIB_TARGET "${HDF5_F90_C_LIB_CORENAME}-static") +set (HDF5_F90_TEST_LIB_TARGET "${HDF5_F90_TEST_LIB_CORENAME}-static") +set (HDF5_F90_C_TEST_LIB_TARGET "${HDF5_F90_C_TEST_LIB_CORENAME}-static") +set (HDF5_HL_F90_LIB_TARGET "${HDF5_HL_F90_LIB_CORENAME}-static") +set (HDF5_HL_F90_C_LIB_TARGET "${HDF5_HL_F90_C_LIB_CORENAME}-static") +set (HDF5_LIBSH_TARGET "${HDF5_LIB_CORENAME}-shared") +set (HDF5_TEST_LIBSH_TARGET "${HDF5_TEST_LIB_CORENAME}-shared") +set (HDF5_CPP_LIBSH_TARGET "${HDF5_CPP_LIB_CORENAME}-shared") +set (HDF5_HL_LIBSH_TARGET "${HDF5_HL_LIB_CORENAME}-shared") +set (HDF5_HL_CPP_LIBSH_TARGET "${HDF5_HL_CPP_LIB_CORENAME}-shared") +set (HDF5_TOOLS_LIBSH_TARGET "${HDF5_TOOLS_LIB_CORENAME}-shared") +set (HDF5_F90_LIBSH_TARGET "${HDF5_F90_LIB_CORENAME}-shared") +set (HDF5_F90_C_LIBSH_TARGET "${HDF5_F90_C_LIB_CORENAME}-shared") +set (HDF5_F90_TEST_LIBSH_TARGET "${HDF5_F90_TEST_LIB_CORENAME}-shared") +set (HDF5_F90_C_TEST_LIBSH_TARGET "${HDF5_F90_C_TEST_LIB_CORENAME}-shared") +set (HDF5_HL_F90_LIBSH_TARGET "${HDF5_HL_F90_LIB_CORENAME}-shared") +set (HDF5_HL_F90_C_LIBSH_TARGET "${HDF5_HL_F90_C_LIB_CORENAME}-shared") #----------------------------------------------------------------------------- # Define some CMake variables for use later in the project @@ -170,6 +183,9 @@ if (NOT HDF5_INSTALL_BIN_DIR) set (HDF5_INSTALL_BIN_DIR bin) endif (NOT HDF5_INSTALL_BIN_DIR) if (NOT HDF5_INSTALL_LIB_DIR) + if (APPLE) + set (HDF5_INSTALL_FMWK_DIR ${CMAKE_INSTALL_FRAMEWORK_PREFIX}) + endif (APPLE) set (HDF5_INSTALL_LIB_DIR lib) endif (NOT HDF5_INSTALL_LIB_DIR) if (NOT HDF5_INSTALL_INCLUDE_DIR) @@ -177,6 +193,15 @@ if (NOT HDF5_INSTALL_INCLUDE_DIR) endif (NOT HDF5_INSTALL_INCLUDE_DIR) if (NOT HDF5_INSTALL_DATA_DIR) if (NOT WIN32) + if (APPLE) + option (HDF5_BUILD_FRAMEWORKS "Create a Mac OSX Framework" OFF) + if (HDF5_BUILD_FRAMEWORKS) + set (HDF5_INSTALL_EXTRA_DIR ../SharedSupport) + else (HDF5_BUILD_FRAMEWORKS) + set (HDF5_INSTALL_EXTRA_DIR share) + endif (HDF5_BUILD_FRAMEWORKS) + set (HDF5_INSTALL_FWRK_DIR ${CMAKE_INSTALL_FRAMEWORK_PREFIX}) + endif (APPLE) set (HDF5_INSTALL_DATA_DIR share) set (HDF5_INSTALL_CMAKE_DIR share/cmake) else (NOT WIN32) @@ -288,20 +313,23 @@ include (${HDF_RESOURCES_DIR}/ConfigureChecks.cmake) set (CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) #----------------------------------------------------------------------------- -# Option to Build Shared/Static libs, default is static +# Mac OS X Options #----------------------------------------------------------------------------- -option (BUILD_SHARED_LIBS "Build Shared Libraries" OFF) -set (LIB_TYPE STATIC) +option (HDF5_BUILD_FRAMEWORKS "TRUE to build as frameworks libraries, FALSE to build according to BUILD_SHARED_LIBS" TRUE) +if (HDF5_BUILD_FRAMEWORKS AND NOT BUILD_SHARED_LIBS) + set (BUILD_SHARED_LIBS ON CACHE BOOL "Build Shared Libraries") +endif (HDF5_BUILD_FRAMEWORKS AND NOT BUILD_SHARED_LIBS) + +#----------------------------------------------------------------------------- +# Option to Build Shared and Static libs, default is static +#----------------------------------------------------------------------------- +option (BUILD_SHARED_LIBS "Build Shared Libraries" ON) set (H5_ENABLE_SHARED_LIB NO) -set (H5_ENABLE_STATIC_LIB NO) if (BUILD_SHARED_LIBS) - set (LIB_TYPE SHARED) - set (H5_BUILT_AS_DYNAMIC_LIB 1) set (H5_ENABLE_SHARED_LIB YES) -else (BUILD_SHARED_LIBS) - set (H5_BUILT_AS_STATIC_LIB 1) - set (H5_ENABLE_STATIC_LIB YES) + set (LINK_SHARED_LIBS ${LINK_LIBS}) endif (BUILD_SHARED_LIBS) +set (H5_ENABLE_STATIC_LIB YES) set (CMAKE_POSITION_INDEPENDENT_CODE ON) #----------------------------------------------------------------------------- @@ -451,6 +479,7 @@ endif (HDF5_ENABLE_PARALLEL) # Parallel IO usage requires MPI to be Linked and Included if (H5_HAVE_PARALLEL) set (LINK_LIBS ${LINK_LIBS} ${MPI_C_LIBRARIES}) + set (LINK_SHARED_LIBS ${LINK_SHARED_LIBS} ${MPI_C_LIBRARIES}) if (MPI_C_LINK_FLAGS) set (CMAKE_EXE_LINKER_FLAGS "${MPI_C_LINK_FLAGS} ${CMAKE_EXE_LINKER_FLAGS}") endif (MPI_C_LINK_FLAGS) @@ -551,9 +580,15 @@ add_subdirectory (${HDF5_SOURCE_DIR}/src ${PROJECT_BINARY_DIR}/src) if (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") if (ZLIB_FOUND AND ZLIB_USE_EXTERNAL) ADD_DEPENDENCIES (${HDF5_LIB_TARGET} ZLIB) + if (BUILD_SHARED_LIBS) + add_dependencies (${HDF5_LIBSH_TARGET} ZLIB) + endif (BUILD_SHARED_LIBS) endif (ZLIB_FOUND AND ZLIB_USE_EXTERNAL) if (SZIP_FOUND AND SZIP_USE_EXTERNAL) ADD_DEPENDENCIES (${HDF5_LIB_TARGET} SZIP) + if (BUILD_SHARED_LIBS) + add_dependencies (${HDF5_LIBSH_TARGET} SZIP) + endif (BUILD_SHARED_LIBS) endif (SZIP_FOUND AND SZIP_USE_EXTERNAL) endif (HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "SVN" OR HDF5_ALLOW_EXTERNAL_SUPPORT MATCHES "TGZ") @@ -638,6 +673,7 @@ if (EXISTS "${HDF5_SOURCE_DIR}/fortran" AND IS_DIRECTORY "${HDF5_SOURCE_DIR}/for endif (BUILD_SHARED_LIBS AND APPLE) option (HDF5_ENABLE_F2003 "Enable FORTRAN 2003 Standard" ON) include (${HDF_RESOURCES_EXT_DIR}/HDFUseFortran.cmake) + include (${HDF_RESOURCES_DIR}/HDF5UseFortran.cmake) if (HDF5_ENABLE_F2003) if (NOT FORTRAN_HAVE_ISO_C_BINDING) set (HDF5_ENABLE_F2003 OFF) diff --git a/c++/CMakeLists.txt b/c++/CMakeLists.txt index 39280e8..6f288a0 100644 --- a/c++/CMakeLists.txt +++ b/c++/CMakeLists.txt @@ -7,15 +7,6 @@ PROJECT (HDF5_CPP) add_definitions (${HDF_EXTRA_C_FLAGS}) #----------------------------------------------------------------------------- -# Shared/Static Libs -#----------------------------------------------------------------------------- -if (BUILD_SHARED_LIBS) - set (CPP_BUILT_AS_DYNAMIC_LIB 1) -else (BUILD_SHARED_LIBS) - set (CPP_BUILT_AS_STATIC_LIB 1) -endif (BUILD_SHARED_LIBS) - -#----------------------------------------------------------------------------- # Generate configure file #----------------------------------------------------------------------------- configure_file (${HDF_RESOURCES_DIR}/H5cxx_config.h.in diff --git a/c++/examples/CMakeLists.txt b/c++/examples/CMakeLists.txt index ff375f3..cfcdd8d 100644 --- a/c++/examples/CMakeLists.txt +++ b/c++/examples/CMakeLists.txt @@ -34,16 +34,16 @@ set (tutr_examples foreach (example ${examples}) add_executable (cpp_ex_${example} ${HDF5_CPP_EXAMPLES_SOURCE_DIR}/${example}.cpp) - TARGET_NAMING (cpp_ex_${example} ${LIB_TYPE}) - TARGET_C_PROPERTIES (cpp_ex_${example} ${LIB_TYPE} " " " ") + TARGET_NAMING (cpp_ex_${example} STATIC) + TARGET_C_PROPERTIES (cpp_ex_${example} STATIC " " " ") target_link_libraries (cpp_ex_${example} ${HDF5_CPP_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (cpp_ex_${example} PROPERTIES FOLDER examples/cpp) endforeach (example ${examples}) foreach (example ${tutr_examples}) add_executable (cpp_ex_${example} ${HDF5_CPP_EXAMPLES_SOURCE_DIR}/${example}.cpp) - TARGET_NAMING (cpp_ex_${example} ${LIB_TYPE}) - TARGET_C_PROPERTIES (cpp_ex_${example} ${LIB_TYPE} " " " ") + TARGET_NAMING (cpp_ex_${example} STATIC) + TARGET_C_PROPERTIES (cpp_ex_${example} STATIC " " " ") target_link_libraries (cpp_ex_${example} ${HDF5_CPP_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (cpp_ex_${example} PROPERTIES FOLDER examples/cpp) endforeach (example ${tutr_examples}) diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt index 2f3a0c4..1ae5647 100644 --- a/c++/src/CMakeLists.txt +++ b/c++/src/CMakeLists.txt @@ -2,13 +2,6 @@ cmake_minimum_required (VERSION 3.1.0) PROJECT (HDF5_CPP_SRC) #----------------------------------------------------------------------------- -# Shared/Static Libs -#----------------------------------------------------------------------------- -if (BUILD_SHARED_LIBS) - set (CPP_BUILT_AS_DYNAMIC_LIB 1) -endif (BUILD_SHARED_LIBS) - -#----------------------------------------------------------------------------- # Generate configure file #----------------------------------------------------------------------------- configure_file (${HDF_RESOURCES_DIR}/H5cxx_config.h.in @@ -83,18 +76,34 @@ set (CPP_HDRS ${HDF5_CPP_SRC_SOURCE_DIR}/H5VarLenType.h ) -add_library (${HDF5_CPP_LIB_TARGET} ${LIB_TYPE} ${CPP_SRCS} ${CPP_HDRS}) -TARGET_C_PROPERTIES (${HDF5_CPP_LIB_TARGET} ${LIB_TYPE} " " " ") +add_library (${HDF5_CPP_LIB_TARGET} STATIC ${CPP_SRCS} ${CPP_HDRS}) +TARGET_C_PROPERTIES (${HDF5_CPP_LIB_TARGET} STATIC " " " ") target_link_libraries (${HDF5_CPP_LIB_TARGET} ${HDF5_LIB_TARGET}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_CPP_LIB_TARGET}") -H5_SET_LIB_OPTIONS (${HDF5_CPP_LIB_TARGET} ${HDF5_CPP_LIB_NAME} ${LIB_TYPE}) +H5_SET_LIB_OPTIONS (${HDF5_CPP_LIB_TARGET} ${HDF5_CPP_LIB_NAME} STATIC) set_target_properties (${HDF5_CPP_LIB_TARGET} PROPERTIES FOLDER libraries/cpp INTERFACE_INCLUDE_DIRECTORIES "$/include>" ) +set (install_targets ${HDF5_CPP_LIB_TARGET}) + +if (BUILD_SHARED_LIBS) + add_library (${HDF5_CPP_LIBSH_TARGET} SHARED ${CPP_SRCS} ${CPP_HDRS}) + TARGET_C_PROPERTIES (${HDF5_CPP_LIBSH_TARGET} SHARED " " " ") + target_link_libraries (${HDF5_CPP_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_CPP_LIBSH_TARGET}") + H5_SET_LIB_OPTIONS (${HDF5_CPP_LIBSH_TARGET} ${HDF5_CPP_LIB_NAME} SHARED) + set_target_properties (${HDF5_CPP_LIBSH_TARGET} PROPERTIES + FOLDER libraries/cpp + COMPILE_DEFINITIONS "H5_BUILT_AS_DYNAMIC_LIB" + INTERFACE_INCLUDE_DIRECTORIES "$/include>" + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB=1 + ) + set (install_targets ${install_targets} ${HDF5_CPP_LIBSH_TARGET}) +endif (BUILD_SHARED_LIBS) #----------------------------------------------------------------------------- -# Add file(s) to CMake Install +# Add file(s) to CMake Install #----------------------------------------------------------------------------- install ( FILES @@ -110,16 +119,17 @@ install ( #----------------------------------------------------------------------------- if (HDF5_EXPORTED_TARGETS) if (BUILD_SHARED_LIBS) - INSTALL_TARGET_PDB (${HDF5_CPP_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} cpplibraries) + INSTALL_TARGET_PDB (${HDF5_CPP_LIBSH_TARGET} ${HDF5_INSTALL_BIN_DIR} cpplibraries) endif (BUILD_SHARED_LIBS) - + install ( TARGETS - ${HDF5_CPP_LIB_TARGET} + ${install_targets} EXPORT ${HDF5_EXPORTED_TARGETS} LIBRARY DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT cpplibraries ARCHIVE DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT cpplibraries RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT cpplibraries + FRAMEWORK DESTINATION ${HDF5_INSTALL_FWRK_DIR} COMPONENT cpplibraries ) endif (HDF5_EXPORTED_TARGETS) diff --git a/c++/test/CMakeLists.txt b/c++/test/CMakeLists.txt index dcdf3a3..6f1d857 100644 --- a/c++/test/CMakeLists.txt +++ b/c++/test/CMakeLists.txt @@ -35,8 +35,8 @@ set (srcdir ${CMAKE_CURRENT_SOURCE_DIR}) configure_file (${HDF5_CPP_TEST_SOURCE_DIR}/H5srcdir_str.h.in H5srcdir_str.h @ONLY) add_executable (cpp_testhdf5 ${CPP_TEST_SRCS} ) -TARGET_NAMING (cpp_testhdf5 ${LIB_TYPE}) -TARGET_C_PROPERTIES (cpp_testhdf5 ${LIB_TYPE} " " " ") +TARGET_NAMING (cpp_testhdf5 STATIC) +TARGET_C_PROPERTIES (cpp_testhdf5 STATIC " " " ") target_link_libraries (cpp_testhdf5 ${HDF5_CPP_LIB_TARGET} ${HDF5_LIB_TARGET} diff --git a/config/cmake/CPack.Info.plist.in b/config/cmake/CPack.Info.plist.in new file mode 100644 index 0000000..08d371b --- /dev/null +++ b/config/cmake/CPack.Info.plist.in @@ -0,0 +1,26 @@ + + + + + CFBundleDevelopmentRegion + English + CFBundleExecutable + @CPACK_PACKAGE_FILE_NAME@ + CFBundleIconFile + @CPACK_BUNDLE_ICON@ + CFBundleIdentifier + org.@CPACK_PACKAGE_VENDOR@.@CPACK_PACKAGE_NAME@@CPACK_MODULE_VERSION_SUFFIX@ + CFBundleInfoDictionaryVersion + 6.0 + CFBundlePackageType + FMWK + CFBundleSignature + ???? + CFBundleVersion + @CPACK_PACKAGE_VERSIO@ + CFBundleShortVersionString + @CPACK_SHORT_VERSION_STRING@ + CSResourcesFileMapped + + + diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index 09f1caf..b9f18a9 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -158,6 +158,17 @@ if (NOT WINDOWS) endif (HDF5_ENABLE_DIRECT_VFD) endif (NOT WINDOWS) +#----------------------------------------------------------------------------- +# Check if C has __float128 extension +#----------------------------------------------------------------------------- + +CHECK_TYPE_SIZE("__float128" SIZEOF___FLOAT128) +if(${HAVE_SIZEOF___FLOAT128}) + SET(H5_HAVE_FLOAT128 1) +else (${HAVE_SIZEOF___FLOAT128}) + SET(H5_HAVE_FLOAT128 0) + SET(SIZEOF___FLOAT128 0) +endif(${HAVE_SIZEOF___FLOAT128}) #----------------------------------------------------------------------------- # Macro to determine the various conversion capabilities diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index 31bcc08..37bcfbf 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -15,24 +15,6 @@ /* Define if using a Windows compiler (i.e. Visual Studio) */ #cmakedefine H5_HAVE_VISUAL_STUDIO @H5_HAVE_VISUAL_STUDIO@ -/* Defined if HDF5 was built with CMake AND build as a shared library */ -#cmakedefine H5_BUILT_AS_DYNAMIC_LIB @H5_BUILT_AS_DYNAMIC_LIB@ - -/* Defined if HDF5 was built with CMake AND build as a static library */ -#cmakedefine H5_BUILT_AS_STATIC_LIB @H5_BUILT_AS_STATIC_LIB@ - -/* Defined if HDF5 CPP was built with CMake AND build as a shared library */ -#cmakedefine H5_CPP_BUILT_AS_DYNAMIC_LIB @H5_CPP_BUILT_AS_DYNAMIC_LIB@ - -/* Defined if HDF5 CPP was built with CMake AND build as a static library */ -#cmakedefine H5_CPP_BUILT_AS_STATIC_LIB @H5_CPP_BUILT_AS_STATIC_LIB@ - -/* Defined if HDF5 HL was built with CMake AND build as a shared library */ -#cmakedefine H5_HL_BUILT_AS_DYNAMIC_LIB @H5_HL_BUILT_AS_DYNAMIC_LIB@ - -/* Defined if HDF5 HL was built with CMake AND build as a static library */ -#cmakedefine H5_HL_BUILT_AS_STATIC_LIB @H5_HL_BUILT_AS_STATIC_LIB@ - /* Define if building universal (internal helper macro) */ #cmakedefine H5_AC_APPLE_UNIVERSAL_BUILD @H5_AC_APPLE_UNIVERSAL_BUILD@ @@ -63,6 +45,18 @@ /* As FC_FUNC, but for C identifiers containing underscores. */ #define @H5_FC_FUNC_@ +/* Define Fortran Maximum Real Decimal Precision */ +#cmakedefine H5_PAC_FC_MAX_REAL_PRECISION @H5_PAC_FC_MAX_REAL_PRECISION@ + +/* Define C Maximum Real Decimal Precision */ +#cmakedefine H5_PAC_C_MAX_REAL_PRECISION @H5_PAC_C_MAX_REAL_PRECISION@ + +/* Define if we have Fortran C_LONG_DOUBLE */ +#cmakedefine H5_FORTRAN_HAVE_C_LONG_DOUBLE @H5_FORTRAN_HAVE_C_LONG_DOUBLE@ + +/* Determine if __float128 is available */ +#cmakedefine H5_HAVE_FLOAT128 @H5_HAVE_FLOAT128@ + /* Define to 1 if you have the `alarm' function. */ #cmakedefine H5_HAVE_ALARM @H5_HAVE_ALARM@ diff --git a/config/cmake/HDF518_Examples.cmake.in b/config/cmake/HDF518_Examples.cmake.in index febf20a..c82fcf2 100644 --- a/config/cmake/HDF518_Examples.cmake.in +++ b/config/cmake/HDF518_Examples.cmake.in @@ -13,7 +13,6 @@ set(CTEST_DASHBOARD_ROOT ${CTEST_SCRIPT_DIRECTORY}) set(CTEST_BUILD_CONFIGURATION "Release") #set(NO_MAC_FORTRAN "true") #set(BUILD_OPTIONS "${BUILD_OPTIONS} -DHDF_BUILD_FORTRAN:BOOL=ON") -set(BUILD_OPTIONS "${BUILD_OPTIONS} -DHDF_ENABLE_F2003:BOOL=ON") #set(CTEST_USE_TAR_SOURCE "${CTEST_SCRIPT_ARG}") ############################################################################################################### @@ -123,4 +122,4 @@ if(res GREATER 0) endif(res GREATER 0) #----------------------------------------------------------------------------- ############################################################################################################## -message(STATUS "DONE") \ No newline at end of file +message(STATUS "DONE") diff --git a/config/cmake/HDF5Macros.cmake b/config/cmake/HDF5Macros.cmake index ee9ed84..976b910 100644 --- a/config/cmake/HDF5Macros.cmake +++ b/config/cmake/HDF5Macros.cmake @@ -26,6 +26,18 @@ macro (H5_SET_LIB_OPTIONS libtarget libname libtype) BUILD_WITH_INSTALL_RPATH ${HDF5_BUILD_WITH_INSTALL_NAME} ) endif (HDF5_BUILD_WITH_INSTALL_NAME) + if (HDF5_BUILD_FRAMEWORKS) + if (${libtype} MATCHES "SHARED") + # adapt target to build frameworks instead of dylibs + set_target_properties(${libtarget} PROPERTIES + XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" + FRAMEWORK TRUE + FRAMEWORK_VERSION ${HDF5_PACKAGE_VERSION_MAJOR} + MACOSX_FRAMEWORK_IDENTIFIER org.hdfgroup.${libtarget} + MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${HDF5_PACKAGE_VERSION_MAJOR} + MACOSX_FRAMEWORK_BUNDLE_VERSION ${HDF5_PACKAGE_VERSION_MAJOR}) + endif (${libtype} MATCHES "SHARED") + endif (HDF5_BUILD_FRAMEWORKS) endif (APPLE) endmacro (H5_SET_LIB_OPTIONS) diff --git a/config/cmake/HDF5UseFortran.cmake b/config/cmake/HDF5UseFortran.cmake new file mode 100644 index 0000000..b3dec14 --- /dev/null +++ b/config/cmake/HDF5UseFortran.cmake @@ -0,0 +1,491 @@ + +## Check for non-standard extenstion quadmath.h + +CHECK_INCLUDE_FILES(quadmath.h C_HAVE_QUADMATH) + +if (${C_HAVE_QUADMATH}) + set(HAVE_QUADMATH 1) +else () + set(HAVE_QUADMATH 0) +endif() + +# +# This file provides functions for HDF5 specific Fortran support. +# +#------------------------------------------------------------------------------- +ENABLE_LANGUAGE (Fortran) + +# The provided CMake Fortran macros don't provide a general compile/run function +# so this one is used. +#----------------------------------------------------------------------------- +MACRO (FORTRAN_RUN FUNCTION CODE RUN_RESULT_VAR1 COMPILE_RESULT_VAR RETURN) +# MSB CHECK WHY THIS CHECK? +# if (NOT DEFINED ${RUN_RESULT_VAR}) + message (STATUS "Detecting Fortran ${FUNCTION}") + if (CMAKE_REQUIRED_LIBRARIES) + set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + else (CMAKE_REQUIRED_LIBRARIES) + set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES) + endif (CMAKE_REQUIRED_LIBRARIES) + file (WRITE + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler1.f90 + "${CODE}" + ) + TRY_RUN (RUN_RESULT_VAR COMPILE_RESULT_VAR + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler1.f90 + CMAKE_FLAGS "${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}" + RUN_OUTPUT_VARIABLE OUTPUT + ) + + + + set(${RETURN} ${OUTPUT}) + + #message ( "Test result1 ${RETURN} ") + #message ( "Test result3 ${RESULT} ") + #message ( "Test result2 ${CMAKE_MATCH_0} ") + #message ( "Test result4 ${CMAKE_MATCH_1} ") + #message ( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") + #message ( "Test result2 ${COMPILE_RESULT_VAR} ") + #message ( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") + #message ( "Test result1 ${RUN_RESULT_VAR} ") + #message ( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") + + if (${COMPILE_RESULT_VAR}) + if (${RUN_RESULT_VAR} MATCHES 0) + message (STATUS "Testing Fortran ${FUNCTION} - OK") + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the Fortran ${FUNCTION} exists passed with the following output:\n" + "${OUTPUT}\n\n" + ) + else () + message (STATUS "Testing Fortran ${FUNCTION} - Fail") + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the Fortran ${FUNCTION} exists failed with the following output:\n" + "${OUTPUT}\n\n") + endif () + endif () +# endif (NOT DEFINED ${RUN_RESULT_VAR}) +ENDMACRO (FORTRAN_RUN) + +#----------------------------------------------------------------------------- +# Check to see C_LONG_DOUBLE is available +CHECK_FORTRAN_FEATURE(c_long_double + " + PROGRAM main + USE ISO_C_BINDING + REAL(KIND=C_LONG_DOUBLE) :: d + END PROGRAM + " + FORTRAN_HAVE_C_LONG_DOUBLE +) +if (${FORTRAN_HAVE_C_LONG_DOUBLE}) + set(FORTRAN_HAVE_C_LONG_DOUBLE 1) +else () + set(FORTRAN_HAVE_C_LONG_DOUBLE 0) +endif() + +# Check to see C_LONG_DOUBLE is different from C_DOUBLE + +CHECK_FORTRAN_FEATURE(c_long_double + " + MODULE type_mod + USE ISO_C_BINDING + INTERFACE h5t + MODULE PROCEDURE h5t_c_double + MODULE PROCEDURE h5t_c_long_double + END INTERFACE + CONTAINS + SUBROUTINE h5t_c_double(r) + REAL(KIND=C_DOUBLE) :: r + END SUBROUTINE h5t_c_double + SUBROUTINE h5t_c_long_double(d) + REAL(KIND=C_LONG_DOUBLE) :: d + END SUBROUTINE h5t_c_long_double + END MODULE type_mod + PROGRAM main + USE ISO_C_BINDING + USE type_mod + REAL(KIND=C_DOUBLE) :: r + REAL(KIND=C_LONG_DOUBLE) :: d + CALL h5t(r) + CALL h5t(d) + END PROGRAM main + " + FORTRAN_C_LONG_DOUBLE_IS_UNIQUE +) +if (${FORTRAN_C_LONG_DOUBLE_IS_UNIQUE}) + set(FORTRAN_C_LONG_DOUBLE_IS_UNIQUE 1) +else () + set(FORTRAN_C_LONG_DOUBLE_IS_UNIQUE 0) +endif() + +## Set the sizeof function for use later in the fortran tests +if(FORTRAN_HAVE_STORAGE_SIZE) + set(FC_SIZEOF_A "STORAGE_SIZE(a, c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t)") + set(FC_SIZEOF_B "STORAGE_SIZE(b, c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t)") + set(FC_SIZEOF_C "STORAGE_SIZE(c, c_size_t)/STORAGE_SIZE(c_char_'a',c_size_t)") +elseif(FORTRAN_HAVE_C_SIZEOF) + set(FC_SIZEOF_A "SIZEOF(a)") + set(FC_SIZEOF_B "SIZEOF(b)") + set(FC_SIZEOF_C "SIZEOF(c)") +else(FORTRAN_HAVE_STORAGE_SIZE) + message (FATAL_ERROR "Fortran compiler requires either intrinsic functions SIZEOF or STORAGE_SIZE") +endif(FORTRAN_HAVE_STORAGE_SIZE) + +#----------------------------------------------------------------------------- +# Determine the available KINDs for REALs and INTEGERs +#----------------------------------------------------------------------------- + +FORTRAN_RUN("REAL and INTEGER KINDs" + " + PROGRAM main + IMPLICIT NONE + INTEGER :: ik, k, lastkind, max_decimal_prec + INTEGER :: num_rkinds, num_ikinds + num_ikinds = 0 + lastkind=SELECTED_INT_KIND(1) + ! Find integer KINDs + DO ik=2,36 + k = SELECTED_INT_KIND(ik) + IF (k .NE. lastkind) THEN + num_ikinds = num_ikinds + 1 + WRITE(*,'(I0)',ADVANCE='NO') lastkind + lastkind = k + IF(k.GT.0) WRITE(*,'(A)',ADVANCE='NO') ',' + ENDIF + IF (k .LE. 0) EXIT + ENDDO + IF (lastkind.NE.-1) THEN + num_ikinds = num_ikinds + 1 + WRITE(*,'(I0)') lastkind + ELSE + WRITE(*,'()') + ENDIF + ! Find real KINDs + num_rkinds = 0 + lastkind=SELECTED_REAL_KIND(1) + max_decimal_prec = 1 + DO ik=2,36 + k = SELECTED_REAL_KIND(ik) + IF (k .NE. lastkind) THEN + num_rkinds = num_rkinds + 1 + WRITE(*,'(I0)',ADVANCE='NO') lastkind + lastkind = k + IF(k.GT.0) WRITE(*,'(A)',ADVANCE='NO') ',' + max_decimal_prec = ik + ENDIF + IF (k .LE. 0) EXIT + ENDDO + IF (lastkind.NE.-1)THEN + num_rkinds = num_rkinds + 1 + WRITE(*,'(I0)') lastkind + ELSE + WRITE(*,'()') + ENDIF + WRITE(*,'(I0)') max_decimal_prec + WRITE(*,'(I0)') num_ikinds + WRITE(*,'(I0)') num_rkinds + END + " + XX + YY + PROG_OUTPUT +) +# dnl The output from the above program will be: +# dnl -- LINE 1 -- valid integer kinds (comma seperated list) +# dnl -- LINE 2 -- valid real kinds (comma seperated list) +# dnl -- LINE 3 -- max decimal precision for reals +# dnl -- LINE 4 -- number of valid integer kinds +# dnl -- LINE 5 -- number of valid real kinds + +# Convert the string to a list of strings by replacing the carriage return with a semicolon +string(REGEX REPLACE "\n" ";" PROG_OUTPUT "${PROG_OUTPUT}") + +list(GET PROG_OUTPUT 0 pac_validIntKinds) +list(GET PROG_OUTPUT 1 pac_validRealKinds) +list(GET PROG_OUTPUT 2 H5_PAC_FC_MAX_REAL_PRECISION) + +set(PAC_FC_ALL_INTEGER_KINDS "\{${pac_validIntKinds}\}") +set(PAC_FC_ALL_REAL_KINDS "\{${pac_validRealKinds}\}") + +list(GET PROG_OUTPUT 3 NUM_IKIND) +list(GET PROG_OUTPUT 4 NUM_RKIND) + +set(H5CONFIG_F_NUM_IKIND "INTEGER, PARAMETER :: num_ikinds = ${NUM_IKIND}") +set(H5CONFIG_F_IKIND "INTEGER, DIMENSION(1:num_ikinds) :: ikind = (/${pac_validIntKinds}/)") + +message ( " ........REAL KINDS FOUND ${PAC_FC_ALL_REAL_KINDS}") +message ( " ........INTEGER KINDS FOUND ${PAC_FC_ALL_REAL_KINDS}") +message ( " ........MAX DECIMAL PRECISION ${H5_PAC_FC_MAX_REAL_PRECISION}") + +#----------------------------------------------------------------------------- +# Determine the available KINDs for REALs and INTEGERs +#----------------------------------------------------------------------------- +# ********** +# INTEGERS +# ********** +string(REGEX REPLACE "," ";" VAR_KIND "${pac_validIntKinds}") + +foreach( KIND ${VAR_KIND} ) + set(PROG_SRC + " + PROGRAM main + USE ISO_C_BINDING + IMPLICIT NONE + INTEGER (KIND=${KIND}) a + WRITE(*,'(I0)') ${FC_SIZEOF_A} + END + " + ) + FORTRAN_RUN("INTEGER KIND SIZEOF" ${PROG_SRC} + XX + YY + PROG_OUTPUT1 + ) + string(REGEX REPLACE "\n" "" PROG_OUTPUT1 "${PROG_OUTPUT1}") + set(pack_int_sizeof "${pack_int_sizeof} ${PROG_OUTPUT1},") +endforeach(KIND) +string(STRIP ${pack_int_sizeof} pack_int_sizeof) + + +#Remove trailing comma +string(REGEX REPLACE ",$" "" pack_int_sizeof "${pack_int_sizeof}") +#Remove spaces +string(REGEX REPLACE " " "" pack_int_sizeof "${pack_int_sizeof}") + +set(PAC_FC_ALL_INTEGER_KINDS_SIZEOF "\{${pack_int_sizeof}\}") + +message("...FOUND SIZEOF for INTEGER KINDs ${PAC_FC_ALL_INTEGER_KINDS_SIZEOF}") +# ********** +# REALS +# ********** +string(REGEX REPLACE "," ";" VAR_KIND "${pac_validRealKinds}") + +#find the maximum kind of the real +list(LENGTH VAR_KIND LEN_VAR_KIND) +MATH (EXPR _LEN "${LEN_VAR_KIND} - 1") +list(GET VAR_KIND ${_LEN} max_real_fortran_kind) + +foreach( KIND ${VAR_KIND} ) + set(PROG_SRC + " + PROGRAM main + USE ISO_C_BINDING + IMPLICIT NONE + REAL (KIND=${KIND}) a + WRITE(*,'(I0)') ${FC_SIZEOF_A} + END + " + ) + FORTRAN_RUN("REAL KIND SIZEOF" ${PROG_SRC} + XX + YY + PROG_OUTPUT1 + ) + string(REGEX REPLACE "\n" "" PROG_OUTPUT1 "${PROG_OUTPUT1}") + set(pack_real_sizeof "${pack_real_sizeof} ${PROG_OUTPUT1},") +endforeach(KIND) +string(STRIP ${pack_real_sizeof} pack_real_sizeof) + +#Remove trailing comma +string(REGEX REPLACE ",$" "" pack_real_sizeof "${pack_real_sizeof}") +#Remove spaces +string(REGEX REPLACE " " "" pack_real_sizeof "${pack_real_sizeof}") + +set(H5CONFIG_F_RKIND_SIZEOF "INTEGER, DIMENSION(1:num_rkinds) :: rkind_sizeof = (/${pack_real_sizeof}/)") + +message("...FOUND SIZEOF for REAL KINDs \{${pack_real_sizeof}\}") + +#find the maximum kind of the real +list(LENGTH VAR_KIND LEN_VAR_KIND) +MATH (EXPR _LEN "${LEN_VAR_KIND} - 1") +list(GET VAR_KIND ${_LEN} max_real_fortran_sizeof) + +set(PAC_FC_ALL_REAL_KINDS_SIZEOF "\{${pack_real_sizeof}\}") +#----------------------------------------------------------------------------- +# Find sizeof of native kinds +#----------------------------------------------------------------------------- +FORTRAN_RUN("SIZEOF NATIVE KINDs" + " + PROGRAM main + USE ISO_C_BINDING + IMPLICIT NONE + INTEGER a + REAL b + DOUBLE PRECISION c + WRITE(*,*) ${FC_SIZEOF_A} + WRITE(*,*) kind(a) + WRITE(*,*) ${FC_SIZEOF_B} + WRITE(*,*) kind(b) + WRITE(*,*) ${FC_SIZEOF_C} + WRITE(*,*) kind(c) + END + " + XX + YY + PROG_OUTPUT +) +# dnl The output from the above program will be: +# dnl -- LINE 1 -- sizeof INTEGER +# dnl -- LINE 2 -- kind of INTEGER +# dnl -- LINE 3 -- sizeof REAL +# dnl -- LINE 4 -- kind of REAL +# dnl -- LINE 5 -- sizeof DOUBLE PRECISION +# dnl -- LINE 6 -- kind of DOUBLE PRECISION + +# Convert the string to a list of strings by replacing the carriage return with a semicolon +string(REGEX REPLACE "\n" ";" PROG_OUTPUT "${PROG_OUTPUT}") + +list(GET PROG_OUTPUT 0 PAC_FORTRAN_NATIVE_INTEGER_SIZEOF) +list(GET PROG_OUTPUT 1 PAC_FORTRAN_NATIVE_INTEGER_KIND) +list(GET PROG_OUTPUT 2 PAC_FORTRAN_NATIVE_REAL_SIZEOF) +list(GET PROG_OUTPUT 3 PAC_FORTRAN_NATIVE_REAL_KIND) +list(GET PROG_OUTPUT 4 PAC_FORTRAN_NATIVE_DOUBLE_SIZEOF) +list(GET PROG_OUTPUT 5 PAC_FORTRAN_NATIVE_DOUBLE_KIND) + +set(FORTRAN_SIZEOF_LONG_DOUBLE ${${HDF_PREFIX}_SIZEOF_LONG_DOUBLE}) +#set(H5_SIZEOF_LONG_DOUBLE ${${HDF_PREFIX}_SIZEOF_LONG_DOUBLE}) + +# remove the invalid kind from the list +if(NOT(${SIZEOF___FLOAT128} EQUAL 0)) + if(NOT(${SIZEOF___FLOAT128} EQUAL ${max_real_fortran_sizeof}) AND NOT(${FORTRAN_SIZEOF_LONG_DOUBLE} EQUAL ${max_real_fortran_sizeof})) + message(WARNING " + Fortran REAL(KIND=${max_real_fortran_kind}) is $max_real_fortran_sizeof Bytes, but no corresponding C float type exists of that size + !!! Fortran interfaces will not be generated for REAL(KIND=${max_real_fortran_kind}) !!!") + string(REGEX REPLACE ",[0-9]+}" "}" PAC_FC_ALL_REAL_KINDS ${PAC_FC_ALL_REAL_KINDS}) + string(REGEX REPLACE ",[0-9]+}" "}" PAC_FC_ALL_REAL_KINDS_SIZEOF ${PAC_FC_ALL_REAL_KINDS_SIZEOF}) + MATH (EXPR NUM_RKIND "${NUM_RKIND} - 1") + endif(NOT(${SIZEOF___FLOAT128} EQUAL ${max_real_fortran_sizeof}) AND NOT(${FORTRAN_SIZEOF_LONG_DOUBLE} EQUAL ${max_real_fortran_sizeof})) +endif(NOT(${SIZEOF___FLOAT128} EQUAL 0)) + +set(H5CONFIG_F_NUM_RKIND "INTEGER, PARAMETER :: num_rkinds = ${NUM_RKIND}") + +string(REGEX REPLACE "{" "" OUT_VAR ${PAC_FC_ALL_REAL_KINDS}) +string(REGEX REPLACE "}" "" OUT_VAR ${OUT_VAR}) +set(H5CONFIG_F_RKIND "INTEGER, DIMENSION(1:num_rkinds) :: rkind = (/${OUT_VAR}/)") + +string(REGEX REPLACE "{" "" OUT_VAR ${PAC_FC_ALL_REAL_KINDS_SIZEOF}) +string(REGEX REPLACE "}" "" OUT_VAR ${OUT_VAR}) +set(H5CONFIG_F_RKIND_SIZEOF "INTEGER, DIMENSION(1:num_rkinds) :: rkind_sizeof = (/${OUT_VAR}/)") + +ENABLE_LANGUAGE (C) + +#----------------------------------------------------------------------------- +# The provided CMake C macros don't provide a general compile/run function +# so this one is used. +#----------------------------------------------------------------------------- +MACRO (C_RUN FUNCTION CODE RUN_RESULT_VAR COMPILE_RESULT_VAR RETURN) +# MSB CHECK WHY THIS CHECK? +# if (NOT DEFINED ${RUN_RESULT_VAR}) + message (STATUS "Detecting C ${FUNCTION}") + if (CMAKE_REQUIRED_LIBRARIES) + set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + else (CMAKE_REQUIRED_LIBRARIES) + set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES) + endif (CMAKE_REQUIRED_LIBRARIES) + file (WRITE + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler1.c + ${CODE} + ) + TRY_RUN (${RUN_RESULT_VAR} ${COMPILE_RESULT_VAR} + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testCCompiler1.c + CMAKE_FLAGS "${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}" + RUN_OUTPUT_VARIABLE OUTPUT + ) + + set(${RETURN} ${OUTPUT}) + + #message ( "Test result1 ${RETURN} ") + #message ( "Test result3 ${RESULT} ") + #message ( "Test result2 ${CMAKE_MATCH_0} ") + #message ( "Test result4 ${CMAKE_MATCH_1} ") + #message ( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") + #message ( "Test result ${COMPILE_RESULT_VAR} ") + #message ( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") + #message ( "Test result ${RUN_RESULT_VAR} ") + #message ( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") + + if (${COMPILE_RESULT_VAR}) + if (${RUN_RESULT_VAR} MATCHES 0) + set (${RUN_RESULT_VAR} 1 CACHE INTERNAL "Have C function ${FUNCTION}") + message (STATUS "Testing C ${FUNCTION} - OK") + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the C ${FUNCTION} exists passed with the following output:\n" + "${OUTPUT}\n\n" + ) + else () + message (STATUS "Testing C ${FUNCTION} - Fail") + set (${RUN_RESULT_VAR} "" CACHE INTERNAL "Have C function ${FUNCTION}") + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the C ${FUNCTION} exists failed with the following output:\n" + "${OUTPUT}\n\n") + endif () + endif() +# endif (NOT DEFINED ${RUN_RESULT_VAR}) +ENDMACRO (C_RUN) + +set(PROG_SRC + " +#include +#include +#define CHECK_FLOAT128 ${SIZEOF___FLOAT128} +#if CHECK_FLOAT128!=0 +# if ${HAVE_QUADMATH}!=0 +#include +# endif +# ifdef FLT128_DIG +#define C_FLT128_DIG FLT128_DIG +# else +#define C_FLT128_DIG 0 +# endif +#else +#define C_FLT128_DIG 0 +#endif +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#define C_LDBL_DIG DECIMAL_DIG +#else +#define C_LDBL_DIG LDBL_DIG +#endif + void main() { + printf(\"%d\\\\n%d\\\\n\", C_LDBL_DIG, C_FLT128_DIG)\\\; + } + " + ) + +C_RUN("maximum decimal precision for C" ${PROG_SRC} + XX + YY + PROG_OUTPUT +) + +# dnl The output from the above program will be: +# dnl -- LINE 1 -- long double decimal precision +# dnl -- LINE 2 -- __float128 decimal precision + +# Convert the string to a list of strings by replacing the carriage return with a semicolon +string(REGEX REPLACE "\n" ";" PROG_OUTPUT "${PROG_OUTPUT}") + +list(GET PROG_OUTPUT 0 LDBL_DIG) +list(GET PROG_OUTPUT 1 FLT128_DIG) + +if(SIZEOF___FLOAT128 EQUAL 0 OR FLT128_DIG EQUAL 0) + SET(H5_HAVE_FLOAT128 0) + SET(SIZEOF___FLOAT128 0) + set(H5_PAC_C_MAX_REAL_PRECISION ${LDBL_DIG}) +else () + set(H5_PAC_C_MAX_REAL_PRECISION ${FLT128_DIG}) +endif() + + +# Setting definition if there is a 16 byte fortran integer +string(FIND ${PAC_FC_ALL_INTEGER_KINDS_SIZEOF} "16" pos) +if(${pos} EQUAL -1) + set(HAVE_Fortran_INTEGER_SIZEOF_16 0) +else () + set(HAVE_Fortran_INTEGER_SIZEOF_16 1) +endif () diff --git a/config/cmake/HDF5_Examples.cmake.in b/config/cmake/HDF5_Examples.cmake.in new file mode 100644 index 0000000..d0c0509 --- /dev/null +++ b/config/cmake/HDF5_Examples.cmake.in @@ -0,0 +1,126 @@ +cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) +############################################################################################################### +# This script will build and run the examples from a compressed file +# Execute from a command line: +# ctest -S HDF5_Examples.cmake,HDF5Examples -C Release -V -O test.log +############################################################################################################### + +set(INSTALLDIR "@CMAKE_INSTALL_PREFIX@") +set(CTEST_CMAKE_GENERATOR "@CMAKE_GENERATOR@") +set(STATICLIBRARIES "@H5_ENABLE_STATIC_LIB@") +set(CTEST_SOURCE_NAME ${CTEST_SCRIPT_ARG}) +set(CTEST_DASHBOARD_ROOT ${CTEST_SCRIPT_DIRECTORY}) +set(CTEST_BUILD_CONFIGURATION "Release") +#set(NO_MAC_FORTRAN "true") +#set(BUILD_OPTIONS "${BUILD_OPTIONS} -DHDF_BUILD_FORTRAN:BOOL=ON") +set(BUILD_OPTIONS "${BUILD_OPTIONS} -DHDF_ENABLE_F2003:BOOL=ON") +#set(CTEST_USE_TAR_SOURCE "${CTEST_SCRIPT_ARG}") + +############################################################################################################### +# Adjust the following SET Commands as needed +############################################################################################################### +if(WIN32) + if(STATICLIBRARIES) + set(BUILD_OPTIONS "${BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF") + endif(STATICLIBRARIES) + set(ENV{HDF5_DIR} "${INSTALLDIR}/cmake") + set(CTEST_BINARY_NAME ${CTEST_SOURCE_NAME}\\build) + set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_SOURCE_NAME}") + set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_BINARY_NAME}") +else(WIN32) + if(STATICLIBRARIES) + set(BUILD_OPTIONS "${BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_ANSI_CFLAGS:STRING=-fPIC") + endif(STATICLIBRARIES) + set(ENV{HDF5_DIR} "${INSTALLDIR}/share/cmake") + set(ENV{LD_LIBRARY_PATH} "${INSTALLDIR}/lib") + set(CTEST_BINARY_NAME ${CTEST_SOURCE_NAME}/build) + set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_SOURCE_NAME}") + set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_BINARY_NAME}") +endif(WIN32) + +############################################################################################################### +# For any comments please contact cdashhelp@hdfgroup.org +# +############################################################################################################### + +#----------------------------------------------------------------------------- +# MAC machines need special option +#----------------------------------------------------------------------------- +if(APPLE) + # Compiler choice + execute_process(COMMAND xcrun --find cc OUTPUT_VARIABLE XCODE_CC OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND xcrun --find c++ OUTPUT_VARIABLE XCODE_CXX OUTPUT_STRIP_TRAILING_WHITESPACE) + set(ENV{CC} "${XCODE_CC}") + set(ENV{CXX} "${XCODE_CXX}") + if(NOT NO_MAC_FORTRAN) + # Shared fortran is not supported, build static + set(BUILD_OPTIONS "${BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_ANSI_CFLAGS:STRING=-fPIC") + else(NOT NO_MAC_FORTRAN) + set(BUILD_OPTIONS "${BUILD_OPTIONS} -DHDF_BUILD_FORTRAN:BOOL=OFF") + endif(NOT NO_MAC_FORTRAN) + set(BUILD_OPTIONS "${BUILD_OPTIONS} -DCTEST_USE_LAUNCHERS:BOOL=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF") +endif(APPLE) + +#----------------------------------------------------------------------------- +set(CTEST_CMAKE_COMMAND "\"${CMAKE_COMMAND}\"") +## -------------------------- +if(CTEST_USE_TAR_SOURCE) + ## Uncompress source if tar or zip file provided + ## -------------------------- + if(WIN32) + message(STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_USE_TAR_SOURCE}.zip]") + execute_process(COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_USE_TAR_SOURCE}.zip RESULT_VARIABLE rv) + else(WIN32) + message(STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_USE_TAR_SOURCE}.tar]") + execute_process(COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_USE_TAR_SOURCE}.tar RESULT_VARIABLE rv) + endif(WIN32) + + if(NOT rv EQUAL 0) + message(STATUS "extracting... [error-(${rv}) clean up]") + file(REMOVE_RECURSE "${CTEST_SOURCE_DIRECTORY}") + message(FATAL_ERROR "error: extract of ${CTEST_SOURCE_NAME} failed") + endif(NOT rv EQUAL 0) +endif(CTEST_USE_TAR_SOURCE) + +#----------------------------------------------------------------------------- +## Clear the build directory +## -------------------------- +set(CTEST_START_WITH_EMPTY_BINARY_DIRECTORY TRUE) +if (EXISTS "${CTEST_BINARY_DIRECTORY}" AND IS_DIRECTORY "${CTEST_BINARY_DIRECTORY}") + ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) +else (EXISTS "${CTEST_BINARY_DIRECTORY}" AND IS_DIRECTORY "${CTEST_BINARY_DIRECTORY}") + file(MAKE_DIRECTORY "${CTEST_BINARY_DIRECTORY}") +endif (EXISTS "${CTEST_BINARY_DIRECTORY}" AND IS_DIRECTORY "${CTEST_BINARY_DIRECTORY}") + +# Use multiple CPU cores to build +include(ProcessorCount) +ProcessorCount(N) +if(NOT N EQUAL 0) + if(NOT WIN32) + set(CTEST_BUILD_FLAGS -j${N}) + endif(NOT WIN32) + set(ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${N}) +endif() +set (CTEST_CONFIGURE_COMMAND + "${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_BUILD_CONFIGURATION} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_SOURCE_DIRECTORY}\"" +) + +#----------------------------------------------------------------------------- +## -- set output to english +set($ENV{LC_MESSAGES} "en_EN") + +#----------------------------------------------------------------------------- +configure_file(${CTEST_SOURCE_DIRECTORY}/config/cmake/CTestCustom.cmake ${CTEST_BINARY_DIRECTORY}/CTestCustom.cmake) +ctest_read_custom_files ("${CTEST_BINARY_DIRECTORY}") +## NORMAL process +## -------------------------- +ctest_start (Experimental) +ctest_configure (BUILD "${CTEST_BINARY_DIRECTORY}") +ctest_build (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND) +ctest_test (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND ${ctest_test_args} RETURN_VALUE res) +if(res GREATER 0) + message (FATAL_ERROR "tests FAILED") +endif(res GREATER 0) +#----------------------------------------------------------------------------- +############################################################################################################## +message(STATUS "DONE") \ No newline at end of file diff --git a/config/cmake/HDFCompilerFlags.cmake b/config/cmake/HDFCompilerFlags.cmake index 56d17bf..c637c73 100644 --- a/config/cmake/HDFCompilerFlags.cmake +++ b/config/cmake/HDFCompilerFlags.cmake @@ -5,7 +5,7 @@ if (CMAKE_COMPILER_IS_GNUCC) if (CMAKE_BUILD_TYPE MATCHES Debug) set (CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS} -std=c99") if (NOT CMAKE_C_COMPILER_VERSION VERSION_LESS 5.0) - set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftrapv -fno-common") + set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Og -ftrapv -fno-common") endif () else (CMAKE_BUILD_TYPE MATCHES Debug) set (CMAKE_C_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_C_FLAGS} -std=c99") @@ -18,7 +18,7 @@ if (CMAKE_COMPILER_IS_GNUCXX) if (CMAKE_BUILD_TYPE MATCHES Debug) set (CMAKE_CXX_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_CXX_FLAGS} -std=c99") if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) - set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftrapv -fno-common") + set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Og -ftrapv -fno-common") endif () else (CMAKE_BUILD_TYPE MATCHES Debug) set (CMAKE_CXX_FLAGS "${CMAKE_ANSI_CFLAGS} ${CMAKE_CXX_FLAGS} -std=c99") diff --git a/config/cmake/README.txt.cmake.in b/config/cmake/README.txt.cmake.in index cc8baeb..a12c5aa 100644 --- a/config/cmake/README.txt.cmake.in +++ b/config/cmake/README.txt.cmake.in @@ -26,18 +26,18 @@ After Installation =========================================================================== The examples folder, HDF5Examples, located in the HDF5 install folder, can be built and tested with CMake and the supplied -HDF518_Examples.cmake file. The HDF518_Examples.cmake expects HDF5 to have +HDF5_Examples.cmake file. The HDF5_Examples.cmake expects HDF5 to have been installed in the default location with above compilers. Also, the CMake utility should be installed. To test the installation with the examples; Create a directory to run the examples. Copy HDF5Examples folder to this directory. - Copy HDF518_Examples.cmake to this directory. - Edit HDF518_Examples.cmake line 8 to set INSTALLDIR to where HDF5 is installed. + Copy HDF5_Examples.cmake to this directory. + Edit HDF5_Examples.cmake line 8 to set INSTALLDIR to where HDF5 is installed. (The default should be correct unless you installed into a different folder.) Execute from this directory: - ctest -S HDF518_Examples.cmake,HDF5Examples-0.1.1-Source -C Release -V -O test.log + ctest -S HDF5_Examples.cmake,HDF5Examples -C Release -V -O test.log When executed, the ctest script will save the results to the log file, test.log, as indicated by the ctest command. If you wish the to see more build and test information, diff --git a/config/cmake/cacheinit.cmake b/config/cmake/cacheinit.cmake index 87d4fcc..cca6e98 100644 --- a/config/cmake/cacheinit.cmake +++ b/config/cmake/cacheinit.cmake @@ -4,16 +4,12 @@ # EXTERNAL cache entries ######################## -set (BUILD_SHARED_LIBS ON CACHE BOOL "Build Shared Libraries" FORCE) - -set (BUILD_TESTING ON CACHE BOOL "Build HDF5 Unit Testing" FORCE) +set (CMAKE_INSTALL_FRAMEWORK_PREFIX "Library/Frameworks" CACHE STRING "Frameworks installation directory" FORCE) set (HDF_PACKAGE_EXT "" CACHE STRING "Name of HDF package extension" FORCE) set (HDF5_BUILD_FORTRAN ON CACHE BOOL "Build FORTRAN support" FORCE) -set (HDF5_ENABLE_F2003 ON CACHE BOOL "Enable FORTRAN 2003 Standard" FORCE) - set (HDF5_BUILD_GENERATORS OFF CACHE BOOL "Build Test Generators" FORCE) set (HDF5_ENABLE_Z_LIB_SUPPORT ON CACHE BOOL "Enable Zlib Filters" FORCE) diff --git a/config/cmake/hdf5-config.cmake.in b/config/cmake/hdf5-config.cmake.in index 667d3e6..adeec55 100644 --- a/config/cmake/hdf5-config.cmake.in +++ b/config/cmake/hdf5-config.cmake.in @@ -6,6 +6,8 @@ string(TOUPPER @HDF5_PACKAGE@ HDF5_PACKAGE_NAME) set (${HDF5_PACKAGE_NAME}_VALID_COMPONENTS + static + shared C CXX Fortran @@ -20,7 +22,6 @@ set (${HDF5_PACKAGE_NAME}_VALID_COMPONENTS #----------------------------------------------------------------------------- set (${HDF5_PACKAGE_NAME}_ENABLE_PARALLEL @HDF5_ENABLE_PARALLEL@) set (${HDF5_PACKAGE_NAME}_BUILD_FORTRAN @HDF5_BUILD_FORTRAN@) -set (${HDF5_PACKAGE_NAME}_ENABLE_F2003 @HDF5_ENABLE_F2003@) set (${HDF5_PACKAGE_NAME}_BUILD_CPP_LIB @HDF5_BUILD_CPP_LIB@) set (${HDF5_PACKAGE_NAME}_BUILD_TOOLS @HDF5_BUILD_TOOLS@) set (${HDF5_PACKAGE_NAME}_BUILD_HL_LIB @HDF5_BUILD_HL_LIB@) @@ -68,12 +69,6 @@ if (${HDF5_PACKAGE_NAME}_BUILD_TOOLS) set_and_check (${HDF5_PACKAGE_NAME}_TOOLS_DIR "@PACKAGE_CURRENT_BUILD_DIR@/bin") endif () -if (HDF5_BUILD_SHARED_LIBS) - set (H5_BUILT_AS_DYNAMIC_LIB 1) -else () - set (H5_BUILT_AS_STATIC_LIB 1) -endif () - #----------------------------------------------------------------------------- # Version Strings #----------------------------------------------------------------------------- @@ -95,14 +90,25 @@ if (NOT TARGET "@HDF5_PACKAGE@") include (@PACKAGE_SHARE_INSTALL_DIR@/@HDF5_PACKAGE@@HDF_PACKAGE_EXT@-targets.cmake) endif () -# Handle default component : +# Handle default component(static) : if (NOT ${HDF5_PACKAGE_NAME}_FIND_COMPONENTS) - set (${HDF5_PACKAGE_NAME}_FIND_COMPONENTS C HL) - set (${HDF5_PACKAGE_NAME}_FIND_REQUIRED_C true) + set (${HDF5_PACKAGE_NAME}_LIB_TYPE) + set (${HDF5_PACKAGE_NAME}_FIND_COMPONENTS C HL static) + set (${HDF5_PACKAGE_NAME}_FIND_REQUIRED_static_C true) endif () # Handle requested components: list (REMOVE_DUPLICATES ${HDF5_PACKAGE_NAME}_FIND_COMPONENTS) +foreach (comp IN LISTS ${HDF5_PACKAGE_NAME}_FIND_COMPONENTS) + if (${comp} STREQUAL "shared") + list (REMOVE_ITEM ${HDF5_PACKAGE_NAME}_FIND_COMPONENTS ${comp}) + set (${HDF5_PACKAGE_NAME}_LIB_TYPE ${${HDF5_PACKAGE_NAME}_LIB_TYPE} ${comp}) + elseif (${comp} STREQUAL "static") + list (REMOVE_ITEM ${HDF5_PACKAGE_NAME}_FIND_COMPONENTS ${comp}) + set (${HDF5_PACKAGE_NAME}_LIB_TYPE ${${HDF5_PACKAGE_NAME}_LIB_TYPE} ${comp}) + endif () +endforeach () +foreach (libtype IN LISTS ${HDF5_PACKAGE_NAME}_LIB_TYPE) foreach (comp IN LISTS ${HDF5_PACKAGE_NAME}_FIND_COMPONENTS) set (hdf5_comp2) if (${comp} STREQUAL "C") @@ -122,26 +128,28 @@ list (REMOVE_DUPLICATES ${HDF5_PACKAGE_NAME}_FIND_COMPONENTS) set (hdf5_comp2 "hdf5_hl_f90cstub") set (hdf5_comp "hdf5_hl_fortran") endif () - list (FIND ${HDF5_PACKAGE_NAME}_EXPORT_LIBRARIES "${hdf5_comp}" HAVE_COMP) + list (FIND ${HDF5_PACKAGE_NAME}_EXPORT_LIBRARIES "${hdf5_comp}-${libtype}" HAVE_COMP) if (${HAVE_COMP} LESS 0) - set (${HDF5_PACKAGE_NAME}_${comp}_FOUND 0) + set (${HDF5_PACKAGE_NAME}_${libtype}_${comp}_FOUND 0) else () if (hdf5_comp2) - list (FIND ${HDF5_PACKAGE_NAME}_EXPORT_LIBRARIES "${hdf5_comp2}" HAVE_COMP2) + list (FIND ${HDF5_PACKAGE_NAME}_EXPORT_LIBRARIES "${hdf5_comp2}-${libtype}" HAVE_COMP2) if (${HAVE_COMP2} LESS 0) - set (${HDF5_PACKAGE_NAME}_${comp}_FOUND 0) + set (${HDF5_PACKAGE_NAME}_${libtype}_${comp}_FOUND 0) else () - set (${HDF5_PACKAGE_NAME}_${comp}_FOUND 1) - string(TOUPPER ${HDF5_PACKAGE_NAME}_${comp}_LIBRARY COMP_LIBRARY) - set (${HDF5_PACKAGE_NAME}_LIBRARIES ${${HDF5_PACKAGE_NAME}_LIBRARIES} ${hdf5_comp2} ${hdf5_comp}) + set (${HDF5_PACKAGE_NAME}_${libtype}_${comp}_FOUND 1) + string(TOUPPER ${HDF5_PACKAGE_NAME}_${comp}_${libtype}_LIBRARY COMP_LIBRARY) + set (${COMP_LIBRARY} ${${COMP_LIBRARY}} ${hdf5_comp2}-${libtype} ${hdf5_comp}-${libtype}) endif () else () - set (${HDF5_PACKAGE_NAME}_${comp}_FOUND 1) - string(TOUPPER ${HDF5_PACKAGE_NAME}_${comp}_LIBRARY COMP_LIBRARY) - set (${HDF5_PACKAGE_NAME}_LIBRARIES ${${HDF5_PACKAGE_NAME}_LIBRARIES} ${hdf5_comp}) + set (${HDF5_PACKAGE_NAME}_${libtype}_${comp}_FOUND 1) + string(TOUPPER ${HDF5_PACKAGE_NAME}_${comp}_${libtype}_LIBRARY COMP_LIBRARY) + set (${COMP_LIBRARY} ${${COMP_LIBRARY}} ${hdf5_comp}-${libtype}) endif () endif () endforeach () +endforeach () - check_required_components(${HDF5_PACKAGE_NAME}_FIND_COMPONENTS) - \ No newline at end of file +foreach (libtype IN LISTS ${HDF5_PACKAGE_NAME}_LIB_TYPE) + check_required_components(${HDF5_PACKAGE_NAME}_${libtype}) +endforeach () diff --git a/config/cmake/libhdf5.settings.cmake.in b/config/cmake/libhdf5.settings.cmake.in index e2124e1..ba764a4 100644 --- a/config/cmake/libhdf5.settings.cmake.in +++ b/config/cmake/libhdf5.settings.cmake.in @@ -38,12 +38,11 @@ Languages: ---------- Fortran: @HDF5_BUILD_FORTRAN@ @BUILD_FORTRAN_CONDITIONAL_TRUE@ Fortran Compiler: @CMAKE_Fortran_COMPILER@ -@BUILD_FORTRAN_CONDITIONAL_TRUE@ Fortran 2003 Compiler: @HDF5_ENABLE_F2003@ @BUILD_FORTRAN_CONDITIONAL_TRUE@ Fortran Flags: @CMAKE_Fortran_FLAGS@ @BUILD_FORTRAN_CONDITIONAL_TRUE@ H5 Fortran Flags: @H5_FCFLAGS@ @BUILD_FORTRAN_CONDITIONAL_TRUE@ AM Fortran Flags: @AM_FCFLAGS@ @BUILD_FORTRAN_CONDITIONAL_TRUE@ Shared Fortran Library: @H5_ENABLE_SHARED_LIB@ -@BUILD_FORTRAN_CONDITIONAL_TRUE@ Static Fortran Library: @H5_ENABLE_STATIC_LIB@ +@BUILD_FORTRAN_CONDITIONAL_TRUE@ Static Fortran Library: YES C++: @HDF5_BUILD_CPP_LIB@ @BUILD_CXX_CONDITIONAL_TRUE@ C++ Compiler: @CMAKE_CXX_COMPILER@ @@ -51,7 +50,7 @@ Languages: @BUILD_CXX_CONDITIONAL_TRUE@ H5 C++ Flags: @H5_CXXFLAGS@ @BUILD_CXX_CONDITIONAL_TRUE@ AM C++ Flags: @AM_CXXFLAGS@ @BUILD_CXX_CONDITIONAL_TRUE@ Shared C++ Library: @H5_ENABLE_SHARED_LIB@ -@BUILD_CXX_CONDITIONAL_TRUE@ Static C++ Library: @H5_ENABLE_STATIC_LIB@ +@BUILD_CXX_CONDITIONAL_TRUE@ Static C++ Library: YES Features: --------- diff --git a/config/cmake/mccacheinit.cmake b/config/cmake/mccacheinit.cmake index af506e6..39ec124 100644 --- a/config/cmake/mccacheinit.cmake +++ b/config/cmake/mccacheinit.cmake @@ -16,8 +16,6 @@ set (HDF5_BUILD_EXAMPLES ON CACHE BOOL "Build HDF5 Library Examples" FORCE) set (HDF5_BUILD_FORTRAN ON CACHE BOOL "Build FORTRAN support" FORCE) -set (HDF5_ENABLE_F2003 ON CACHE BOOL "Enable FORTRAN 2003 Standard" FORCE) - set (HDF5_BUILD_HL_LIB ON CACHE BOOL "Build HIGH Level HDF5 Library" FORCE) set (HDF5_BUILD_TOOLS ON CACHE BOOL "Build HDF5 Tools" FORCE) diff --git a/config/cmake/scripts/CTestScript.cmake b/config/cmake/scripts/CTestScript.cmake old mode 100755 new mode 100644 index 0cd686a..1c33a07 --- a/config/cmake/scripts/CTestScript.cmake +++ b/config/cmake/scripts/CTestScript.cmake @@ -1,282 +1,282 @@ -cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) -######################################################## -# This dashboard is maintained by The HDF Group -# For any comments please contact cdashhelp@hdfgroup.org -# -######################################################## -# ----------------------------------------------------------- -# -- Get environment -# ----------------------------------------------------------- -if(NOT SITE_OS_NAME) - ## machine name not provided - attempt to discover with uname - ## -- set hostname - ## -------------------------- - find_program(HOSTNAME_CMD NAMES hostname) - exec_program(${HOSTNAME_CMD} ARGS OUTPUT_VARIABLE HOSTNAME) - set(CTEST_SITE "${HOSTNAME}${CTEST_SITE_EXT}") - find_program(UNAME NAMES uname) - macro(getuname name flag) - exec_program("${UNAME}" ARGS "${flag}" OUTPUT_VARIABLE "${name}") - endmacro(getuname) - - getuname(osname -s) - getuname(osrel -r) - getuname(cpu -m) - message(STATUS "Dashboard script uname output: ${osname}-${osrel}-${cpu}\n") - - set(CTEST_BUILD_NAME "${osname}-${osrel}-${cpu}") - if(USE_AUTOTOOLS) - set(CTEST_BUILD_NAME "AT-${CTEST_BUILD_NAME}") - endif() - if(SITE_BUILDNAME_SUFFIX) - set(CTEST_BUILD_NAME "${CTEST_BUILD_NAME}-${SITE_BUILDNAME_SUFFIX}") - endif() - set(BUILD_OPTIONS "${ADD_BUILD_OPTIONS}") -else(NOT SITE_OS_NAME) - ## machine name provided - ## -------------------------- - if(CMAKE_HOST_UNIX) - set(CTEST_BUILD_NAME "${SITE_OS_NAME}-${SITE_OS_VERSION}-${SITE_OS_BITS}-${SITE_COMPILER_NAME}-${SITE_COMPILER_VERSION}") - else() - set(CTEST_BUILD_NAME "${SITE_OS_NAME}-${SITE_OS_VERSION}-${SITE_COMPILER_NAME}") - endif() - if(SITE_BUILDNAME_SUFFIX) - set(CTEST_BUILD_NAME ${CTEST_BUILD_NAME}-${SITE_BUILDNAME_SUFFIX}) - endif() - set(BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DSITE:STRING=${CTEST_SITE} -DBUILDNAME:STRING=${CTEST_BUILD_NAME}") -endif(NOT SITE_OS_NAME) - -#----------------------------------------------------------------------------- -# MAC machines need special option -#----------------------------------------------------------------------------- -if(APPLE) - # Compiler choice - execute_process(COMMAND xcrun --find cc OUTPUT_VARIABLE XCODE_CC OUTPUT_STRIP_TRAILING_WHITESPACE) - execute_process(COMMAND xcrun --find c++ OUTPUT_VARIABLE XCODE_CXX OUTPUT_STRIP_TRAILING_WHITESPACE) - set(ENV{CC} "${XCODE_CC}") - set(ENV{CXX} "${XCODE_CXX}") - - set(BUILD_OPTIONS "${BUILD_OPTIONS} -DCTEST_USE_LAUNCHERS:BOOL=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF") -endif(APPLE) - -#----------------------------------------------------------------------------- -set(NEED_REPOSITORY_CHECKOUT 0) -set(CTEST_CMAKE_COMMAND "\"${CMAKE_COMMAND}\"") -if(CTEST_USE_TAR_SOURCE) - ## Uncompress source if tar file provided - ## -------------------------- - if(WIN32) - message(STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} x ${CTEST_USE_TAR_SOURCE}.zip]") - execute_process(COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}\\${CTEST_USE_TAR_SOURCE}.zip RESULT_VARIABLE rv) - else() - message(STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_USE_TAR_SOURCE}.tar]") - execute_process(COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}/${CTEST_USE_TAR_SOURCE}.tar RESULT_VARIABLE rv) - endif() - - if(NOT rv EQUAL 0) - message(STATUS "extracting... [error-(${rv}) clean up]") - file(REMOVE_RECURSE "${CTEST_SOURCE_DIRECTORY}") - message(FATAL_ERROR "error: extract of ${CTEST_USE_TAR_SOURCE} failed") - endif() - - file(RENAME ${CTEST_DASHBOARD_ROOT}/${CTEST_USE_TAR_SOURCE} ${CTEST_SOURCE_DIRECTORY}) -else(CTEST_USE_TAR_SOURCE) - if(LOCAL_UPDATE) - if(CTEST_USE_GIT_SOURCE) - find_program(CTEST_GIT_COMMAND NAMES git git.cmd) - set(CTEST_GIT_UPDATE_OPTIONS) - - if(NOT EXISTS "${CTEST_SOURCE_DIRECTORY}") - set(NEED_REPOSITORY_CHECKOUT 1) - endif() - - if(${NEED_REPOSITORY_CHECKOUT}) - if(REPOSITORY_BRANCH) - set(GITUpdateOptions "clone \"${REPOSITORY_URL}\" --branch \"${REPOSITORY_BRANCH}\" \"${CTEST_SOURCE_DIRECTORY}\" --recurse-submodules") - else() - set(GITUpdateOptions "clone \"${REPOSITORY_URL}\" \"${CTEST_SOURCE_DIRECTORY}\" --recurse-submodules") - endif() - set(CTEST_CHECKOUT_COMMAND "${CTEST_GIT_COMMAND} ${GITUpdateOptions}") - else() - set(GITUpdateOptions "pull") - endif() - set(CTEST_UPDATE_COMMAND "${CTEST_GIT_COMMAND}") - else(CTEST_USE_GIT_SOURCE) - ## -------------------------- - ## use subversion to get source - #----------------------------------------------------------------------------- - ## cygwin does not handle the find_package() call - ## -------------------------- - set(CTEST_UPDATE_COMMAND "SVNCommand") - if(NOT SITE_CYGWIN}) - find_package (Subversion) - set(CTEST_SVN_COMMAND "${Subversion_SVN_EXECUTABLE}") - set(CTEST_UPDATE_COMMAND "${Subversion_SVN_EXECUTABLE}") - else() - set(CTEST_SVN_COMMAND "/usr/bin/svn") - set(CTEST_UPDATE_COMMAND "/usr/bin/svn") - endif() - - if(NOT EXISTS "${CTEST_SOURCE_DIRECTORY}") - set(NEED_REPOSITORY_CHECKOUT 1) - endif() - - if(NOT CTEST_REPO_VERSION) - set(CTEST_REPO_VERSION "HEAD") - endif() - if(${NEED_REPOSITORY_CHECKOUT}) - set(CTEST_CHECKOUT_COMMAND - "${CTEST_SVN_COMMAND} co ${REPOSITORY_URL} \"${CTEST_SOURCE_DIRECTORY}\" -r ${CTEST_REPO_VERSION}") - else(${NEED_REPOSITORY_CHECKOUT}) - if(CTEST_REPO_VERSION) - set(CTEST_SVN_UPDATE_OPTIONS "-r ${CTEST_REPO_VERSION}") - endif() - endif(${NEED_REPOSITORY_CHECKOUT}) - endif(CTEST_USE_GIT_SOURCE) - endif(LOCAL_UPDATE) -endif(CTEST_USE_TAR_SOURCE) - -#----------------------------------------------------------------------------- -## Clear the build directory -## -------------------------- -set(CTEST_START_WITH_EMPTY_BINARY_DIRECTORY TRUE) -if(NOT EXISTS "${CTEST_BINARY_DIRECTORY}") - file(MAKE_DIRECTORY "${CTEST_BINARY_DIRECTORY}") -else() - ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) -endif() - -# Use multiple CPU cores to build -include(ProcessorCount) -ProcessorCount(N) -if(NOT N EQUAL 0) - if(NOT WIN32) - set(CTEST_BUILD_FLAGS -j${N}) - endif() - set(ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${N}) -endif() - -#----------------------------------------------------------------------------- -# Send the main script as a note. -list(APPEND CTEST_NOTES_FILES - "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}" - "${CMAKE_CURRENT_LIST_FILE}" - "${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake" -) - -#----------------------------------------------------------------------------- -# Check for required variables. -# -------------------------- -foreach(req - CTEST_CMAKE_GENERATOR - CTEST_SITE - CTEST_BUILD_NAME - ) - if(NOT DEFINED ${req}) - message(FATAL_ERROR "The containing script must set ${req}") - endif() -endforeach(req) - -#----------------------------------------------------------------------------- -# Initialize the CTEST commands -#------------------------------ -if(LOCAL_MEMCHECK_TEST) - find_program(CTEST_MEMORYCHECK_COMMAND NAMES valgrind) - set (CTEST_CONFIGURE_COMMAND - "${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/mccacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_BUILD_CONFIGURATION} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_SOURCE_DIRECTORY}\"" - ) -else() - if(LOCAL_COVERAGE_TEST) - find_program(CTEST_COVERAGE_COMMAND NAMES gcov) - endif() - set (CTEST_CONFIGURE_COMMAND - "${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_BUILD_CONFIGURATION} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_SOURCE_DIRECTORY}\"" - ) -endif() - -#----------------------------------------------------------------------------- -## -- set output to english -set($ENV{LC_MESSAGES} "en_EN") - -# Print summary information. -foreach(v - CTEST_SITE - CTEST_BUILD_NAME - CTEST_SOURCE_DIRECTORY - CTEST_BINARY_DIRECTORY - CTEST_CMAKE_GENERATOR - CTEST_BUILD_CONFIGURATION - CTEST_GIT_COMMAND - CTEST_CHECKOUT_COMMAND - CTEST_CONFIGURE_COMMAND - CTEST_SCRIPT_DIRECTORY - CTEST_USE_LAUNCHERS - ) - set(vars "${vars} ${v}=[${${v}}]\n") -endforeach(v) -message(STATUS "Dashboard script configuration:\n${vars}\n") - -#----------------------------------------------------------------------------- -#----------------------------------------------------------------------------- - ## NORMAL process - ## -- LOCAL_UPDATE updates the source folder from svn - ## -- LOCAL_SUBMIT reports to CDash server - ## -- LOCAL_SKIP_TEST skips the test process (only builds) - ## -- LOCAL_MEMCHECK_TEST executes the Valgrind testing - ## -- LOCAL_COVERAGE_TEST executes code coverage process - ## -------------------------- - ctest_start (${MODEL} TRACK ${MODEL}) - if(LOCAL_UPDATE) - ctest_update (SOURCE "${CTEST_SOURCE_DIRECTORY}") - endif() - configure_file(${CTEST_SOURCE_DIRECTORY}/config/cmake/CTestCustom.cmake ${CTEST_BINARY_DIRECTORY}/CTestCustom.cmake) - ctest_read_custom_files ("${CTEST_BINARY_DIRECTORY}") - ctest_configure (BUILD "${CTEST_BINARY_DIRECTORY}") - if(LOCAL_SUBMIT) - ctest_submit (PARTS Update Configure Notes) - endif() - - ctest_build (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND) - if(LOCAL_SUBMIT) - ctest_submit (PARTS Build) - endif() - - if(NOT LOCAL_SKIP_TEST) - if(NOT LOCAL_MEMCHECK_TEST) - ctest_test (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND ${ctest_test_args} RETURN_VALUE res) - if(LOCAL_SUBMIT) - ctest_submit (PARTS Test) - endif() - if(res GREATER 0) - message(FATAL_ERROR "Failed tests: ${res}\n") - endif() - else() - ctest_memcheck (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND ${ctest_test_args}) - if(LOCAL_SUBMIT) - ctest_submit (PARTS MemCheck) - endif(LOCAL_SUBMIT) - endif() - if(LOCAL_COVERAGE_TEST) - ctest_coverage (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND) - if(LOCAL_SUBMIT) - ctest_submit (PARTS Coverage) - endif() - endif() - endif(NOT LOCAL_SKIP_TEST) - - if(NOT LOCAL_MEMCHECK_TEST AND NOT LOCAL_NO_PACKAGE) - ##----------------------------------------------- - ## Package the product - ##----------------------------------------------- - execute_process(COMMAND cpack -C ${CTEST_BUILD_CONFIGURATION} -V - WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} - RESULT_VARIABLE cpackResult - OUTPUT_VARIABLE cpackLog - ERROR_VARIABLE cpackLog.err - ) - file(WRITE ${CTEST_BINARY_DIRECTORY}/cpack.log "${cpackLog.err}" "${cpackLog}") - if(cpackResult GREATER 0) - message (FATAL_ERROR "Failed packaging: ${cpackResult}\n") - endif() - endif(NOT LOCAL_MEMCHECK_TEST AND NOT LOCAL_NO_PACKAGE) -#----------------------------------------------------------------------------- +cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) +######################################################## +# This dashboard is maintained by The HDF Group +# For any comments please contact cdashhelp@hdfgroup.org +# +######################################################## +# ----------------------------------------------------------- +# -- Get environment +# ----------------------------------------------------------- +if(NOT SITE_OS_NAME) + ## machine name not provided - attempt to discover with uname + ## -- set hostname + ## -------------------------- + find_program(HOSTNAME_CMD NAMES hostname) + exec_program(${HOSTNAME_CMD} ARGS OUTPUT_VARIABLE HOSTNAME) + set(CTEST_SITE "${HOSTNAME}${CTEST_SITE_EXT}") + find_program(UNAME NAMES uname) + macro(getuname name flag) + exec_program("${UNAME}" ARGS "${flag}" OUTPUT_VARIABLE "${name}") + endmacro(getuname) + + getuname(osname -s) + getuname(osrel -r) + getuname(cpu -m) + message(STATUS "Dashboard script uname output: ${osname}-${osrel}-${cpu}\n") + + set(CTEST_BUILD_NAME "${osname}-${osrel}-${cpu}") + if(USE_AUTOTOOLS) + set(CTEST_BUILD_NAME "AT-${CTEST_BUILD_NAME}") + endif() + if(SITE_BUILDNAME_SUFFIX) + set(CTEST_BUILD_NAME "${CTEST_BUILD_NAME}-${SITE_BUILDNAME_SUFFIX}") + endif() + set(BUILD_OPTIONS "${ADD_BUILD_OPTIONS}") +else(NOT SITE_OS_NAME) + ## machine name provided + ## -------------------------- + if(CMAKE_HOST_UNIX) + set(CTEST_BUILD_NAME "${SITE_OS_NAME}-${SITE_OS_VERSION}-${SITE_OS_BITS}-${SITE_COMPILER_NAME}-${SITE_COMPILER_VERSION}") + else() + set(CTEST_BUILD_NAME "${SITE_OS_NAME}-${SITE_OS_VERSION}-${SITE_COMPILER_NAME}") + endif() + if(SITE_BUILDNAME_SUFFIX) + set(CTEST_BUILD_NAME ${CTEST_BUILD_NAME}-${SITE_BUILDNAME_SUFFIX}) + endif() + set(BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DSITE:STRING=${CTEST_SITE} -DBUILDNAME:STRING=${CTEST_BUILD_NAME}") +endif(NOT SITE_OS_NAME) + +#----------------------------------------------------------------------------- +# MAC machines need special option +#----------------------------------------------------------------------------- +if(APPLE) + # Compiler choice + execute_process(COMMAND xcrun --find cc OUTPUT_VARIABLE XCODE_CC OUTPUT_STRIP_TRAILING_WHITESPACE) + execute_process(COMMAND xcrun --find c++ OUTPUT_VARIABLE XCODE_CXX OUTPUT_STRIP_TRAILING_WHITESPACE) + set(ENV{CC} "${XCODE_CC}") + set(ENV{CXX} "${XCODE_CXX}") + + set(BUILD_OPTIONS "${BUILD_OPTIONS} -DCTEST_USE_LAUNCHERS:BOOL=ON -DCMAKE_BUILD_WITH_INSTALL_RPATH:BOOL=OFF") +endif(APPLE) + +#----------------------------------------------------------------------------- +set(NEED_REPOSITORY_CHECKOUT 0) +set(CTEST_CMAKE_COMMAND "\"${CMAKE_COMMAND}\"") +if(CTEST_USE_TAR_SOURCE) + ## Uncompress source if tar file provided + ## -------------------------- + if(WIN32) + message(STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} x ${CTEST_USE_TAR_SOURCE}.zip]") + execute_process(COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}\\${CTEST_USE_TAR_SOURCE}.zip RESULT_VARIABLE rv) + else() + message(STATUS "extracting... [${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_USE_TAR_SOURCE}.tar]") + execute_process(COMMAND ${CMAKE_EXECUTABLE_NAME} -E tar -xvf ${CTEST_DASHBOARD_ROOT}/${CTEST_USE_TAR_SOURCE}.tar RESULT_VARIABLE rv) + endif() + + if(NOT rv EQUAL 0) + message(STATUS "extracting... [error-(${rv}) clean up]") + file(REMOVE_RECURSE "${CTEST_SOURCE_DIRECTORY}") + message(FATAL_ERROR "error: extract of ${CTEST_USE_TAR_SOURCE} failed") + endif() + + file(RENAME ${CTEST_DASHBOARD_ROOT}/${CTEST_USE_TAR_SOURCE} ${CTEST_SOURCE_DIRECTORY}) +else(CTEST_USE_TAR_SOURCE) + if(LOCAL_UPDATE) + if(CTEST_USE_GIT_SOURCE) + find_program(CTEST_GIT_COMMAND NAMES git git.cmd) + set(CTEST_GIT_UPDATE_OPTIONS) + + if(NOT EXISTS "${CTEST_SOURCE_DIRECTORY}") + set(NEED_REPOSITORY_CHECKOUT 1) + endif() + + if(${NEED_REPOSITORY_CHECKOUT}) + if(REPOSITORY_BRANCH) + set(GITUpdateOptions "clone \"${REPOSITORY_URL}\" --branch \"${REPOSITORY_BRANCH}\" \"${CTEST_SOURCE_DIRECTORY}\" --recurse-submodules") + else() + set(GITUpdateOptions "clone \"${REPOSITORY_URL}\" \"${CTEST_SOURCE_DIRECTORY}\" --recurse-submodules") + endif() + set(CTEST_CHECKOUT_COMMAND "${CTEST_GIT_COMMAND} ${GITUpdateOptions}") + else() + set(GITUpdateOptions "pull") + endif() + set(CTEST_UPDATE_COMMAND "${CTEST_GIT_COMMAND}") + else(CTEST_USE_GIT_SOURCE) + ## -------------------------- + ## use subversion to get source + #----------------------------------------------------------------------------- + ## cygwin does not handle the find_package() call + ## -------------------------- + set(CTEST_UPDATE_COMMAND "SVNCommand") + if(NOT SITE_CYGWIN}) + find_package (Subversion) + set(CTEST_SVN_COMMAND "${Subversion_SVN_EXECUTABLE}") + set(CTEST_UPDATE_COMMAND "${Subversion_SVN_EXECUTABLE}") + else() + set(CTEST_SVN_COMMAND "/usr/bin/svn") + set(CTEST_UPDATE_COMMAND "/usr/bin/svn") + endif() + + if(NOT EXISTS "${CTEST_SOURCE_DIRECTORY}") + set(NEED_REPOSITORY_CHECKOUT 1) + endif() + + if(NOT CTEST_REPO_VERSION) + set(CTEST_REPO_VERSION "HEAD") + endif() + if(${NEED_REPOSITORY_CHECKOUT}) + set(CTEST_CHECKOUT_COMMAND + "${CTEST_SVN_COMMAND} co ${REPOSITORY_URL} \"${CTEST_SOURCE_DIRECTORY}\" -r ${CTEST_REPO_VERSION}") + else(${NEED_REPOSITORY_CHECKOUT}) + if(CTEST_REPO_VERSION) + set(CTEST_SVN_UPDATE_OPTIONS "-r ${CTEST_REPO_VERSION}") + endif() + endif(${NEED_REPOSITORY_CHECKOUT}) + endif(CTEST_USE_GIT_SOURCE) + endif(LOCAL_UPDATE) +endif(CTEST_USE_TAR_SOURCE) + +#----------------------------------------------------------------------------- +## Clear the build directory +## -------------------------- +set(CTEST_START_WITH_EMPTY_BINARY_DIRECTORY TRUE) +if(NOT EXISTS "${CTEST_BINARY_DIRECTORY}") + file(MAKE_DIRECTORY "${CTEST_BINARY_DIRECTORY}") +else() + ctest_empty_binary_directory(${CTEST_BINARY_DIRECTORY}) +endif() + +# Use multiple CPU cores to build +include(ProcessorCount) +ProcessorCount(N) +if(NOT N EQUAL 0) + if(NOT WIN32) + set(CTEST_BUILD_FLAGS -j${N}) + endif() + set(ctest_test_args ${ctest_test_args} PARALLEL_LEVEL ${N}) +endif() + +#----------------------------------------------------------------------------- +# Send the main script as a note. +list(APPEND CTEST_NOTES_FILES + "${CTEST_SCRIPT_DIRECTORY}/${CTEST_SCRIPT_NAME}" + "${CMAKE_CURRENT_LIST_FILE}" + "${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake" +) + +#----------------------------------------------------------------------------- +# Check for required variables. +# -------------------------- +foreach(req + CTEST_CMAKE_GENERATOR + CTEST_SITE + CTEST_BUILD_NAME + ) + if(NOT DEFINED ${req}) + message(FATAL_ERROR "The containing script must set ${req}") + endif() +endforeach(req) + +#----------------------------------------------------------------------------- +# Initialize the CTEST commands +#------------------------------ +if(LOCAL_MEMCHECK_TEST) + find_program(CTEST_MEMORYCHECK_COMMAND NAMES valgrind) + set (CTEST_CONFIGURE_COMMAND + "${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/mccacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_BUILD_CONFIGURATION} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_SOURCE_DIRECTORY}\"" + ) +else() + if(LOCAL_COVERAGE_TEST) + find_program(CTEST_COVERAGE_COMMAND NAMES gcov) + endif() + set (CTEST_CONFIGURE_COMMAND + "${CTEST_CMAKE_COMMAND} -C \"${CTEST_SOURCE_DIRECTORY}/config/cmake/cacheinit.cmake\" -DCMAKE_BUILD_TYPE:STRING=${CTEST_BUILD_CONFIGURATION} ${BUILD_OPTIONS} \"-G${CTEST_CMAKE_GENERATOR}\" \"${CTEST_SOURCE_DIRECTORY}\"" + ) +endif() + +#----------------------------------------------------------------------------- +## -- set output to english +set($ENV{LC_MESSAGES} "en_EN") + +# Print summary information. +foreach(v + CTEST_SITE + CTEST_BUILD_NAME + CTEST_SOURCE_DIRECTORY + CTEST_BINARY_DIRECTORY + CTEST_CMAKE_GENERATOR + CTEST_BUILD_CONFIGURATION + CTEST_GIT_COMMAND + CTEST_CHECKOUT_COMMAND + CTEST_CONFIGURE_COMMAND + CTEST_SCRIPT_DIRECTORY + CTEST_USE_LAUNCHERS + ) + set(vars "${vars} ${v}=[${${v}}]\n") +endforeach(v) +message(STATUS "Dashboard script configuration:\n${vars}\n") + +#----------------------------------------------------------------------------- +#----------------------------------------------------------------------------- + ## NORMAL process + ## -- LOCAL_UPDATE updates the source folder from svn + ## -- LOCAL_SUBMIT reports to CDash server + ## -- LOCAL_SKIP_TEST skips the test process (only builds) + ## -- LOCAL_MEMCHECK_TEST executes the Valgrind testing + ## -- LOCAL_COVERAGE_TEST executes code coverage process + ## -------------------------- + ctest_start (${MODEL} TRACK ${MODEL}) + if(LOCAL_UPDATE) + ctest_update (SOURCE "${CTEST_SOURCE_DIRECTORY}") + endif() + configure_file(${CTEST_SOURCE_DIRECTORY}/config/cmake/CTestCustom.cmake ${CTEST_BINARY_DIRECTORY}/CTestCustom.cmake) + ctest_read_custom_files ("${CTEST_BINARY_DIRECTORY}") + ctest_configure (BUILD "${CTEST_BINARY_DIRECTORY}") + if(LOCAL_SUBMIT) + ctest_submit (PARTS Update Configure Notes) + endif() + + ctest_build (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND) + if(LOCAL_SUBMIT) + ctest_submit (PARTS Build) + endif() + + if(NOT LOCAL_SKIP_TEST) + if(NOT LOCAL_MEMCHECK_TEST) + ctest_test (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND ${ctest_test_args} RETURN_VALUE res) + if(LOCAL_SUBMIT) + ctest_submit (PARTS Test) + endif() + if(res GREATER 0) + message(FATAL_ERROR "Failed tests: ${res}\n") + endif() + else() + ctest_memcheck (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND ${ctest_test_args}) + if(LOCAL_SUBMIT) + ctest_submit (PARTS MemCheck) + endif(LOCAL_SUBMIT) + endif() + if(LOCAL_COVERAGE_TEST) + ctest_coverage (BUILD "${CTEST_BINARY_DIRECTORY}" APPEND) + if(LOCAL_SUBMIT) + ctest_submit (PARTS Coverage) + endif() + endif() + endif(NOT LOCAL_SKIP_TEST) + + if(NOT LOCAL_MEMCHECK_TEST AND NOT LOCAL_NO_PACKAGE) + ##----------------------------------------------- + ## Package the product + ##----------------------------------------------- + execute_process(COMMAND cpack -C ${CTEST_BUILD_CONFIGURATION} -V + WORKING_DIRECTORY ${CTEST_BINARY_DIRECTORY} + RESULT_VARIABLE cpackResult + OUTPUT_VARIABLE cpackLog + ERROR_VARIABLE cpackLog.err + ) + file(WRITE ${CTEST_BINARY_DIRECTORY}/cpack.log "${cpackLog.err}" "${cpackLog}") + if(cpackResult GREATER 0) + message (FATAL_ERROR "Failed packaging: ${cpackResult}\n") + endif() + endif(NOT LOCAL_MEMCHECK_TEST AND NOT LOCAL_NO_PACKAGE) +#----------------------------------------------------------------------------- diff --git a/config/cmake/scripts/HDF518config.cmake b/config/cmake/scripts/HDF518config.cmake old mode 100755 new mode 100644 index aee5389..02ce6fc --- a/config/cmake/scripts/HDF518config.cmake +++ b/config/cmake/scripts/HDF518config.cmake @@ -1,173 +1,173 @@ -########################################################################## -### For Windows ${CTEST_SCRIPT_ARG} is one of ### -### [64-VS2013, 32-VS2013, 64-VS2012, 32-VS2012] ### -### ctest -S HDF518config.cmake,32-VS2012 -C Release -VV -O hdf518.log ### -### ### -### Other platforms do not use ${CTEST_SCRIPT_ARG} ### -### ctest -S HDF518config.cmake -C Release -VV -O hdf518.log ### -########################################################################## - -cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) -set(CTEST_SOURCE_VERSION 1.8.15) -set(CTEST_SOURCE_VERSEXT "") -set(CTEST_SOURCE_NAME hdf5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}) -set(CTEST_BINARY_NAME "build") -set(CTEST_DASHBOARD_ROOT "${CTEST_SCRIPT_DIRECTORY}") -if(WIN32) - set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_SOURCE_NAME}") - set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_BINARY_NAME}") -else() - set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_SOURCE_NAME}") - set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_BINARY_NAME}") -endif() - -################################################################### -### Following Line is one of [Release, RelWithDebInfo, Debug] ##### -set(CTEST_BUILD_CONFIGURATION "Release") -################################################################### - -################################################################### -######### Following describes compiler ############ -if(WIN32) - set(SITE_OS_NAME "Windows") - set(SITE_OS_VERSION "WIN7") - if(${CTEST_SCRIPT_ARG} STREQUAL "64-VS2013") - set(CTEST_CMAKE_GENERATOR "Visual Studio 12 2013 Win64") - set(SITE_OS_BITS "64") - set(SITE_COMPILER_NAME "vs2013") - set(SITE_COMPILER_VERSION "12") - elseif(${CTEST_SCRIPT_ARG} STREQUAL "32-VS2013") - set(CTEST_CMAKE_GENERATOR "Visual Studio 12 2013") - set(SITE_OS_BITS "32") - set(SITE_COMPILER_NAME "vs2013") - set(SITE_COMPILER_VERSION "12") - elseif(${CTEST_SCRIPT_ARG} STREQUAL "64-VS2012") - set(CTEST_CMAKE_GENERATOR "Visual Studio 11 2012 Win64") - set(SITE_OS_BITS "64") - set(SITE_COMPILER_NAME "vs2012") - set(SITE_COMPILER_VERSION "11") - elseif(${CTEST_SCRIPT_ARG} STREQUAL "32-VS2012") - set(CTEST_CMAKE_GENERATOR "Visual Studio 11 2012") - set(SITE_OS_BITS "32") - set(SITE_COMPILER_NAME "vs2012") - set(SITE_COMPILER_VERSION "11") - endif() -## Set the following to unique id your computer ## - set(CTEST_SITE "WIN7${CTEST_SCRIPT_ARG}.XXXX") -else() - set(CTEST_CMAKE_GENERATOR "Unix Makefiles") -## Set the following to unique id your computer ## - if(APPLE) - set(CTEST_SITE "MAC.XXXX") - else() - set(CTEST_SITE "LINUX.XXXX") - endif() -endif() -################################################################### - -################################################################### -######### Following is for submission to CDash ############ -################################################################### -set(MODEL "Experimental") -######### Following describes computer ############ -## following is optional to describe build ## -set(SITE_BUILDNAME_SUFFIX "STATIC") -################################################################### - -################################################################### -##### Following controls CDash submission ##### -#set(LOCAL_SUBMIT "TRUE") -##### Following controls test process ##### -#set(LOCAL_SKIP_TEST "TRUE") -#set(LOCAL_MEMCHECK_TEST "TRUE") -#set(LOCAL_COVERAGE_TEST "TRUE") -##### Following controls cpack command ##### -#set(LOCAL_NO_PACKAGE "TRUE") -##### Following controls source update ##### -#set(LOCAL_UPDATE "TRUE") -set(REPOSITORY_URL "http://svn.hdfgroup.uiuc.edu/hdf5/branches/hdf5_1_8") -#uncomment to use a compressed source file: *.tar on linux or mac *.zip on windows -#set(CTEST_USE_TAR_SOURCE "${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}") -################################################################### - -################################################################### -#### Change default configuration of options in config/cmake/cacheinit.cmake file ### -#### format: set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DXXX:YY=ZZZZ") - -### uncomment/comment or change the following lines for configuration options - -### comment the following line or change OFF to ON in order to build shared libraries -set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF") - -#### ext libraries #### -### ext libs from tgz -set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING=TGZ -DTGZPATH:PATH=${CTEST_SCRIPT_DIRECTORY}") -### ext libs from svn -#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING=SVN") -### ext libs on system -#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_LIBRARY:FILEPATH=some_location/lib/zlib.lib -DZLIB_INCLUDE_DIR:PATH=some_location/include") -#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DSZIP_LIBRARY:FILEPATH=some_location/lib/szlib.lib -DSZIP_INCLUDE_DIR:PATH=some_location/include") -### disable ext libs building -#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=OFF") -#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=OFF") -#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_ENCODING:BOOL=OFF") -#### fortran #### -### enable Fortran 2003 depends on HDF5_BUILD_FORTRAN -set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_F2003:BOOL=ON") -### disable Fortran; change OFF to ON in order to build FORTRAN libraries -set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF") - -### disable test program builds -#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DBUILD_TESTING:BOOL=OFF") - -### disable packaging -#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_NO_PACKAGES:BOOL=ON") -### Create install package with external libraries (szip, zlib, jpeg) -set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_PACKAGE_EXTLIBS:BOOL=ON") - -### change install prefix -#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_INSTALL_PREFIX:PATH=install") - -################################################################### - -if(WIN32) - include(${CTEST_SCRIPT_DIRECTORY}\\CTestScript.cmake) - if(EXISTS "${CTEST_BINARY_DIRECTORY}\\HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-win${SITE_OS_BITS}.exe") - file(COPY "${CTEST_BINARY_DIRECTORY}\\HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-win${SITE_OS_BITS}.exe" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif() - if(EXISTS "${CTEST_BINARY_DIRECTORY}\\HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-win${SITE_OS_BITS}.msi") - file(COPY "${CTEST_BINARY_DIRECTORY}\\HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-win${SITE_OS_BITS}.msi" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif() - if(EXISTS "${CTEST_BINARY_DIRECTORY}\\HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-win${SITE_OS_BITS}.zip") - file(COPY "${CTEST_BINARY_DIRECTORY}\\HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-win${SITE_OS_BITS}.zip" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif() -else() - include(${CTEST_SCRIPT_DIRECTORY}/CTestScript.cmake) - if(APPLE) - if(EXISTS "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Darwin.dmg") - file(COPY "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Darwin.dmg" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif() - if(EXISTS "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Darwin.tar.gz") - file(COPY "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Darwin.tar.gz" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif() - if(EXISTS "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Darwin.sh") - file(COPY "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Darwin.sh" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif() - else() - if(CYGWIN) - if(EXISTS "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-CYGWIN.sh") - file(COPY "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-CYGWIN.sh" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif() - if(EXISTS "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-CYGWIN.tar.gz") - file(COPY "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-CYGWIN.tar.gz" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif() - else() - if(EXISTS "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Linux.sh") - file(COPY "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Linux.sh" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif() - if(EXISTS "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Linux.tar.gz") - file(COPY "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Linux.tar.gz" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) - endif() - endif() - endif() -endif() +########################################################################## +### For Windows ${CTEST_SCRIPT_ARG} is one of ### +### [64-VS2013, 32-VS2013, 64-VS2012, 32-VS2012] ### +### ctest -S HDF518config.cmake,32-VS2012 -C Release -VV -O hdf518.log ### +### ### +### Other platforms do not use ${CTEST_SCRIPT_ARG} ### +### ctest -S HDF518config.cmake -C Release -VV -O hdf518.log ### +########################################################################## + +cmake_minimum_required(VERSION 3.1.0 FATAL_ERROR) +set(CTEST_SOURCE_VERSION 1.8.15) +set(CTEST_SOURCE_VERSEXT "") +set(CTEST_SOURCE_NAME hdf5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}) +set(CTEST_BINARY_NAME "build") +set(CTEST_DASHBOARD_ROOT "${CTEST_SCRIPT_DIRECTORY}") +if(WIN32) + set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_SOURCE_NAME}") + set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}\\${CTEST_BINARY_NAME}") +else() + set(CTEST_SOURCE_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_SOURCE_NAME}") + set(CTEST_BINARY_DIRECTORY "${CTEST_DASHBOARD_ROOT}/${CTEST_BINARY_NAME}") +endif() + +################################################################### +### Following Line is one of [Release, RelWithDebInfo, Debug] ##### +set(CTEST_BUILD_CONFIGURATION "Release") +################################################################### + +################################################################### +######### Following describes compiler ############ +if(WIN32) + set(SITE_OS_NAME "Windows") + set(SITE_OS_VERSION "WIN7") + if(${CTEST_SCRIPT_ARG} STREQUAL "64-VS2013") + set(CTEST_CMAKE_GENERATOR "Visual Studio 12 2013 Win64") + set(SITE_OS_BITS "64") + set(SITE_COMPILER_NAME "vs2013") + set(SITE_COMPILER_VERSION "12") + elseif(${CTEST_SCRIPT_ARG} STREQUAL "32-VS2013") + set(CTEST_CMAKE_GENERATOR "Visual Studio 12 2013") + set(SITE_OS_BITS "32") + set(SITE_COMPILER_NAME "vs2013") + set(SITE_COMPILER_VERSION "12") + elseif(${CTEST_SCRIPT_ARG} STREQUAL "64-VS2012") + set(CTEST_CMAKE_GENERATOR "Visual Studio 11 2012 Win64") + set(SITE_OS_BITS "64") + set(SITE_COMPILER_NAME "vs2012") + set(SITE_COMPILER_VERSION "11") + elseif(${CTEST_SCRIPT_ARG} STREQUAL "32-VS2012") + set(CTEST_CMAKE_GENERATOR "Visual Studio 11 2012") + set(SITE_OS_BITS "32") + set(SITE_COMPILER_NAME "vs2012") + set(SITE_COMPILER_VERSION "11") + endif() +## Set the following to unique id your computer ## + set(CTEST_SITE "WIN7${CTEST_SCRIPT_ARG}.XXXX") +else() + set(CTEST_CMAKE_GENERATOR "Unix Makefiles") +## Set the following to unique id your computer ## + if(APPLE) + set(CTEST_SITE "MAC.XXXX") + else() + set(CTEST_SITE "LINUX.XXXX") + endif() +endif() +################################################################### + +################################################################### +######### Following is for submission to CDash ############ +################################################################### +set(MODEL "Experimental") +######### Following describes computer ############ +## following is optional to describe build ## +set(SITE_BUILDNAME_SUFFIX "STATIC") +################################################################### + +################################################################### +##### Following controls CDash submission ##### +#set(LOCAL_SUBMIT "TRUE") +##### Following controls test process ##### +#set(LOCAL_SKIP_TEST "TRUE") +#set(LOCAL_MEMCHECK_TEST "TRUE") +#set(LOCAL_COVERAGE_TEST "TRUE") +##### Following controls cpack command ##### +#set(LOCAL_NO_PACKAGE "TRUE") +##### Following controls source update ##### +#set(LOCAL_UPDATE "TRUE") +set(REPOSITORY_URL "http://svn.hdfgroup.uiuc.edu/hdf5/branches/hdf5_1_8") +#uncomment to use a compressed source file: *.tar on linux or mac *.zip on windows +#set(CTEST_USE_TAR_SOURCE "${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}") +################################################################### + +################################################################### +#### Change default configuration of options in config/cmake/cacheinit.cmake file ### +#### format: set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DXXX:YY=ZZZZ") + +### uncomment/comment or change the following lines for configuration options + +### comment the following line or change OFF to ON in order to build shared libraries +set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DBUILD_SHARED_LIBS:BOOL=OFF") + +#### ext libraries #### +### ext libs from tgz +set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING=TGZ -DTGZPATH:PATH=${CTEST_SCRIPT_DIRECTORY}") +### ext libs from svn +#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING=SVN") +### ext libs on system +#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_LIBRARY:FILEPATH=some_location/lib/zlib.lib -DZLIB_INCLUDE_DIR:PATH=some_location/include") +#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DSZIP_LIBRARY:FILEPATH=some_location/lib/szlib.lib -DSZIP_INCLUDE_DIR:PATH=some_location/include") +### disable ext libs building +#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=OFF") +#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=OFF") +#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_ENCODING:BOOL=OFF") +#### fortran #### +### enable Fortran 2003 depends on HDF5_BUILD_FORTRAN +set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_F2003:BOOL=ON") +### disable Fortran; change OFF to ON in order to build FORTRAN libraries +set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_BUILD_FORTRAN:BOOL=OFF") + +### disable test program builds +#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DBUILD_TESTING:BOOL=OFF") + +### disable packaging +#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_NO_PACKAGES:BOOL=ON") +### Create install package with external libraries (szip, zlib, jpeg) +set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_PACKAGE_EXTLIBS:BOOL=ON") + +### change install prefix +#set(ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DCMAKE_INSTALL_PREFIX:PATH=install") + +################################################################### + +if(WIN32) + include(${CTEST_SCRIPT_DIRECTORY}\\CTestScript.cmake) + if(EXISTS "${CTEST_BINARY_DIRECTORY}\\HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-win${SITE_OS_BITS}.exe") + file(COPY "${CTEST_BINARY_DIRECTORY}\\HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-win${SITE_OS_BITS}.exe" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) + endif() + if(EXISTS "${CTEST_BINARY_DIRECTORY}\\HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-win${SITE_OS_BITS}.msi") + file(COPY "${CTEST_BINARY_DIRECTORY}\\HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-win${SITE_OS_BITS}.msi" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) + endif() + if(EXISTS "${CTEST_BINARY_DIRECTORY}\\HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-win${SITE_OS_BITS}.zip") + file(COPY "${CTEST_BINARY_DIRECTORY}\\HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-win${SITE_OS_BITS}.zip" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) + endif() +else() + include(${CTEST_SCRIPT_DIRECTORY}/CTestScript.cmake) + if(APPLE) + if(EXISTS "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Darwin.dmg") + file(COPY "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Darwin.dmg" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) + endif() + if(EXISTS "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Darwin.tar.gz") + file(COPY "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Darwin.tar.gz" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) + endif() + if(EXISTS "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Darwin.sh") + file(COPY "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Darwin.sh" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) + endif() + else() + if(CYGWIN) + if(EXISTS "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-CYGWIN.sh") + file(COPY "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-CYGWIN.sh" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) + endif() + if(EXISTS "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-CYGWIN.tar.gz") + file(COPY "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-CYGWIN.tar.gz" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) + endif() + else() + if(EXISTS "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Linux.sh") + file(COPY "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Linux.sh" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) + endif() + if(EXISTS "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Linux.tar.gz") + file(COPY "${CTEST_BINARY_DIRECTORY}/HDF5-${CTEST_SOURCE_VERSION}${CTEST_SOURCE_VERSEXT}-Linux.tar.gz" DESTINATION ${CTEST_SCRIPT_DIRECTORY}) + endif() + endif() + endif() +endif() diff --git a/config/cmake_ext_mod/CTestCustom.cmake b/config/cmake_ext_mod/CTestCustom.cmake new file mode 100644 index 0000000..025bce4 --- /dev/null +++ b/config/cmake_ext_mod/CTestCustom.cmake @@ -0,0 +1,16 @@ +set (CTEST_CUSTOM_MAXIMUM_NUMBER_OF_WARNINGS 3000) + +set (CTEST_CUSTOM_WARNING_EXCEPTION + ${CTEST_CUSTOM_WARNING_EXCEPTION} + "note.*expected.*void.*but argument is of type.*volatile" + "SZIP.src.*:[ \t]*warning" + "jpeg.src.*:[ \t]*warning" + "POSIX name for this item is deprecated" + "disabling jobserver mode" + "warning.*implicit declaration of function" + "note: expanded from macro" +) + +set (CTEST_CUSTOM_MEMCHECK_IGNORE + ${CTEST_CUSTOM_MEMCHECK_IGNORE} +) diff --git a/config/cmake_ext_mod/CheckTypeSize.cmake b/config/cmake_ext_mod/CheckTypeSize.cmake new file mode 100644 index 0000000..5095a27 --- /dev/null +++ b/config/cmake_ext_mod/CheckTypeSize.cmake @@ -0,0 +1,50 @@ +# +# Check if the type exists and determine size of type. if the type +# exists, the size will be stored to the variable. +# +# CHECK_TYPE_SIZE - macro which checks the size of type +# VARIABLE - variable to store size if the type exists. +# HAVE_${VARIABLE} - does the variable exists or not +# + +MACRO (HDF_CHECK_TYPE_SIZE TYPE VARIABLE) + set (CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS 1) + if ("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$") + set (MACRO_CHECK_TYPE_SIZE_FLAGS + "-DCHECK_TYPE_SIZE_TYPE=\"${TYPE}\" ${CMAKE_REQUIRED_FLAGS}" + ) + foreach (def HAVE_SYS_TYPES_H HAVE_STDINT_H HAVE_STDDEF_H HAVE_INTTYPES_H) + if ("${def}") + set (MACRO_CHECK_TYPE_SIZE_FLAGS "${MACRO_CHECK_TYPE_SIZE_FLAGS} -D${def}") + endif ("${def}") + endforeach (def) + + message (STATUS "Check size of ${TYPE}") + if (CMAKE_REQUIRED_LIBRARIES) + set (CHECK_TYPE_SIZE_ADD_LIBRARIES + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}" + ) + endif (CMAKE_REQUIRED_LIBRARIES) + try_run (${VARIABLE} HAVE_${VARIABLE} + ${CMAKE_BINARY_DIR} + ${HDF_RESOURCES_EXT_DIR}/CheckTypeSize.c + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_TYPE_SIZE_FLAGS} + "${CHECK_TYPE_SIZE_ADD_LIBRARIES}" + OUTPUT_VARIABLE OUTPUT + ) + if (HAVE_${VARIABLE}) + message (STATUS "Check size of ${TYPE} - done") + file (APPEND + ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log + "Determining size of ${TYPE} passed with the following output:\n${OUTPUT}\n\n" + ) + else (HAVE_${VARIABLE}) + message (STATUS "Check size of ${TYPE} - failed") + file (APPEND + ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log + "Determining size of ${TYPE} failed with the following output:\n${OUTPUT}\n\n" + ) + endif (HAVE_${VARIABLE}) + endif ("HAVE_${VARIABLE}" MATCHES "^HAVE_${VARIABLE}$") + set (CMAKE_ALLOW_UNKNOWN_VARIABLE_READ_ACCESS) +ENDMACRO (HDF_CHECK_TYPE_SIZE) diff --git a/config/cmake_ext_mod/ConfigureChecks.cmake b/config/cmake_ext_mod/ConfigureChecks.cmake new file mode 100644 index 0000000..e058b10 --- /dev/null +++ b/config/cmake_ext_mod/ConfigureChecks.cmake @@ -0,0 +1,756 @@ +#----------------------------------------------------------------------------- +# Include all the necessary files for macros +#----------------------------------------------------------------------------- +include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake) +include (${CMAKE_ROOT}/Modules/CheckIncludeFile.cmake) +include (${CMAKE_ROOT}/Modules/CheckIncludeFileCXX.cmake) +include (${CMAKE_ROOT}/Modules/CheckIncludeFiles.cmake) +include (${CMAKE_ROOT}/Modules/CheckLibraryExists.cmake) +include (${CMAKE_ROOT}/Modules/CheckSymbolExists.cmake) +include (${CMAKE_ROOT}/Modules/CheckTypeSize.cmake) +include (${CMAKE_ROOT}/Modules/CheckVariableExists.cmake) +include (${CMAKE_ROOT}/Modules/CheckFortranFunctionExists.cmake) +include (${CMAKE_ROOT}/Modules/TestBigEndian.cmake) +if(CMAKE_CXX_COMPILER) + include (${CMAKE_ROOT}/Modules/TestForSTDNamespace.cmake) +endif(CMAKE_CXX_COMPILER) + +#----------------------------------------------------------------------------- +# APPLE/Darwin setup +#----------------------------------------------------------------------------- +if (APPLE) + list (LENGTH CMAKE_OSX_ARCHITECTURES ARCH_LENGTH) + if (ARCH_LENGTH GREATER 1) + set (CMAKE_OSX_ARCHITECTURES "" CACHE STRING "" FORCE) + message(FATAL_ERROR "Building Universal Binaries on OS X is NOT supported by the HDF5 project. This is" + "due to technical reasons. The best approach would be build each architecture in separate directories" + "and use the 'lipo' tool to combine them into a single executable or library. The 'CMAKE_OSX_ARCHITECTURES'" + "variable has been set to a blank value which will build the default architecture for this system.") + endif () + set (${HDF_PREFIX}_AC_APPLE_UNIVERSAL_BUILD 0) +endif (APPLE) + +# Check for Darwin (not just Apple - we also want to catch OpenDarwin) +if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set (${HDF_PREFIX}_HAVE_DARWIN 1) +endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + +# Check for Solaris +if (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") + set (${HDF_PREFIX}_HAVE_SOLARIS 1) +endif (${CMAKE_SYSTEM_NAME} MATCHES "SunOS") + +#----------------------------------------------------------------------------- +# This MACRO checks IF the symbol exists in the library and IF it +# does, it appends library to the list. +#----------------------------------------------------------------------------- +set (LINK_LIBS "") +MACRO (CHECK_LIBRARY_EXISTS_CONCAT LIBRARY SYMBOL VARIABLE) + CHECK_LIBRARY_EXISTS ("${LIBRARY};${LINK_LIBS}" ${SYMBOL} "" ${VARIABLE}) + if (${VARIABLE}) + set (LINK_LIBS ${LINK_LIBS} ${LIBRARY}) + endif (${VARIABLE}) +ENDMACRO (CHECK_LIBRARY_EXISTS_CONCAT) + +# ---------------------------------------------------------------------- +# WINDOWS Hard code Values +# ---------------------------------------------------------------------- + +set (WINDOWS) +if (WIN32) + if (MINGW) + set (${HDF_PREFIX}_HAVE_MINGW 1) + set (WINDOWS 1) # MinGW tries to imitate Windows + set (CMAKE_REQUIRED_FLAGS "-DWIN32_LEAN_AND_MEAN=1 -DNOGDI=1") + endif (MINGW) + set (${HDF_PREFIX}_HAVE_WIN32_API 1) + set (CMAKE_REQUIRED_LIBRARIES "ws2_32.lib;wsock32.lib") + if (NOT UNIX AND NOT MINGW) + set (WINDOWS 1) + set (CMAKE_REQUIRED_FLAGS "/DWIN32_LEAN_AND_MEAN=1 /DNOGDI=1") + if (MSVC) + set (${HDF_PREFIX}_HAVE_VISUAL_STUDIO 1) + endif (MSVC) + endif (NOT UNIX AND NOT MINGW) +endif (WIN32) + +if (WINDOWS) + set (${HDF_PREFIX}_HAVE_STDDEF_H 1) + set (${HDF_PREFIX}_HAVE_SYS_STAT_H 1) + set (${HDF_PREFIX}_HAVE_SYS_TYPES_H 1) + set (${HDF_PREFIX}_HAVE_LIBM 1) + set (${HDF_PREFIX}_HAVE_STRDUP 1) + set (${HDF_PREFIX}_HAVE_SYSTEM 1) + set (${HDF_PREFIX}_HAVE_LONGJMP 1) + if (NOT MINGW) + set (${HDF_PREFIX}_HAVE_GETHOSTNAME 1) + endif (NOT MINGW) + if (NOT UNIX AND NOT CYGWIN AND NOT MINGW) + set (${HDF_PREFIX}_HAVE_GETCONSOLESCREENBUFFERINFO 1) + endif (NOT UNIX AND NOT CYGWIN AND NOT MINGW) + set (${HDF_PREFIX}_HAVE_FUNCTION 1) + set (${HDF_PREFIX}_GETTIMEOFDAY_GIVES_TZ 1) + set (${HDF_PREFIX}_HAVE_TIMEZONE 1) + set (${HDF_PREFIX}_HAVE_GETTIMEOFDAY 1) + if (MINGW) + set (${HDF_PREFIX}_HAVE_WINSOCK2_H 1) + endif (MINGW) + set (${HDF_PREFIX}_HAVE_LIBWS2_32 1) + set (${HDF_PREFIX}_HAVE_LIBWSOCK32 1) +endif (WINDOWS) + +# ---------------------------------------------------------------------- +# END of WINDOWS Hard code Values +# ---------------------------------------------------------------------- + +if (CYGWIN) + set (${HDF_PREFIX}_HAVE_LSEEK64 0) +endif (CYGWIN) + +#----------------------------------------------------------------------------- +# Check for the math library "m" +#----------------------------------------------------------------------------- +if (NOT WINDOWS) + CHECK_LIBRARY_EXISTS_CONCAT ("m" ceil ${HDF_PREFIX}_HAVE_LIBM) + CHECK_LIBRARY_EXISTS_CONCAT ("dl" dlopen ${HDF_PREFIX}_HAVE_LIBDL) + CHECK_LIBRARY_EXISTS_CONCAT ("ws2_32" WSAStartup ${HDF_PREFIX}_HAVE_LIBWS2_32) + CHECK_LIBRARY_EXISTS_CONCAT ("wsock32" gethostbyname ${HDF_PREFIX}_HAVE_LIBWSOCK32) +endif (NOT WINDOWS) + +CHECK_LIBRARY_EXISTS_CONCAT ("ucb" gethostname ${HDF_PREFIX}_HAVE_LIBUCB) +CHECK_LIBRARY_EXISTS_CONCAT ("socket" connect ${HDF_PREFIX}_HAVE_LIBSOCKET) +CHECK_LIBRARY_EXISTS ("c" gethostbyname "" NOT_NEED_LIBNSL) + +if (NOT NOT_NEED_LIBNSL) + CHECK_LIBRARY_EXISTS_CONCAT ("nsl" gethostbyname ${HDF_PREFIX}_HAVE_LIBNSL) +endif (NOT NOT_NEED_LIBNSL) + +# For other tests to use the same libraries +set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${LINK_LIBS}) + +set (USE_INCLUDES "") +if (WINDOWS) + set (USE_INCLUDES ${USE_INCLUDES} "windows.h") +endif (WINDOWS) + +if (NOT WINDOWS) + TEST_BIG_ENDIAN (${HDF_PREFIX}_WORDS_BIGENDIAN) +endif (NOT WINDOWS) + +# For other specific tests, use this MACRO. +MACRO (HDF_FUNCTION_TEST OTHER_TEST) + if ("${HDF_PREFIX}_${OTHER_TEST}" MATCHES "^${HDF_PREFIX}_${OTHER_TEST}$") + set (MACRO_CHECK_FUNCTION_DEFINITIONS "-D${OTHER_TEST} ${CMAKE_REQUIRED_FLAGS}") + set (OTHER_TEST_ADD_LIBRARIES) + if (CMAKE_REQUIRED_LIBRARIES) + set (OTHER_TEST_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + endif (CMAKE_REQUIRED_LIBRARIES) + + foreach (def ${HDF_EXTRA_TEST_DEFINITIONS}) + set (MACRO_CHECK_FUNCTION_DEFINITIONS "${MACRO_CHECK_FUNCTION_DEFINITIONS} -D${def}=${${def}}") + endforeach (def) + + foreach (def + HAVE_SYS_TIME_H + HAVE_UNISTD_H + HAVE_SYS_TYPES_H + HAVE_SYS_SOCKET_H + ) + if ("${${HDF_PREFIX}_${def}}") + set (MACRO_CHECK_FUNCTION_DEFINITIONS "${MACRO_CHECK_FUNCTION_DEFINITIONS} -D${def}") + endif ("${${HDF_PREFIX}_${def}}") + endforeach (def) + + if (LARGEFILE) + set (MACRO_CHECK_FUNCTION_DEFINITIONS + "${MACRO_CHECK_FUNCTION_DEFINITIONS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE" + ) + endif (LARGEFILE) + + #message (STATUS "Performing ${OTHER_TEST}") + TRY_COMPILE (${OTHER_TEST} + ${CMAKE_BINARY_DIR} + ${HDF_RESOURCES_EXT_DIR}/HDFTests.c + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + "${OTHER_TEST_ADD_LIBRARIES}" + OUTPUT_VARIABLE OUTPUT + ) + if (${OTHER_TEST}) + set (${HDF_PREFIX}_${OTHER_TEST} 1 CACHE INTERNAL "Other test ${FUNCTION}") + message (STATUS "Performing Other Test ${OTHER_TEST} - Success") + else (${OTHER_TEST}) + message (STATUS "Performing Other Test ${OTHER_TEST} - Failed") + set (${HDF_PREFIX}_${OTHER_TEST} "" CACHE INTERNAL "Other test ${FUNCTION}") + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Performing Other Test ${OTHER_TEST} failed with the following output:\n" + "${OUTPUT}\n" + ) + endif (${OTHER_TEST}) + endif ("${HDF_PREFIX}_${OTHER_TEST}" MATCHES "^${HDF_PREFIX}_${OTHER_TEST}$") +ENDMACRO (HDF_FUNCTION_TEST) + +#----------------------------------------------------------------------------- +# Check for these functions before the time headers are checked +#----------------------------------------------------------------------------- +HDF_FUNCTION_TEST (STDC_HEADERS) + +#----------------------------------------------------------------------------- +# Check IF header file exists and add it to the list. +#----------------------------------------------------------------------------- +MACRO (CHECK_INCLUDE_FILE_CONCAT FILE VARIABLE) + CHECK_INCLUDE_FILES ("${USE_INCLUDES};${FILE}" ${VARIABLE}) + if (${VARIABLE}) + set (USE_INCLUDES ${USE_INCLUDES} ${FILE}) + endif (${VARIABLE}) +ENDMACRO (CHECK_INCLUDE_FILE_CONCAT) + +#----------------------------------------------------------------------------- +# Check for the existence of certain header files +#----------------------------------------------------------------------------- +CHECK_INCLUDE_FILE_CONCAT ("sys/resource.h" ${HDF_PREFIX}_HAVE_SYS_RESOURCE_H) +CHECK_INCLUDE_FILE_CONCAT ("sys/time.h" ${HDF_PREFIX}_HAVE_SYS_TIME_H) +CHECK_INCLUDE_FILE_CONCAT ("unistd.h" ${HDF_PREFIX}_HAVE_UNISTD_H) +CHECK_INCLUDE_FILE_CONCAT ("sys/ioctl.h" ${HDF_PREFIX}_HAVE_SYS_IOCTL_H) +CHECK_INCLUDE_FILE_CONCAT ("sys/stat.h" ${HDF_PREFIX}_HAVE_SYS_STAT_H) +CHECK_INCLUDE_FILE_CONCAT ("sys/socket.h" ${HDF_PREFIX}_HAVE_SYS_SOCKET_H) +CHECK_INCLUDE_FILE_CONCAT ("sys/types.h" ${HDF_PREFIX}_HAVE_SYS_TYPES_H) +CHECK_INCLUDE_FILE_CONCAT ("stddef.h" ${HDF_PREFIX}_HAVE_STDDEF_H) +CHECK_INCLUDE_FILE_CONCAT ("setjmp.h" ${HDF_PREFIX}_HAVE_SETJMP_H) +CHECK_INCLUDE_FILE_CONCAT ("features.h" ${HDF_PREFIX}_HAVE_FEATURES_H) +CHECK_INCLUDE_FILE_CONCAT ("dirent.h" ${HDF_PREFIX}_HAVE_DIRENT_H) +CHECK_INCLUDE_FILE_CONCAT ("stdint.h" ${HDF_PREFIX}_HAVE_STDINT_H) + +# IF the c compiler found stdint, check the C++ as well. On some systems this +# file will be found by C but not C++, only do this test IF the C++ compiler +# has been initialized (e.g. the project also includes some c++) +if (${HDF_PREFIX}_HAVE_STDINT_H AND CMAKE_CXX_COMPILER_LOADED) + CHECK_INCLUDE_FILE_CXX ("stdint.h" ${HDF_PREFIX}_HAVE_STDINT_H_CXX) + if (NOT ${HDF_PREFIX}_HAVE_STDINT_H_CXX) + set (${HDF_PREFIX}_HAVE_STDINT_H "" CACHE INTERNAL "Have includes HAVE_STDINT_H") + set (USE_INCLUDES ${USE_INCLUDES} "stdint.h") + endif (NOT ${HDF_PREFIX}_HAVE_STDINT_H_CXX) +endif (${HDF_PREFIX}_HAVE_STDINT_H AND CMAKE_CXX_COMPILER_LOADED) + +# Darwin +CHECK_INCLUDE_FILE_CONCAT ("mach/mach_time.h" ${HDF_PREFIX}_HAVE_MACH_MACH_TIME_H) + +# Windows +CHECK_INCLUDE_FILE_CONCAT ("io.h" ${HDF_PREFIX}_HAVE_IO_H) +if (NOT CYGWIN) + CHECK_INCLUDE_FILE_CONCAT ("winsock2.h" ${HDF_PREFIX}_HAVE_WINSOCK2_H) +endif (NOT CYGWIN) +CHECK_INCLUDE_FILE_CONCAT ("sys/timeb.h" ${HDF_PREFIX}_HAVE_SYS_TIMEB_H) + +if (CMAKE_SYSTEM_NAME MATCHES "OSF") + CHECK_INCLUDE_FILE_CONCAT ("sys/sysinfo.h" ${HDF_PREFIX}_HAVE_SYS_SYSINFO_H) + CHECK_INCLUDE_FILE_CONCAT ("sys/proc.h" ${HDF_PREFIX}_HAVE_SYS_PROC_H) +else (CMAKE_SYSTEM_NAME MATCHES "OSF") + set (${HDF_PREFIX}_HAVE_SYS_SYSINFO_H "" CACHE INTERNAL "" FORCE) + set (${HDF_PREFIX}_HAVE_SYS_PROC_H "" CACHE INTERNAL "" FORCE) +endif (CMAKE_SYSTEM_NAME MATCHES "OSF") + +CHECK_INCLUDE_FILE_CONCAT ("globus/common.h" ${HDF_PREFIX}_HAVE_GLOBUS_COMMON_H) +CHECK_INCLUDE_FILE_CONCAT ("pdb.h" ${HDF_PREFIX}_HAVE_PDB_H) +CHECK_INCLUDE_FILE_CONCAT ("pthread.h" ${HDF_PREFIX}_HAVE_PTHREAD_H) +CHECK_INCLUDE_FILE_CONCAT ("srbclient.h" ${HDF_PREFIX}_HAVE_SRBCLIENT_H) +CHECK_INCLUDE_FILE_CONCAT ("string.h" ${HDF_PREFIX}_HAVE_STRING_H) +CHECK_INCLUDE_FILE_CONCAT ("strings.h" ${HDF_PREFIX}_HAVE_STRINGS_H) +CHECK_INCLUDE_FILE_CONCAT ("stdlib.h" ${HDF_PREFIX}_HAVE_STDLIB_H) +CHECK_INCLUDE_FILE_CONCAT ("memory.h" ${HDF_PREFIX}_HAVE_MEMORY_H) +CHECK_INCLUDE_FILE_CONCAT ("dlfcn.h" ${HDF_PREFIX}_HAVE_DLFCN_H) +CHECK_INCLUDE_FILE_CONCAT ("inttypes.h" ${HDF_PREFIX}_HAVE_INTTYPES_H) +CHECK_INCLUDE_FILE_CONCAT ("netinet/in.h" ${HDF_PREFIX}_HAVE_NETINET_IN_H) + +#----------------------------------------------------------------------------- +# Check for large file support +#----------------------------------------------------------------------------- + +# The linux-lfs option is deprecated. +set (LINUX_LFS 0) + +set (HDF_EXTRA_C_FLAGS) +set (HDF_EXTRA_FLAGS) +if (NOT WINDOWS) + if (NOT ${HDF_PREFIX}_HAVE_SOLARIS) + # Linux Specific flags + # This was originally defined as _POSIX_SOURCE which was updated to + # _POSIX_C_SOURCE=199506L to expose a greater amount of POSIX + # functionality so clock_gettime and CLOCK_MONOTONIC are defined + # correctly. + # POSIX feature information can be found in the gcc manual at: + # http://www.gnu.org/s/libc/manual/html_node/Feature-Test-Macros.html + set (HDF_EXTRA_C_FLAGS -D_POSIX_C_SOURCE=199506L) + # _BSD_SOURCE deprecated in GLIBC >= 2.20 + TRY_RUN (HAVE_DEFAULT_SOURCE_RUN HAVE_DEFAULT_SOURCE_COMPILE + ${CMAKE_BINARY_DIR} + ${HDF_RESOURCES_EXT_DIR}/HDFTests.c + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=-DHAVE_DEFAULT_SOURCE + OUTPUT_VARIABLE OUTPUT + ) + if (HAVE_DEFAULT_SOURCE_COMPILE AND HAVE_DEFAULT_SOURCE_RUN) + set (HDF_EXTRA_FLAGS -D_DEFAULT_SOURCE) + else (HAVE_DEFAULT_SOURCE_COMPILE AND HAVE_DEFAULT_SOURCE_RUN) + set (HDF_EXTRA_FLAGS -D_BSD_SOURCE) + endif (HAVE_DEFAULT_SOURCE_COMPILE AND HAVE_DEFAULT_SOURCE_RUN) + + option (HDF_ENABLE_LARGE_FILE "Enable support for large (64-bit) files on Linux." ON) + if (HDF_ENABLE_LARGE_FILE) + set (msg "Performing TEST_LFS_WORKS") + TRY_RUN (TEST_LFS_WORKS_RUN TEST_LFS_WORKS_COMPILE + ${CMAKE_BINARY_DIR} + ${HDF_RESOURCES_EXT_DIR}/HDFTests.c + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=-DTEST_LFS_WORKS + OUTPUT_VARIABLE OUTPUT + ) + if (TEST_LFS_WORKS_COMPILE) + if (TEST_LFS_WORKS_RUN MATCHES 0) + set (TEST_LFS_WORKS 1 CACHE INTERNAL ${msg}) + set (LARGEFILE 1) + set (HDF_EXTRA_FLAGS ${HDF_EXTRA_FLAGS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE) + message (STATUS "${msg}... yes") + else (TEST_LFS_WORKS_RUN MATCHES 0) + set (TEST_LFS_WORKS "" CACHE INTERNAL ${msg}) + message (STATUS "${msg}... no") + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Test TEST_LFS_WORKS Run failed with the following output and exit code:\n ${OUTPUT}\n" + ) + endif (TEST_LFS_WORKS_RUN MATCHES 0) + else (TEST_LFS_WORKS_COMPILE ) + set (TEST_LFS_WORKS "" CACHE INTERNAL ${msg}) + message (STATUS "${msg}... no") + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Test TEST_LFS_WORKS Compile failed with the following output:\n ${OUTPUT}\n" + ) + endif (TEST_LFS_WORKS_COMPILE) + endif (HDF_ENABLE_LARGE_FILE) + set (CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} ${HDF_EXTRA_FLAGS}) + endif (NOT ${HDF_PREFIX}_HAVE_SOLARIS) +endif (NOT WINDOWS) + +add_definitions (${HDF_EXTRA_FLAGS}) + +#----------------------------------------------------------------------------- +# Check for HAVE_OFF64_T functionality +#----------------------------------------------------------------------------- +if (NOT WINDOWS OR MINGW) + HDF_FUNCTION_TEST (HAVE_OFF64_T) + if (${HDF_PREFIX}_HAVE_OFF64_T) + CHECK_FUNCTION_EXISTS (lseek64 ${HDF_PREFIX}_HAVE_LSEEK64) + CHECK_FUNCTION_EXISTS (fseeko64 ${HDF_PREFIX}_HAVE_FSEEKO64) + CHECK_FUNCTION_EXISTS (ftello64 ${HDF_PREFIX}_HAVE_FTELLO64) + CHECK_FUNCTION_EXISTS (ftruncate64 ${HDF_PREFIX}_HAVE_FTRUNCATE64) + endif (${HDF_PREFIX}_HAVE_OFF64_T) + + CHECK_FUNCTION_EXISTS (fseeko ${HDF_PREFIX}_HAVE_FSEEKO) + CHECK_FUNCTION_EXISTS (ftello ${HDF_PREFIX}_HAVE_FTELLO) + + HDF_FUNCTION_TEST (HAVE_STAT64_STRUCT) + if (HAVE_STAT64_STRUCT) + CHECK_FUNCTION_EXISTS (fstat64 ${HDF_PREFIX}_HAVE_FSTAT64) + CHECK_FUNCTION_EXISTS (stat64 ${HDF_PREFIX}_HAVE_STAT64) + endif (HAVE_STAT64_STRUCT) +endif (NOT WINDOWS OR MINGW) + +#----------------------------------------------------------------------------- +# Check the size in bytes of all the int and float types +#----------------------------------------------------------------------------- +MACRO (HDF_CHECK_TYPE_SIZE type var) + set (aType ${type}) + set (aVar ${var}) +# message (STATUS "Checking size of ${aType} and storing into ${aVar}") + CHECK_TYPE_SIZE (${aType} ${aVar}) + if (NOT ${aVar}) + set (${aVar} 0 CACHE INTERNAL "SizeOf for ${aType}") +# message (STATUS "Size of ${aType} was NOT Found") + endif (NOT ${aVar}) +ENDMACRO (HDF_CHECK_TYPE_SIZE) + +HDF_CHECK_TYPE_SIZE (char ${HDF_PREFIX}_SIZEOF_CHAR) +HDF_CHECK_TYPE_SIZE (short ${HDF_PREFIX}_SIZEOF_SHORT) +HDF_CHECK_TYPE_SIZE (int ${HDF_PREFIX}_SIZEOF_INT) +HDF_CHECK_TYPE_SIZE (unsigned ${HDF_PREFIX}_SIZEOF_UNSIGNED) +if (NOT APPLE) + HDF_CHECK_TYPE_SIZE (long ${HDF_PREFIX}_SIZEOF_LONG) +endif (NOT APPLE) +HDF_CHECK_TYPE_SIZE ("long long" ${HDF_PREFIX}_SIZEOF_LONG_LONG) +HDF_CHECK_TYPE_SIZE (__int64 ${HDF_PREFIX}_SIZEOF___INT64) +if (NOT ${HDF_PREFIX}_SIZEOF___INT64) + set (${HDF_PREFIX}_SIZEOF___INT64 0) +endif (NOT ${HDF_PREFIX}_SIZEOF___INT64) + +HDF_CHECK_TYPE_SIZE (float ${HDF_PREFIX}_SIZEOF_FLOAT) +HDF_CHECK_TYPE_SIZE (double ${HDF_PREFIX}_SIZEOF_DOUBLE) +HDF_CHECK_TYPE_SIZE ("long double" ${HDF_PREFIX}_SIZEOF_LONG_DOUBLE) + +HDF_CHECK_TYPE_SIZE (int8_t ${HDF_PREFIX}_SIZEOF_INT8_T) +HDF_CHECK_TYPE_SIZE (uint8_t ${HDF_PREFIX}_SIZEOF_UINT8_T) +HDF_CHECK_TYPE_SIZE (int_least8_t ${HDF_PREFIX}_SIZEOF_INT_LEAST8_T) +HDF_CHECK_TYPE_SIZE (uint_least8_t ${HDF_PREFIX}_SIZEOF_UINT_LEAST8_T) +HDF_CHECK_TYPE_SIZE (int_fast8_t ${HDF_PREFIX}_SIZEOF_INT_FAST8_T) +HDF_CHECK_TYPE_SIZE (uint_fast8_t ${HDF_PREFIX}_SIZEOF_UINT_FAST8_T) + +HDF_CHECK_TYPE_SIZE (int16_t ${HDF_PREFIX}_SIZEOF_INT16_T) +HDF_CHECK_TYPE_SIZE (uint16_t ${HDF_PREFIX}_SIZEOF_UINT16_T) +HDF_CHECK_TYPE_SIZE (int_least16_t ${HDF_PREFIX}_SIZEOF_INT_LEAST16_T) +HDF_CHECK_TYPE_SIZE (uint_least16_t ${HDF_PREFIX}_SIZEOF_UINT_LEAST16_T) +HDF_CHECK_TYPE_SIZE (int_fast16_t ${HDF_PREFIX}_SIZEOF_INT_FAST16_T) +HDF_CHECK_TYPE_SIZE (uint_fast16_t ${HDF_PREFIX}_SIZEOF_UINT_FAST16_T) + +HDF_CHECK_TYPE_SIZE (int32_t ${HDF_PREFIX}_SIZEOF_INT32_T) +HDF_CHECK_TYPE_SIZE (uint32_t ${HDF_PREFIX}_SIZEOF_UINT32_T) +HDF_CHECK_TYPE_SIZE (int_least32_t ${HDF_PREFIX}_SIZEOF_INT_LEAST32_T) +HDF_CHECK_TYPE_SIZE (uint_least32_t ${HDF_PREFIX}_SIZEOF_UINT_LEAST32_T) +HDF_CHECK_TYPE_SIZE (int_fast32_t ${HDF_PREFIX}_SIZEOF_INT_FAST32_T) +HDF_CHECK_TYPE_SIZE (uint_fast32_t ${HDF_PREFIX}_SIZEOF_UINT_FAST32_T) + +HDF_CHECK_TYPE_SIZE (int64_t ${HDF_PREFIX}_SIZEOF_INT64_T) +HDF_CHECK_TYPE_SIZE (uint64_t ${HDF_PREFIX}_SIZEOF_UINT64_T) +HDF_CHECK_TYPE_SIZE (int_least64_t ${HDF_PREFIX}_SIZEOF_INT_LEAST64_T) +HDF_CHECK_TYPE_SIZE (uint_least64_t ${HDF_PREFIX}_SIZEOF_UINT_LEAST64_T) +HDF_CHECK_TYPE_SIZE (int_fast64_t ${HDF_PREFIX}_SIZEOF_INT_FAST64_T) +HDF_CHECK_TYPE_SIZE (uint_fast64_t ${HDF_PREFIX}_SIZEOF_UINT_FAST64_T) + +if (NOT APPLE) + HDF_CHECK_TYPE_SIZE (size_t ${HDF_PREFIX}_SIZEOF_SIZE_T) + HDF_CHECK_TYPE_SIZE (ssize_t ${HDF_PREFIX}_SIZEOF_SSIZE_T) + if (NOT ${HDF_PREFIX}_SIZEOF_SSIZE_T) + set (${HDF_PREFIX}_SIZEOF_SSIZE_T 0) + endif (NOT ${HDF_PREFIX}_SIZEOF_SSIZE_T) + if (NOT WINDOWS) + HDF_CHECK_TYPE_SIZE (ptrdiff_t ${HDF_PREFIX}_SIZEOF_PTRDIFF_T) + endif (NOT WINDOWS) +endif (NOT APPLE) + +HDF_CHECK_TYPE_SIZE (off_t ${HDF_PREFIX}_SIZEOF_OFF_T) +HDF_CHECK_TYPE_SIZE (off64_t ${HDF_PREFIX}_SIZEOF_OFF64_T) +if (NOT ${HDF_PREFIX}_SIZEOF_OFF64_T) + set (${HDF_PREFIX}_SIZEOF_OFF64_T 0) +endif (NOT ${HDF_PREFIX}_SIZEOF_OFF64_T) + +if (NOT WINDOWS) + #----------------------------------------------------------------------------- + # Check if the dev_t type is a scalar type + #----------------------------------------------------------------------------- + HDF_FUNCTION_TEST (DEV_T_IS_SCALAR) + + # ---------------------------------------------------------------------- + # Check for MONOTONIC_TIMER support (used in clock_gettime). This has + # to be done after any POSIX/BSD defines to ensure that the test gets + # the correct POSIX level on linux. + CHECK_VARIABLE_EXISTS (CLOCK_MONOTONIC HAVE_CLOCK_MONOTONIC) + + #----------------------------------------------------------------------------- + # Check a bunch of time functions + #----------------------------------------------------------------------------- + foreach (test + HAVE_TM_GMTOFF + HAVE___TM_GMTOFF +# HAVE_TIMEZONE + HAVE_STRUCT_TIMEZONE + GETTIMEOFDAY_GIVES_TZ + TIME_WITH_SYS_TIME + HAVE_TM_ZONE + HAVE_STRUCT_TM_TM_ZONE + ) + HDF_FUNCTION_TEST (${test}) + endforeach (test) + if (NOT CYGWIN AND NOT MINGW) + HDF_FUNCTION_TEST (HAVE_TIMEZONE) +# HDF_FUNCTION_TEST (HAVE_STAT_ST_BLOCKS) + endif (NOT CYGWIN AND NOT MINGW) + + # ---------------------------------------------------------------------- + # Does the struct stat have the st_blocks field? This field is not Posix. + # + HDF_FUNCTION_TEST (HAVE_STAT_ST_BLOCKS) + + # ---------------------------------------------------------------------- + # How do we figure out the width of a tty in characters? + # + CHECK_FUNCTION_EXISTS (ioctl ${HDF_PREFIX}_HAVE_IOCTL) + HDF_FUNCTION_TEST (HAVE_STRUCT_VIDEOCONFIG) + HDF_FUNCTION_TEST (HAVE_STRUCT_TEXT_INFO) + CHECK_FUNCTION_EXISTS (_getvideoconfig ${HDF_PREFIX}_HAVE__GETVIDEOCONFIG) + CHECK_FUNCTION_EXISTS (gettextinfo ${HDF_PREFIX}_HAVE_GETTEXTINFO) + CHECK_FUNCTION_EXISTS (_scrsize ${HDF_PREFIX}_HAVE__SCRSIZE) + if (NOT CYGWIN AND NOT MINGW) + CHECK_FUNCTION_EXISTS (GetConsoleScreenBufferInfo ${HDF_PREFIX}_HAVE_GETCONSOLESCREENBUFFERINFO) + endif (NOT CYGWIN AND NOT MINGW) + CHECK_SYMBOL_EXISTS (TIOCGWINSZ "sys/ioctl.h" ${HDF_PREFIX}_HAVE_TIOCGWINSZ) + CHECK_SYMBOL_EXISTS (TIOCGETD "sys/ioctl.h" ${HDF_PREFIX}_HAVE_TIOCGETD) +endif (NOT WINDOWS) + +#----------------------------------------------------------------------------- +# Check for some functions that are used +# +CHECK_FUNCTION_EXISTS (alarm ${HDF_PREFIX}_HAVE_ALARM) +CHECK_FUNCTION_EXISTS (fork ${HDF_PREFIX}_HAVE_FORK) +CHECK_FUNCTION_EXISTS (frexpf ${HDF_PREFIX}_HAVE_FREXPF) +CHECK_FUNCTION_EXISTS (frexpl ${HDF_PREFIX}_HAVE_FREXPL) + +CHECK_FUNCTION_EXISTS (gethostname ${HDF_PREFIX}_HAVE_GETHOSTNAME) +CHECK_FUNCTION_EXISTS (getpwuid ${HDF_PREFIX}_HAVE_GETPWUID) +CHECK_FUNCTION_EXISTS (getrusage ${HDF_PREFIX}_HAVE_GETRUSAGE) +CHECK_FUNCTION_EXISTS (lstat ${HDF_PREFIX}_HAVE_LSTAT) + +CHECK_FUNCTION_EXISTS (rand_r ${HDF_PREFIX}_HAVE_RAND_R) +CHECK_FUNCTION_EXISTS (random ${HDF_PREFIX}_HAVE_RANDOM) +CHECK_FUNCTION_EXISTS (setsysinfo ${HDF_PREFIX}_HAVE_SETSYSINFO) + +CHECK_FUNCTION_EXISTS (signal ${HDF_PREFIX}_HAVE_SIGNAL) +CHECK_FUNCTION_EXISTS (longjmp ${HDF_PREFIX}_HAVE_LONGJMP) +CHECK_FUNCTION_EXISTS (setjmp ${HDF_PREFIX}_HAVE_SETJMP) +CHECK_FUNCTION_EXISTS (siglongjmp ${HDF_PREFIX}_HAVE_SIGLONGJMP) +CHECK_FUNCTION_EXISTS (sigsetjmp ${HDF_PREFIX}_HAVE_SIGSETJMP) +CHECK_FUNCTION_EXISTS (sigprocmask ${HDF_PREFIX}_HAVE_SIGPROCMASK) + +CHECK_FUNCTION_EXISTS (snprintf ${HDF_PREFIX}_HAVE_SNPRINTF) +CHECK_FUNCTION_EXISTS (srandom ${HDF_PREFIX}_HAVE_SRANDOM) +CHECK_FUNCTION_EXISTS (strdup ${HDF_PREFIX}_HAVE_STRDUP) +CHECK_FUNCTION_EXISTS (symlink ${HDF_PREFIX}_HAVE_SYMLINK) +CHECK_FUNCTION_EXISTS (system ${HDF_PREFIX}_HAVE_SYSTEM) + +CHECK_FUNCTION_EXISTS (tmpfile ${HDF_PREFIX}_HAVE_TMPFILE) +CHECK_FUNCTION_EXISTS (asprintf ${HDF_PREFIX}_HAVE_ASPRINTF) +CHECK_FUNCTION_EXISTS (vasprintf ${HDF_PREFIX}_HAVE_VASPRINTF) +CHECK_FUNCTION_EXISTS (waitpid ${HDF_PREFIX}_HAVE_WAITPID) + +CHECK_FUNCTION_EXISTS (vsnprintf ${HDF_PREFIX}_HAVE_VSNPRINTF) +if (NOT WINDOWS) + if (${HDF_PREFIX}_HAVE_VSNPRINTF) + HDF_FUNCTION_TEST (VSNPRINTF_WORKS) + endif (${HDF_PREFIX}_HAVE_VSNPRINTF) +endif (NOT WINDOWS) + +#----------------------------------------------------------------------------- +# sigsetjmp is special; may actually be a macro +#----------------------------------------------------------------------------- +if (NOT ${HDF_PREFIX}_HAVE_SIGSETJMP) + if (${HDF_PREFIX}_HAVE_SETJMP_H) + CHECK_SYMBOL_EXISTS (sigsetjmp "setjmp.h" ${HDF_PREFIX}_HAVE_MACRO_SIGSETJMP) + if (${HDF_PREFIX}_HAVE_MACRO_SIGSETJMP) + set (${HDF_PREFIX}_HAVE_SIGSETJMP 1) + endif (${HDF_PREFIX}_HAVE_MACRO_SIGSETJMP) + endif (${HDF_PREFIX}_HAVE_SETJMP_H) +endif (NOT ${HDF_PREFIX}_HAVE_SIGSETJMP) + +#----------------------------------------------------------------------------- +# Check a bunch of other functions +#----------------------------------------------------------------------------- +if (NOT WINDOWS) + foreach (test + HAVE_ATTRIBUTE + HAVE_C99_FUNC +# STDC_HEADERS + HAVE_FUNCTION + HAVE_C99_DESIGNATED_INITIALIZER + SYSTEM_SCOPE_THREADS + HAVE_SOCKLEN_T + CXX_HAVE_OFFSETOF + ) + HDF_FUNCTION_TEST (${test}) + endforeach (test) +endif (NOT WINDOWS) + +# For other CXX specific tests, use this MACRO. +MACRO (HDF_CXX_FUNCTION_TEST OTHER_TEST) + if ("${OTHER_TEST}" MATCHES "^${OTHER_TEST}$") + set (MACRO_CHECK_FUNCTION_DEFINITIONS "-D${OTHER_TEST} ${CMAKE_REQUIRED_FLAGS}") + set (OTHER_TEST_ADD_LIBRARIES) + if (CMAKE_REQUIRED_LIBRARIES) + set (OTHER_TEST_ADD_LIBRARIES "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + endif (CMAKE_REQUIRED_LIBRARIES) + + foreach (def ${HDF_EXTRA_TEST_DEFINITIONS}) + set (MACRO_CHECK_FUNCTION_DEFINITIONS "${MACRO_CHECK_FUNCTION_DEFINITIONS} -D${def}=${${def}}") + endforeach (def) + + foreach (def + HAVE_SYS_TIME_H + HAVE_UNISTD_H + HAVE_SYS_TYPES_H + HAVE_SYS_SOCKET_H + ) + if ("${${HDF_PREFIX}_${def}}") + set (MACRO_CHECK_FUNCTION_DEFINITIONS "${MACRO_CHECK_FUNCTION_DEFINITIONS} -D${def}") + endif ("${${HDF_PREFIX}_${def}}") + endforeach (def) + + if (LARGEFILE) + set (MACRO_CHECK_FUNCTION_DEFINITIONS + "${MACRO_CHECK_FUNCTION_DEFINITIONS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE" + ) + endif (LARGEFILE) + + #message (STATUS "Performing ${OTHER_TEST}") + TRY_COMPILE (${OTHER_TEST} + ${CMAKE_BINARY_DIR} + ${HDF_RESOURCES_EXT_DIR}/HDFCXXTests.cpp + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + "${OTHER_TEST_ADD_LIBRARIES}" + OUTPUT_VARIABLE OUTPUT + ) + if (${OTHER_TEST} EQUAL 0) + set (${OTHER_TEST} 1 CACHE INTERNAL "CXX test ${FUNCTION}") + message (STATUS "Performing CXX Test ${OTHER_TEST} - Success") + else (${OTHER_TEST} EQUAL 0) + message (STATUS "Performing CXX Test ${OTHER_TEST} - Failed") + set (${OTHER_TEST} "" CACHE INTERNAL "CXX test ${FUNCTION}") + file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log + "Performing CXX Test ${OTHER_TEST} failed with the following output:\n" + "${OUTPUT}\n" + ) + endif (${OTHER_TEST} EQUAL 0) + endif ("${OTHER_TEST}" MATCHES "^${OTHER_TEST}$") +ENDMACRO (HDF_CXX_FUNCTION_TEST) + +#----------------------------------------------------------------------------- +# Check a bunch of cxx functions +#----------------------------------------------------------------------------- +if (CMAKE_CXX_COMPILER_LOADED) + foreach (test + OLD_HEADER_FILENAME + ${HDF_PREFIX}_NO_NAMESPACE + ${HDF_PREFIX}_NO_STD + BOOL_NOTDEFINED + NO_STATIC_CAST + ) + HDF_CXX_FUNCTION_TEST (${test}) + endforeach (test) +endif (CMAKE_CXX_COMPILER_LOADED) + +#----------------------------------------------------------------------------- +# Check if InitOnceExecuteOnce is available +#----------------------------------------------------------------------------- +if (WINDOWS) + if (NOT HDF_NO_IOEO_TEST) + message (STATUS "Checking for InitOnceExecuteOnce:") + if ("${${HDF_PREFIX}_HAVE_IOEO}" MATCHES "^${${HDF_PREFIX}_HAVE_IOEO}$") + if (LARGEFILE) + set (CMAKE_REQUIRED_DEFINITIONS + "${CURRENT_TEST_DEFINITIONS} -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE -D_LARGEFILE_SOURCE" + ) + endif (LARGEFILE) + set (MACRO_CHECK_FUNCTION_DEFINITIONS + "-DHAVE_IOEO ${CMAKE_REQUIRED_FLAGS}") + if (CMAKE_REQUIRED_LIBRARIES) + set (CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + else (CMAKE_REQUIRED_LIBRARIES) + set (CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES) + endif (CMAKE_REQUIRED_LIBRARIES) + if (CMAKE_REQUIRED_INCLUDES) + set (CHECK_C_SOURCE_COMPILES_ADD_INCLUDES + "-DINCLUDE_DIRECTORIES:STRING=${CMAKE_REQUIRED_INCLUDES}") + else (CMAKE_REQUIRED_INCLUDES) + set (CHECK_C_SOURCE_COMPILES_ADD_INCLUDES) + endif (CMAKE_REQUIRED_INCLUDES) + + TRY_RUN(HAVE_IOEO_EXITCODE HAVE_IOEO_COMPILED + ${CMAKE_BINARY_DIR} + ${HDF_RESOURCES_EXT_DIR}/HDFTests.c + COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS} + -DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH} + "${CHECK_C_SOURCE_COMPILES_ADD_LIBRARIES}" + "${CHECK_C_SOURCE_COMPILES_ADD_INCLUDES}" + COMPILE_OUTPUT_VARIABLE OUTPUT) + # if it did not compile make the return value fail code of 1 + if (NOT HAVE_IOEO_COMPILED) + set (HAVE_IOEO_EXITCODE 1) + endif (NOT HAVE_IOEO_COMPILED) + # if the return value was 0 then it worked + if ("${HAVE_IOEO_EXITCODE}" EQUAL 0) + set (${HDF_PREFIX}_HAVE_IOEO 1 CACHE INTERNAL "Test InitOnceExecuteOnce") + message (STATUS "Performing Test InitOnceExecuteOnce - Success") + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Performing C SOURCE FILE Test InitOnceExecuteOnce succeded with the following output:\n" + "${OUTPUT}\n" + "Return value: ${HAVE_IOEO}\n") + else ("${HAVE_IOEO_EXITCODE}" EQUAL 0) + if (CMAKE_CROSSCOMPILING AND "${HAVE_IOEO_EXITCODE}" MATCHES "FAILED_TO_RUN") + set (${HDF_PREFIX}_HAVE_IOEO "${HAVE_IOEO_EXITCODE}") + else (CMAKE_CROSSCOMPILING AND "${HAVE_IOEO_EXITCODE}" MATCHES "FAILED_TO_RUN") + set (${HDF_PREFIX}_HAVE_IOEO "" CACHE INTERNAL "Test InitOnceExecuteOnce") + endif (CMAKE_CROSSCOMPILING AND "${HAVE_IOEO_EXITCODE}" MATCHES "FAILED_TO_RUN") + + message (STATUS "Performing Test InitOnceExecuteOnce - Failed") + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Performing InitOnceExecuteOnce Test failed with the following output:\n" + "${OUTPUT}\n" + "Return value: ${HAVE_IOEO_EXITCODE}\n") + endif ("${HAVE_IOEO_EXITCODE}" EQUAL 0) + endif ("${${HDF_PREFIX}_HAVE_IOEO}" MATCHES "^${${HDF_PREFIX}_HAVE_IOEO}$") + endif (NOT HDF_NO_IOEO_TEST) +endif (WINDOWS) + +#----------------------------------------------------------------------------- +# Determine how 'inline' is used +#----------------------------------------------------------------------------- +set (HDF_EXTRA_TEST_DEFINITIONS INLINE_TEST_INLINE) +foreach (inline_test inline __inline__ __inline) + set (INLINE_TEST_INLINE ${inline_test}) + HDF_FUNCTION_TEST (INLINE_TEST_${inline_test}) +endforeach (inline_test) + +set (HDF_EXTRA_TEST_DEFINITIONS) +if (INLINE_TEST___inline__) + set (${HDF_PREFIX}_inline __inline__) +else (INLINE_TEST___inline__) + if (INLINE_TEST___inline) + set (${HDF_PREFIX}_inline __inline) + else (INLINE_TEST___inline) + if (INLINE_TEST_inline) + set (${HDF_PREFIX}_inline inline) + endif (INLINE_TEST_inline) + endif (INLINE_TEST___inline) +endif (INLINE_TEST___inline__) + +#----------------------------------------------------------------------------- +# Check how to print a Long Long integer +#----------------------------------------------------------------------------- +if (NOT ${HDF_PREFIX}_PRINTF_LL_WIDTH OR ${HDF_PREFIX}_PRINTF_LL_WIDTH MATCHES "unknown") + set (PRINT_LL_FOUND 0) + message (STATUS "Checking for appropriate format for 64 bit long:") + foreach (HDF5_PRINTF_LL l64 l L q I64 ll) + set (CURRENT_TEST_DEFINITIONS "-DPRINTF_LL_WIDTH=${HDF5_PRINTF_LL}") + if (${HDF_PREFIX}_SIZEOF_LONG_LONG) + set (CURRENT_TEST_DEFINITIONS "${CURRENT_TEST_DEFINITIONS} -DHAVE_LONG_LONG") + endif (${HDF_PREFIX}_SIZEOF_LONG_LONG) + TRY_RUN (HDF5_PRINTF_LL_TEST_RUN HDF5_PRINTF_LL_TEST_COMPILE + ${CMAKE_BINARY_DIR} + ${HDF_RESOURCES_EXT_DIR}/HDFTests.c + CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CURRENT_TEST_DEFINITIONS} + OUTPUT_VARIABLE OUTPUT + ) + if (HDF5_PRINTF_LL_TEST_COMPILE) + if (HDF5_PRINTF_LL_TEST_RUN MATCHES 0) + set (${HDF_PREFIX}_PRINTF_LL_WIDTH "\"${HDF5_PRINTF_LL}\"" CACHE INTERNAL "Width for printf for type `long long' or `__int64', us. `ll") + set (PRINT_LL_FOUND 1) + else (HDF5_PRINTF_LL_TEST_RUN MATCHES 0) + message ("Width with ${HDF5_PRINTF_LL} failed with result: ${HDF5_PRINTF_LL_TEST_RUN}") + endif (HDF5_PRINTF_LL_TEST_RUN MATCHES 0) + else (HDF5_PRINTF_LL_TEST_COMPILE) + file (APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log + "Test ${HDF_PREFIX}_PRINTF_LL_WIDTH for ${HDF5_PRINTF_LL} failed with the following output:\n ${OUTPUT}\n" + ) + endif (HDF5_PRINTF_LL_TEST_COMPILE) + endforeach (HDF5_PRINTF_LL) + + if (PRINT_LL_FOUND) + message (STATUS "Checking for apropriate format for 64 bit long: found ${${HDF_PREFIX}_PRINTF_LL_WIDTH}") + else (PRINT_LL_FOUND) + message (STATUS "Checking for apropriate format for 64 bit long: not found") + set (${HDF_PREFIX}_PRINTF_LL_WIDTH "\"unknown\"" CACHE INTERNAL + "Width for printf for type `long long' or `__int64', us. `ll" + ) + endif (PRINT_LL_FOUND) +endif (NOT ${HDF_PREFIX}_PRINTF_LL_WIDTH OR ${HDF_PREFIX}_PRINTF_LL_WIDTH MATCHES "unknown") + +# ---------------------------------------------------------------------- +# Set the flag to indicate that the machine can handle converting +# denormalized floating-point values. +# (This flag should be set for all machines, except for the Crays, where +# the cache value is set in it's config file) +# +set (${HDF_PREFIX}_CONVERT_DENORMAL_FLOAT 1) diff --git a/config/cmake_ext_mod/FindMPI.cmake b/config/cmake_ext_mod/FindMPI.cmake new file mode 100644 index 0000000..1c9a2e3 --- /dev/null +++ b/config/cmake_ext_mod/FindMPI.cmake @@ -0,0 +1,684 @@ +#.rst: +# FindMPI +# ------- +# +# Find a Message Passing Interface (MPI) implementation +# +# The Message Passing Interface (MPI) is a library used to write +# high-performance distributed-memory parallel applications, and is +# typically deployed on a cluster. MPI is a standard interface (defined +# by the MPI forum) for which many implementations are available. All +# of them have somewhat different include paths, libraries to link +# against, etc., and this module tries to smooth out those differences. +# +# === Variables === +# +# This module will set the following variables per language in your +# project, where is one of C, CXX, or Fortran: +# +# :: +# +# MPI__FOUND TRUE if FindMPI found MPI flags for +# MPI__COMPILER MPI Compiler wrapper for +# MPI__COMPILE_FLAGS Compilation flags for MPI programs +# MPI__INCLUDE_PATH Include path(s) for MPI header +# MPI__LINK_FLAGS Linking flags for MPI programs +# MPI__LIBRARIES All libraries to link MPI programs against +# +# Additionally, FindMPI sets the following variables for running MPI +# programs from the command line: +# +# :: +# +# MPIEXEC Executable for running MPI programs +# MPIEXEC_NUMPROC_FLAG Flag to pass to MPIEXEC before giving +# it the number of processors to run on +# MPIEXEC_PREFLAGS Flags to pass to MPIEXEC directly +# before the executable to run. +# MPIEXEC_POSTFLAGS Flags to pass to MPIEXEC after other flags +# +# === Usage === +# +# To use this module, simply call FindMPI from a CMakeLists.txt file, or +# run find_package(MPI), then run CMake. If you are happy with the +# auto- detected configuration for your language, then you're done. If +# not, you have two options: +# +# :: +# +# 1. Set MPI__COMPILER to the MPI wrapper (mpicc, etc.) of your +# choice and reconfigure. FindMPI will attempt to determine all the +# necessary variables using THAT compiler's compile and link flags. +# 2. If this fails, or if your MPI implementation does not come with +# a compiler wrapper, then set both MPI__LIBRARIES and +# MPI__INCLUDE_PATH. You may also set any other variables +# listed above, but these two are required. This will circumvent +# autodetection entirely. +# +# When configuration is successful, MPI__COMPILER will be set to +# the compiler wrapper for , if it was found. MPI__FOUND +# and other variables above will be set if any MPI implementation was +# found for , regardless of whether a compiler was found. +# +# When using MPIEXEC to execute MPI applications, you should typically +# use all of the MPIEXEC flags as follows: +# +# :: +# +# ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} PROCS +# ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS +# +# where PROCS is the number of processors on which to execute the +# program, EXECUTABLE is the MPI program, and ARGS are the arguments to +# pass to the MPI program. +# +# === Backward Compatibility === +# +# For backward compatibility with older versions of FindMPI, these +# variables are set, but deprecated: +# +# :: +# +# MPI_FOUND MPI_COMPILER MPI_LIBRARY +# MPI_COMPILE_FLAGS MPI_INCLUDE_PATH MPI_EXTRA_LIBRARY +# MPI_LINK_FLAGS MPI_LIBRARIES +# +# In new projects, please use the MPI__XXX equivalents. + +#============================================================================= +# Copyright 2001-2011 Kitware, Inc. +# Copyright 2010-2011 Todd Gamblin tgamblin@llnl.gov +# Copyright 2001-2009 Dave Partyka +# +# Distributed under the OSI-approved BSD License (the "License"); +# see accompanying file Copyright.txt for details. +# +# This software is distributed WITHOUT ANY WARRANTY; without even the +# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# See the License for more information. +#============================================================================= +# (To distribute this file outside of CMake, substitute the full +# License text for the above reference.) + +# include this to handle the QUIETLY and REQUIRED arguments +include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake) +include(GetPrerequisites) + +# +# This part detects MPI compilers, attempting to wade through the mess of compiler names in +# a sensible way. +# +# The compilers are detected in this order: +# +# 1. Try to find the most generic available MPI compiler, as this is usually set up by +# cluster admins. e.g., if plain old mpicc is available, we'll use it and assume it's +# the right compiler. +# +# 2. If a generic mpicc is NOT found, then we attempt to find one that matches +# CMAKE__COMPILER_ID. e.g. if you are using XL compilers, we'll try to find mpixlc +# and company, but not mpiicc. This hopefully prevents toolchain mismatches. +# +# If you want to force a particular MPI compiler other than what we autodetect (e.g. if you +# want to compile regular stuff with GNU and parallel stuff with Intel), you can always set +# your favorite MPI__COMPILER explicitly and this stuff will be ignored. +# + +# Start out with the generic MPI compiler names, as these are most commonly used. +set(_MPI_C_COMPILER_NAMES mpicc mpcc mpicc_r mpcc_r) +set(_MPI_CXX_COMPILER_NAMES mpicxx mpiCC mpcxx mpCC mpic++ mpc++ + mpicxx_r mpiCC_r mpcxx_r mpCC_r mpic++_r mpc++_r) +set(_MPI_Fortran_COMPILER_NAMES mpif95 mpif95_r mpf95 mpf95_r + mpif90 mpif90_r mpf90 mpf90_r + mpif77 mpif77_r mpf77 mpf77_r) + +# GNU compiler names +set(_MPI_GNU_C_COMPILER_NAMES mpigcc mpgcc mpigcc_r mpgcc_r) +set(_MPI_GNU_CXX_COMPILER_NAMES mpig++ mpg++ mpig++_r mpg++_r) +set(_MPI_GNU_Fortran_COMPILER_NAMES mpigfortran mpgfortran mpigfortran_r mpgfortran_r + mpig77 mpig77_r mpg77 mpg77_r) + +# Intel MPI compiler names +set(_MPI_Intel_C_COMPILER_NAMES mpiicc) +set(_MPI_Intel_CXX_COMPILER_NAMES mpiicpc mpiicxx mpiic++ mpiiCC) +set(_MPI_Intel_Fortran_COMPILER_NAMES mpiifort mpiif95 mpiif90 mpiif77) + +# PGI compiler names +set(_MPI_PGI_C_COMPILER_NAMES mpipgcc mppgcc) +set(_MPI_PGI_CXX_COMPILER_NAMES mpipgCC mppgCC) +set(_MPI_PGI_Fortran_COMPILER_NAMES mpipgf95 mpipgf90 mppgf95 mppgf90 mpipgf77 mppgf77) + +# XLC MPI Compiler names +set(_MPI_XL_C_COMPILER_NAMES mpxlc mpxlc_r mpixlc mpixlc_r) +set(_MPI_XL_CXX_COMPILER_NAMES mpixlcxx mpixlC mpixlc++ mpxlcxx mpxlc++ mpixlc++ mpxlCC + mpixlcxx_r mpixlC_r mpixlc++_r mpxlcxx_r mpxlc++_r mpixlc++_r mpxlCC_r) +set(_MPI_XL_Fortran_COMPILER_NAMES mpixlf95 mpixlf95_r mpxlf95 mpxlf95_r + mpixlf90 mpixlf90_r mpxlf90 mpxlf90_r + mpixlf77 mpixlf77_r mpxlf77 mpxlf77_r + mpixlf mpixlf_r mpxlf mpxlf_r) + +# append vendor-specific compilers to the list if we either don't know the compiler id, +# or if we know it matches the regular compiler. +foreach (lang C CXX Fortran) + foreach (id GNU Intel PGI XL) + if (NOT CMAKE_${lang}_COMPILER_ID OR CMAKE_${lang}_COMPILER_ID STREQUAL id) + list(APPEND _MPI_${lang}_COMPILER_NAMES ${_MPI_${id}_${lang}_COMPILER_NAMES}) + endif() + unset(_MPI_${id}_${lang}_COMPILER_NAMES) # clean up the namespace here + endforeach() +endforeach() + + +# Names to try for MPI exec +set(_MPI_EXEC_NAMES mpiexec mpirun lamexec srun) + +# Grab the path to MPI from the registry if we're on windows. +set(_MPI_PREFIX_PATH) +if(WIN32) + # MSMPI + file(TO_CMAKE_PATH "$ENV{MSMPI_BIN}" msmpi_bin_path) # The default path ends with a '\' and doesn't mix with ';' when appending. + list(APPEND _MPI_PREFIX_PATH "${msmpi_bin_path}") + unset(msmpi_bin_path) + list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\MPI;InstallRoot]/Bin") + list(APPEND _MPI_PREFIX_PATH "$ENV{MSMPI_INC}/..") # The SDK is installed separately from the runtime + # MPICH + list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH\\SMPD;binary]/..") + list(APPEND _MPI_PREFIX_PATH "[HKEY_LOCAL_MACHINE\\SOFTWARE\\MPICH2;Path]") + list(APPEND _MPI_PREFIX_PATH "$ENV{ProgramW6432}/MPICH2/") +endif() + +# Build a list of prefixes to search for MPI. +foreach(SystemPrefixDir ${CMAKE_SYSTEM_PREFIX_PATH}) + foreach(MpiPackageDir ${_MPI_PREFIX_PATH}) + if(EXISTS ${SystemPrefixDir}/${MpiPackageDir}) + list(APPEND _MPI_PREFIX_PATH "${SystemPrefixDir}/${MpiPackageDir}") + endif() + endforeach() +endforeach() + +function (_mpi_check_compiler compiler options cmdvar resvar) + execute_process( + COMMAND "${compiler}" ${options} + OUTPUT_VARIABLE cmdline OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE cmdline ERROR_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE success) + # Intel MPI 5.0.1 will return a zero return code even when the + # argument to the MPI compiler wrapper is unknown. Attempt to + # catch this case. + if("${cmdline}" MATCHES "undefined reference") + set(success 255 ) + endif() + set(${cmdvar} "${cmdline}" PARENT_SCOPE) + set(${resvar} "${success}" PARENT_SCOPE) +endfunction() + +# +# interrogate_mpi_compiler(lang try_libs) +# +# Attempts to extract compiler and linker args from an MPI compiler. The arguments set +# by this function are: +# +# MPI__INCLUDE_PATH MPI__LINK_FLAGS MPI__FOUND +# MPI__COMPILE_FLAGS MPI__LIBRARIES +# +# MPI__COMPILER must be set beforehand to the absolute path to an MPI compiler for +# . Additionally, MPI__INCLUDE_PATH and MPI__LIBRARIES may be set +# to skip autodetection. +# +# If try_libs is TRUE, this will also attempt to find plain MPI libraries in the usual +# way. In general, this is not as effective as interrogating the compilers, as it +# ignores language-specific flags and libraries. However, some MPI implementations +# (Windows implementations) do not have compiler wrappers, so this approach must be used. +# +function (interrogate_mpi_compiler lang try_libs) + # MPI_${lang}_NO_INTERROGATE will be set to a compiler name when the *regular* compiler was + # discovered to be the MPI compiler. This happens on machines like the Cray XE6 that use + # modules to set cc, CC, and ftn to the MPI compilers. If the user force-sets another MPI + # compiler, MPI_${lang}_COMPILER won't be equal to MPI_${lang}_NO_INTERROGATE, and we'll + # inspect that compiler anew. This allows users to set new compilers w/o rm'ing cache. + string(COMPARE NOTEQUAL "${MPI_${lang}_NO_INTERROGATE}" "${MPI_${lang}_COMPILER}" interrogate) + + # If MPI is set already in the cache, don't bother with interrogating the compiler. + if (interrogate AND ((NOT MPI_${lang}_INCLUDE_PATH) OR (NOT MPI_${lang}_LIBRARIES))) + if (MPI_${lang}_COMPILER) + # Check whether the -showme:compile option works. This indicates that we have either OpenMPI + # or a newer version of LAM-MPI, and implies that -showme:link will also work. + _mpi_check_compiler("${MPI_${lang}_COMPILER}" "-showme:compile" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) + if (MPI_COMPILER_RETURN EQUAL 0) + # If we appear to have -showme:compile, then we should + # also have -showme:link. Try it. + execute_process( + COMMAND ${MPI_${lang}_COMPILER} -showme:link + OUTPUT_VARIABLE MPI_LINK_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE MPI_LINK_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE MPI_COMPILER_RETURN) + + if (MPI_COMPILER_RETURN EQUAL 0) + # We probably have -showme:incdirs and -showme:libdirs as well, + # so grab that while we're at it. + execute_process( + COMMAND ${MPI_${lang}_COMPILER} -showme:incdirs + OUTPUT_VARIABLE MPI_INCDIRS OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE MPI_INCDIRS ERROR_STRIP_TRAILING_WHITESPACE) + + execute_process( + COMMAND ${MPI_${lang}_COMPILER} -showme:libdirs + OUTPUT_VARIABLE MPI_LIBDIRS OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE MPI_LIBDIRS ERROR_STRIP_TRAILING_WHITESPACE) + + else() + # reset things here if something went wrong. + set(MPI_COMPILE_CMDLINE) + set(MPI_LINK_CMDLINE) + endif() + endif () + + # Older versions of LAM-MPI have "-showme". Try to find that. + if (NOT MPI_COMPILER_RETURN EQUAL 0) + _mpi_check_compiler("${MPI_${lang}_COMPILER}" "-showme" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) + endif() + + # MVAPICH uses -compile-info and -link-info. Try them. + if (NOT MPI_COMPILER_RETURN EQUAL 0) + _mpi_check_compiler("${MPI_${lang}_COMPILER}" "-compile-info" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) + + # If we have compile-info, also have link-info. + if (MPI_COMPILER_RETURN EQUAL 0) + execute_process( + COMMAND ${MPI_${lang}_COMPILER} -link-info + OUTPUT_VARIABLE MPI_LINK_CMDLINE OUTPUT_STRIP_TRAILING_WHITESPACE + ERROR_VARIABLE MPI_LINK_CMDLINE ERROR_STRIP_TRAILING_WHITESPACE + RESULT_VARIABLE MPI_COMPILER_RETURN) + endif() + + # make sure we got compile and link. Reset vars if something's wrong. + if (NOT MPI_COMPILER_RETURN EQUAL 0) + set(MPI_COMPILE_CMDLINE) + set(MPI_LINK_CMDLINE) + endif() + endif() + + # MPICH just uses "-show". Try it. + if (NOT MPI_COMPILER_RETURN EQUAL 0) + _mpi_check_compiler("${MPI_${lang}_COMPILER}" "-show" MPI_COMPILE_CMDLINE MPI_COMPILER_RETURN) + endif() + + if (MPI_COMPILER_RETURN EQUAL 0) + # We have our command lines, but we might need to copy MPI_COMPILE_CMDLINE + # into MPI_LINK_CMDLINE, if we didn't find the link line. + if (NOT MPI_LINK_CMDLINE) + set(MPI_LINK_CMDLINE ${MPI_COMPILE_CMDLINE}) + endif() + else() + message(STATUS "Unable to determine MPI from MPI driver ${MPI_${lang}_COMPILER}") + set(MPI_COMPILE_CMDLINE) + set(MPI_LINK_CMDLINE) + endif() + + # Here, we're done with the interrogation part, and we'll try to extract args we care + # about from what we learned from the compiler wrapper scripts. + + # If interrogation came back with something, extract our variable from the MPI command line + if (MPI_COMPILE_CMDLINE OR MPI_LINK_CMDLINE) + # Extract compile flags from the compile command line. + string(REGEX MATCHALL "(^| )-[Df]([^\" ]+|\"[^\"]+\")" MPI_ALL_COMPILE_FLAGS "${MPI_COMPILE_CMDLINE}") + set(MPI_COMPILE_FLAGS_WORK) + + foreach(FLAG ${MPI_ALL_COMPILE_FLAGS}) + if (MPI_COMPILE_FLAGS_WORK) + set(MPI_COMPILE_FLAGS_WORK "${MPI_COMPILE_FLAGS_WORK} ${FLAG}") + else() + set(MPI_COMPILE_FLAGS_WORK ${FLAG}) + endif() + endforeach() + + # Extract include paths from compile command line + string(REGEX MATCHALL "(^| )-I([^\" ]+|\"[^\"]+\")" MPI_ALL_INCLUDE_PATHS "${MPI_COMPILE_CMDLINE}") + foreach(IPATH ${MPI_ALL_INCLUDE_PATHS}) + string(REGEX REPLACE "^ ?-I" "" IPATH ${IPATH}) + string(REPLACE "//" "/" IPATH ${IPATH}) + list(APPEND MPI_INCLUDE_PATH_WORK ${IPATH}) + endforeach() + + # try using showme:incdirs if extracting didn't work. + if (NOT MPI_INCLUDE_PATH_WORK) + set(MPI_INCLUDE_PATH_WORK ${MPI_INCDIRS}) + separate_arguments(MPI_INCLUDE_PATH_WORK) + endif() + + # If all else fails, just search for mpi.h in the normal include paths. + if (NOT MPI_INCLUDE_PATH_WORK) + set(MPI_HEADER_PATH "MPI_HEADER_PATH-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) + find_path(MPI_HEADER_PATH mpi.h + HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} + PATH_SUFFIXES include) + set(MPI_INCLUDE_PATH_WORK ${MPI_HEADER_PATH}) + endif() + + # Extract linker paths from the link command line + string(REGEX MATCHALL "(^| |-Wl,)-L([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_PATHS "${MPI_LINK_CMDLINE}") + set(MPI_LINK_PATH) + foreach(LPATH ${MPI_ALL_LINK_PATHS}) + string(REGEX REPLACE "^(| |-Wl,)-L" "" LPATH ${LPATH}) + string(REPLACE "//" "/" LPATH ${LPATH}) + list(APPEND MPI_LINK_PATH ${LPATH}) + endforeach() + + # try using showme:libdirs if extracting didn't work. + if (NOT MPI_LINK_PATH) + set(MPI_LINK_PATH ${MPI_LIBDIRS}) + separate_arguments(MPI_LINK_PATH) + endif() + + # Extract linker flags from the link command line + string(REGEX MATCHALL "(^| )(-Wl,|-Xlinker )([^\" ]+|\"[^\"]+\")" MPI_ALL_LINK_FLAGS "${MPI_LINK_CMDLINE}") + set(MPI_LINK_FLAGS_WORK) + foreach(FLAG ${MPI_ALL_LINK_FLAGS}) + if (MPI_LINK_FLAGS_WORK) + set(MPI_LINK_FLAGS_WORK "${MPI_LINK_FLAGS_WORK} ${FLAG}") + else() + set(MPI_LINK_FLAGS_WORK ${FLAG}) + endif() + endforeach() + + # Extract the set of libraries to link against from the link command + # line + string(REGEX MATCHALL "(^| )-l([^\" ]+|\"[^\"]+\")" MPI_LIBNAMES "${MPI_LINK_CMDLINE}") + + # add the compiler implicit directories because some compilers + # such as the intel compiler have libraries that show up + # in the showme list that can only be found in the implicit + # link directories of the compiler. + if (DEFINED CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES) + set(MPI_LINK_PATH + "${MPI_LINK_PATH};${CMAKE_${lang}_IMPLICIT_LINK_DIRECTORIES}") + endif () + + # Determine full path names for all of the libraries that one needs + # to link against in an MPI program + foreach(LIB ${MPI_LIBNAMES}) + string(REGEX REPLACE "^ ?-l" "" LIB ${LIB}) + # MPI_LIB is cached by find_library, but we don't want that. Clear it first. + set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) + find_library(MPI_LIB NAMES ${LIB} HINTS ${MPI_LINK_PATH}) + + if (MPI_LIB) + list(APPEND MPI_LIBRARIES_WORK ${MPI_LIB}) + elseif (NOT MPI_FIND_QUIETLY) + message(WARNING "Unable to find MPI library ${LIB}") + endif() + endforeach() + + # Sanity check MPI_LIBRARIES to make sure there are enough libraries + list(LENGTH MPI_LIBRARIES_WORK MPI_NUMLIBS) + list(LENGTH MPI_LIBNAMES MPI_NUMLIBS_EXPECTED) + if (NOT MPI_NUMLIBS EQUAL MPI_NUMLIBS_EXPECTED) + set(MPI_LIBRARIES_WORK "MPI_${lang}_LIBRARIES-NOTFOUND") + endif() + endif() + + elseif(try_libs) + # If we didn't have an MPI compiler script to interrogate, attempt to find everything + # with plain old find functions. This is nasty because MPI implementations have LOTS of + # different library names, so this section isn't going to be very generic. We need to + # make sure it works for MS MPI, though, since there are no compiler wrappers for that. + find_path(MPI_HEADER_PATH mpi.h + HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} + PATH_SUFFIXES include Inc) + set(MPI_INCLUDE_PATH_WORK ${MPI_HEADER_PATH}) + + # Decide between 32-bit and 64-bit libraries for Microsoft's MPI + if("${CMAKE_SIZEOF_VOID_P}" EQUAL 8) + set(MS_MPI_ARCH_DIR x64) + set(MS_MPI_ARCH_DIR2 amd64) + else() + set(MS_MPI_ARCH_DIR x86) + set(MS_MPI_ARCH_DIR2 i386) + endif() + + set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) + find_library(MPI_LIB + NAMES mpi mpich mpich2 msmpi + HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} + PATH_SUFFIXES lib lib/${MS_MPI_ARCH_DIR} Lib Lib/${MS_MPI_ARCH_DIR} lib/${MS_MPI_ARCH_DIR2} Lib/${MS_MPI_ARCH_DIR2}) + set(MPI_LIBRARIES_WORK ${MPI_LIB}) + + # Right now, we only know about the extra libs for C++. + # We could add Fortran here (as there is usually libfmpich, etc.), but + # this really only has to work with MS MPI on Windows. + # Assume that other MPI's are covered by the compiler wrappers. + if (${lang} STREQUAL CXX) + set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) + find_library(MPI_LIB + NAMES mpi++ mpicxx cxx mpi_cxx + HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} + PATH_SUFFIXES lib) + if (MPI_LIBRARIES_WORK AND MPI_LIB) + list(APPEND MPI_LIBRARIES_WORK ${MPI_LIB}) + endif() + endif() + + if (${lang} STREQUAL Fortran) + set(MPI_HEADER_PATH "MPI_HEADER_PATH-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) + find_path(MPI_HEADER_PATH mpifptr.h + HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} + PATH_SUFFIXES include include/${MS_MPI_ARCH_DIR} include/${MS_MPI_ARCH_DIR2} Inc Inc/${MS_MPI_ARCH_DIR} Inc/${MS_MPI_ARCH_DIR2}) + if (MPI_INCLUDE_PATH_WORK AND MPI_HEADER_PATH) + list(APPEND MPI_INCLUDE_PATH_WORK ${MPI_HEADER_PATH}) + endif() + + set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) + find_library(MPI_LIB + NAMES fmpi fmpich fmpich2 fmpich2g msmpifec msmpifmc + HINTS ${_MPI_BASE_DIR} ${_MPI_PREFIX_PATH} + PATH_SUFFIXES lib lib/${MS_MPI_ARCH_DIR} Lib Lib/${MS_MPI_ARCH_DIR}) + if (MPI_LIBRARIES_WORK AND MPI_LIB) + list(APPEND MPI_LIBRARIES_WORK ${MPI_LIB}) + endif() + endif() + + if (NOT MPI_LIBRARIES_WORK) + set(MPI_LIBRARIES_WORK "MPI_${lang}_LIBRARIES-NOTFOUND") + endif() + endif() + + # If we found MPI, set up all of the appropriate cache entries + set(MPI_${lang}_COMPILE_FLAGS ${MPI_COMPILE_FLAGS_WORK} CACHE STRING "MPI ${lang} compilation flags" FORCE) + set(MPI_${lang}_INCLUDE_PATH ${MPI_INCLUDE_PATH_WORK} CACHE STRING "MPI ${lang} include path" FORCE) + set(MPI_${lang}_LINK_FLAGS ${MPI_LINK_FLAGS_WORK} CACHE STRING "MPI ${lang} linking flags" FORCE) + set(MPI_${lang}_LIBRARIES ${MPI_LIBRARIES_WORK} CACHE STRING "MPI ${lang} libraries to link against" FORCE) + mark_as_advanced(MPI_${lang}_COMPILE_FLAGS MPI_${lang}_INCLUDE_PATH MPI_${lang}_LINK_FLAGS MPI_${lang}_LIBRARIES) + + # clear out our temporary lib/header detectionv variable here. + set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI lib detection" FORCE) + set(MPI_HEADER_PATH "MPI_HEADER_PATH-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI header detection" FORCE) + endif() + + # finally set a found variable for each MPI language + if (MPI_${lang}_INCLUDE_PATH AND MPI_${lang}_LIBRARIES) + set(MPI_${lang}_FOUND TRUE PARENT_SCOPE) + else() + set(MPI_${lang}_FOUND FALSE PARENT_SCOPE) + endif() +endfunction() + + +# This function attempts to compile with the regular compiler, to see if MPI programs +# work with it. This is a last ditch attempt after we've tried interrogating mpicc and +# friends, and after we've tried to find generic libraries. Works on machines like +# Cray XE6, where the modules environment changes what MPI version cc, CC, and ftn use. +function(try_regular_compiler lang success) + set(scratch_directory ${CMAKE_CURRENT_BINARY_DIR}${CMAKE_FILES_DIRECTORY}) + if (${lang} STREQUAL Fortran) + set(test_file ${scratch_directory}/cmake_mpi_test.f90) + file(WRITE ${test_file} + "program hello\n" + "include 'mpif.h'\n" + "integer ierror\n" + "call MPI_INIT(ierror)\n" + "call MPI_FINALIZE(ierror)\n" + "end\n") + else() + if (${lang} STREQUAL CXX) + set(test_file ${scratch_directory}/cmake_mpi_test.cpp) + else() + set(test_file ${scratch_directory}/cmake_mpi_test.c) + endif() + file(WRITE ${test_file} + "#include \n" + "int main(int argc, char **argv) {\n" + " MPI_Init(&argc, &argv);\n" + " MPI_Finalize();\n" + "}\n") + endif() + try_compile(compiler_has_mpi ${scratch_directory} ${test_file}) + if (compiler_has_mpi) + set(MPI_${lang}_NO_INTERROGATE ${CMAKE_${lang}_COMPILER} CACHE STRING "Whether to interrogate MPI ${lang} compiler" FORCE) + set(MPI_${lang}_COMPILER ${CMAKE_${lang}_COMPILER} CACHE STRING "MPI ${lang} compiler" FORCE) + set(MPI_${lang}_COMPILE_FLAGS "" CACHE STRING "MPI ${lang} compilation flags" FORCE) + set(MPI_${lang}_INCLUDE_PATH "" CACHE STRING "MPI ${lang} include path" FORCE) + set(MPI_${lang}_LINK_FLAGS "" CACHE STRING "MPI ${lang} linking flags" FORCE) + set(MPI_${lang}_LIBRARIES "" CACHE STRING "MPI ${lang} libraries to link against" FORCE) + endif() + set(${success} ${compiler_has_mpi} PARENT_SCOPE) + unset(compiler_has_mpi CACHE) +endfunction() + +# End definitions, commence real work here. + +# Most mpi distros have some form of mpiexec which gives us something we can reliably look for. +find_program(MPIEXEC + NAMES ${_MPI_EXEC_NAMES} + HINTS ${MPI_HOME} $ENV{MPI_HOME} + PATHS ${_MPI_PREFIX_PATH} + PATH_SUFFIXES bin + DOC "Executable for running MPI programs.") + +# call get_filename_component twice to remove mpiexec and the directory it exists in (typically bin). +# This gives us a fairly reliable base directory to search for /bin /lib and /include from. +get_filename_component(_MPI_BASE_DIR "${MPIEXEC}" PATH) +get_filename_component(_MPI_BASE_DIR "${_MPI_BASE_DIR}" PATH) + +set(MPIEXEC_NUMPROC_FLAG "-np" CACHE STRING "Flag used by MPI to specify the number of processes for MPIEXEC; the next option will be the number of processes.") +set(MPIEXEC_PREFLAGS "" CACHE STRING "These flags will be directly before the executable that is being run by MPIEXEC.") +set(MPIEXEC_POSTFLAGS "" CACHE STRING "These flags will come after all flags given to MPIEXEC.") +set(MPIEXEC_MAX_NUMPROCS "2" CACHE STRING "Maximum number of processors available to run MPI applications.") +mark_as_advanced(MPIEXEC MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS MPIEXEC_POSTFLAGS MPIEXEC_MAX_NUMPROCS) + + +#============================================================================= +# Backward compatibility input hacks. Propagate the FindMPI hints to C and +# CXX if the respective new versions are not defined. Translate the old +# MPI_LIBRARY and MPI_EXTRA_LIBRARY to respective MPI_${lang}_LIBRARIES. +# +# Once we find the new variables, we translate them back into their old +# equivalents below. +foreach (lang C CXX) + # Old input variables. + set(_MPI_OLD_INPUT_VARS COMPILER COMPILE_FLAGS INCLUDE_PATH LINK_FLAGS) + + # Set new vars based on their old equivalents, if the new versions are not already set. + foreach (var ${_MPI_OLD_INPUT_VARS}) + if (NOT MPI_${lang}_${var} AND MPI_${var}) + set(MPI_${lang}_${var} "${MPI_${var}}") + endif() + endforeach() + + # Special handling for MPI_LIBRARY and MPI_EXTRA_LIBRARY, which we nixed in the + # new FindMPI. These need to be merged into MPI__LIBRARIES + if (NOT MPI_${lang}_LIBRARIES AND (MPI_LIBRARY OR MPI_EXTRA_LIBRARY)) + set(MPI_${lang}_LIBRARIES ${MPI_LIBRARY} ${MPI_EXTRA_LIBRARY}) + endif() +endforeach() +#============================================================================= + + +# This loop finds the compilers and sends them off for interrogation. +foreach (lang C CXX Fortran) + if (CMAKE_${lang}_COMPILER_WORKS) + # If the user supplies a compiler *name* instead of an absolute path, assume that we need to find THAT compiler. + if (MPI_${lang}_COMPILER) + is_file_executable(MPI_${lang}_COMPILER MPI_COMPILER_IS_EXECUTABLE) + if (NOT MPI_COMPILER_IS_EXECUTABLE) + # Get rid of our default list of names and just search for the name the user wants. + set(_MPI_${lang}_COMPILER_NAMES ${MPI_${lang}_COMPILER}) + set(MPI_${lang}_COMPILER "MPI_${lang}_COMPILER-NOTFOUND" CACHE FILEPATH "Cleared" FORCE) + # If the user specifies a compiler, we don't want to try to search libraries either. + set(try_libs FALSE) + endif() + else() + set(try_libs TRUE) + endif() + + find_program(MPI_${lang}_COMPILER + NAMES ${_MPI_${lang}_COMPILER_NAMES} + HINTS ${_MPI_BASE_DIR}/bin + PATHS ${_MPI_PREFIX_PATH} + ) + interrogate_mpi_compiler(${lang} ${try_libs}) + mark_as_advanced(MPI_${lang}_COMPILER) + + # last ditch try -- if nothing works so far, just try running the regular compiler and + # see if we can create an MPI executable. + set(regular_compiler_worked 0) + if (NOT MPI_${lang}_LIBRARIES OR NOT MPI_${lang}_INCLUDE_PATH) + try_regular_compiler(${lang} regular_compiler_worked) + endif() + + set(MPI_${lang}_FIND_QUIETLY ${MPI_FIND_QUIETLY}) + set(MPI_${lang}_FIND_REQUIRED ${MPI_FIND_REQUIRED}) + set(MPI_${lang}_FIND_VERSION ${MPI_FIND_VERSION}) + set(MPI_${lang}_FIND_VERSION_EXACT ${MPI_FIND_VERSION_EXACT}) + + if (regular_compiler_worked) + find_package_handle_standard_args(MPI_${lang} DEFAULT_MSG MPI_${lang}_COMPILER) + else() + find_package_handle_standard_args(MPI_${lang} DEFAULT_MSG MPI_${lang}_LIBRARIES MPI_${lang}_INCLUDE_PATH) + endif() + endif() +endforeach() + + +#============================================================================= +# More backward compatibility stuff +# +# Bare MPI sans ${lang} vars are set to CXX then C, depending on what was found. +# This mimics the behavior of the old language-oblivious FindMPI. +set(_MPI_OLD_VARS FOUND COMPILER INCLUDE_PATH COMPILE_FLAGS LINK_FLAGS LIBRARIES) +if (MPI_CXX_FOUND) + foreach (var ${_MPI_OLD_VARS}) + set(MPI_${var} ${MPI_CXX_${var}}) + endforeach() +elseif (MPI_C_FOUND) + foreach (var ${_MPI_OLD_VARS}) + set(MPI_${var} ${MPI_C_${var}}) + endforeach() +else() + # Note that we might still have found Fortran, but you'll need to use MPI_Fortran_FOUND + set(MPI_FOUND FALSE) +endif() + +# Chop MPI_LIBRARIES into the old-style MPI_LIBRARY and MPI_EXTRA_LIBRARY, and set them in cache. +if (MPI_LIBRARIES) + list(GET MPI_LIBRARIES 0 MPI_LIBRARY_WORK) + set(MPI_LIBRARY ${MPI_LIBRARY_WORK} CACHE FILEPATH "MPI library to link against" FORCE) +else() + set(MPI_LIBRARY "MPI_LIBRARY-NOTFOUND" CACHE FILEPATH "MPI library to link against" FORCE) +endif() + +list(LENGTH MPI_LIBRARIES MPI_NUMLIBS) +if (MPI_NUMLIBS GREATER 1) + set(MPI_EXTRA_LIBRARY_WORK ${MPI_LIBRARIES}) + list(REMOVE_AT MPI_EXTRA_LIBRARY_WORK 0) + set(MPI_EXTRA_LIBRARY ${MPI_EXTRA_LIBRARY_WORK} CACHE STRING "Extra MPI libraries to link against" FORCE) +else() + set(MPI_EXTRA_LIBRARY "MPI_EXTRA_LIBRARY-NOTFOUND" CACHE STRING "Extra MPI libraries to link against" FORCE) +endif() +#============================================================================= + +# unset these vars to cleanup namespace +unset(_MPI_OLD_VARS) +unset(_MPI_PREFIX_PATH) +unset(_MPI_BASE_DIR) +foreach (lang C CXX Fortran) + unset(_MPI_${lang}_COMPILER_NAMES) +endforeach() diff --git a/config/cmake_ext_mod/FindSZIP.cmake b/config/cmake_ext_mod/FindSZIP.cmake new file mode 100644 index 0000000..5f0f031 --- /dev/null +++ b/config/cmake_ext_mod/FindSZIP.cmake @@ -0,0 +1,172 @@ + +# - Find SZIP library +# - Derived from the FindTiff.cmake that is included with cmake +# Find the native SZIP includes and library +# This module defines +# SZIP_INCLUDE_DIRS, where to find tiff.h, etc. +# SZIP_LIBRARIES, libraries to link against to use SZIP. +# SZIP_FOUND, If false, do not try to use SZIP. +# also defined, but not for general use are +# SZIP_LIBRARY, where to find the SZIP library. +# SZIP_LIBRARY_DEBUG - Debug version of SZIP library +# SZIP_LIBRARY_RELEASE - Release Version of SZIP library + +# message (STATUS "Finding SZIP library and headers..." ) + +############################################ +# +# Check the existence of the libraries. +# +############################################ +# This macro was taken directly from the FindQt4.cmake file that is included +# with the CMake distribution. This is NOT my work. All work was done by the +# original authors of the FindQt4.cmake file. Only minor modifications were +# made to remove references to Qt and make this file more generally applicable +######################################################################### + +MACRO (SZIP_ADJUST_LIB_VARS basename) + if (${basename}_INCLUDE_DIR) + + # if only the release version was found, set the debug variable also to the release version + if (${basename}_LIBRARY_RELEASE AND NOT ${basename}_LIBRARY_DEBUG) + set (${basename}_LIBRARY_DEBUG ${${basename}_LIBRARY_RELEASE}) + set (${basename}_LIBRARY ${${basename}_LIBRARY_RELEASE}) + set (${basename}_LIBRARIES ${${basename}_LIBRARY_RELEASE}) + endif (${basename}_LIBRARY_RELEASE AND NOT ${basename}_LIBRARY_DEBUG) + + # if only the debug version was found, set the release variable also to the debug version + if (${basename}_LIBRARY_DEBUG AND NOT ${basename}_LIBRARY_RELEASE) + set (${basename}_LIBRARY_RELEASE ${${basename}_LIBRARY_DEBUG}) + set (${basename}_LIBRARY ${${basename}_LIBRARY_DEBUG}) + set (${basename}_LIBRARIES ${${basename}_LIBRARY_DEBUG}) + endif (${basename}_LIBRARY_DEBUG AND NOT ${basename}_LIBRARY_RELEASE) + if (${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE) + # if the generator supports configuration types then set + # optimized and debug libraries, or if the CMAKE_BUILD_TYPE has a value + if (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + set (${basename}_LIBRARY optimized ${${basename}_LIBRARY_RELEASE} debug ${${basename}_LIBRARY_DEBUG}) + else (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + # if there are no configuration types and CMAKE_BUILD_TYPE has no value + # then just use the release libraries + set (${basename}_LIBRARY ${${basename}_LIBRARY_RELEASE} ) + endif (CMAKE_CONFIGURATION_TYPES OR CMAKE_BUILD_TYPE) + set (${basename}_LIBRARIES optimized ${${basename}_LIBRARY_RELEASE} debug ${${basename}_LIBRARY_DEBUG}) + endif (${basename}_LIBRARY_DEBUG AND ${basename}_LIBRARY_RELEASE) + + set (${basename}_LIBRARY ${${basename}_LIBRARY} CACHE FILEPATH "The ${basename} library") + + if (${basename}_LIBRARY) + set (${basename}_FOUND 1) + endif (${basename}_LIBRARY) + + endif (${basename}_INCLUDE_DIR ) + + # Make variables changeble to the advanced user + MARK_AS_ADVANCED (${basename}_LIBRARY ${basename}_LIBRARY_RELEASE ${basename}_LIBRARY_DEBUG ${basename}_INCLUDE_DIR ) +ENDMACRO (SZIP_ADJUST_LIB_VARS) + + +# Look for the header file. +set (SZIP_INCLUDE_SEARCH_DIRS + $ENV{SZIP_INSTALL}/include + $ENV{SZIP_INSTALL}/include/szip + /usr/include + /usr/include/szip +) + +set (SZIP_LIB_SEARCH_DIRS + $ENV{SZIP_INSTALL}/lib + /usr/lib +) + +set (SZIP_BIN_SEARCH_DIRS + $ENV{SZIP_INSTALL}/bin + /usr/bin +) + +FIND_PATH (SZIP_INCLUDE_DIR + NAMES szlib.h + PATHS ${SZIP_INCLUDE_SEARCH_DIRS} + NO_DEFAULT_PATH +) + +if (WIN32) + set (SZIP_SEARCH_DEBUG_NAMES "sz_d;libsz_d") + set (SZIP_SEARCH_RELEASE_NAMES "sz;libsz;libszip") +else (WIN32) + set (SZIP_SEARCH_DEBUG_NAMES "sz_d") + set (SZIP_SEARCH_RELEASE_NAMES "sz;szip") +endif (WIN32) + +# Look for the library. +FIND_LIBRARY (SZIP_LIBRARY_DEBUG + NAMES ${SZIP_SEARCH_DEBUG_NAMES} + PATHS ${SZIP_LIB_SEARCH_DIRS} + NO_DEFAULT_PATH +) + +FIND_LIBRARY (SZIP_LIBRARY_RELEASE + NAMES ${SZIP_SEARCH_RELEASE_NAMES} + PATHS ${SZIP_LIB_SEARCH_DIRS} + NO_DEFAULT_PATH +) + +SZIP_ADJUST_LIB_VARS (SZIP) + +if (SZIP_INCLUDE_DIR AND SZIP_LIBRARY) + set (SZIP_FOUND 1) + set (SZIP_LIBRARIES ${SZIP_LIBRARY}) + set (SZIP_INCLUDE_DIRS ${SZIP_INCLUDE_DIR}) + if (SZIP_LIBRARY_DEBUG) + get_filename_component (SZIP_LIBRARY_PATH ${SZIP_LIBRARY_DEBUG} PATH) + set (SZIP_LIB_DIR ${SZIP_LIBRARY_PATH}) + elseif (SZIP_LIBRARY_RELEASE) + get_filename_component (SZIP_LIBRARY_PATH ${SZIP_LIBRARY_RELEASE} PATH) + set (SZIP_LIB_DIR ${SZIP_LIBRARY_PATH}) + endif (SZIP_LIBRARY_DEBUG) + +else (SZIP_INCLUDE_DIR AND SZIP_LIBRARY) + set (SZIP_FOUND 0) + set (SZIP_LIBRARIES) + set (SZIP_INCLUDE_DIRS) +endif (SZIP_INCLUDE_DIR AND SZIP_LIBRARY) + +# Report the results. +if (NOT SZIP_FOUND) + set (SZIP_DIR_MESSAGE + "SZip was not found. Make sure SZIP_LIBRARY and SZIP_INCLUDE_DIR are set or set the SZIP_INSTALL environment variable." + ) + if (NOT SZIP_FIND_QUIETLY) + message (STATUS "${SZIP_DIR_MESSAGE}") + else (NOT SZIP_FIND_QUIETLY) + if (SZIP_FIND_REQUIRED) + message (FATAL_ERROR "SZip was NOT found and is Required by this project") + endif (SZIP_FIND_REQUIRED) + endif (NOT SZIP_FIND_QUIETLY) +endif (NOT SZIP_FOUND) + +if (SZIP_FOUND) + include (CheckSymbolExists) + ############################################# + # Find out if SZIP was build using dll's + ############################################# + # Save required variable + set (CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES}) + set (CMAKE_REQUIRED_FLAGS_SAVE ${CMAKE_REQUIRED_FLAGS}) + # Add SZIP_INCLUDE_DIR to CMAKE_REQUIRED_INCLUDES + set (CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES};${SZIP_INCLUDE_DIRS}") + + # Restore CMAKE_REQUIRED_INCLUDES and CMAKE_REQUIRED_FLAGS variables + set (CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE}) + set (CMAKE_REQUIRED_FLAGS ${CMAKE_REQUIRED_FLAGS_SAVE}) + # + ############################################# +endif (SZIP_FOUND) + +if (FIND_SZIP_DEBUG) + message (STATUS "SZIP_INCLUDE_DIR: ${SZIP_INCLUDE_DIR}") + message (STATUS "SZIP_INCLUDE_DIRS: ${SZIP_INCLUDE_DIRS}") + message (STATUS "SZIP_LIBRARY_DEBUG: ${SZIP_LIBRARY_DEBUG}") + message (STATUS "SZIP_LIBRARY_RELEASE: ${SZIP_LIBRARY_RELEASE}") + message (STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") +endif (FIND_SZIP_DEBUG) diff --git a/config/cmake_ext_mod/GetTimeOfDayTest.cpp b/config/cmake_ext_mod/GetTimeOfDayTest.cpp new file mode 100644 index 0000000..3b5bf60 --- /dev/null +++ b/config/cmake_ext_mod/GetTimeOfDayTest.cpp @@ -0,0 +1,15 @@ +#if defined (TRY_SYS_TIME_H) +#include +/* #include */ +#endif + + +#if defined (TRY_TIME_H) +#include +#endif + +int main(int argc, char **argv) { + struct timeval t1; + gettimeofday(&t1, 0x00); + return 0; +} diff --git a/config/cmake_ext_mod/HDFCXXTests.cpp b/config/cmake_ext_mod/HDFCXXTests.cpp new file mode 100644 index 0000000..6b47421 --- /dev/null +++ b/config/cmake_ext_mod/HDFCXXTests.cpp @@ -0,0 +1,56 @@ + +#ifdef OLD_HEADER_FILENAME + +#include + +int main(void) { return 0; } + +#endif + + +#ifdef HDF_NO_NAMESPACE + +namespace HDF { +int fnord; +} + +int main(void) { + using namespace HDF; + fnord = 37; + return 0; +} + +#endif + +#ifdef HDF_NO_STD + +#include + +using namespace std; + +int main(void) { + string myString("testing namespace std"); + return 0; +} + +#endif + +#ifdef BOOL_NOTDEFINED +int main(void) { + bool flag; + return 0; +} + +#endif + +#ifdef NO_STATIC_CAST + +int main(void) { + float test_float; + int test_int; + test_float = 37.0; + test_int = static_cast (test_float); + return 0; +} + +#endif diff --git a/config/cmake_ext_mod/HDFLibMacros.cmake b/config/cmake_ext_mod/HDFLibMacros.cmake new file mode 100644 index 0000000..7660a8a --- /dev/null +++ b/config/cmake_ext_mod/HDFLibMacros.cmake @@ -0,0 +1,270 @@ +#------------------------------------------------------------------------------- +MACRO (EXTERNAL_JPEG_LIBRARY compress_type jpeg_pic) + # May need to build JPEG with PIC on x64 machines with gcc + # Need to use CMAKE_ANSI_CFLAGS define so that compiler test works + + if (${compress_type} MATCHES "SVN") + EXTERNALPROJECT_ADD (JPEG + SVN_REPOSITORY ${JPEG_URL} + # [SVN_REVISION rev] + INSTALL_COMMAND "" + CMAKE_ARGS + -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DJPEG_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} + -DJPEG_EXTERNALLY_CONFIGURED:BOOL=OFF + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} + -DCMAKE_ANSI_CFLAGS:STRING=${jpeg_pic} + ) + elseif (${compress_type} MATCHES "GIT") + EXTERNALPROJECT_ADD (JPEG + GIT_REPOSITORY ${JPEG_URL} + INSTALL_COMMAND "" + CMAKE_ARGS + -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DJPEG_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} + -DJPEG_EXTERNALLY_CONFIGURED:BOOL=OFF + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} + -DCMAKE_ANSI_CFLAGS:STRING=${jpeg_pic} + ) + elseif (${compress_type} MATCHES "TGZ") + EXTERNALPROJECT_ADD (JPEG + URL ${JPEG_URL} + URL_MD5 "" + INSTALL_COMMAND "" + CMAKE_ARGS + -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DJPEG_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} + -DJPEG_EXTERNALLY_CONFIGURED:BOOL=OFF + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} + -DCMAKE_ANSI_CFLAGS:STRING=${jpeg_pic} + ) + endif (${compress_type} MATCHES "SVN") + externalproject_get_property (JPEG BINARY_DIR SOURCE_DIR) + +##include (${BINARY_DIR}/${JPEG_PACKAGE_NAME}${HDF_PACKAGE_EXT}-targets.cmake) +# Create imported target jpeg-static + add_library(jpeg-static STATIC IMPORTED) +# Create imported target jpeg-shared + add_library(jpeg-shared SHARED IMPORTED) + if (BUILD_SHARED_LIBS) + HDF_IMPORT_SET_LIB_OPTIONS (jpeg-shared "jpeg" SHARED "") + add_dependencies (JPEG jpeg-shared) + set (JPEG_SHARED_LIBRARY "jpeg-shared") + set (JPEG_LIBRARIES ${JPEG_shared_LIBRARY}) + endif (BUILD_SHARED_LIBS) + HDF_IMPORT_SET_LIB_OPTIONS (jpeg-static "jpeg" STATIC "") + add_dependencies (JPEG jpeg-static) + set (JPEG_STATIC_LIBRARY "jpeg-static") + set (JPEG_LIBRARIES ${JPEG_static_LIBRARY}) + + set (JPEG_INCLUDE_DIR_GEN "${BINARY_DIR}") + set (JPEG_INCLUDE_DIR "${SOURCE_DIR}/src") + set (JPEG_FOUND 1) + set (JPEG_INCLUDE_DIRS ${JPEG_INCLUDE_DIR_GEN} ${JPEG_INCLUDE_DIR}) +ENDMACRO (EXTERNAL_JPEG_LIBRARY) + +#------------------------------------------------------------------------------- +MACRO (PACKAGE_JPEG_LIBRARY compress_type) + add_custom_target (JPEG-GenHeader-Copy ALL + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${JPEG_INCLUDE_DIR_GEN}/jconfig.h ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ + COMMENT "Copying ${JPEG_INCLUDE_DIR_GEN}/jconfig.h to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/" + ) + set (EXTERNAL_HEADER_LIST ${EXTERNAL_HEADER_LIST} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/jconfig.h) + if (${compress_type} MATCHES "SVN" OR ${compress_type} MATCHES "TGZ") + add_dependencies (JPEG-GenHeader-Copy JPEG) + endif (${compress_type} MATCHES "SVN" OR ${compress_type} MATCHES "TGZ") +ENDMACRO (PACKAGE_JPEG_LIBRARY) + +#------------------------------------------------------------------------------- +MACRO (EXTERNAL_SZIP_LIBRARY compress_type encoding) + if (${compress_type} MATCHES "SVN") + EXTERNALPROJECT_ADD (SZIP + SVN_REPOSITORY ${SZIP_URL} + # [SVN_REVISION rev] + INSTALL_COMMAND "" + CMAKE_ARGS + -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DSZIP_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} + -DSZIP_EXTERNALLY_CONFIGURED:BOOL=OFF + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} + -DCMAKE_ANSI_CFLAGS:STRING=${CMAKE_ANSI_CFLAGS} + -DSZIP_ENABLE_ENCODING:BOOL=${encoding} + ) + elseif (${compress_type} MATCHES "GIT") + EXTERNALPROJECT_ADD (SZIP + GIT_REPOSITORY ${SZIP_URL} + # [SVN_REVISION rev] + INSTALL_COMMAND "" + CMAKE_ARGS + -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DSZIP_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} + -DSZIP_EXTERNALLY_CONFIGURED:BOOL=OFF + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} + -DCMAKE_ANSI_CFLAGS:STRING=${CMAKE_ANSI_CFLAGS} + -DSZIP_ENABLE_ENCODING:BOOL=${encoding} + ) + elseif (${compress_type} MATCHES "TGZ") + EXTERNALPROJECT_ADD (SZIP + URL ${SZIP_URL} + URL_MD5 "" + INSTALL_COMMAND "" + CMAKE_ARGS + -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DSZIP_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} + -DSZIP_EXTERNALLY_CONFIGURED:BOOL=OFF + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} + -DCMAKE_ANSI_CFLAGS:STRING=${CMAKE_ANSI_CFLAGS} + -DSZIP_ENABLE_ENCODING:BOOL=${encoding} + ) + endif (${compress_type} MATCHES "SVN") + externalproject_get_property (SZIP BINARY_DIR SOURCE_DIR) + +##include (${BINARY_DIR}/${SZIP_PACKAGE_NAME}${HDF_PACKAGE_EXT}-targets.cmake) +# Create imported target szip-static + add_library(szip-static STATIC IMPORTED) +# Create imported target szip-shared + add_library(szip-shared SHARED IMPORTED) + if (BUILD_SHARED_LIBS) + HDF_IMPORT_SET_LIB_OPTIONS (szip-shared "szip" SHARED "") + add_dependencies (SZIP szip-shared) + set (SZIP_SHARED_LIBRARY "szip-shared") + set (SZIP_LIBRARIES ${SZIP_shared_LIBRARY}) + endif (BUILD_SHARED_LIBS) + HDF_IMPORT_SET_LIB_OPTIONS (szip-static "szip" STATIC "") + add_dependencies (SZIP szip-static) + set (SZIP_STATIC_LIBRARY "szip-static") + set (SZIP_LIBRARIES ${SZIP_static_LIBRARY}) + + set (SZIP_INCLUDE_DIR_GEN "${BINARY_DIR}") + set (SZIP_INCLUDE_DIR "${SOURCE_DIR}/src") + set (SZIP_FOUND 1) + set (SZIP_INCLUDE_DIRS ${SZIP_INCLUDE_DIR_GEN} ${SZIP_INCLUDE_DIR}) +ENDMACRO (EXTERNAL_SZIP_LIBRARY) + +#------------------------------------------------------------------------------- +MACRO (PACKAGE_SZIP_LIBRARY compress_type) + add_custom_target (SZIP-GenHeader-Copy ALL + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${SZIP_INCLUDE_DIR_GEN}/SZconfig.h ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ + COMMENT "Copying ${SZIP_INCLUDE_DIR_GEN}/SZconfig.h to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/" + ) + set (EXTERNAL_HEADER_LIST ${EXTERNAL_HEADER_LIST} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/SZconfig.h) + if (${compress_type} MATCHES "SVN" OR ${compress_type} MATCHES "TGZ") + add_dependencies (SZIP-GenHeader-Copy SZIP) + endif (${compress_type} MATCHES "SVN" OR ${compress_type} MATCHES "TGZ") +ENDMACRO (PACKAGE_SZIP_LIBRARY) + +#------------------------------------------------------------------------------- +MACRO (EXTERNAL_ZLIB_LIBRARY compress_type) + if (${compress_type} MATCHES "SVN") + EXTERNALPROJECT_ADD (ZLIB + SVN_REPOSITORY ${ZLIB_URL} + # [SVN_REVISION rev] + INSTALL_COMMAND "" + CMAKE_ARGS + -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DZLIB_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} + -DZLIB_EXTERNALLY_CONFIGURED:BOOL=OFF + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} + -DCMAKE_ANSI_CFLAGS:STRING=${CMAKE_ANSI_CFLAGS} + ) + elseif (${compress_type} MATCHES "GIT") + EXTERNALPROJECT_ADD (ZLIB + GIT_REPOSITORY ${ZLIB_URL} + # [SVN_REVISION rev] + INSTALL_COMMAND "" + CMAKE_ARGS + -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DZLIB_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} + -DZLIB_EXTERNALLY_CONFIGURED:BOOL=OFF + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} + -DCMAKE_ANSI_CFLAGS:STRING=${CMAKE_ANSI_CFLAGS} + ) + elseif (${compress_type} MATCHES "TGZ") + EXTERNALPROJECT_ADD (ZLIB + URL ${ZLIB_URL} + URL_MD5 "" + INSTALL_COMMAND "" + CMAKE_ARGS + -DBUILD_SHARED_LIBS:BOOL=${BUILD_SHARED_LIBS} + -DZLIB_PACKAGE_EXT:STRING=${HDF_PACKAGE_EXT} + -DZLIB_EXTERNALLY_CONFIGURED:BOOL=OFF + -DCMAKE_BUILD_TYPE:STRING=${CMAKE_BUILD_TYPE} + -DCMAKE_INSTALL_PREFIX:PATH=${CMAKE_INSTALL_PREFIX} + -DCMAKE_RUNTIME_OUTPUT_DIRECTORY:PATH=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + -DCMAKE_LIBRARY_OUTPUT_DIRECTORY:PATH=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} + -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY:PATH=${CMAKE_ARCHIVE_OUTPUT_DIRECTORY} + -DCMAKE_ANSI_CFLAGS:STRING=${CMAKE_ANSI_CFLAGS} + ) + endif (${compress_type} MATCHES "SVN") + externalproject_get_property (ZLIB BINARY_DIR SOURCE_DIR) + + if (WIN32) + set (ZLIB_LIB_NAME "zlib") + else (WIN32) + set (ZLIB_LIB_NAME "z") + endif (WIN32) +##include (${BINARY_DIR}/${ZLIB_PACKAGE_NAME}${HDF_PACKAGE_EXT}-targets.cmake) +# Create imported target zlib-static + add_library(zlib-static STATIC IMPORTED) +# Create imported target zlib-shared + add_library(zlib-shared SHARED IMPORTED) + if (BUILD_SHARED_LIBS) + HDF_IMPORT_SET_LIB_OPTIONS (zlib-shared ${ZLIB_LIB_NAME} SHARED "") + add_dependencies (ZLIB zlib-shared) + set (ZLIB_SHARED_LIBRARY "zlib-shared") + set (ZLIB_LIBRARIES ${ZLIB_SHARED_LIBRARY}) + endif (BUILD_SHARED_LIBS) + HDF_IMPORT_SET_LIB_OPTIONS (zlib-static ${ZLIB_LIB_NAME} STATIC "") + add_dependencies (ZLIB zlib-static) + set (ZLIB_STATIC_LIBRARY "zlib-static") + set (ZLIB_LIBRARIES ${ZLIB_static_LIBRARY}) + + set (ZLIB_INCLUDE_DIR_GEN "${BINARY_DIR}") + set (ZLIB_INCLUDE_DIR "${SOURCE_DIR}") + set (ZLIB_FOUND 1) + set (ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR_GEN} ${ZLIB_INCLUDE_DIR}) +ENDMACRO (EXTERNAL_ZLIB_LIBRARY) + +#------------------------------------------------------------------------------- +MACRO (PACKAGE_ZLIB_LIBRARY compress_type) + add_custom_target (ZLIB-GenHeader-Copy ALL + COMMAND ${CMAKE_COMMAND} -E copy_if_different ${ZLIB_INCLUDE_DIR_GEN}/zconf.h ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ + COMMENT "Copying ${ZLIB_INCLUDE_DIR_GEN}/zconf.h to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/" + ) + set (EXTERNAL_HEADER_LIST ${EXTERNAL_HEADER_LIST} ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/zconf.h) + if (${compress_type} MATCHES "SVN" OR ${compress_type} MATCHES "TGZ") + add_dependencies (ZLIB-GenHeader-Copy ZLIB) + endif (${compress_type} MATCHES "SVN" OR ${compress_type} MATCHES "TGZ") +ENDMACRO (PACKAGE_ZLIB_LIBRARY) diff --git a/config/cmake_ext_mod/HDFMacros.cmake b/config/cmake_ext_mod/HDFMacros.cmake new file mode 100644 index 0000000..d3ac36b --- /dev/null +++ b/config/cmake_ext_mod/HDFMacros.cmake @@ -0,0 +1,277 @@ +#------------------------------------------------------------------------------- +macro (SET_GLOBAL_VARIABLE name value) + set (${name} ${value} CACHE INTERNAL "Used to pass variables between directories" FORCE) +endmacro (SET_GLOBAL_VARIABLE) + +#------------------------------------------------------------------------------- +macro (IDE_GENERATED_PROPERTIES SOURCE_PATH HEADERS SOURCES) + #set(source_group_path "Source/AIM/${NAME}") + string (REPLACE "/" "\\\\" source_group_path ${SOURCE_PATH}) + source_group (${source_group_path} FILES ${HEADERS} ${SOURCES}) + + #-- The following is needed if we ever start to use OS X Frameworks but only + #-- works on CMake 2.6 and greater + #set_property (SOURCE ${HEADERS} + # PROPERTY MACOSX_PACKAGE_LOCATION Headers/${NAME} + #) +endmacro (IDE_GENERATED_PROPERTIES) + +#------------------------------------------------------------------------------- +macro (IDE_SOURCE_PROPERTIES SOURCE_PATH HEADERS SOURCES) + # install (FILES ${HEADERS} + # DESTINATION include/R3D/${NAME} + # COMPONENT Headers + # ) + + string (REPLACE "/" "\\\\" source_group_path ${SOURCE_PATH} ) + source_group (${source_group_path} FILES ${HEADERS} ${SOURCES}) + + #-- The following is needed if we ever start to use OS X Frameworks but only + #-- works on CMake 2.6 and greater + #set_property (SOURCE ${HEADERS} + # PROPERTY MACOSX_PACKAGE_LOCATION Headers/${NAME} + #) +endmacro (IDE_SOURCE_PROPERTIES) + +#------------------------------------------------------------------------------- +macro (TARGET_NAMING libtarget libtype) + if (${libtype} MATCHES "SHARED") + set_target_properties (${libtarget} PROPERTIES OUTPUT_NAME "${libtarget}${ARGN}") + endif (${libtype} MATCHES "SHARED") +endmacro (TARGET_NAMING) + +#------------------------------------------------------------------------------- +macro (INSTALL_TARGET_PDB libtarget targetdestination targetcomponent) + if (WIN32 AND MSVC) + get_target_property (target_name ${libtarget} OUTPUT_NAME_RELWITHDEBINFO) + install ( + FILES + ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/${CMAKE_IMPORT_LIBRARY_PREFIX}${target_name}.pdb + DESTINATION + ${targetdestination} + CONFIGURATIONS RelWithDebInfo + COMPONENT ${targetcomponent} + ) + endif (WIN32 AND MSVC) +endmacro (INSTALL_TARGET_PDB) + +#------------------------------------------------------------------------------- +macro (INSTALL_PROGRAM_PDB progtarget targetdestination targetcomponent) + if (WIN32 AND MSVC) + get_target_property (target_name ${progtarget} OUTPUT_NAME_RELWITHDEBINFO) + get_target_property (target_prefix ${progtarget} PREFIX) + install ( + FILES + ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/${target_prefix}${target_name}.pdb + DESTINATION + ${targetdestination} + CONFIGURATIONS RelWithDebInfo + COMPONENT ${targetcomponent} + ) + endif (WIN32 AND MSVC) +endmacro (INSTALL_PROGRAM_PDB) + +#------------------------------------------------------------------------------- +macro (HDF_SET_LIB_OPTIONS libtarget libname libtype) + if (${libtype} MATCHES "SHARED") + if (WIN32) + set (LIB_RELEASE_NAME "${libname}") + set (LIB_DEBUG_NAME "${libname}_D") + else (WIN32) + set (LIB_RELEASE_NAME "${libname}") + set (LIB_DEBUG_NAME "${libname}_debug") + endif (WIN32) + else (${libtype} MATCHES "SHARED") + if (WIN32) + set (LIB_RELEASE_NAME "lib${libname}") + set (LIB_DEBUG_NAME "lib${libname}_D") + else (WIN32) + set (LIB_RELEASE_NAME "${libname}") + set (LIB_DEBUG_NAME "${libname}_debug") + endif (WIN32) + endif (${libtype} MATCHES "SHARED") + + set_target_properties (${libtarget} + PROPERTIES + OUTPUT_NAME_DEBUG ${LIB_DEBUG_NAME} + OUTPUT_NAME_RELEASE ${LIB_RELEASE_NAME} + OUTPUT_NAME_MINSIZEREL ${LIB_RELEASE_NAME} + OUTPUT_NAME_RELWITHDEBINFO ${LIB_RELEASE_NAME} + ) + + #----- Use MSVC Naming conventions for Shared Libraries + if (MINGW AND ${libtype} MATCHES "SHARED") + set_target_properties (${libtarget} + PROPERTIES + IMPORT_SUFFIX ".lib" + IMPORT_PREFIX "" + PREFIX "" + ) + endif (MINGW AND ${libtype} MATCHES "SHARED") + +endmacro (HDF_SET_LIB_OPTIONS) + +#------------------------------------------------------------------------------- +macro (HDF_IMPORT_SET_LIB_OPTIONS libtarget libname libtype libversion) + HDF_SET_LIB_OPTIONS (${libtarget} ${libname} ${libtype}) + + if (${importtype} MATCHES "IMPORT") + set (importprefix "${CMAKE_STATIC_LIBRARY_PREFIX}") + endif (${importtype} MATCHES "IMPORT") + if (${CMAKE_BUILD_TYPE} MATCHES "Debug") + set (IMPORT_LIB_NAME ${LIB_DEBUG_NAME}) + else (${CMAKE_BUILD_TYPE} MATCHES "Debug") + set (IMPORT_LIB_NAME ${LIB_RELEASE_NAME}) + endif (${CMAKE_BUILD_TYPE} MATCHES "Debug") + + if (${libtype} MATCHES "SHARED") + if (WIN32) + if (MINGW) + set_target_properties (${libtarget} PROPERTIES + IMPORTED_IMPLIB "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${IMPORT_LIB_NAME}.lib" + IMPORTED_LOCATION "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${IMPORT_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}" + ) + else (MINGW) + set_target_properties (${libtarget} PROPERTIES + IMPORTED_IMPLIB "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/${CMAKE_IMPORT_LIBRARY_PREFIX}${IMPORT_LIB_NAME}${CMAKE_IMPORT_LIBRARY_SUFFIX}" + IMPORTED_LOCATION "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/${CMAKE_IMPORT_LIBRARY_PREFIX}${IMPORT_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}" + ) + endif (MINGW) + else (WIN32) + if (CYGWIN) + set_target_properties (${libtarget} PROPERTIES + IMPORTED_IMPLIB "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_IMPORT_LIBRARY_PREFIX}${IMPORT_LIB_NAME}${CMAKE_IMPORT_LIBRARY_SUFFIX}" + IMPORTED_LOCATION "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_IMPORT_LIBRARY_PREFIX}${IMPORT_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}" + ) + else (CYGWIN) + set_target_properties (${libtarget} PROPERTIES + IMPORTED_LOCATION "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_SHARED_LIBRARY_PREFIX}${IMPORT_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}" + IMPORTED_SONAME "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_SHARED_LIBRARY_PREFIX}${IMPORT_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}.${libversion}" + SOVERSION "${libversion}" + ) + endif (CYGWIN) + endif (WIN32) + else (${libtype} MATCHES "SHARED") + if (WIN32 AND NOT MINGW) + set_target_properties (${libtarget} PROPERTIES + IMPORTED_LOCATION "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_BUILD_TYPE}/${IMPORT_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + ) + else (WIN32 AND NOT MINGW) + set_target_properties (${libtarget} PROPERTIES + IMPORTED_LOCATION "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_STATIC_LIBRARY_PREFIX}${IMPORT_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}" + IMPORTED_LINK_INTERFACE_LANGUAGES "C" + ) + endif (WIN32 AND NOT MINGW) + endif (${libtype} MATCHES "SHARED") + +endmacro (HDF_IMPORT_SET_LIB_OPTIONS) + +#------------------------------------------------------------------------------- +macro (TARGET_C_PROPERTIES wintarget libtype addcompileflags addlinkflags) + if (MSVC) + TARGET_MSVC_PROPERTIES (${wintarget} ${libtype} "${addcompileflags} ${WIN_COMPILE_FLAGS}" "${addlinkflags} ${WIN_LINK_FLAGS}") + else (MSVC) + set_target_properties (${wintarget} + PROPERTIES + COMPILE_FLAGS "${addcompileflags}" + LINK_FLAGS "${addlinkflags}" + ) + endif (MSVC) +endmacro (TARGET_C_PROPERTIES) + +#------------------------------------------------------------------------------- +macro (TARGET_MSVC_PROPERTIES wintarget libtype addcompileflags addlinkflags) + if (MSVC) + set_target_properties (${wintarget} + PROPERTIES + COMPILE_FLAGS "${addcompileflags}" + LINK_FLAGS "${addlinkflags}" + ) + endif (MSVC) +endmacro (TARGET_MSVC_PROPERTIES) + +#------------------------------------------------------------------------------- +macro (TARGET_FORTRAN_PROPERTIES forttarget libtype addcompileflags addlinkflags) + if (WIN32) + TARGET_FORTRAN_WIN_PROPERTIES (${forttarget} ${libtype} "${addcompileflags} ${WIN_COMPILE_FLAGS}" "${addlinkflags} ${WIN_LINK_FLAGS}") + endif (WIN32) +endmacro (TARGET_FORTRAN_PROPERTIES) + +#------------------------------------------------------------------------------- +macro (TARGET_FORTRAN_WIN_PROPERTIES forttarget libtype addcompileflags addlinkflags) + if (MSVC) + if (${libtype} MATCHES "SHARED") + set_target_properties (${forttarget} + PROPERTIES + COMPILE_FLAGS "/dll ${addcompileflags}" + LINK_FLAGS "/SUBSYSTEM:CONSOLE ${addlinkflags}" + ) + else (${libtype} MATCHES "SHARED") + set_target_properties (${forttarget} + PROPERTIES + COMPILE_FLAGS "${addcompileflags}" + LINK_FLAGS "/SUBSYSTEM:CONSOLE ${addlinkflags}" + ) + endif (${libtype} MATCHES "SHARED") + endif (MSVC) +endmacro (TARGET_FORTRAN_WIN_PROPERTIES) + +#----------------------------------------------------------------------------- +# Configure the README.txt file for the binary package +#----------------------------------------------------------------------------- +macro (HDF_README_PROPERTIES target_fortran) + set (BINARY_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}) + set (BINARY_PLATFORM "${CMAKE_SYSTEM_NAME}") + if (WIN32) + set (BINARY_EXAMPLE_ENDING "zip") + set (BINARY_INSTALL_ENDING "msi") + if (CMAKE_CL_64) + set (BINARY_SYSTEM_NAME "win64") + else (CMAKE_CL_64) + set (BINARY_SYSTEM_NAME "win32") + endif (CMAKE_CL_64) + if (${CMAKE_SYSTEM_VERSION} MATCHES "6.1") + set (BINARY_PLATFORM "${BINARY_PLATFORM} 7") + elseif (${CMAKE_SYSTEM_VERSION} MATCHES "6.2") + set (BINARY_PLATFORM "${BINARY_PLATFORM} 8") + endif (${CMAKE_SYSTEM_VERSION} MATCHES "6.1") + set (BINARY_PLATFORM "${BINARY_PLATFORM} ${MSVC_C_ARCHITECTURE_ID}") + if (${CMAKE_C_COMPILER_VERSION} MATCHES "16.*") + set (BINARY_PLATFORM "${BINARY_PLATFORM}, using VISUAL STUDIO 2010") + elseif (${CMAKE_C_COMPILER_VERSION} MATCHES "15.*") + set (BINARY_PLATFORM "${BINARY_PLATFORM}, using VISUAL STUDIO 2008") + elseif (${CMAKE_C_COMPILER_VERSION} MATCHES "17.*") + set (BINARY_PLATFORM "${BINARY_PLATFORM}, using VISUAL STUDIO 2012") + elseif (${CMAKE_C_COMPILER_VERSION} MATCHES "18.*") + set (BINARY_PLATFORM "${BINARY_PLATFORM}, using VISUAL STUDIO 2013") + else (${CMAKE_C_COMPILER_VERSION} MATCHES "16.*") + set (BINARY_PLATFORM "${BINARY_PLATFORM}, using VISUAL STUDIO ${CMAKE_C_COMPILER_VERSION}") + endif (${CMAKE_C_COMPILER_VERSION} MATCHES "16.*") + elseif (APPLE) + set (BINARY_EXAMPLE_ENDING "tar.gz") + set (BINARY_INSTALL_ENDING "dmg") + set (BINARY_PLATFORM "${BINARY_PLATFORM} ${CMAKE_SYSTEM_VERSION} ${CMAKE_SYSTEM_PROCESSOR}") + set (BINARY_PLATFORM "${BINARY_PLATFORM}, using ${CMAKE_C_COMPILER_ID} C ${CMAKE_C_COMPILER_VERSION}") + else (WIN32) + set (BINARY_EXAMPLE_ENDING "tar.gz") + set (BINARY_INSTALL_ENDING "sh") + set (BINARY_PLATFORM "${BINARY_PLATFORM} ${CMAKE_SYSTEM_VERSION} ${CMAKE_SYSTEM_PROCESSOR}") + set (BINARY_PLATFORM "${BINARY_PLATFORM}, using ${CMAKE_C_COMPILER_ID} C ${CMAKE_C_COMPILER_VERSION}") + endif (WIN32) + + if (target_fortran) + set (BINARY_PLATFORM "${BINARY_PLATFORM} / ${CMAKE_Fortran_COMPILER_ID} Fortran") + endif (target_fortran) + + if (BUILD_SHARED_LIBS) + set (LIB_TYPE "Static and Shared") + else (BUILD_SHARED_LIBS) + set (LIB_TYPE "Static") + endif (BUILD_SHARED_LIBS) + + configure_file ( + ${HDF_RESOURCES_DIR}/README.txt.cmake.in + ${CMAKE_BINARY_DIR}/README.txt @ONLY + ) +endmacro (HDF_README_PROPERTIES) diff --git a/config/cmake_ext_mod/HDFTests.c b/config/cmake_ext_mod/HDFTests.c new file mode 100644 index 0000000..1c23ac3 --- /dev/null +++ b/config/cmake_ext_mod/HDFTests.c @@ -0,0 +1,466 @@ +#define SIMPLE_TEST(x) int main(){ x; return 0; } + +#ifdef HAVE_C99_DESIGNATED_INITIALIZER + +#ifdef FC_DUMMY_MAIN +#ifndef FC_DUMMY_MAIN_EQ_F77 +# ifdef __cplusplus +extern "C" +# endif +int FC_DUMMY_MAIN() +{ return 1;} +#endif +#endif +int +main () +{ + + typedef struct + { + int x; + union + { + int i; + double d; + }u; + }di_struct_t; + di_struct_t x = + { 0, + { .d = 0.0}}; + ; + return 0; +} + +#endif + +#ifdef HAVE_C99_FUNC + +#ifdef FC_DUMMY_MAIN +#ifndef FC_DUMMY_MAIN_EQ_F77 +# ifdef __cplusplus + extern "C" +# endif + int FC_DUMMY_MAIN() { return 1; } +#endif +#endif +int +main () +{ + const char *fname = __func__; + ; + return 0; +} + +#endif + +#ifdef VSNPRINTF_WORKS +#include +#include +#include + +int test_vsnprintf(const char *fmt,...) +{ + va_list ap; + char *s = malloc(16); + int ret; + + va_start(ap, fmt); + ret=vsnprintf(s,16,"%s",ap); + va_end(ap); + + return(ret!=42 ? 1 : 0); +} + +int main(void) +{ + return(test_vsnprintf("%s","A string that is longer than 16 characters")); +} +#endif + + +#ifdef TIME_WITH_SYS_TIME +/* Time with sys/time test */ + +#include +#include +#include + +int +main () +{ +if ((struct tm *) 0) +return 0; + ; + return 0; +} + +#endif + +#ifdef STDC_HEADERS +#include +#include +#include +#include +int main() { return 0; } +#endif /* STDC_HEADERS */ + + +#ifdef HAVE_ATTRIBUTE + +#if 0 +static void test int __attribute((unused)) var) +{ + int __attribute__((unused)) x = var; +} + +int main(void) +{ + test(19); +} + +#else +int +main () +{ +int __attribute__((unused)) x + ; + return 0; +} +#endif + + +#endif /* HAVE_ATTRIBUTE */ + +#ifdef HAVE_FUNCTION + +#ifdef FC_DUMMY_MAIN +#ifndef FC_DUMMY_MAIN_EQ_F77 +# ifdef __cplusplus + extern "C" +# endif + int FC_DUMMY_MAIN() { return 1; } +#endif +#endif +int +main () +{ +(void)__FUNCTION__ + ; + return 0; +} + +#endif /* HAVE_FUNCTION */ + +#ifdef HAVE_TM_GMTOFF + +#ifdef HAVE_SYS_TIME_H +#include +#endif +#include +SIMPLE_TEST(struct tm tm; tm.tm_gmtoff=0); + +#endif /* HAVE_TM_GMTOFF */ + +#ifdef HAVE___TM_GMTOFF + +#ifdef HAVE_SYS_TIME_H +#include +#endif +#include +SIMPLE_TEST(struct tm tm; tm.__tm_gmtoff=0); + +#endif /* HAVE_TM_GMTOFF */ + +#ifdef HAVE_TIMEZONE + +#ifdef HAVE_SYS_TIME_H +#include +#endif +#include +SIMPLE_TEST(timezone=0); + +#endif /* HAVE_TIMEZONE */ + +#ifdef HAVE_STRUCT_TIMEZONE + +#include +#ifdef HAVE_SYS_TIME_H +#include +#endif +#include +SIMPLE_TEST(struct timezone tz; tz.tz_minuteswest=0); + +#endif /* HAVE_STRUCT_TIMEZONE */ + +#ifdef HAVE_STAT_ST_BLOCKS + +#include +SIMPLE_TEST(struct stat sb; sb.st_blocks=0); + +#endif /* HAVE_STAT_ST_BLOCKS */ + +#ifdef PRINTF_LL_WIDTH + +#ifdef HAVE_LONG_LONG +# define LL_TYPE long long +#else /* HAVE_LONG_LONG */ +# define LL_TYPE __int64 +#endif /* HAVE_LONG_LONG */ + +#include +#include +#include + +int main(void) +{ + char *llwidthArgs[] = { "l64", "l", "L", "q", "ll", NULL }; + char *s = malloc(128); + char **currentArg = NULL; + LL_TYPE x = (LL_TYPE)1048576 * (LL_TYPE)1048576; + for (currentArg = llwidthArgs; *currentArg != NULL; currentArg++) + { + char formatString[64]; + sprintf(formatString, "%%%sd", *currentArg); + sprintf(s, formatString, x); + if (strcmp(s, "1099511627776") == 0) + { + printf("PRINTF_LL_WIDTH=[%s]\n", *currentArg); + return 0; + } + } + return 1; +} + +#endif /* PRINTF_LL_WIDTH */ + +#ifdef SYSTEM_SCOPE_THREADS +#include +#include + +int main(void) +{ + pthread_attr_t attribute; + int ret; + + pthread_attr_init(&attribute); + ret=pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM); + if (ret==0) + return 0; + return 1; +} + +#endif /* SYSTEM_SCOPE_THREADS */ + +#ifdef HAVE_SOCKLEN_T + +#include +#include +#ifdef HAVE_UNISTD_H +#include +#endif +#ifdef HAVE_SYS_TYPES_H +#include +#endif +#ifdef HAVE_SYS_SOCKET_H +#include +#endif + +SIMPLE_TEST(socklen_t foo); + +#endif /* HAVE_SOCKLEN_T */ + +#ifdef DEV_T_IS_SCALAR + +#ifdef HAVE_SYS_TYPES_H +#include +#endif + +int main () +{ + dev_t d1, d2; + if(d1==d2) + return 0; + return 1; +} + +#endif /* DEV_T_IS_SCALAR */ + +#ifdef HAVE_OFF64_T +#include +int main() +{ + off64_t n = 0; + return (int)n; +} +#endif + +#ifdef HAVE_STAT64_STRUCT +#include +#include ], +struct stat64 sb; +int main() +{ + return 0; +} +#endif + +#ifdef TEST_DIRECT_VFD_WORKS +#include +#include +#include +int main(void) +{ + int fid; + if((fid=open("tst_file", O_CREAT | O_TRUNC | O_DIRECT, 0755))<0) + return 1; + close(fid); + remove("tst_file"); + return 0; +} +#endif + +#ifdef HAVE_DIRECT + SIMPLE_TEST(posix_memalign()); +#endif + +#ifdef HAVE_DEFAULT_SOURCE +/* check default source */ +#include + +int +main(void) +{ +#ifdef __GLIBC_PREREQ + return __GLIBC_PREREQ(2,19); +#else + return 0; +#endif /* defined(__GLIBC_PREREQ) */ +} +#endif + +#ifdef TEST_LFS_WORKS +/* Return 0 when LFS is available and 1 otherwise. */ +#define _LARGEFILE_SOURCE +#define _LARGEFILE64_SOURCE +#define _LARGE_FILES +#define _FILE_OFFSET_BITS 64 +#include +#include +#include +#include + +int main(int argc, char **argv) +{ + /* check that off_t can hold 2^63 - 1 and perform basic operations... */ +#define OFF_T_64 (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) + if (OFF_T_64 % 2147483647 != 1) + return 1; + + /* stat breaks on SCO OpenServer */ + struct stat buf; + stat( argv[0], &buf ); + if (!S_ISREG(buf.st_mode)) + return 2; + + FILE *file = fopen( argv[0], "r" ); + off_t offset = ftello( file ); + fseek( file, offset, SEEK_CUR ); + fclose( file ); + return 0; +} +#endif + +#ifdef GETTIMEOFDAY_GIVES_TZ +#include +#ifdef HAVE_SYS_TIME_H +#include +#endif +int main(void) +{ + struct timeval tv; + struct timezone tz; + tz.tz_minuteswest = 7777; /* Initialize to an unreasonable number */ + tz.tz_dsttime = 7; + gettimeofday(&tv, &tz); + /* Check whether the function returned any value at all */ + if(tz.tz_minuteswest == 7777 && tz.tz_dsttime == 7) + return 1; + else return 0; +} +#endif + +#ifdef CXX_HAVE_OFFSETOF + +#include +#include + +#ifdef FC_DUMMY_MAIN +#ifndef FC_DUMMY_MAIN_EQ_F77 +# ifdef __cplusplus +extern "C" +# endif +int FC_DUMMY_MAIN() +{ return 1;} +#endif +#endif +int +main () +{ + + struct index_st + { + unsigned char type; + unsigned char num; + unsigned int len; + }; + typedef struct index_st index_t; + int x,y; + x = offsetof(struct index_st, len); + y = offsetof(index_t, num) + + ; + return 0; +} + +#endif + +#ifdef HAVE_IOEO + +#include +typedef void (WINAPI *PGNSI)(LPSYSTEM_INFO); +int main () +{ + PGNSI pGNSI; + pGNSI = (PGNSI) GetProcAddress( + GetModuleHandle(TEXT("kernel32.dll")), + "InitOnceExecuteOnce"); + if(NULL == pGNSI) + return 1; + else + return 0; +} + +#endif /* HAVE_IOEO */ + +#ifdef HAVE_STRUCT_VIDEOCONFIG + +SIMPLE_TEST(struct videoconfig w; w.numtextcols=0); + +#endif /* HAVE_TM_GMTOFF */ + +#ifdef HAVE_STRUCT_TEXT_INFO + +SIMPLE_TEST(struct text_info w; w.screenwidth=0); + +#endif /* HAVE_TM_GMTOFF */ + + +#if defined( INLINE_TEST_inline ) || defined( INLINE_TEST___inline__ ) || defined( INLINE_TEST___inline ) +#ifndef __cplusplus +typedef int foo_t; +static INLINE_TEST_INLINE foo_t static_foo () { return 0; } +INLINE_TEST_INLINE foo_t foo () {return 0; } +int main() { return 0; } +#endif + +#endif /* INLINE_TEST */ diff --git a/config/cmake_ext_mod/HDFUseFortran.cmake b/config/cmake_ext_mod/HDFUseFortran.cmake new file mode 100644 index 0000000..66a631f --- /dev/null +++ b/config/cmake_ext_mod/HDFUseFortran.cmake @@ -0,0 +1,176 @@ +# +# This file provides functions for Fortran support. +# +#------------------------------------------------------------------------------- +ENABLE_LANGUAGE (Fortran) + +#----------------------------------------------------------------------------- +# Detect name mangling convention used between Fortran and C +#----------------------------------------------------------------------------- +include (FortranCInterface) +FortranCInterface_HEADER ( + ${CMAKE_BINARY_DIR}/FCMangle.h + MACRO_NAMESPACE "H5_FC_" + SYMBOL_NAMESPACE "H5_FC_" + SYMBOLS mysub mymod:my_sub +) + +file (STRINGS ${CMAKE_BINARY_DIR}/FCMangle.h CONTENTS REGEX "H5_FC_GLOBAL\\(.*,.*\\) +(.*)") +string (REGEX MATCH "H5_FC_GLOBAL\\(.*,.*\\) +(.*)" RESULT ${CONTENTS}) +set (H5_FC_FUNC "H5_FC_FUNC(name,NAME) ${CMAKE_MATCH_1}") + +file (STRINGS ${CMAKE_BINARY_DIR}/FCMangle.h CONTENTS REGEX "H5_FC_GLOBAL_\\(.*,.*\\) +(.*)") +string (REGEX MATCH "H5_FC_GLOBAL_\\(.*,.*\\) +(.*)" RESULT ${CONTENTS}) +set (H5_FC_FUNC_ "H5_FC_FUNC_(name,NAME) ${CMAKE_MATCH_1}") + +#----------------------------------------------------------------------------- +# The provided CMake Fortran macros don't provide a general check function +# so this one is used for a sizeof test. +#----------------------------------------------------------------------------- +MACRO (CHECK_FORTRAN_FEATURE FUNCTION CODE VARIABLE) + if (NOT DEFINED ${VARIABLE}) + message (STATUS "Testing Fortran ${FUNCTION}") + if (CMAKE_REQUIRED_LIBRARIES) + set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES + "-DLINK_LIBRARIES:STRING=${CMAKE_REQUIRED_LIBRARIES}") + else (CMAKE_REQUIRED_LIBRARIES) + set (CHECK_FUNCTION_EXISTS_ADD_LIBRARIES) + endif (CMAKE_REQUIRED_LIBRARIES) + file (WRITE + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f90 + "${CODE}" + ) + TRY_COMPILE (${VARIABLE} + ${CMAKE_BINARY_DIR} + ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/testFortranCompiler.f90 + CMAKE_FLAGS "${CHECK_FUNCTION_EXISTS_ADD_LIBRARIES}" + OUTPUT_VARIABLE OUTPUT + ) + +# message ( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") +# message ( "Test result ${OUTPUT}") +# message ( "* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * ") + + if (${VARIABLE}) + set (${VARIABLE} 1 CACHE INTERNAL "Have Fortran function ${FUNCTION}") + message (STATUS "Testing Fortran ${FUNCTION} - OK") + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log + "Determining if the Fortran ${FUNCTION} exists passed with the following output:\n" + "${OUTPUT}\n\n" + ) + else (${VARIABLE}) + message (STATUS "Testing Fortran ${FUNCTION} - Fail") + set (${VARIABLE} "" CACHE INTERNAL "Have Fortran function ${FUNCTION}") + file (APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log + "Determining if the Fortran ${FUNCTION} exists failed with the following output:\n" + "${OUTPUT}\n\n") + endif (${VARIABLE}) + endif (NOT DEFINED ${VARIABLE}) +ENDMACRO (CHECK_FORTRAN_FEATURE) + +#----------------------------------------------------------------------------- +# Configure Checks which require Fortran compilation must go in here +# not in the main ConfigureChecks.cmake files, because if the user has +# no Fortran compiler, problems arise. +# +# Be careful with leading spaces here, do not remove them. +#----------------------------------------------------------------------------- + +# Check for Non-standard extension intrinsic function SIZEOF +CHECK_FORTRAN_FEATURE(sizeof + " + PROGRAM main + i = sizeof(x) + END PROGRAM + " + FORTRAN_HAVE_SIZEOF +) + +# Check for F2008 standard intrinsic function C_SIZEOF +CHECK_FORTRAN_FEATURE(c_sizeof + " + PROGRAM main + USE ISO_C_BINDING + INTEGER(C_INT) :: a + INTEGER(C_SIZE_T) :: result + result = c_sizeof(a) + END PROGRAM + " + FORTRAN_HAVE_C_SIZEOF +) + +# Check for F2008 standard intrinsic function STORAGE_SIZE +CHECK_FORTRAN_FEATURE(storage_size + " + PROGRAM main + INTEGER :: a + INTEGER :: result + result = storage_size(a) + END PROGRAM + " + FORTRAN_HAVE_STORAGE_SIZE +) + +# Check for F2008 standard intrinsic module "ISO_FORTRAN_ENV" +CHECK_FORTRAN_FEATURE(ISO_FORTRAN_ENV + " + PROGRAM main + USE, INTRINSIC :: ISO_FORTRAN_ENV + END PROGRAM + " + HAVE_ISO_FORTRAN_ENV +) + +CHECK_FORTRAN_FEATURE(RealIsNotDouble + " + MODULE type_mod + INTERFACE h5t + MODULE PROCEDURE h5t_real + MODULE PROCEDURE h5t_dble + END INTERFACE + CONTAINS + SUBROUTINE h5t_real(r) + REAL :: r + END SUBROUTINE h5t_real + SUBROUTINE h5t_dble(d) + DOUBLE PRECISION :: d + END SUBROUTINE h5t_dble + END MODULE type_mod + PROGRAM main + USE type_mod + REAL :: r + DOUBLE PRECISION :: d + CALL h5t(r) + CALL h5t(d) + END PROGRAM main + " + FORTRAN_DEFAULT_REAL_NOT_DOUBLE +) + +#----------------------------------------------------------------------------- +# Checks if the ISO_C_BINDING module meets all the requirements +#----------------------------------------------------------------------------- +CHECK_FORTRAN_FEATURE(iso_c_binding + " + PROGRAM main + USE iso_c_binding + IMPLICIT NONE + TYPE(C_PTR) :: ptr + TYPE(C_FUNPTR) :: funptr + INTEGER(C_INT64_T) :: c_int64_type + CHARACTER(LEN=80, KIND=c_char), TARGET :: ichr + ptr = C_LOC(ichr(1:1)) + END PROGRAM + " + FORTRAN_HAVE_ISO_C_BINDING +) + +#----------------------------------------------------------------------------- +# Add debug information (intel Fortran : JB) +#----------------------------------------------------------------------------- +if (CMAKE_Fortran_COMPILER MATCHES ifort) + if (WIN32) + set (CMAKE_Fortran_FLAGS_DEBUG "/debug:full /dbglibs " CACHE "flags" STRING FORCE) + set (CMAKE_EXE_LINKER_FLAGS_DEBUG "/DEBUG" CACHE "flags" STRING FORCE) + endif (WIN32) +endif (CMAKE_Fortran_COMPILER MATCHES ifort) diff --git a/config/cmake_ext_mod/NSIS.InstallOptions.ini.in b/config/cmake_ext_mod/NSIS.InstallOptions.ini.in new file mode 100644 index 0000000..9954f28 --- /dev/null +++ b/config/cmake_ext_mod/NSIS.InstallOptions.ini.in @@ -0,0 +1,37 @@ +[Settings] +NumFields=5 + +[Field 1] +Type=label +Text=By default the @CPACK_PACKAGE_NAME@ bin directory is added to the system PATH. This allows shared library (dll) discovery (if installed) and running HDF5 tools from the command line. +Left=0 +Right=-1 +Top=0 +Bottom=20 + +[Field 2] +Type=radiobutton +Text=Do not add @CPACK_PACKAGE_NAME@ to the system PATH +Left=0 +Right=-1 +Top=30 +Bottom=40 +State=0 + +[Field 3] +Type=radiobutton +Text=Add @CPACK_PACKAGE_NAME@ to the system PATH for all users +Left=0 +Right=-1 +Top=40 +Bottom=50 +State=1 + +[Field 4] +Type=radiobutton +Text=Add @CPACK_PACKAGE_NAME@ to the system PATH for current user +Left=0 +Right=-1 +Top=50 +Bottom=60 +State=0 diff --git a/config/cmake_ext_mod/NSIS.template.in b/config/cmake_ext_mod/NSIS.template.in new file mode 100644 index 0000000..ecced05 --- /dev/null +++ b/config/cmake_ext_mod/NSIS.template.in @@ -0,0 +1,974 @@ +; CPack install script designed for a nmake build + +;-------------------------------- +; You must define these values + + !define VERSION "@CPACK_PACKAGE_VERSION@" + !define PATCH "@CPACK_PACKAGE_VERSION_PATCH@" + !define INST_DIR "@CPACK_TEMPORARY_DIRECTORY@" + +;-------------------------------- +;Variables + + Var MUI_TEMP + Var STARTMENU_FOLDER + Var SV_ALLUSERS + Var START_MENU + Var DO_NOT_ADD_TO_PATH + Var ADD_TO_PATH_ALL_USERS + Var ADD_TO_PATH_CURRENT_USER + Var INSTALL_DESKTOP + Var IS_DEFAULT_INSTALLDIR +;-------------------------------- +;Include Modern UI + + !include "MUI.nsh" + + ;Default installation folder + InstallDir "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" + +;-------------------------------- +;General + + ;Name and file + Name "@CPACK_NSIS_PACKAGE_NAME@" + OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@" + + ;Set compression + SetCompressor @CPACK_NSIS_COMPRESSOR@ + +@CPACK_NSIS_DEFINES@ + + !include Sections.nsh + +;--- Component support macros: --- +; The code for the add/remove functionality is from: +; http://nsis.sourceforge.net/Add/Remove_Functionality +; It has been modified slightly and extended to provide +; inter-component dependencies. +Var AR_SecFlags +Var AR_RegFlags +@CPACK_NSIS_SECTION_SELECTED_VARS@ + +; Loads the "selected" flag for the section named SecName into the +; variable VarName. +!macro LoadSectionSelectedIntoVar SecName VarName + SectionGetFlags ${${SecName}} $${VarName} + IntOp $${VarName} $${VarName} & ${SF_SELECTED} ;Turn off all other bits +!macroend + +; Loads the value of a variable... can we get around this? +!macro LoadVar VarName + IntOp $R0 0 + $${VarName} +!macroend + +; Sets the value of a variable +!macro StoreVar VarName IntValue + IntOp $${VarName} 0 + ${IntValue} +!macroend + +!macro InitSection SecName + ; This macro reads component installed flag from the registry and + ;changes checked state of the section on the components page. + ;Input: section index constant name specified in Section command. + + ClearErrors + ;Reading component status from registry + ReadRegDWORD $AR_RegFlags HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" "Installed" + IfErrors "default_${SecName}" + ;Status will stay default if registry value not found + ;(component was never installed) + IntOp $AR_RegFlags $AR_RegFlags & ${SF_SELECTED} ;Turn off all other bits + SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading default section flags + IntOp $AR_SecFlags $AR_SecFlags & 0xFFFE ;Turn lowest (enabled) bit off + IntOp $AR_SecFlags $AR_RegFlags | $AR_SecFlags ;Change lowest bit + + ; Note whether this component was installed before + !insertmacro StoreVar ${SecName}_was_installed $AR_RegFlags + IntOp $R0 $AR_RegFlags & $AR_RegFlags + + ;Writing modified flags + SectionSetFlags ${${SecName}} $AR_SecFlags + + "default_${SecName}:" + !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected +!macroend + +!macro FinishSection SecName + ; This macro reads section flag set by user and removes the section + ;if it is not selected. + ;Then it writes component installed flag to registry + ;Input: section index constant name specified in Section command. + + SectionGetFlags ${${SecName}} $AR_SecFlags ;Reading section flags + ;Checking lowest bit: + IntOp $AR_SecFlags $AR_SecFlags & ${SF_SELECTED} + IntCmp $AR_SecFlags 1 "leave_${SecName}" + ;Section is not selected: + ;Calling Section uninstall macro and writing zero installed flag + !insertmacro "Remove_${${SecName}}" + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \ + "Installed" 0 + Goto "exit_${SecName}" + + "leave_${SecName}:" + ;Section is selected: + WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@\Components\${SecName}" \ + "Installed" 1 + + "exit_${SecName}:" +!macroend + +!macro RemoveSection_CPack SecName + ; This macro is used to call section's Remove_... macro + ;from the uninstaller. + ;Input: section index constant name specified in Section command. + + !insertmacro "Remove_${${SecName}}" +!macroend + +; Determine whether the selection of SecName changed +!macro MaybeSelectionChanged SecName + !insertmacro LoadVar ${SecName}_selected + SectionGetFlags ${${SecName}} $R1 + IntOp $R1 $R1 & ${SF_SELECTED} ;Turn off all other bits + + ; See if the status has changed: + IntCmp $R0 $R1 "${SecName}_unchanged" + !insertmacro LoadSectionSelectedIntoVar ${SecName} ${SecName}_selected + + IntCmp $R1 ${SF_SELECTED} "${SecName}_was_selected" + !insertmacro "Deselect_required_by_${SecName}" + goto "${SecName}_unchanged" + + "${SecName}_was_selected:" + !insertmacro "Select_${SecName}_depends" + + "${SecName}_unchanged:" +!macroend +;--- End of Add/Remove macros --- + +;-------------------------------- +;Interface Settings + + !define MUI_HEADERIMAGE + !define MUI_ABORTWARNING + +;-------------------------------- +; path functions + +!verbose 3 +!include "WinMessages.NSH" +!verbose 4 + +;---------------------------------------- +; based upon a script of "Written by KiCHiK 2003-01-18 05:57:02" +;---------------------------------------- +!verbose 3 +!include "WinMessages.NSH" +!verbose 4 +;==================================================== +; get_NT_environment +; Returns: the selected environment +; Output : head of the stack +;==================================================== +!macro select_NT_profile UN +Function ${UN}select_NT_profile + StrCmp $ADD_TO_PATH_ALL_USERS "1" 0 environment_single + DetailPrint "Selected environment for all users" + Push "all" + Return + environment_single: + DetailPrint "Selected environment for current user only." + Push "current" + Return +FunctionEnd +!macroend +!insertmacro select_NT_profile "" +!insertmacro select_NT_profile "un." +;---------------------------------------------------- +!define NT_current_env 'HKCU "Environment"' +!define NT_all_env 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' + +!ifndef WriteEnvStr_RegKey + !ifdef ALL_USERS + !define WriteEnvStr_RegKey \ + 'HKLM "SYSTEM\CurrentControlSet\Control\Session Manager\Environment"' + !else + !define WriteEnvStr_RegKey 'HKCU "Environment"' + !endif +!endif + +; AddToPath - Adds the given dir to the search path. +; Input - head of the stack +; Note - Win9x systems requires reboot + +Function AddToPath + Exch $0 + Push $1 + Push $2 + Push $3 + + # don't add if the path doesn't exist + IfFileExists "$0\*.*" "" AddToPath_done + + ReadEnvStr $1 PATH + ; if the path is too long for a NSIS variable NSIS will return a 0 + ; length string. If we find that, then warn and skip any path + ; modification as it will trash the existing path. + StrLen $2 $1 + IntCmp $2 0 CheckPathLength_ShowPathWarning CheckPathLength_Done CheckPathLength_Done + CheckPathLength_ShowPathWarning: + Messagebox MB_OK|MB_ICONEXCLAMATION "Warning! PATH too long installer unable to modify PATH!" + Goto AddToPath_done + CheckPathLength_Done: + Push "$1;" + Push "$0;" + Call StrStr + Pop $2 + StrCmp $2 "" "" AddToPath_done + Push "$1;" + Push "$0\;" + Call StrStr + Pop $2 + StrCmp $2 "" "" AddToPath_done + GetFullPathName /SHORT $3 $0 + Push "$1;" + Push "$3;" + Call StrStr + Pop $2 + StrCmp $2 "" "" AddToPath_done + Push "$1;" + Push "$3\;" + Call StrStr + Pop $2 + StrCmp $2 "" "" AddToPath_done + + Call IsNT + Pop $1 + StrCmp $1 1 AddToPath_NT + ; Not on NT + StrCpy $1 $WINDIR 2 + FileOpen $1 "$1\autoexec.bat" a + FileSeek $1 -1 END + FileReadByte $1 $2 + IntCmp $2 26 0 +2 +2 # DOS EOF + FileSeek $1 -1 END # write over EOF + FileWrite $1 "$\r$\nSET PATH=%PATH%;$3$\r$\n" + FileClose $1 + SetRebootFlag true + Goto AddToPath_done + + AddToPath_NT: + StrCmp $ADD_TO_PATH_ALL_USERS "1" ReadAllKey + ReadRegStr $1 ${NT_current_env} "PATH" + Goto DoTrim + ReadAllKey: + ReadRegStr $1 ${NT_all_env} "PATH" + DoTrim: + StrCmp $1 "" AddToPath_NTdoIt + Push $1 + Call Trim + Pop $1 + StrCpy $0 "$1;$0" + AddToPath_NTdoIt: + StrCmp $ADD_TO_PATH_ALL_USERS "1" WriteAllKey + WriteRegExpandStr ${NT_current_env} "PATH" $0 + Goto DoSend + WriteAllKey: + WriteRegExpandStr ${NT_all_env} "PATH" $0 + DoSend: + SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 + + AddToPath_done: + Pop $3 + Pop $2 + Pop $1 + Pop $0 +FunctionEnd + + +; RemoveFromPath - Remove a given dir from the path +; Input: head of the stack + +Function un.RemoveFromPath + Exch $0 + Push $1 + Push $2 + Push $3 + Push $4 + Push $5 + Push $6 + + IntFmt $6 "%c" 26 # DOS EOF + + Call un.IsNT + Pop $1 + StrCmp $1 1 unRemoveFromPath_NT + ; Not on NT + StrCpy $1 $WINDIR 2 + FileOpen $1 "$1\autoexec.bat" r + GetTempFileName $4 + FileOpen $2 $4 w + GetFullPathName /SHORT $0 $0 + StrCpy $0 "SET PATH=%PATH%;$0" + Goto unRemoveFromPath_dosLoop + + unRemoveFromPath_dosLoop: + FileRead $1 $3 + StrCpy $5 $3 1 -1 # read last char + StrCmp $5 $6 0 +2 # if DOS EOF + StrCpy $3 $3 -1 # remove DOS EOF so we can compare + StrCmp $3 "$0$\r$\n" unRemoveFromPath_dosLoopRemoveLine + StrCmp $3 "$0$\n" unRemoveFromPath_dosLoopRemoveLine + StrCmp $3 "$0" unRemoveFromPath_dosLoopRemoveLine + StrCmp $3 "" unRemoveFromPath_dosLoopEnd + FileWrite $2 $3 + Goto unRemoveFromPath_dosLoop + unRemoveFromPath_dosLoopRemoveLine: + SetRebootFlag true + Goto unRemoveFromPath_dosLoop + + unRemoveFromPath_dosLoopEnd: + FileClose $2 + FileClose $1 + StrCpy $1 $WINDIR 2 + Delete "$1\autoexec.bat" + CopyFiles /SILENT $4 "$1\autoexec.bat" + Delete $4 + Goto unRemoveFromPath_done + + unRemoveFromPath_NT: + StrCmp $ADD_TO_PATH_ALL_USERS "1" unReadAllKey + ReadRegStr $1 ${NT_current_env} "PATH" + Goto unDoTrim + unReadAllKey: + ReadRegStr $1 ${NT_all_env} "PATH" + unDoTrim: + StrCpy $5 $1 1 -1 # copy last char + StrCmp $5 ";" +2 # if last char != ; + StrCpy $1 "$1;" # append ; + Push $1 + Push "$0;" + Call un.StrStr ; Find `$0;` in $1 + Pop $2 ; pos of our dir + StrCmp $2 "" unRemoveFromPath_done + ; else, it is in path + # $0 - path to add + # $1 - path var + StrLen $3 "$0;" + StrLen $4 $2 + StrCpy $5 $1 -$4 # $5 is now the part before the path to remove + StrCpy $6 $2 "" $3 # $6 is now the part after the path to remove + StrCpy $3 $5$6 + + StrCpy $5 $3 1 -1 # copy last char + StrCmp $5 ";" 0 +2 # if last char == ; + StrCpy $3 $3 -1 # remove last char + + StrCmp $ADD_TO_PATH_ALL_USERS "1" unWriteAllKey + WriteRegExpandStr ${NT_current_env} "PATH" $3 + Goto unDoSend + unWriteAllKey: + WriteRegExpandStr ${NT_all_env} "PATH" $3 + unDoSend: + SendMessage ${HWND_BROADCAST} ${WM_WININICHANGE} 0 "STR:Environment" /TIMEOUT=5000 + + unRemoveFromPath_done: + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Pop $0 +FunctionEnd + +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +; Uninstall sutff +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +########################################### +# Utility Functions # +########################################### + +;==================================================== +; IsNT - Returns 1 if the current system is NT, 0 +; otherwise. +; Output: head of the stack +;==================================================== +; IsNT +; no input +; output, top of the stack = 1 if NT or 0 if not +; +; Usage: +; Call IsNT +; Pop $R0 +; ($R0 at this point is 1 or 0) + +!macro IsNT un +Function ${un}IsNT + Push $0 + ReadRegStr $0 HKLM "SOFTWARE\Microsoft\Windows NT\CurrentVersion" CurrentVersion + StrCmp $0 "" 0 IsNT_yes + ; we are not NT. + Pop $0 + Push 0 + Return + + IsNT_yes: + ; NT!!! + Pop $0 + Push 1 +FunctionEnd +!macroend +!insertmacro IsNT "" +!insertmacro IsNT "un." + +; StrStr +; input, top of stack = string to search for +; top of stack-1 = string to search in +; output, top of stack (replaces with the portion of the string remaining) +; modifies no other variables. +; +; Usage: +; Push "this is a long ass string" +; Push "ass" +; Call StrStr +; Pop $R0 +; ($R0 at this point is "ass string") + +!macro StrStr un +Function ${un}StrStr +Exch $R1 ; st=haystack,old$R1, $R1=needle + Exch ; st=old$R1,haystack + Exch $R2 ; st=old$R1,old$R2, $R2=haystack + Push $R3 + Push $R4 + Push $R5 + StrLen $R3 $R1 + StrCpy $R4 0 + ; $R1=needle + ; $R2=haystack + ; $R3=len(needle) + ; $R4=cnt + ; $R5=tmp + loop: + StrCpy $R5 $R2 $R3 $R4 + StrCmp $R5 $R1 done + StrCmp $R5 "" done + IntOp $R4 $R4 + 1 + Goto loop +done: + StrCpy $R1 $R2 "" $R4 + Pop $R5 + Pop $R4 + Pop $R3 + Pop $R2 + Exch $R1 +FunctionEnd +!macroend +!insertmacro StrStr "" +!insertmacro StrStr "un." + +Function Trim ; Added by Pelaca + Exch $R1 + Push $R2 +Loop: + StrCpy $R2 "$R1" 1 -1 + StrCmp "$R2" " " RTrim + StrCmp "$R2" "$\n" RTrim + StrCmp "$R2" "$\r" RTrim + StrCmp "$R2" ";" RTrim + GoTo Done +RTrim: + StrCpy $R1 "$R1" -1 + Goto Loop +Done: + Pop $R2 + Exch $R1 +FunctionEnd + +Function ConditionalAddToRegisty + Pop $0 + Pop $1 + StrCmp "$0" "" ConditionalAddToRegisty_EmptyString + WriteRegStr SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" \ + "$1" "$0" + ;MessageBox MB_OK "Set Registry: '$1' to '$0'" + DetailPrint "Set install registry entry: '$1' to '$0'" + ConditionalAddToRegisty_EmptyString: +FunctionEnd + +;-------------------------------- + +!ifdef CPACK_USES_DOWNLOAD +Function DownloadFile + IfFileExists $INSTDIR\* +2 + CreateDirectory $INSTDIR + Pop $0 + + ; Skip if already downloaded + IfFileExists $INSTDIR\$0 0 +2 + Return + + StrCpy $1 "@CPACK_DOWNLOAD_SITE@" + + try_again: + NSISdl::download "$1/$0" "$INSTDIR\$0" + + Pop $1 + StrCmp $1 "success" success + StrCmp $1 "Cancelled" cancel + MessageBox MB_OK "Download failed: $1" + cancel: + Return + success: +FunctionEnd +!endif + +;-------------------------------- +; Installation types +@CPACK_NSIS_INSTALLATION_TYPES@ + +;-------------------------------- +; Component sections +@CPACK_NSIS_COMPONENT_SECTIONS@ + +;-------------------------------- +; Define some macro setting for the gui +@CPACK_NSIS_INSTALLER_MUI_ICON_CODE@ +@CPACK_NSIS_INSTALLER_ICON_CODE@ +@CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@ +@CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE@ + +;-------------------------------- +;Pages + !insertmacro MUI_PAGE_WELCOME + + !insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@" + Page custom InstallOptionsPage + !insertmacro MUI_PAGE_DIRECTORY + + ;Start Menu Folder Page Configuration + !define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX" + !define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" + !define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder" + !insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER + + @CPACK_NSIS_PAGE_COMPONENTS@ + + !insertmacro MUI_PAGE_INSTFILES + !insertmacro MUI_PAGE_FINISH + + !insertmacro MUI_UNPAGE_CONFIRM + !insertmacro MUI_UNPAGE_INSTFILES + +;-------------------------------- +;Languages + + !insertmacro MUI_LANGUAGE "English" ;first language is the default language + !insertmacro MUI_LANGUAGE "Albanian" + !insertmacro MUI_LANGUAGE "Arabic" + !insertmacro MUI_LANGUAGE "Basque" + !insertmacro MUI_LANGUAGE "Belarusian" + !insertmacro MUI_LANGUAGE "Bosnian" + !insertmacro MUI_LANGUAGE "Breton" + !insertmacro MUI_LANGUAGE "Bulgarian" + !insertmacro MUI_LANGUAGE "Croatian" + !insertmacro MUI_LANGUAGE "Czech" + !insertmacro MUI_LANGUAGE "Danish" + !insertmacro MUI_LANGUAGE "Dutch" + !insertmacro MUI_LANGUAGE "Estonian" + !insertmacro MUI_LANGUAGE "Farsi" + !insertmacro MUI_LANGUAGE "Finnish" + !insertmacro MUI_LANGUAGE "French" + !insertmacro MUI_LANGUAGE "German" + !insertmacro MUI_LANGUAGE "Greek" + !insertmacro MUI_LANGUAGE "Hebrew" + !insertmacro MUI_LANGUAGE "Hungarian" + !insertmacro MUI_LANGUAGE "Icelandic" + !insertmacro MUI_LANGUAGE "Indonesian" + !insertmacro MUI_LANGUAGE "Irish" + !insertmacro MUI_LANGUAGE "Italian" + !insertmacro MUI_LANGUAGE "Japanese" + !insertmacro MUI_LANGUAGE "Korean" + !insertmacro MUI_LANGUAGE "Kurdish" + !insertmacro MUI_LANGUAGE "Latvian" + !insertmacro MUI_LANGUAGE "Lithuanian" + !insertmacro MUI_LANGUAGE "Luxembourgish" + !insertmacro MUI_LANGUAGE "Macedonian" + !insertmacro MUI_LANGUAGE "Malay" + !insertmacro MUI_LANGUAGE "Mongolian" + !insertmacro MUI_LANGUAGE "Norwegian" + !insertmacro MUI_LANGUAGE "Polish" + !insertmacro MUI_LANGUAGE "Portuguese" + !insertmacro MUI_LANGUAGE "PortugueseBR" + !insertmacro MUI_LANGUAGE "Romanian" + !insertmacro MUI_LANGUAGE "Russian" + !insertmacro MUI_LANGUAGE "Serbian" + !insertmacro MUI_LANGUAGE "SerbianLatin" + !insertmacro MUI_LANGUAGE "SimpChinese" + !insertmacro MUI_LANGUAGE "Slovak" + !insertmacro MUI_LANGUAGE "Slovenian" + !insertmacro MUI_LANGUAGE "Spanish" + !insertmacro MUI_LANGUAGE "Swedish" + !insertmacro MUI_LANGUAGE "Thai" + !insertmacro MUI_LANGUAGE "TradChinese" + !insertmacro MUI_LANGUAGE "Turkish" + !insertmacro MUI_LANGUAGE "Ukrainian" + !insertmacro MUI_LANGUAGE "Welsh" + + +;-------------------------------- +;Reserve Files + + ;These files should be inserted before other files in the data block + ;Keep these lines before any File command + ;Only for solid compression (by default, solid compression is enabled for BZIP2 and LZMA) + + ReserveFile "NSIS.InstallOptions.ini" + !insertmacro MUI_RESERVEFILE_INSTALLOPTIONS + +;-------------------------------- +;Installer Sections + +Section "-Core installation" + ;Use the entire tree produced by the INSTALL target. Keep the + ;list of directories here in sync with the RMDir commands below. + SetOutPath "$INSTDIR" + @CPACK_NSIS_EXTRA_PREINSTALL_COMMANDS@ + @CPACK_NSIS_FULL_INSTALL@ + + ;Store installation folder + WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR + + ;Create uninstaller + WriteUninstaller "$INSTDIR\Uninstall.exe" + Push "DisplayName" + Push "@CPACK_NSIS_DISPLAY_NAME@" + Call ConditionalAddToRegisty + Push "DisplayVersion" + Push "@CPACK_PACKAGE_VERSION@" + Call ConditionalAddToRegisty + Push "Publisher" + Push "@CPACK_PACKAGE_VENDOR@" + Call ConditionalAddToRegisty + Push "UninstallString" + Push "$INSTDIR\Uninstall.exe" + Call ConditionalAddToRegisty + Push "NoRepair" + Push "1" + Call ConditionalAddToRegisty + + !ifdef CPACK_NSIS_ADD_REMOVE + ;Create add/remove functionality + Push "ModifyPath" + Push "$INSTDIR\AddRemove.exe" + Call ConditionalAddToRegisty + !else + Push "NoModify" + Push "1" + Call ConditionalAddToRegisty + !endif + + ; Optional registration + Push "DisplayIcon" + Push "$INSTDIR\@CPACK_NSIS_INSTALLED_ICON_NAME@" + Call ConditionalAddToRegisty + Push "HelpLink" + Push "@CPACK_NSIS_HELP_LINK@" + Call ConditionalAddToRegisty + Push "URLInfoAbout" + Push "@CPACK_NSIS_URL_INFO_ABOUT@" + Call ConditionalAddToRegisty + Push "Contact" + Push "@CPACK_NSIS_CONTACT@" + Call ConditionalAddToRegisty + !insertmacro MUI_INSTALLOPTIONS_READ $INSTALL_DESKTOP "NSIS.InstallOptions.ini" "Field 5" "State" + !insertmacro MUI_STARTMENU_WRITE_BEGIN Application + + ;Create shortcuts + CreateDirectory "$SMPROGRAMS\$STARTMENU_FOLDER" +@CPACK_NSIS_CREATE_ICONS@ +@CPACK_NSIS_CREATE_ICONS_EXTRA@ + CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe" + + ;Read a value from an InstallOptions INI file + !insertmacro MUI_INSTALLOPTIONS_READ $DO_NOT_ADD_TO_PATH "NSIS.InstallOptions.ini" "Field 2" "State" + !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_ALL_USERS "NSIS.InstallOptions.ini" "Field 3" "State" + !insertmacro MUI_INSTALLOPTIONS_READ $ADD_TO_PATH_CURRENT_USER "NSIS.InstallOptions.ini" "Field 4" "State" + + ; Write special uninstall registry entries + Push "StartMenu" + Push "$STARTMENU_FOLDER" + Call ConditionalAddToRegisty + Push "DoNotAddToPath" + Push "$DO_NOT_ADD_TO_PATH" + Call ConditionalAddToRegisty + Push "AddToPathAllUsers" + Push "$ADD_TO_PATH_ALL_USERS" + Call ConditionalAddToRegisty + Push "AddToPathCurrentUser" + Push "$ADD_TO_PATH_CURRENT_USER" + Call ConditionalAddToRegisty + Push "InstallToDesktop" + Push "$INSTALL_DESKTOP" + Call ConditionalAddToRegisty + + !insertmacro MUI_STARTMENU_WRITE_END + +@CPACK_NSIS_EXTRA_INSTALL_COMMANDS@ + +SectionEnd + +Section "-Add to path" + Push $INSTDIR\bin + StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 doNotAddToPath + StrCmp $DO_NOT_ADD_TO_PATH "1" doNotAddToPath 0 + Call AddToPath + doNotAddToPath: +SectionEnd + +;-------------------------------- +; Create custom pages +Function InstallOptionsPage + !insertmacro MUI_HEADER_TEXT "Install Options" "Choose options for installing @CPACK_NSIS_PACKAGE_NAME@" + !insertmacro MUI_INSTALLOPTIONS_DISPLAY "NSIS.InstallOptions.ini" + +FunctionEnd + +;-------------------------------- +; determine admin versus local install +Function un.onInit + + ClearErrors + UserInfo::GetName + IfErrors noLM + Pop $0 + UserInfo::GetAccountType + Pop $1 + StrCmp $1 "Admin" 0 +3 + SetShellVarContext all + ;MessageBox MB_OK 'User "$0" is in the Admin group' + Goto done + StrCmp $1 "Power" 0 +3 + SetShellVarContext all + ;MessageBox MB_OK 'User "$0" is in the Power Users group' + Goto done + + noLM: + ;Get installation folder from registry if available + + done: + +FunctionEnd + +;--- Add/Remove callback functions: --- +!macro SectionList MacroName + ;This macro used to perform operation on multiple sections. + ;List all of your components in following manner here. +@CPACK_NSIS_COMPONENT_SECTION_LIST@ +!macroend + +Section -FinishComponents + ;Removes unselected components and writes component status to registry + !insertmacro SectionList "FinishSection" + +!ifdef CPACK_NSIS_ADD_REMOVE + ; Get the name of the installer executable + System::Call 'kernel32::GetModuleFileNameA(i 0, t .R0, i 1024) i r1' + StrCpy $R3 $R0 + + ; Strip off the last 13 characters, to see if we have AddRemove.exe + StrLen $R1 $R0 + IntOp $R1 $R0 - 13 + StrCpy $R2 $R0 13 $R1 + StrCmp $R2 "AddRemove.exe" addremove_installed + + ; We're not running AddRemove.exe, so install it + CopyFiles $R3 $INSTDIR\AddRemove.exe + + addremove_installed: +!endif +SectionEnd +;--- End of Add/Remove callback functions --- + +;-------------------------------- +; Component dependencies +Function .onSelChange + !insertmacro SectionList MaybeSelectionChanged +FunctionEnd + +;-------------------------------- +;Uninstaller Section + +Section "Uninstall" + ReadRegStr $START_MENU SHCTX \ + "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "StartMenu" + ;MessageBox MB_OK "Start menu is in: $START_MENU" + ReadRegStr $DO_NOT_ADD_TO_PATH SHCTX \ + "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "DoNotAddToPath" + ReadRegStr $ADD_TO_PATH_ALL_USERS SHCTX \ + "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathAllUsers" + ReadRegStr $ADD_TO_PATH_CURRENT_USER SHCTX \ + "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "AddToPathCurrentUser" + ;MessageBox MB_OK "Add to path: $DO_NOT_ADD_TO_PATH all users: $ADD_TO_PATH_ALL_USERS" + ReadRegStr $INSTALL_DESKTOP SHCTX \ + "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "InstallToDesktop" + ;MessageBox MB_OK "Install to desktop: $INSTALL_DESKTOP " + +@CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS@ + + ;Remove files we installed. + ;Keep the list of directories here in sync with the File commands above. +@CPACK_NSIS_DELETE_FILES@ +@CPACK_NSIS_DELETE_DIRECTORIES@ + +!ifdef CPACK_NSIS_ADD_REMOVE + ;Remove the add/remove program + Delete "$INSTDIR\AddRemove.exe" +!endif + + ;Remove the uninstaller itself. + Delete "$INSTDIR\Uninstall.exe" + DeleteRegKey SHCTX "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" + + ;Remove the installation directory if it is empty. + RMDir "$INSTDIR" + + ; Remove the registry entries. + DeleteRegKey SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" + + ; Removes all optional components + !insertmacro SectionList "RemoveSection_CPack" + + !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP + + Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" +@CPACK_NSIS_DELETE_ICONS@ +@CPACK_NSIS_DELETE_ICONS_EXTRA@ + + ;Delete empty start menu parent diretories + StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP" + + startMenuDeleteLoop: + ClearErrors + RMDir $MUI_TEMP + GetFullPathName $MUI_TEMP "$MUI_TEMP\.." + + IfErrors startMenuDeleteLoopDone + + StrCmp "$MUI_TEMP" "$SMPROGRAMS" startMenuDeleteLoopDone startMenuDeleteLoop + startMenuDeleteLoopDone: + + ; If the user changed the shortcut, then untinstall may not work. This should + ; try to fix it. + StrCpy $MUI_TEMP "$START_MENU" + Delete "$SMPROGRAMS\$MUI_TEMP\Uninstall.lnk" +@CPACK_NSIS_DELETE_ICONS_EXTRA@ + + ;Delete empty start menu parent diretories + StrCpy $MUI_TEMP "$SMPROGRAMS\$MUI_TEMP" + + secondStartMenuDeleteLoop: + ClearErrors + RMDir $MUI_TEMP + GetFullPathName $MUI_TEMP "$MUI_TEMP\.." + + IfErrors secondStartMenuDeleteLoopDone + + StrCmp "$MUI_TEMP" "$SMPROGRAMS" secondStartMenuDeleteLoopDone secondStartMenuDeleteLoop + secondStartMenuDeleteLoopDone: + + DeleteRegKey /ifempty SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" + + Push $INSTDIR\bin + StrCmp $DO_NOT_ADD_TO_PATH_ "1" doNotRemoveFromPath 0 + Call un.RemoveFromPath + doNotRemoveFromPath: +SectionEnd + +;-------------------------------- +; determine admin versus local install +; Is install for "AllUsers" or "JustMe"? +; Default to "JustMe" - set to "AllUsers" if admin or on Win9x +; This function is used for the very first "custom page" of the installer. +; This custom page does not show up visibly, but it executes prior to the +; first visible page and sets up $INSTDIR properly... +; Choose different default installation folder based on SV_ALLUSERS... +; "Program Files" for AllUsers, "My Documents" for JustMe... + +Function .onInit + StrCmp "@CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL@" "ON" 0 inst + + ReadRegStr $0 HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "UninstallString" + StrCmp $0 "" inst + + MessageBox MB_YESNOCANCEL|MB_ICONEXCLAMATION \ + "@CPACK_NSIS_PACKAGE_NAME@ is already installed. $\n$\nDo you want to uninstall the old version before installing the new one?" \ + IDYES uninst IDNO inst + Abort + +;Run the uninstaller +uninst: + ClearErrors + StrLen $2 "\Uninstall.exe" + StrCpy $3 $0 -$2 # remove "\Uninstall.exe" from UninstallString to get path + ExecWait '$0 _?=$3' ;Do not copy the uninstaller to a temp file + + IfErrors uninst_failed inst +uninst_failed: + MessageBox MB_OK|MB_ICONSTOP "Uninstall failed." + Abort + + +inst: + ; Reads components status for registry + !insertmacro SectionList "InitSection" + + ; check to see if /D has been used to change + ; the install directory by comparing it to the + ; install directory that is expected to be the + ; default + StrCpy $IS_DEFAULT_INSTALLDIR 0 + StrCmp "$INSTDIR" "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" 0 +2 + StrCpy $IS_DEFAULT_INSTALLDIR 1 + + StrCpy $SV_ALLUSERS "JustMe" + ; if default install dir then change the default + ; if it is installed for JustMe + StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2 + StrCpy $INSTDIR "$DOCUMENTS\@CPACK_PACKAGE_INSTALL_DIRECTORY@" + + ClearErrors + UserInfo::GetName + IfErrors noLM + Pop $0 + UserInfo::GetAccountType + Pop $1 + StrCmp $1 "Admin" 0 +4 + SetShellVarContext all + ;MessageBox MB_OK 'User "$0" is in the Admin group' + StrCpy $SV_ALLUSERS "AllUsers" + Goto done + StrCmp $1 "Power" 0 +4 + SetShellVarContext all + ;MessageBox MB_OK 'User "$0" is in the Power Users group' + StrCpy $SV_ALLUSERS "AllUsers" + Goto done + + noLM: + StrCpy $SV_ALLUSERS "AllUsers" + ;Get installation folder from registry if available + + done: + StrCmp $SV_ALLUSERS "AllUsers" 0 +3 + StrCmp "$IS_DEFAULT_INSTALLDIR" "1" 0 +2 + StrCpy $INSTDIR "@CPACK_NSIS_INSTALL_ROOT@\@CPACK_PACKAGE_INSTALL_DIRECTORY@" + + StrCmp "@CPACK_NSIS_MODIFY_PATH@" "ON" 0 noOptionsPage + !insertmacro MUI_INSTALLOPTIONS_EXTRACT "NSIS.InstallOptions.ini" + + noOptionsPage: +FunctionEnd diff --git a/config/cmake_ext_mod/grepTest.cmake b/config/cmake_ext_mod/grepTest.cmake new file mode 100644 index 0000000..579d855 --- /dev/null +++ b/config/cmake_ext_mod/grepTest.cmake @@ -0,0 +1,64 @@ +# grepTest.cmake executes a command and captures the output in a file. File is then compared +# against a reference file. Exit status of command can also be compared. + +# arguments checking +if (NOT TEST_PROGRAM) + message (FATAL_ERROR "Require TEST_PROGRAM to be defined") +endif (NOT TEST_PROGRAM) +#if (NOT TEST_ARGS) +# message (STATUS "Require TEST_ARGS to be defined") +#endif (NOT TEST_ARGS) +if (NOT TEST_FOLDER) + message ( FATAL_ERROR "Require TEST_FOLDER to be defined") +endif (NOT TEST_FOLDER) +if (NOT TEST_OUTPUT) + message (FATAL_ERROR "Require TEST_OUTPUT to be defined") +endif (NOT TEST_OUTPUT) +#if (NOT TEST_EXPECT) +# message (STATUS "Require TEST_EXPECT to be defined") +#endif (NOT TEST_EXPECT) +if (NOT TEST_FILTER) + message (STATUS "Require TEST_FILTER to be defined") +endif (NOT TEST_FILTER) +if (NOT TEST_REFERENCE) + message (FATAL_ERROR "Require TEST_REFERENCE to be defined") +endif (NOT TEST_REFERENCE) + +message (STATUS "COMMAND: ${TEST_PROGRAM} ${TEST_ARGS}") + +# run the test program, capture the stdout/stderr and the result var +EXECUTE_PROCESS ( + COMMAND ${TEST_PROGRAM} ${TEST_ARGS} + WORKING_DIRECTORY ${TEST_FOLDER} + RESULT_VARIABLE TEST_RESULT + OUTPUT_FILE ${TEST_OUTPUT} + ERROR_FILE ${TEST_OUTPUT}.err + OUTPUT_VARIABLE TEST_ERROR + ERROR_VARIABLE TEST_ERROR +) + +message (STATUS "COMMAND Result: ${TEST_RESULT}") +message (STATUS "COMMAND Error: ${TEST_ERROR}") + +# now grep the output with the reference +file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) + +# TEST_REFERENCE should always be matched +STRING(REGEX MATCH "${TEST_REFERENCE}" TEST_MATCH ${TEST_STREAM}) +STRING(COMPARE EQUAL "${TEST_REFERENCE}" "${TEST_MATCH}" TEST_RESULT) +if (${TEST_RESULT} STREQUAL "0") + message (FATAL_ERROR "Failed: The output of ${TEST_PROGRAM} did not contain ${TEST_REFERENCE}") +endif (${TEST_RESULT} STREQUAL "0") + +STRING(REGEX MATCH "${TEST_FILTER}" TEST_MATCH ${TEST_STREAM}) +if (${TEST_EXPECT} STREQUAL "1") + # TEST_EXPECT (1) interperts TEST_FILTER as NOT to match + STRING(LENGTH "${TEST_MATCH}" TEST_RESULT) + if (NOT ${TEST_RESULT} STREQUAL "0") + message (FATAL_ERROR "Failed: The output of ${TEST_PROGRAM} did contain ${TEST_FILTER}") + endif (NOT ${TEST_RESULT} STREQUAL "0") +endif (${TEST_EXPECT} STREQUAL "1") + +# everything went fine... +message ("Passed: The output of ${TEST_PROGRAM} matched") + diff --git a/config/cmake_ext_mod/hdf.bmp b/config/cmake_ext_mod/hdf.bmp new file mode 100644 index 0000000..9e9e4aa Binary files /dev/null and b/config/cmake_ext_mod/hdf.bmp differ diff --git a/config/cmake_ext_mod/hdf.icns b/config/cmake_ext_mod/hdf.icns new file mode 100644 index 0000000..66f025d Binary files /dev/null and b/config/cmake_ext_mod/hdf.icns differ diff --git a/config/cmake_ext_mod/hdf.ico b/config/cmake_ext_mod/hdf.ico new file mode 100644 index 0000000..26abc96 Binary files /dev/null and b/config/cmake_ext_mod/hdf.ico differ diff --git a/config/cmake_ext_mod/prunTest.cmake b/config/cmake_ext_mod/prunTest.cmake new file mode 100644 index 0000000..3d5ec31 --- /dev/null +++ b/config/cmake_ext_mod/prunTest.cmake @@ -0,0 +1,145 @@ +# runTest.cmake executes a command and captures the output in a file. File is then compared +# against a reference file. Exit status of command can also be compared. +cmake_policy(SET CMP0007 NEW) + +# arguments checking +if (NOT TEST_PROGRAM) + message (FATAL_ERROR "Require TEST_PROGRAM to be defined") +endif (NOT TEST_PROGRAM) +#if (NOT TEST_ARGS) +# message (STATUS "Require TEST_ARGS to be defined") +#endif (NOT TEST_ARGS) +if (NOT TEST_FOLDER) + message ( FATAL_ERROR "Require TEST_FOLDER to be defined") +endif (NOT TEST_FOLDER) +if (NOT TEST_OUTPUT) + message (FATAL_ERROR "Require TEST_OUTPUT to be defined") +endif (NOT TEST_OUTPUT) +#if (NOT TEST_EXPECT) +# message (STATUS "Require TEST_EXPECT to be defined") +#endif (NOT TEST_EXPECT) +#if (NOT TEST_FILTER) +# message (STATUS "Require TEST_FILTER to be defined") +#endif (NOT TEST_FILTER) +if (NOT TEST_SKIP_COMPARE AND NOT TEST_REFERENCE) + message (FATAL_ERROR "Require TEST_REFERENCE to be defined") +endif (NOT TEST_SKIP_COMPARE AND NOT TEST_REFERENCE) + +set (ERROR_APPEND 1) + +message (STATUS "COMMAND: ${TEST_PROGRAM} ${TEST_ARGS}") + +if (TEST_ENV_VAR) + set (ENV{${TEST_ENV_VAR}} "${TEST_ENV_VALUE}") +endif (TEST_ENV_VAR) + +# run the test program, capture the stdout/stderr and the result var +EXECUTE_PROCESS ( + COMMAND ${TEST_PROGRAM} ${TEST_ARGS} + WORKING_DIRECTORY ${TEST_FOLDER} + RESULT_VARIABLE TEST_RESULT + OUTPUT_FILE ${TEST_OUTPUT} + ERROR_FILE ${TEST_OUTPUT}.err + OUTPUT_VARIABLE TEST_ERROR + ERROR_VARIABLE TEST_ERROR +) + +message (STATUS "COMMAND Result: ${TEST_RESULT}") + +file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) +file (WRITE ${TEST_FOLDER}/P_${TEST_REFERENCE} "${TEST_STREAM}") + +if (ERROR_APPEND) + file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM) + file (APPEND ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") +endif (ERROR_APPEND) + +if (TEST_APPEND) + file (APPEND ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_APPEND} ${TEST_ERROR}\n") +endif (TEST_APPEND) + +message (STATUS "COMMAND Error: ${TEST_ERROR}") + +if (TEST_MASK) + file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) + STRING(REGEX REPLACE "Storage:[^\n]+\n" "Storage:
\n" TEST_STREAM "${TEST_STREAM}") + file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") +endif (TEST_MASK) + +if (TEST_MASK_MOD) + file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) + STRING(REGEX REPLACE "Modified:[^\n]+\n" "Modified: XXXX-XX-XX XX:XX:XX XXX\n" TEST_STREAM "${TEST_STREAM}") + file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") +endif (TEST_MASK_MOD) + +if (TEST_MASK_ERROR) + file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) + STRING(REGEX REPLACE "thread [0-9]*:" "thread (IDs):" TEST_STREAM "${TEST_STREAM}") + STRING(REGEX REPLACE ": ([^\n]*)[.]c " ": (file name) " TEST_STREAM "${TEST_STREAM}") + STRING(REGEX REPLACE " line [0-9]*" " line (number)" TEST_STREAM "${TEST_STREAM}") + STRING(REGEX REPLACE "v[1-9]*[.][0-9]*[.]" "version (number)." TEST_STREAM "${TEST_STREAM}") + STRING(REGEX REPLACE "[1-9]*[.][0-9]*[.][0-9]*[^)]*" "version (number)" TEST_STREAM "${TEST_STREAM}") + STRING(REGEX REPLACE "H5Eget_auto[1-2]*" "H5Eget_auto(1 or 2)" TEST_STREAM "${TEST_STREAM}") + STRING(REGEX REPLACE "H5Eset_auto[1-2]*" "H5Eset_auto(1 or 2)" TEST_STREAM "${TEST_STREAM}") + file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") +endif (TEST_MASK_ERROR) + +if (TEST_FILTER) + file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) + STRING(REGEX REPLACE "${TEST_FILTER}" "" TEST_STREAM "${TEST_STREAM}") + file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") +endif (TEST_FILTER) + +#if (TEST_REF_FILTER) +# message (STATUS "TEST_REF_FILTER: ${TEST_APPEND}${TEST_REF_FILTER}") +# file (READ ${TEST_FOLDER}/P_${TEST_REFERENCE} TEST_STREAM) +# STRING(REGEX REPLACE "${TEST_APPEND}" "${TEST_REF_FILTER}" TEST_STREAM "${TEST_STREAM}") +# file (WRITE ${TEST_FOLDER}/P_${TEST_REFERENCE} "${TEST_STREAM}") +#endif (TEST_REF_FILTER) + +if (NOT TEST_SKIP_COMPARE) + if (WIN32 AND NOT MINGW) + file (READ ${TEST_FOLDER}/P_${TEST_REFERENCE} TEST_STREAM) + file (WRITE ${TEST_FOLDER}/P_${TEST_REFERENCE} "${TEST_STREAM}") + endif (WIN32 AND NOT MINGW) + + # now compare the output with the reference + EXECUTE_PROCESS ( + COMMAND ${CMAKE_COMMAND} -E compare_files ${TEST_FOLDER}/${TEST_OUTPUT} ${TEST_FOLDER}/P_${TEST_REFERENCE} + RESULT_VARIABLE TEST_RESULT + ) + if (NOT ${TEST_RESULT} STREQUAL 0) + set (TEST_RESULT 0) + file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} test_act) + LIST (LENGTH test_act len_act) + file (STRINGS ${TEST_FOLDER}/P_${TEST_REFERENCE} test_ref) + LIST (LENGTH test_ref len_ref) + if (NOT ${len_act} STREQUAL "0") + MATH (EXPR _FP_LEN "${len_ref} - 1") + foreach (line RANGE 0 ${_FP_LEN}) + LIST (GET test_act ${line} str_act) + LIST (GET test_ref ${line} str_ref) + if (NOT "${str_act}" STREQUAL "${str_ref}") + if (NOT "${str_act}" STREQUAL "") + set (TEST_RESULT 1) + message ("line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n") + endif (NOT "${str_act}" STREQUAL "") + endif (NOT "${str_act}" STREQUAL "${str_ref}") + endforeach (line RANGE 0 ${_FP_LEN}) + endif (NOT ${len_act} STREQUAL "0") + if (NOT ${len_act} STREQUAL ${len_ref}) + set (TEST_RESULT 1) + endif (NOT ${len_act} STREQUAL ${len_ref}) + endif (NOT ${TEST_RESULT} STREQUAL 0) + + message (STATUS "COMPARE Result: ${TEST_RESULT}") + + # again, if return value is !=0 scream and shout + if (NOT ${TEST_RESULT} STREQUAL 0) + message (FATAL_ERROR "Failed: The output of ${TEST_OUTPUT} did not match P_${TEST_REFERENCE}") + endif (NOT ${TEST_RESULT} STREQUAL 0) +endif (NOT TEST_SKIP_COMPARE) + +# everything went fine... +message ("Passed: The output of ${TEST_PROGRAM} matches P_${TEST_REFERENCE}") + diff --git a/config/cmake_ext_mod/runTest.cmake b/config/cmake_ext_mod/runTest.cmake new file mode 100644 index 0000000..bfaae2b --- /dev/null +++ b/config/cmake_ext_mod/runTest.cmake @@ -0,0 +1,207 @@ +# runTest.cmake executes a command and captures the output in a file. File is then compared +# against a reference file. Exit status of command can also be compared. +cmake_policy(SET CMP0007 NEW) + +# arguments checking +if (NOT TEST_PROGRAM) + message (FATAL_ERROR "Require TEST_PROGRAM to be defined") +endif (NOT TEST_PROGRAM) +#if (NOT TEST_ARGS) +# message (STATUS "Require TEST_ARGS to be defined") +#endif (NOT TEST_ARGS) +if (NOT TEST_FOLDER) + message ( FATAL_ERROR "Require TEST_FOLDER to be defined") +endif (NOT TEST_FOLDER) +if (NOT TEST_OUTPUT) + message (FATAL_ERROR "Require TEST_OUTPUT to be defined") +endif (NOT TEST_OUTPUT) +if (NOT TEST_EXPECT) + message (STATUS "Require TEST_EXPECT to be defined") +endif (NOT TEST_EXPECT) +#if (NOT TEST_FILTER) +# message (STATUS "Require TEST_FILTER to be defined") +#endif (NOT TEST_FILTER) +if (NOT TEST_SKIP_COMPARE AND NOT TEST_REFERENCE) + message (FATAL_ERROR "Require TEST_REFERENCE to be defined") +endif (NOT TEST_SKIP_COMPARE AND NOT TEST_REFERENCE) + +if (NOT TEST_ERRREF) + set (ERROR_APPEND 1) +endif (NOT TEST_ERRREF) + +message (STATUS "COMMAND: ${TEST_PROGRAM} ${TEST_ARGS}") + +if (TEST_ENV_VAR) + set (ENV{${TEST_ENV_VAR}} "${TEST_ENV_VALUE}") +endif (TEST_ENV_VAR) + +if (NOT TEST_INPUT) + # run the test program, capture the stdout/stderr and the result var + EXECUTE_PROCESS ( + COMMAND ${TEST_PROGRAM} ${TEST_ARGS} + WORKING_DIRECTORY ${TEST_FOLDER} + RESULT_VARIABLE TEST_RESULT + OUTPUT_FILE ${TEST_OUTPUT} + ERROR_FILE ${TEST_OUTPUT}.err + OUTPUT_VARIABLE TEST_ERROR + ERROR_VARIABLE TEST_ERROR + ) +else (NOT TEST_INPUT) + # run the test program with stdin, capture the stdout/stderr and the result var + EXECUTE_PROCESS ( + COMMAND ${TEST_PROGRAM} ${TEST_ARGS} + WORKING_DIRECTORY ${TEST_FOLDER} + RESULT_VARIABLE TEST_RESULT + INPUT_FILE ${TEST_INPUT} + OUTPUT_FILE ${TEST_OUTPUT} + ERROR_FILE ${TEST_OUTPUT}.err + OUTPUT_VARIABLE TEST_ERROR + ERROR_VARIABLE TEST_ERROR + ) +endif (NOT TEST_INPUT) + +message (STATUS "COMMAND Result: ${TEST_RESULT}") + +if (ERROR_APPEND) + file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM) + file (APPEND ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") +endif (ERROR_APPEND) + +if (TEST_APPEND) + file (APPEND ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_APPEND} ${TEST_RESULT}\n") +endif (TEST_APPEND) + +# if the return value is !=${TEST_EXPECT} bail out +if (NOT ${TEST_RESULT} STREQUAL ${TEST_EXPECT}) + message ( FATAL_ERROR "Failed: Test program ${TEST_PROGRAM} exited != ${TEST_EXPECT}.\n${TEST_ERROR}") +endif (NOT ${TEST_RESULT} STREQUAL ${TEST_EXPECT}) + +message (STATUS "COMMAND Error: ${TEST_ERROR}") + +if (TEST_MASK) + file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) + STRING(REGEX REPLACE "Storage:[^\n]+\n" "Storage:
\n" TEST_STREAM "${TEST_STREAM}") + file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") +endif (TEST_MASK) + +if (TEST_MASK_MOD) + file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) + STRING(REGEX REPLACE "Modified:[^\n]+\n" "Modified: XXXX-XX-XX XX:XX:XX XXX\n" TEST_STREAM "${TEST_STREAM}") + file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") +endif (TEST_MASK_MOD) + +if (TEST_MASK_ERROR) + if (NOT TEST_ERRREF) + file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) + else (NOT TEST_ERRREF) + file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM) + endif (NOT TEST_ERRREF) + STRING(REGEX REPLACE "thread [0-9]*:" "thread (IDs):" TEST_STREAM "${TEST_STREAM}") + STRING(REGEX REPLACE ": ([^\n]*)[.]c " ": (file name) " TEST_STREAM "${TEST_STREAM}") + STRING(REGEX REPLACE " line [0-9]*" " line (number)" TEST_STREAM "${TEST_STREAM}") + STRING(REGEX REPLACE "v[1-9]*[.][0-9]*[.]" "version (number)." TEST_STREAM "${TEST_STREAM}") + STRING(REGEX REPLACE "[1-9]*[.][0-9]*[.][0-9]*[^)]*" "version (number)" TEST_STREAM "${TEST_STREAM}") + STRING(REGEX REPLACE "H5Eget_auto[1-2]*" "H5Eget_auto(1 or 2)" TEST_STREAM "${TEST_STREAM}") + STRING(REGEX REPLACE "H5Eset_auto[1-2]*" "H5Eset_auto(1 or 2)" TEST_STREAM "${TEST_STREAM}") + if (NOT TEST_ERRREF) + file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") + else (NOT TEST_ERRREF) + file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT}.err "${TEST_STREAM}") + endif (NOT TEST_ERRREF) +endif (TEST_MASK_ERROR) + +if (TEST_FILTER) + file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) + STRING(REGEX REPLACE "${TEST_FILTER}" "" TEST_STREAM "${TEST_STREAM}") + file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") +endif (TEST_FILTER) + +if (NOT TEST_SKIP_COMPARE) + if (WIN32 AND NOT MINGW) + file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) + file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}") + endif (WIN32 AND NOT MINGW) + + # now compare the output with the reference + EXECUTE_PROCESS ( + COMMAND ${CMAKE_COMMAND} -E compare_files ${TEST_FOLDER}/${TEST_OUTPUT} ${TEST_FOLDER}/${TEST_REFERENCE} + RESULT_VARIABLE TEST_RESULT + ) + if (NOT ${TEST_RESULT} STREQUAL 0) + set (TEST_RESULT 0) + file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} test_act) + LIST (LENGTH test_act len_act) + file (STRINGS ${TEST_FOLDER}/${TEST_REFERENCE} test_ref) + LIST (LENGTH test_ref len_ref) + if (NOT ${len_act} STREQUAL "0") + MATH (EXPR _FP_LEN "${len_ref} - 1") + foreach (line RANGE 0 ${_FP_LEN}) + LIST (GET test_act ${line} str_act) + LIST (GET test_ref ${line} str_ref) + if (NOT "${str_act}" STREQUAL "${str_ref}") + if (NOT "${str_act}" STREQUAL "") + set (TEST_RESULT 1) + message ("line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n") + endif (NOT "${str_act}" STREQUAL "") + endif (NOT "${str_act}" STREQUAL "${str_ref}") + endforeach (line RANGE 0 ${_FP_LEN}) + endif (NOT ${len_act} STREQUAL "0") + if (NOT ${len_act} STREQUAL ${len_ref}) + set (TEST_RESULT 1) + endif (NOT ${len_act} STREQUAL ${len_ref}) + endif (NOT ${TEST_RESULT} STREQUAL 0) + + message (STATUS "COMPARE Result: ${TEST_RESULT}") + + # again, if return value is !=0 scream and shout + if (NOT ${TEST_RESULT} STREQUAL 0) + message (FATAL_ERROR "Failed: The output of ${TEST_OUTPUT} did not match ${TEST_REFERENCE}") + endif (NOT ${TEST_RESULT} STREQUAL 0) + + if (TEST_ERRREF) + if (WIN32 AND NOT MINGW) + file (READ ${TEST_FOLDER}/${TEST_ERRREF} TEST_STREAM) + file (WRITE ${TEST_FOLDER}/${TEST_ERRREF} "${TEST_STREAM}") + endif (WIN32 AND NOT MINGW) + + # now compare the error output with the error reference + EXECUTE_PROCESS ( + COMMAND ${CMAKE_COMMAND} -E compare_files ${TEST_FOLDER}/${TEST_OUTPUT}.err ${TEST_FOLDER}/${TEST_ERRREF} + RESULT_VARIABLE TEST_RESULT + ) + if (NOT ${TEST_RESULT} STREQUAL 0) + set (TEST_RESULT 0) + file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT}.err test_act) + LIST (LENGTH test_act len_act) + file (STRINGS ${TEST_FOLDER}/${TEST_ERRREF} test_ref) + LIST (LENGTH test_ref len_ref) + MATH (EXPR _FP_LEN "${len_ref} - 1") + if (NOT ${len_act} STREQUAL "0") + MATH (EXPR _FP_LEN "${len_ref} - 1") + foreach (line RANGE 0 ${_FP_LEN}) + LIST (GET test_act ${line} str_act) + LIST (GET test_ref ${line} str_ref) + if (NOT "${str_act}" STREQUAL "${str_ref}") + if (NOT "${str_act}" STREQUAL "") + set (TEST_RESULT 1) + message ("line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n") + endif (NOT "${str_act}" STREQUAL "") + endif (NOT "${str_act}" STREQUAL "${str_ref}") + endforeach (line RANGE 0 ${_FP_LEN}) + endif (NOT ${len_act} STREQUAL "0") + if (NOT ${len_act} STREQUAL ${len_ref}) + set (TEST_RESULT 1) + endif (NOT ${len_act} STREQUAL ${len_ref}) + endif (NOT ${TEST_RESULT} STREQUAL 0) + + message (STATUS "COMPARE Result: ${TEST_RESULT}") + + # again, if return value is !=0 scream and shout + if (NOT ${TEST_RESULT} STREQUAL 0) + message (FATAL_ERROR "Failed: The error output of ${TEST_OUTPUT}.err did not match ${TEST_ERRREF}") + endif (NOT ${TEST_RESULT} STREQUAL 0) + endif (TEST_ERRREF) +endif (NOT TEST_SKIP_COMPARE) + +# everything went fine... +message ("Passed: The output of ${TEST_PROGRAM} matches ${TEST_REFERENCE}") diff --git a/config/cmake_ext_mod/version.plist.in b/config/cmake_ext_mod/version.plist.in new file mode 100644 index 0000000..817d89e --- /dev/null +++ b/config/cmake_ext_mod/version.plist.in @@ -0,0 +1,17 @@ + + + + + + BuildVersion + @CPACK_PACKAGE_VERSION_MAJOR@ + CFBundleShortVersionString + @CPACK_APPLE_GUI_SHORT_VERSION_STRING@ + CFBundleVersion + @CPACK_APPLE_GUI_SHORT_VERSION_STRING@ + ProjectName + @CPACK_APPLE_GUI_BUNDLE_NAME@ + SourceVersion + @CPACK_PACKAGE_VERSION_MINOR@ + + diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 1f33f04..7953161 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -38,18 +38,32 @@ set (examples foreach (example ${examples}) add_executable (${example} ${HDF5_EXAMPLES_SOURCE_DIR}/${example}.c) - TARGET_NAMING (${example} ${LIB_TYPE}) - TARGET_C_PROPERTIES (${example} ${LIB_TYPE} " " " ") + TARGET_NAMING (${example} STATIC) + TARGET_C_PROPERTIES (${example} STATIC " " " ") target_link_libraries (${example} ${HDF5_LIB_TARGET}) set_target_properties (${example} PROPERTIES FOLDER examples) + if (BUILD_SHARED_LIBS) + add_executable (${example}-shared ${HDF5_EXAMPLES_SOURCE_DIR}/${example}.c) + TARGET_NAMING (${example}-shared SHARED) + TARGET_C_PROPERTIES (${example}-shared SHARED " " " ") + target_link_libraries (${example}-shared ${HDF5_LIBSH_TARGET}) + set_target_properties (${example}-shared PROPERTIES FOLDER examples) + endif (BUILD_SHARED_LIBS) endforeach (example ${examples}) if (H5_HAVE_PARALLEL) add_executable (ph5example ${HDF5_EXAMPLES_SOURCE_DIR}/ph5example.c) - TARGET_NAMING (ph5example ${LIB_TYPE}) - TARGET_C_PROPERTIES (ph5example ${LIB_TYPE} " " " ") + TARGET_NAMING (ph5example STATIC) + TARGET_C_PROPERTIES (ph5example STATIC " " " ") target_link_libraries (ph5example ${HDF5_LIB_TARGET}) set_target_properties (ph5example PROPERTIES FOLDER examples) + if (BUILD_SHARED_LIBS) + add_executable (ph5example-shared ${HDF5_EXAMPLES_SOURCE_DIR}/ph5example.c) + TARGET_NAMING (ph5example-shared SHARED) + TARGET_C_PROPERTIES (ph5example-shared SHARED " " " ") + target_link_libraries (ph5example-shared ${HDF5_LIBSH_TARGET}) + set_target_properties (ph5example-shared PROPERTIES FOLDER examples) + endif (BUILD_SHARED_LIBS) endif (H5_HAVE_PARALLEL) if (BUILD_TESTING) diff --git a/examples/CMakeTests.cmake b/examples/CMakeTests.cmake index 5a756c8..42b42b3 100644 --- a/examples/CMakeTests.cmake +++ b/examples/CMakeTests.cmake @@ -5,6 +5,10 @@ ############################################################################## ############################################################################## file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/red ${PROJECT_BINARY_DIR}/blue ${PROJECT_BINARY_DIR}/u2w) + if (BUILD_SHARED_LIBS) + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5EX-shared") + file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/H5EX-shared/red ${PROJECT_BINARY_DIR}/H5EX-shared/blue ${PROJECT_BINARY_DIR}/H5EX-shared/u2w) + endif (BUILD_SHARED_LIBS) # Remove any output file left over from previous test run add_test ( @@ -56,6 +60,61 @@ set (last_test "EXAMPLES-${example}") endforeach (example ${examples}) + if (BUILD_SHARED_LIBS) + # Remove any output file left over from previous test run + add_test ( + NAME EXAMPLES-shared-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + Attributes.h5 + btrees_file.h5 + cmprss.h5 + default_file.h5 + dset.h5 + extend.h5 + extlink_prefix_source.h5 + extlink_source.h5 + extlink_target.h5 + group.h5 + groups.h5 + hard_link.h5 + mount1.h5 + mount2.h5 + one_index_file.h5 + only_dspaces_and_attrs_file.h5 + only_huge_mesgs_file.h5 + REF_REG.h5 + refere.h5 + SDS.h5 + SDScompound.h5 + SDSextendible.h5 + Select.h5 + separate_indexes_file.h5 + small_lists_file.h5 + soft_link.h5 + subset.h5 + unix2win.h5 + blue/prefix_target.h5 + red/prefix_target.h5 + u2w/u2w_target.h5 + WORKING_DIRECTORY + ${PROJECT_BINARY_DIR}/H5EX-shared + ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (EXAMPLES-shared-clear-objects PROPERTIES DEPENDS ${last_test}) + endif (NOT "${last_test}" STREQUAL "") + set (last_test "EXAMPLES-shared-clear-objects") + + foreach (example ${examples}) + add_test (NAME EXAMPLES-shared-${example} COMMAND $) + set_tests_properties (EXAMPLES-shared-${example} PROPERTIES WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/H5EX-shared) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (EXAMPLES-shared-${example} PROPERTIES DEPENDS ${last_test}) + endif (NOT "${last_test}" STREQUAL "") + set (last_test "EXAMPLES-shared-${example}") + endforeach (example ${examples}) + endif (BUILD_SHARED_LIBS) + ### Windows pops up a modal permission dialog on this test if (H5_HAVE_PARALLEL AND NOT WIN32) add_test (NAME EXAMPLES-ph5example COMMAND $) @@ -63,4 +122,12 @@ set_tests_properties (EXAMPLES-ph5example PROPERTIES DEPENDS ${last_test}) endif (NOT "${last_test}" STREQUAL "") set (last_test "EXAMPLES-ph5example") + if (BUILD_SHARED_LIBS) + add_test (NAME EXAMPLES-shared-ph5example COMMAND $) + set_tests_properties (EXAMPLES-shared-ph5example PROPERTIES WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/H5EX-shared) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (EXAMPLES-shared-ph5example PROPERTIES DEPENDS ${last_test}) + endif (NOT "${last_test}" STREQUAL "") + set (last_test "EXAMPLES-shared-ph5example") + endif (BUILD_SHARED_LIBS) endif (H5_HAVE_PARALLEL AND NOT WIN32) diff --git a/fortran/examples/CMakeLists.txt b/fortran/examples/CMakeLists.txt index 2bf0bf6..f2dc896 100644 --- a/fortran/examples/CMakeLists.txt +++ b/fortran/examples/CMakeLists.txt @@ -40,8 +40,8 @@ set (F2003_examples foreach (example ${examples}) add_executable (f90_ex_${example} ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90) - TARGET_NAMING (f90_ex_${example} ${LIB_TYPE}) - TARGET_FORTRAN_PROPERTIES (f90_ex_${example} ${LIB_TYPE} " " " ") + TARGET_NAMING (f90_ex_${example} STATIC) + TARGET_FORTRAN_PROPERTIES (f90_ex_${example} STATIC " " " ") target_link_libraries (f90_ex_${example} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} @@ -50,32 +50,60 @@ foreach (example ${examples}) set_target_properties (f90_ex_${example} PROPERTIES LINKER_LANGUAGE Fortran FOLDER examples/fortran - Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/static ) + if (BUILD_SHARED_LIBS) + add_executable (f90_ex_${example}-shared ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90) + TARGET_NAMING (f90_ex_${example}-shared SHARED) + TARGET_FORTRAN_PROPERTIES (f90_ex_${example}-shared SHARED " " " ") + target_link_libraries (f90_ex_${example}-shared + ${HDF5_F90_LIBSH_TARGET} + ${HDF5_LIBSH_TARGET} + ) + target_include_directories (f90_ex_${example}-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + set_target_properties (f90_ex_${example}-shared PROPERTIES + LINKER_LANGUAGE Fortran + FOLDER examples/fortran + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + ) + endif (BUILD_SHARED_LIBS) endforeach (example ${examples}) -if (HDF5_ENABLE_F2003) - foreach (example ${F2003_examples}) - add_executable (f03_ex_${example} ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90) - TARGET_NAMING (f03_ex_${example} ${LIB_TYPE}) - TARGET_FORTRAN_PROPERTIES (f03_ex_${example} ${LIB_TYPE} " " " ") - target_link_libraries (f03_ex_${example} - ${HDF5_F90_LIB_TARGET} - ${HDF5_LIB_TARGET} +foreach (example ${F2003_examples}) + add_executable (f03_ex_${example} ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90) + TARGET_NAMING (f03_ex_${example} STATIC) + TARGET_FORTRAN_PROPERTIES (f03_ex_${example} STATIC " " " ") + target_link_libraries (f03_ex_${example} + ${HDF5_F90_LIB_TARGET} + ${HDF5_LIB_TARGET} + ) + target_include_directories (f03_ex_${example} PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) + set_target_properties (f03_ex_${example} PROPERTIES + LINKER_LANGUAGE Fortran + FOLDER examples/fortran03 + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} + ) + if (BUILD_SHARED_LIBS) + add_executable (f03_ex_${example}-shared ${HDF5_F90_EXAMPLES_SOURCE_DIR}/${example}.f90) + TARGET_NAMING (f03_ex_${example}-shared SHARED) + TARGET_FORTRAN_PROPERTIES (f03_ex_${example}-shared SHARED " " " ") + target_link_libraries (f03_ex_${example}-shared + ${HDF5_F90_LIBSH_TARGET} + ${HDF5_LIBSH_TARGET} ) - target_include_directories (f03_ex_${example} PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) - set_target_properties (f03_ex_${example} PROPERTIES + target_include_directories (f03_ex_${example}-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + set_target_properties (f03_ex_${example}-shared PROPERTIES LINKER_LANGUAGE Fortran FOLDER examples/fortran03 - Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared ) - endforeach (example ${F2003_examples}) -endif (HDF5_ENABLE_F2003) + endif (BUILD_SHARED_LIBS) +endforeach (example ${F2003_examples}) if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) add_executable (f90_ex_ph5example ${HDF5_F90_EXAMPLES_SOURCE_DIR}/ph5example.f90) - TARGET_NAMING (f90_ex_ph5example ${LIB_TYPE}) - TARGET_FORTRAN_PROPERTIES (f90_ex_ph5example ${LIB_TYPE} " " " ") + TARGET_NAMING (f90_ex_ph5example STATIC) + TARGET_FORTRAN_PROPERTIES (f90_ex_ph5example STATIC " " " ") target_link_libraries (f90_ex_ph5example ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} @@ -85,8 +113,24 @@ if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) set_target_properties (f90_ex_ph5example PROPERTIES LINKER_LANGUAGE Fortran FOLDER examples/fortran - Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/static ) + if (BUILD_SHARED_LIBS) + add_executable (f90_ex_ph5example-shared ${HDF5_F90_EXAMPLES_SOURCE_DIR}/ph5example.f90) + TARGET_NAMING (f90_ex_ph5example-shared SHARED) + TARGET_FORTRAN_PROPERTIES (f90_ex_ph5example-shared SHARED " " " ") + target_link_libraries (f90_ex_ph5example-shared + ${HDF5_F90_LIBSH_TARGET} + ${HDF5_LIBSH_TARGET} + ${MPI_Fortran_LIBRARIES} + ) + target_include_directories (f90_ex_ph5example-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + set_target_properties (f90_ex_ph5example-shared PROPERTIES + LINKER_LANGUAGE Fortran + FOLDER examples/fortran + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + ) + endif (BUILD_SHARED_LIBS) endif (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) if (BUILD_TESTING) diff --git a/fortran/examples/CMakeTests.cmake b/fortran/examples/CMakeTests.cmake index 57aec53..173984c 100644 --- a/fortran/examples/CMakeTests.cmake +++ b/fortran/examples/CMakeTests.cmake @@ -28,6 +28,30 @@ set_tests_properties (f90_ex-clear-objects PROPERTIES DEPENDS ${last_test}) endif (NOT "${last_test}" STREQUAL "") set (last_test "f90_ex-clear-objects") + if (BUILD_SHARED_LIBS) + add_test ( + NAME f90_ex-shared-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + compound.h5 + copy1.h5 + copy2.h5 + dsetf.h5 + extend.h5 + FORTRAN.h5 + groupf.h5 + groupsf.h5 + h5_cmprss.h5 + mount1.h5 + mount2.h5 + sdsf.h5 + subset.h5 + ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (f90_ex-shared-clear-objects PROPERTIES DEPENDS ${last_test}) + endif (NOT "${last_test}" STREQUAL "") + set (last_test "f90_ex-shared-clear-objects") + endif (BUILD_SHARED_LIBS) foreach (example ${examples}) add_test (NAME f90_ex_${example} COMMAND $) @@ -35,6 +59,13 @@ foreach (example ${examples}) set_tests_properties (f90_ex_${example} PROPERTIES DEPENDS ${last_test}) endif (NOT "${last_test}" STREQUAL "") set (last_test "f90_ex_${example}") + if (BUILD_SHARED_LIBS) + add_test (NAME f90_ex-shared_${example} COMMAND $) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (f90_ex-shared_${example} PROPERTIES DEPENDS ${last_test}) + endif (NOT "${last_test}" STREQUAL "") + set (last_test "f90_ex-shared_${example}") + endif (BUILD_SHARED_LIBS) endforeach (example ${examples}) if (HDF5_ENABLE_F2003) @@ -44,9 +75,19 @@ if (HDF5_ENABLE_F2003) set_tests_properties (f03_ex_${example} PROPERTIES DEPENDS ${last_test}) endif (NOT "${last_test}" STREQUAL "") set (last_test "f03_ex_${example}") + if (BUILD_SHARED_LIBS) + add_test (NAME f03_ex-shared_${example} COMMAND $) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (f03_ex-shared_${example} PROPERTIES DEPENDS ${last_test}) + endif (NOT "${last_test}" STREQUAL "") + set (last_test "f03_ex-shared_${example}") + endif (BUILD_SHARED_LIBS) endforeach (example ${F2003_examples}) endif (HDF5_ENABLE_F2003) if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) add_test (NAME f90_ex_ph5example COMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_POSTFLAGS} $) + if (BUILD_SHARED_LIBS) + add_test (NAME f90_ex-shared_ph5example COMMAND ${MPIEXEC} ${MPIEXEC_PREFLAGS} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS} ${MPIEXEC_POSTFLAGS} $) + endif (BUILD_SHARED_LIBS) endif (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt index c015072..8f63b3c 100644 --- a/fortran/src/CMakeLists.txt +++ b/fortran/src/CMakeLists.txt @@ -19,81 +19,49 @@ if (WIN32) endif (BUILD_SHARED_LIBS) endif (WIN32) +# configure for Fortran preprocessor + +# Define Parallel variable for passing to H5config_f.inc.cmake +set (CMAKE_H5_HAVE_PARALLEL 0) +if (H5_HAVE_PARALLEL) + set (CMAKE_H5_HAVE_PARALLEL 1) +endif (H5_HAVE_PARALLEL) + +set (CMAKE_H5_HAVE_FLOAT128 0) +if (HAVE_FLOAT128) + set (CMAKE_H5_HAVE_FLOAT128 1) +endif(HAVE_FLOAT128) + +configure_file (${HDF5_F90_SRC_SOURCE_DIR}/H5config_f.inc.cmake ${CMAKE_BINARY_DIR}/H5config_f.inc @ONLY) +configure_file (${HDF5_F90_SRC_SOURCE_DIR}/H5fort_type_defines.h.in ${HDF5_F90_BINARY_DIR}/H5fort_type_defines.h @ONLY) + #----------------------------------------------------------------------------- # Setup the Fortran auto-detection utilities -# H5test_kind(_SIZEOF,_STORAGE_SIZE).f90 used to generate H5fortran_detect.f90 -# H5fortran_detect.f90 used to generate H5fort_type_defines.h -# H5fort_type_defines.h used to generate H5f90i_gen.h + H5fortran_types.f90 +# H5_buildiface.F90 used to generate various KIND interfaces +# H5fort_type_defines.h used to generate H5f90i_gen.h + H5fortran_types.F90 #----------------------------------------------------------------------------- -if (FORTRAN_HAVE_STORAGE_SIZE) - add_executable (H5test_FortranHavekind - ${HDF5_F90_SRC_SOURCE_DIR}/H5test_kind_STORAGE_SIZE.f90 + +add_executable (H5_buildiface + ${HDF5_F90_SRC_SOURCE_DIR}/H5_buildiface.F90 ) - set (H5_TEST_KIND_NAME "h5test_kind_storage_size_mod") -else (FORTRAN_HAVE_STORAGE_SIZE) - if (FORTRAN_HAVE_SIZEOF) - add_executable (H5test_FortranHavekind - ${HDF5_F90_SRC_SOURCE_DIR}/H5test_kind_SIZEOF.f90 - ) - set (H5_TEST_KIND_NAME "h5test_kind_sizeof_mod") - else (FORTRAN_HAVE_SIZEOF) - add_executable (H5test_FortranHavekind - ${HDF5_F90_SRC_SOURCE_DIR}/H5test_kind.f90 - ) - endif (FORTRAN_HAVE_SIZEOF) -endif (FORTRAN_HAVE_STORAGE_SIZE) + if (WIN32 AND MSVC) if (BUILD_SHARED_LIBS) - set_target_properties (H5test_FortranHavekind + set_target_properties (H5_buildiface PROPERTIES COMPILE_FLAGS "/MT" ) endif (BUILD_SHARED_LIBS) - set_target_properties (H5test_FortranHavekind + set_target_properties (H5_buildiface PROPERTIES LINK_FLAGS "/SUBSYSTEM:CONSOLE" ) endif (WIN32 AND MSVC) -set_target_properties (H5test_FortranHavekind PROPERTIES +set_target_properties (H5_buildiface PROPERTIES LINKER_LANGUAGE Fortran Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} ) -set (CMD $) -add_custom_command ( - OUTPUT ${HDF5_F90_BINARY_DIR}/H5fortran_detect.f90 - COMMAND ${CMD} - ARGS > ${HDF5_F90_BINARY_DIR}/H5fortran_detect.f90 - WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR} - DEPENDS H5test_FortranHavekind -) -#----------------------------------------------------------------------------- -add_executable (H5fortran_detect - ${HDF5_F90_BINARY_DIR}/H5fortran_detect.f90 -) -if (WIN32 AND MSVC) - if (BUILD_SHARED_LIBS) - set_target_properties (H5fortran_detect - PROPERTIES - COMPILE_FLAGS "/MT" - ) - endif (BUILD_SHARED_LIBS) - set_target_properties (H5fortran_detect - PROPERTIES - LINK_FLAGS "/SUBSYSTEM:CONSOLE" - ) -endif (WIN32 AND MSVC) -set_target_properties (H5fortran_detect PROPERTIES LINKER_LANGUAGE Fortran) - -set (CMD $) -add_custom_command ( - OUTPUT ${HDF5_F90_BINARY_DIR}/H5fort_type_defines.h - COMMAND ${CMD} - ARGS > ${HDF5_F90_BINARY_DIR}/H5fort_type_defines.h - WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR} - DEPENDS H5fortran_detect -) - INCLUDE_DIRECTORIES (${HDF5_F90_BINARY_DIR} ${CMAKE_Fortran_MODULE_DIRECTORY}) #----------------------------------------------------------------------------- add_executable (H5match_types @@ -103,7 +71,7 @@ add_executable (H5match_types set (CMD $) add_custom_command ( OUTPUT ${HDF5_F90_BINARY_DIR}/H5f90i_gen.h - ${HDF5_F90_BINARY_DIR}/H5fortran_types.f90 + ${HDF5_F90_BINARY_DIR}/H5fortran_types.F90 COMMAND ${CMD} WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR} DEPENDS H5match_types @@ -131,12 +99,6 @@ set (f90CStub_C_SRCS ${HDF5_F90_SRC_SOURCE_DIR}/H5Zf.c ) -if (H5_HAVE_PARALLEL) - set (f90CStub_C_SRCS - ${f90CStub_C_SRCS} - ${HDF5_F90_SRC_SOURCE_DIR}/H5FDmpiof.c - ) -endif (H5_HAVE_PARALLEL) set_source_files_properties (${f90CStub_C_SRCS} PROPERTIES LANGUAGE C) set (f90CStub_C_HDRS @@ -144,147 +106,164 @@ set (f90CStub_C_HDRS ${HDF5_F90_BINARY_DIR}/H5f90i_gen.h ) -add_library (${HDF5_F90_C_LIB_TARGET} ${LIB_TYPE} ${f90CStub_C_SRCS} ${f90CStub_C_HDRS}) -TARGET_C_PROPERTIES (${HDF5_F90_C_LIB_TARGET} ${LIB_TYPE} " " " ") +add_library (${HDF5_F90_C_LIB_TARGET} STATIC ${f90CStub_C_SRCS} ${f90CStub_C_HDRS}) +TARGET_C_PROPERTIES (${HDF5_F90_C_LIB_TARGET} STATIC " " " ") target_link_libraries (${HDF5_F90_C_LIB_TARGET} ${HDF5_LIB_TARGET} ${LINK_LIBS}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_C_LIB_TARGET}") -H5_SET_LIB_OPTIONS (${HDF5_F90_C_LIB_TARGET} ${HDF5_F90_C_LIB_NAME} ${LIB_TYPE}) +H5_SET_LIB_OPTIONS (${HDF5_F90_C_LIB_TARGET} ${HDF5_F90_C_LIB_NAME} STATIC) set_target_properties (${HDF5_F90_C_LIB_TARGET} PROPERTIES FOLDER libraries/fortran LINKER_LANGUAGE C INTERFACE_INCLUDE_DIRECTORIES "$/include>" ) +set (install_targets ${HDF5_F90_C_LIB_TARGET}) -#----------------------------------------------------------------------------- -# Fortran 2003 standard -#----------------------------------------------------------------------------- -if (HDF5_ENABLE_F2003) - # F2003 features are enabled - set (F_STATUS "_F03") -else (HDF5_ENABLE_F2003) - # F2003 features are not enabled - set (F_STATUS "_F90") -endif (HDF5_ENABLE_F2003) +if (BUILD_SHARED_LIBS) + add_library (${HDF5_F90_C_LIBSH_TARGET} SHARED ${f90CStub_C_SRCS} ${f90CStub_C_HDRS}) + TARGET_C_PROPERTIES (${HDF5_F90_C_LIBSH_TARGET} SHARED " " " ") + target_link_libraries (${HDF5_F90_C_LIBSH_TARGET} ${HDF5_LIBSH_TARGET} ${LINK_SHARED_LIBS}) + set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_C_LIBSH_TARGET}") + H5_SET_LIB_OPTIONS (${HDF5_F90_C_LIBSH_TARGET} ${HDF5_F90_C_LIB_NAME} SHARED) + set_target_properties (${HDF5_F90_C_LIBSH_TARGET} PROPERTIES + FOLDER libraries/fortran + LINKER_LANGUAGE C + COMPILE_DEFINITIONS "H5_BUILT_AS_DYNAMIC_LIB" + INTERFACE_INCLUDE_DIRECTORIES "$/include>" + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB=1 + ) + set (install_targets ${install_targets} ${HDF5_F90_C_LIBSH_TARGET}) +endif (BUILD_SHARED_LIBS) -#----------------------------------------------------------------------------- -# Fortran Real Size -#----------------------------------------------------------------------------- -if (FORTRAN_DEFAULT_REAL_NOT_DOUBLE) - # default real is 4 bytes, so include double signatures - set (F_DBLE "Include") -else (FORTRAN_DEFAULT_REAL_NOT_DOUBLE) - # default real is 8 bytes, so exclude double signatures - set (F_DBLE "Exclude") -endif (FORTRAN_DEFAULT_REAL_NOT_DOUBLE) +set_source_files_properties (${HDF5_F90_BINARY_DIR}/H5_gen.F90 PROPERTIES GENERATED TRUE) #----------------------------------------------------------------------------- # Fortran Modules #----------------------------------------------------------------------------- -set (f90_F_SRCS +set (f90_F_BASE_SRCS # generated files - ${HDF5_F90_BINARY_DIR}/H5fortran_types.f90 + ${HDF5_F90_BINARY_DIR}/H5fortran_types.F90 # normal distribution - ${HDF5_F90_SRC_SOURCE_DIR}/H5f90global.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5_ff${F_STATUS}.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5_ff.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Aff.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Dff.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Eff.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Fff.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Gff.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Iff.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Lff.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Off.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Pff.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Rff.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Sff.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Tff.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Zff.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Aff${F_STATUS}.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Dff${F_STATUS}.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Eff${F_STATUS}.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Fff${F_STATUS}.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Lff${F_STATUS}.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Off${F_STATUS}.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Pff${F_STATUS}.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Rff${F_STATUS}.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5Tff${F_STATUS}.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5_DBLE_Interface${F_DBLE}.f90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5f90global.F90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5_ff.F90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Aff.F90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Dff.F90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Eff.F90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Fff.F90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Gff.F90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Iff.F90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Lff.F90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Off.F90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Pff.F90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Rff.F90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Sff.F90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Tff.F90 + ${HDF5_F90_SRC_SOURCE_DIR}/H5Zff.F90 +) + +set (f90_F_SRCS + ${f90_F_BASE_SRCS} + + # generated file + ${HDF5_F90_BINARY_DIR}/H5_gen.F90 + + # normal distribution + ${HDF5_F90_SRC_SOURCE_DIR}/HDF5.F90 +) + +set (CMD $) +add_custom_target (H5gen ALL + COMMAND ${CMD} +#v3.2 BYPRODUCT ${HDF5_F90_BINARY_DIR}/H5_gen.F90 + WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR} + DEPENDS ${f90_F_BASE_SRCS} ) -#----------------------------------------------------------------------------- -# Add H5FDMPIO if parallel -#----------------------------------------------------------------------------- -if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) - set (f90_F_SRCS - ${f90_F_SRCS} - ${HDF5_F90_SRC_SOURCE_DIR}/HDF5mpio.f90 - ${HDF5_F90_SRC_SOURCE_DIR}/H5FDmpioff.f90 - ) -else (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) - set (f90_F_SRCS - ${f90_F_SRCS} - ${HDF5_F90_SRC_SOURCE_DIR}/HDF5.f90 - ) -endif (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) set_source_files_properties (${f90_F_SRCS} PROPERTIES LANGUAGE Fortran) #----------------------------------------------------------------------------- # Add Main fortran library #----------------------------------------------------------------------------- -add_library (${HDF5_F90_LIB_TARGET} ${LIB_TYPE} ${f90_F_SRCS}) +add_library (${HDF5_F90_LIB_TARGET} STATIC ${f90_F_SRCS}) set (SHARED_LINK_FLAGS " ") -if (WIN32) - if (BUILD_SHARED_LIBS) - set_property (TARGET ${HDF5_F90_LIB_TARGET} - APPEND PROPERTY COMPILE_DEFINITIONS - BUILD_HDF5_DLL - ) - if (MSVC) - set (SHARED_LINK_FLAGS "/DLL /DEF:${HDF5_F90_SRC_BINARY_DIR}/hdf5_fortrandll.def") - endif (MSVC) - endif (BUILD_SHARED_LIBS) - set_property (TARGET ${HDF5_F90_LIB_TARGET} - APPEND PROPERTY COMPILE_DEFINITIONS - HDF5F90_WINDOWS - ) -endif (WIN32) -TARGET_FORTRAN_PROPERTIES (${HDF5_F90_LIB_TARGET} ${LIB_TYPE} " " ${SHARED_LINK_FLAGS}) +TARGET_FORTRAN_PROPERTIES (${HDF5_F90_LIB_TARGET} STATIC " " " ") target_link_libraries (${HDF5_F90_LIB_TARGET} ${HDF5_F90_C_LIB_TARGET} ${HDF5_LIB_TARGET}) if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) target_link_libraries (${HDF5_F90_LIB_TARGET} ${MPI_Fortran_LIBRARIES}) endif (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_LIB_TARGET}") -H5_SET_LIB_OPTIONS (${HDF5_F90_LIB_TARGET} ${HDF5_F90_LIB_NAME} ${LIB_TYPE}) +H5_SET_LIB_OPTIONS (${HDF5_F90_LIB_TARGET} ${HDF5_F90_LIB_NAME} STATIC) set_target_properties (${HDF5_F90_LIB_TARGET} PROPERTIES FOLDER libraries/fortran LINKER_LANGUAGE Fortran INTERFACE_INCLUDE_DIRECTORIES "$/include>" - Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/static ) +if (WIN32) + set_property (TARGET ${HDF5_F90_LIB_TARGET} + APPEND PROPERTY COMPILE_DEFINITIONS "HDF5F90_WINDOWS" + ) +endif (WIN32) +set (install_targets ${install_targets} ${HDF5_F90_LIB_TARGET}) + +if (BUILD_SHARED_LIBS) + add_library (${HDF5_F90_LIBSH_TARGET} SHARED ${f90_F_SRCS}) + set (SHARED_LINK_FLAGS " ") + if (WIN32 AND MSVC) + set (SHARED_LINK_FLAGS "/DLL /DEF:${HDF5_F90_SRC_BINARY_DIR}/hdf5_fortrandll.def") + endif (WIN32 AND MSVC) + TARGET_FORTRAN_PROPERTIES (${HDF5_F90_LIBSH_TARGET} SHARED " " ${SHARED_LINK_FLAGS}) + target_link_libraries (${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_C_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + if (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) + target_link_libraries (${HDF5_F90_LIBSH_TARGET} ${MPI_Fortran_LIBRARIES}) + endif (H5_HAVE_PARALLEL AND MPI_Fortran_FOUND) + set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_F90_LIBSH_TARGET}") + H5_SET_LIB_OPTIONS (${HDF5_F90_LIBSH_TARGET} ${HDF5_F90_LIB_NAME} SHARED) + set_target_properties (${HDF5_F90_LIBSH_TARGET} PROPERTIES + FOLDER libraries/fortran + LINKER_LANGUAGE Fortran + COMPILE_DEFINITIONS "H5_BUILT_AS_DYNAMIC_LIB" + INTERFACE_INCLUDE_DIRECTORIES "$/include>" + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB=1 + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + ) + if (WIN32) + set_property (TARGET ${HDF5_F90_LIBSH_TARGET} + APPEND PROPERTY COMPILE_DEFINITIONS "BUILD_HDF5_DLL;HDF5F90_WINDOWS" + ) + endif (WIN32) + set (install_targets ${install_targets} ${HDF5_F90_LIBSH_TARGET}) +endif (BUILD_SHARED_LIBS) #----------------------------------------------------------------------------- # Add file(s) to CMake Install #----------------------------------------------------------------------------- install ( - FILES - ${HDF5_F90_SRC_SOURCE_DIR}/H5f90.h - ${HDF5_F90_SRC_SOURCE_DIR}/H5f90i.h - ${HDF5_F90_SRC_SOURCE_DIR}/H5f90proto.h + FILES + ${HDF5_F90_SRC_SOURCE_DIR}/H5f90.h + ${HDF5_F90_SRC_SOURCE_DIR}/H5f90i.h + ${HDF5_F90_SRC_SOURCE_DIR}/H5f90proto.h ${HDF5_F90_BINARY_DIR}/H5f90i_gen.h - ${HDF5_F90_BINARY_DIR}/H5fortran_types.f90 - DESTINATION + ${HDF5_F90_BINARY_DIR}/H5fortran_types.F90 + DESTINATION ${HDF5_INSTALL_INCLUDE_DIR} - COMPONENT + COMPONENT fortheaders ) -if (WIN32) - set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/\${BUILD_TYPE}) -else (WIN32) - set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}) -endif (WIN32) +if (BUILD_SHARED_LIBS) + if (WIN32) + set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/shared/\${BUILD_TYPE}) + else (WIN32) + set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + endif (WIN32) +else (BUILD_SHARED_LIBS) + if (WIN32) + set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/static/\${BUILD_TYPE}) + else (WIN32) + set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/static) + endif (WIN32) +endif (BUILD_SHARED_LIBS) set (mod_files ${MOD_BUILD_DIR}/h5fortran_types.mod @@ -304,17 +283,7 @@ set (mod_files ${MOD_BUILD_DIR}/h5s.mod ${MOD_BUILD_DIR}/h5t.mod ${MOD_BUILD_DIR}/h5z.mod - ${MOD_BUILD_DIR}/h5a_provisional.mod - ${MOD_BUILD_DIR}/h5d_provisional.mod - ${MOD_BUILD_DIR}/h5e_provisional.mod - ${MOD_BUILD_DIR}/h5f_provisional.mod - ${MOD_BUILD_DIR}/h5l_provisional.mod - ${MOD_BUILD_DIR}/h5lib_provisional.mod - ${MOD_BUILD_DIR}/h5o_provisional.mod - ${MOD_BUILD_DIR}/h5p_provisional.mod - ${MOD_BUILD_DIR}/h5r_provisional.mod - ${MOD_BUILD_DIR}/h5t_provisional.mod - ${MOD_BUILD_DIR}/h5_dble_interface.mod + ${MOD_BUILD_DIR}/h5_gen.mod ) install ( FILES @@ -330,18 +299,18 @@ install ( #----------------------------------------------------------------------------- if (HDF5_EXPORTED_TARGETS) if (BUILD_SHARED_LIBS) - INSTALL_TARGET_PDB (${HDF5_F90_C_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} fortlibraries) - #INSTALL_TARGET_PDB (${HDF5_F90_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} fortlibraries) + INSTALL_TARGET_PDB (${HDF5_F90_C_LIBSH_TARGET} ${HDF5_INSTALL_BIN_DIR} fortlibraries) + #INSTALL_TARGET_PDB (${HDF5_F90_LIBSH_TARGET} ${HDF5_INSTALL_BIN_DIR} fortlibraries) endif (BUILD_SHARED_LIBS) install ( TARGETS - ${HDF5_F90_C_LIB_TARGET} - ${HDF5_F90_LIB_TARGET} + ${install_targets} EXPORT ${HDF5_EXPORTED_TARGETS} LIBRARY DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT fortlibraries ARCHIVE DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT fortlibraries RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT fortlibraries + FRAMEWORK DESTINATION ${HDF5_INSTALL_FWRK_DIR} COMPONENT fortlibraries ) endif (HDF5_EXPORTED_TARGETS) diff --git a/fortran/test/CMakeLists.txt b/fortran/test/CMakeLists.txt index 2893156..19d4975 100644 --- a/fortran/test/CMakeLists.txt +++ b/fortran/test/CMakeLists.txt @@ -9,57 +9,123 @@ INCLUDE_DIRECTORIES (${HDF5_F90_BINARY_DIR} ${HDF5_F90_SRC_DIR}/src) #----------------------------------------------------------------------------- # Add Test Lib #----------------------------------------------------------------------------- -add_library (${HDF5_F90_C_TEST_LIB_TARGET} ${LIB_TYPE} t.c) +add_library (${HDF5_F90_C_TEST_LIB_TARGET} STATIC t.c) set_source_files_properties (t.c PROPERTIES LANGUAGE C) -TARGET_C_PROPERTIES (${HDF5_F90_C_TEST_LIB_TARGET} ${LIB_TYPE} " " " ") +TARGET_C_PROPERTIES (${HDF5_F90_C_TEST_LIB_TARGET} STATIC " " " ") target_link_libraries (${HDF5_F90_C_TEST_LIB_TARGET} ${HDF5_F90_C_LIB_TARGET} ${HDF5_TEST_LIB_TARGET} ) -H5_SET_LIB_OPTIONS (${HDF5_F90_C_TEST_LIB_TARGET} ${HDF5_F90_C_TEST_LIB_NAME} ${LIB_TYPE}) +H5_SET_LIB_OPTIONS (${HDF5_F90_C_TEST_LIB_TARGET} ${HDF5_F90_C_TEST_LIB_NAME} STATIC) set_target_properties (${HDF5_F90_C_TEST_LIB_TARGET} PROPERTIES FOLDER libraries/test/fortran LINKER_LANGUAGE C INTERFACE_INCLUDE_DIRECTORIES "$/include>" ) +if (BUILD_SHARED_LIBS) + add_library (${HDF5_F90_C_TEST_LIBSH_TARGET} SHARED t.c) + TARGET_C_PROPERTIES (${HDF5_F90_C_TEST_LIBSH_TARGET} SHARED " " " ") + target_link_libraries (${HDF5_F90_C_TEST_LIBSH_TARGET} + ${HDF5_F90_C_LIBSH_TARGET} + ${HDF5_TEST_LIBSH_TARGET} + ) + H5_SET_LIB_OPTIONS (${HDF5_F90_C_TEST_LIBSH_TARGET} ${HDF5_F90_C_TEST_LIB_NAME} SHARED) + set_target_properties (${HDF5_F90_C_TEST_LIBSH_TARGET} PROPERTIES + FOLDER libraries/test/fortran + LINKER_LANGUAGE C + COMPILE_DEFINITIONS "H5_BUILT_AS_DYNAMIC_LIB" + INTERFACE_INCLUDE_DIRECTORIES "$/include>" + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB=1 + ) +endif (BUILD_SHARED_LIBS) -# See if the F2008 intrinsic STORAGE_SIZE and C_SIZEOF are supported. If not then -# fall back to F2003. If F2003 not supported then use F90 for the tests. - -set_source_files_properties (tf_F90.f90 tf_F03.f90 tf_F08.f90 tf.f90 PROPERTIES LANGUAGE Fortran) -if (FORTRAN_HAVE_STORAGE_SIZE AND FORTRAN_HAVE_C_SIZEOF) - add_library (${HDF5_F90_TEST_LIB_TARGET} ${LIB_TYPE} tf_F08.f90 tf.f90) -elseif (HDF5_ENABLE_F2003) - add_library (${HDF5_F90_TEST_LIB_TARGET} ${LIB_TYPE} tf_F03.f90 tf.f90) -else (FORTRAN_HAVE_STORAGE_SIZE AND FORTRAN_HAVE_C_SIZEOF) - add_library (${HDF5_F90_TEST_LIB_TARGET} ${LIB_TYPE} tf_F90.f90 tf.f90) -endif (FORTRAN_HAVE_STORAGE_SIZE AND FORTRAN_HAVE_C_SIZEOF) - +set_source_files_properties (tf.F90 ${HDF5_F90_BINARY_DIR}/tf_gen.F90 PROPERTIES LANGUAGE Fortran) +add_library (${HDF5_F90_TEST_LIB_TARGET} STATIC tf.F90 ${HDF5_F90_BINARY_DIR}/tf_gen.F90) +if (BUILD_SHARED_LIBS) + add_library (${HDF5_F90_TEST_LIBSH_TARGET} SHARED tf.F90 ${HDF5_F90_BINARY_DIR}/tf_gen.F90) +endif (BUILD_SHARED_LIBS) -set (SHARED_LINK_FLAGS " ") -if (WIN32) - if (BUILD_SHARED_LIBS) - set_property (TARGET ${HDF5_F90_TEST_LIB_TARGET} APPEND PROPERTY COMPILE_DEFINITIONS BUILD_HDF5_TEST_DLL) - if (MSVC) - set (SHARED_LINK_FLAGS "/DLL") - endif (MSVC) - endif (BUILD_SHARED_LIBS) - set_property (TARGET ${HDF5_F90_TEST_LIB_TARGET} APPEND PROPERTY COMPILE_DEFINITIONS HDF5F90_WINDOWS) -endif (WIN32) -TARGET_FORTRAN_PROPERTIES (${HDF5_F90_TEST_LIB_TARGET} ${LIB_TYPE} " " ${SHARED_LINK_FLAGS}) +TARGET_FORTRAN_PROPERTIES (${HDF5_F90_TEST_LIB_TARGET} STATIC " " " ") target_link_libraries (${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_C_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} ) -H5_SET_LIB_OPTIONS (${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_TEST_LIB_NAME} ${LIB_TYPE}) +H5_SET_LIB_OPTIONS (${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_TEST_LIB_NAME} STATIC) +target_include_directories (${HDF5_F90_TEST_LIB_TARGET} PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) set_target_properties (${HDF5_F90_TEST_LIB_TARGET} PROPERTIES FOLDER libraries/test/fortran LINKER_LANGUAGE Fortran INTERFACE_INCLUDE_DIRECTORIES "$/include>" + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/static +) +if (WIN32) + set_property (TARGET ${HDF5_F90_TEST_LIB_TARGET} APPEND PROPERTY + COMPILE_DEFINITIONS "HDF5F90_WINDOWS" + ) +endif (WIN32) +if (BUILD_SHARED_LIBS) + set (SHARED_LINK_FLAGS " ") + if (WIN32 AND MSVC) + set (SHARED_LINK_FLAGS "/DLL") + endif (WIN32 AND MSVC) + TARGET_FORTRAN_PROPERTIES (${HDF5_F90_TEST_LIBSH_TARGET} SHARED " " ${SHARED_LINK_FLAGS}) + target_link_libraries (${HDF5_F90_TEST_LIBSH_TARGET} + ${HDF5_F90_C_TEST_LIBSH_TARGET} + ${HDF5_F90_LIBSH_TARGET} + ${HDF5_LIBSH_TARGET} + ) + H5_SET_LIB_OPTIONS (${HDF5_F90_TEST_LIBSH_TARGET} ${HDF5_F90_TEST_LIB_NAME} SHARED) + target_include_directories (${HDF5_F90_TEST_LIBSH_TARGET} PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + set_target_properties (${HDF5_F90_TEST_LIBSH_TARGET} PROPERTIES + FOLDER libraries/test/fortran + LINKER_LANGUAGE Fortran + COMPILE_DEFINITIONS "H5_BUILT_AS_DYNAMIC_LIB" + INTERFACE_INCLUDE_DIRECTORIES "$/include>" + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB=1 + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + ) + if (WIN32) + set_property (TARGET ${HDF5_F90_TEST_LIBSH_TARGET} APPEND PROPERTY + COMPILE_DEFINITIONS "BUILD_HDF5_TEST_DLL;HDF5F90_WINDOWS" + ) + endif (WIN32) +endif (BUILD_SHARED_LIBS) + +#----------------------------------------------------------------------------- +# Setup the Fortran auto-detection utilities +# H5_test_buildiface.F90 used to generate various KIND test interfaces +#----------------------------------------------------------------------------- + +add_executable (H5_test_buildiface + ${HDF5_F90_SRC_DIR}/test/H5_test_buildiface.F90 + ) + +if (WIN32 AND MSVC) + if (BUILD_SHARED_LIBS) + set_target_properties (H5_test_buildiface + PROPERTIES + COMPILE_FLAGS "/MT" + ) + endif (BUILD_SHARED_LIBS) + set_target_properties (H5_test_buildiface + PROPERTIES + LINK_FLAGS "/SUBSYSTEM:CONSOLE" + ) +endif (WIN32 AND MSVC) +set_target_properties (H5_test_buildiface PROPERTIES + LINKER_LANGUAGE Fortran Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} ) +set (CMD $) +add_custom_command ( + OUTPUT ${HDF5_F90_BINARY_DIR}/tf_gen.F90 + COMMAND ${CMD} + WORKING_DIRECTORY ${HDF5_F90_BINARY_DIR} + DEPENDS H5_test_buildiface +) + #----------------------------------------------------------------------------- # Add Tests #----------------------------------------------------------------------------- @@ -82,8 +148,8 @@ add_executable (testhdf5_fortran tH5Z.f90 tHDF5.f90 ) -TARGET_NAMING (testhdf5_fortran ${LIB_TYPE}) -TARGET_FORTRAN_PROPERTIES (testhdf5_fortran ${LIB_TYPE} " " " ") +TARGET_NAMING (testhdf5_fortran STATIC) +TARGET_FORTRAN_PROPERTIES (testhdf5_fortran STATIC " " " ") target_link_libraries (testhdf5_fortran ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} @@ -96,8 +162,43 @@ target_include_directories (testhdf5_fortran PRIVATE ${CMAKE_Fortran_MODULE_DIRE set_target_properties (testhdf5_fortran PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran - Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/static ) +if (BUILD_SHARED_LIBS) + add_executable (testhdf5_fortran-shared + fortranlib_test.f90 + tH5A.f90 + tH5D.f90 + tH5E.f90 + tH5F.f90 + tH5G.f90 + tH5I.f90 + tH5P.f90 + tH5R.f90 + tH5S.f90 + tH5Sselect.f90 + tH5T.f90 + tH5VL.f90 + tH5Z.f90 + tHDF5.f90 + ) + TARGET_NAMING (testhdf5_fortran-shared SHARED) + TARGET_FORTRAN_PROPERTIES (testhdf5_fortran-shared SHARED " " " ") + target_link_libraries (testhdf5_fortran-shared + ${HDF5_F90_TEST_LIBSH_TARGET} + ${HDF5_F90_LIBSH_TARGET} + ${HDF5_LIBSH_TARGET} + ) + if (WIN32 AND MSVC) + target_link_libraries (testhdf5_fortran-shared "ws2_32.lib") + endif (WIN32 AND MSVC) + target_include_directories (testhdf5_fortran-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + set_target_properties (testhdf5_fortran-shared PROPERTIES + LINKER_LANGUAGE Fortran + FOLDER test/fortran + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + ) +endif (BUILD_SHARED_LIBS) #-- Adding test for testhdf5_fortran_1_8 add_executable (testhdf5_fortran_1_8 @@ -108,8 +209,8 @@ add_executable (testhdf5_fortran_1_8 tH5MISC_1_8.f90 tHDF5_1_8.f90 ) -TARGET_NAMING (testhdf5_fortran_1_8 ${LIB_TYPE}) -TARGET_FORTRAN_PROPERTIES (testhdf5_fortran_1_8 ${LIB_TYPE} " " " ") +TARGET_NAMING (testhdf5_fortran_1_8 STATIC) +TARGET_FORTRAN_PROPERTIES (testhdf5_fortran_1_8 STATIC " " " ") target_link_libraries (testhdf5_fortran_1_8 ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} @@ -122,43 +223,95 @@ target_include_directories (testhdf5_fortran_1_8 PRIVATE ${CMAKE_Fortran_MODULE_ set_target_properties (testhdf5_fortran_1_8 PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran - Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/static ) +if (BUILD_SHARED_LIBS) + add_executable (testhdf5_fortran_1_8-shared + fortranlib_test_1_8.f90 + tH5O.f90 + tH5A_1_8.f90 + tH5G_1_8.f90 + tH5MISC_1_8.f90 + tHDF5_1_8.f90 + ) + TARGET_NAMING (testhdf5_fortran_1_8-shared SHARED) + TARGET_FORTRAN_PROPERTIES (testhdf5_fortran_1_8-shared SHARED " " " ") + target_link_libraries (testhdf5_fortran_1_8-shared + ${HDF5_F90_TEST_LIBSH_TARGET} + ${HDF5_F90_LIBSH_TARGET} + ${HDF5_LIBSH_TARGET} + ) + if (WIN32 AND MSVC) + target_link_libraries (testhdf5_fortran_1_8-shared "ws2_32.lib") + endif (WIN32 AND MSVC) + target_include_directories (testhdf5_fortran_1_8-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + set_target_properties (testhdf5_fortran_1_8-shared PROPERTIES + LINKER_LANGUAGE Fortran + FOLDER test/fortran + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + ) +endif (BUILD_SHARED_LIBS) #-- Adding test for fortranlib_test_F03 -if (HDF5_ENABLE_F2003) - add_executable (fortranlib_test_F03 +add_executable (fortranlib_test_F03 + fortranlib_test_F03.f90 + tH5E_F03.f90 + tH5F_F03.f90 + tH5L_F03.f90 + tH5O_F03.f90 + tH5P_F03.f90 + tH5T_F03.F90 + tHDF5_F03.f90 +) +TARGET_NAMING (fortranlib_test_F03 STATIC) +TARGET_FORTRAN_PROPERTIES (fortranlib_test_F03 STATIC " " " ") +target_link_libraries (fortranlib_test_F03 + ${HDF5_F90_TEST_LIB_TARGET} + ${HDF5_F90_LIB_TARGET} + ${HDF5_LIB_TARGET} +) +if (WIN32 AND MSVC) + target_link_libraries (fortranlib_test_F03 "ws2_32.lib") +endif (WIN32 AND MSVC) +target_include_directories (fortranlib_test_F03 PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) +set_target_properties (fortranlib_test_F03 PROPERTIES + LINKER_LANGUAGE Fortran + FOLDER test/fortran + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/static +) +if (BUILD_SHARED_LIBS) + add_executable (fortranlib_test_F03-shared fortranlib_test_F03.f90 tH5E_F03.f90 tH5F_F03.f90 tH5L_F03.f90 tH5O_F03.f90 tH5P_F03.f90 - tH5T_F03.f90 + tH5T_F03.F90 tHDF5_F03.f90 ) - TARGET_NAMING (fortranlib_test_F03 ${LIB_TYPE}) - TARGET_FORTRAN_PROPERTIES (fortranlib_test_F03 ${LIB_TYPE} " " " ") - target_link_libraries (fortranlib_test_F03 - ${HDF5_F90_TEST_LIB_TARGET} - ${HDF5_F90_LIB_TARGET} - ${HDF5_LIB_TARGET} + TARGET_NAMING (fortranlib_test_F03-shared SHARED) + TARGET_FORTRAN_PROPERTIES (fortranlib_test_F03-shared SHARED " " " ") + target_link_libraries (fortranlib_test_F03-shared + ${HDF5_F90_TEST_LIBSH_TARGET} + ${HDF5_F90_LIBSH_TARGET} + ${HDF5_LIBSH_TARGET} ) if (WIN32 AND MSVC) - target_link_libraries (fortranlib_test_F03 "ws2_32.lib") + target_link_libraries (fortranlib_test_F03-shared "ws2_32.lib") endif (WIN32 AND MSVC) - target_include_directories (fortranlib_test_F03 PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) - set_target_properties (fortranlib_test_F03 PROPERTIES + target_include_directories (fortranlib_test_F03-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + set_target_properties (fortranlib_test_F03-shared PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran - Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} - ) -endif (HDF5_ENABLE_F2003) + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared +) +endif (BUILD_SHARED_LIBS) #-- Adding test for fflush1 add_executable (fflush1 fflush1.f90) -TARGET_NAMING (fflush1 ${LIB_TYPE}) -TARGET_FORTRAN_PROPERTIES (fflush1 ${LIB_TYPE} " " " ") +TARGET_NAMING (fflush1 STATIC) +TARGET_FORTRAN_PROPERTIES (fflush1 STATIC " " " ") target_link_libraries (fflush1 ${HDF5_F90_LIB_TARGET} ${HDF5_F90_TEST_LIB_TARGET} @@ -171,13 +324,32 @@ target_include_directories (fflush1 PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/st set_target_properties (fflush1 PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran - Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/static ) +if (BUILD_SHARED_LIBS) + add_executable (fflush1-shared fflush1.f90) + TARGET_NAMING (fflush1-shared SHARED) + TARGET_FORTRAN_PROPERTIES (fflush1-shared SHARED " " " ") + target_link_libraries (fflush1-shared + ${HDF5_F90_LIBSH_TARGET} + ${HDF5_F90_TEST_LIBSH_TARGET} + ${HDF5_LIBSH_TARGET} + ) + if (WIN32 AND MSVC) + target_link_libraries (fflush1-shared "ws2_32.lib") + endif (WIN32 AND MSVC) + target_include_directories (fflush1-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + set_target_properties (fflush1-shared PROPERTIES + LINKER_LANGUAGE Fortran + FOLDER test/fortran + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + ) +endif (BUILD_SHARED_LIBS) #-- Adding test for fflush2 add_executable (fflush2 fflush2.f90) -TARGET_NAMING (fflush2 ${LIB_TYPE}) -TARGET_FORTRAN_PROPERTIES (fflush2 ${LIB_TYPE} " " " ") +TARGET_NAMING (fflush2 STATIC) +TARGET_FORTRAN_PROPERTIES (fflush2 STATIC " " " ") target_link_libraries (fflush2 ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} @@ -190,7 +362,26 @@ target_include_directories (fflush2 PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/st set_target_properties (fflush2 PROPERTIES LINKER_LANGUAGE Fortran FOLDER test/fortran - Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/static ) +if (BUILD_SHARED_LIBS) + add_executable (fflush2-shared fflush2.f90) + TARGET_NAMING (fflush2-shared SHARED) + TARGET_FORTRAN_PROPERTIES (fflush2-shared SHARED " " " ") + target_link_libraries (fflush2-shared + ${HDF5_F90_TEST_LIBSH_TARGET} + ${HDF5_F90_LIBSH_TARGET} + ${HDF5_LIBSH_TARGET} + ) + if (WIN32 AND MSVC) + target_link_libraries (fflush2-shared "ws2_32.lib") + endif (WIN32 AND MSVC) + target_include_directories (fflush2-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + set_target_properties (fflush2-shared PROPERTIES + LINKER_LANGUAGE Fortran + FOLDER test/fortran + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + ) +endif (BUILD_SHARED_LIBS) include (CMakeTests.cmake) diff --git a/fortran/test/CMakeTests.cmake b/fortran/test/CMakeTests.cmake index 4df50ad..94f6b64 100644 --- a/fortran/test/CMakeTests.cmake +++ b/fortran/test/CMakeTests.cmake @@ -26,3 +26,29 @@ add_test (NAME FORTRAN_fflush1 COMMAND $) #-- Adding test for fflush2 add_test (NAME FORTRAN_fflush2 COMMAND $) set_tests_properties (FORTRAN_fflush2 PROPERTIES DEPENDS FORTRAN_fflush1) + +if (BUILD_SHARED_LIBS) + add_test (NAME FORTRAN_testhdf5_fortran-shared COMMAND $) + set_tests_properties (FORTRAN_testhdf5_fortran-shared PROPERTIES PASS_REGULAR_EXPRESSION "[ ]*0 error.s") + set_tests_properties (FORTRAN_testhdf5_fortran-shared PROPERTIES DEPENDS FORTRAN_testhdf5_fortran) + + #-- Adding test for testhdf5_fortran_1_8 + add_test (NAME FORTRAN_testhdf5_fortran_1_8-shared COMMAND $) + set_tests_properties (FORTRAN_testhdf5_fortran_1_8-shared PROPERTIES PASS_REGULAR_EXPRESSION "[ ]*0 error.s") + set_tests_properties (FORTRAN_testhdf5_fortran_1_8-shared PROPERTIES DEPENDS FORTRAN_testhdf5_fortran_1_8) + + #-- Adding test for fortranlib_test_F03 + if (HDF5_ENABLE_F2003) + add_test (NAME FORTRAN_fortranlib_test_F03-shared COMMAND $) + set_tests_properties (FORTRAN_fortranlib_test_F03-shared PROPERTIES PASS_REGULAR_EXPRESSION "[ ]*0 error.s") + set_tests_properties (FORTRAN_fortranlib_test_F03-shared PROPERTIES DEPENDS FORTRAN_fortranlib_test_F03) + endif (HDF5_ENABLE_F2003) + + #-- Adding test for fflush1 + add_test (NAME FORTRAN_fflush1-shared COMMAND $) + set_tests_properties (FORTRAN_fflush1-shared PROPERTIES DEPENDS FORTRAN_fflush2) + + #-- Adding test for fflush2 + add_test (NAME FORTRAN_fflush2-shared COMMAND $) + set_tests_properties (FORTRAN_fflush2-shared PROPERTIES DEPENDS FORTRAN_fflush1-shared) +endif (BUILD_SHARED_LIBS) diff --git a/fortran/testpar/CMakeLists.txt b/fortran/testpar/CMakeLists.txt index 98ef6c8..4f21419 100644 --- a/fortran/testpar/CMakeLists.txt +++ b/fortran/testpar/CMakeLists.txt @@ -16,8 +16,8 @@ add_executable (parallel_test hyper.f90 mdset.f90 ) -TARGET_NAMING (parallel_test ${LIB_TYPE}) -TARGET_FORTRAN_PROPERTIES (parallel_test ${LIB_TYPE} " " " ") +TARGET_NAMING (parallel_test STATIC) +TARGET_FORTRAN_PROPERTIES (parallel_test STATIC " " " ") target_link_libraries (parallel_test ${HDF5_F90_TEST_LIB_TARGET} ${HDF5_F90_LIB_TARGET} @@ -27,7 +27,7 @@ target_link_libraries (parallel_test if (WIN32 AND MSVC) target_link_libraries (parallel_test "ws2_32.lib") endif (WIN32 AND MSVC) -target_include_directories (parallel_test PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}) +target_include_directories (parallel_test PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) set_target_properties (parallel_test PROPERTIES LINKER_LANGUAGE Fortran) set_target_properties (parallel_test PROPERTIES FOLDER test/fortran) diff --git a/hl/CMakeLists.txt b/hl/CMakeLists.txt index b5d4308..bed8291 100644 --- a/hl/CMakeLists.txt +++ b/hl/CMakeLists.txt @@ -6,14 +6,6 @@ PROJECT (HDF5_HL C CXX) #----------------------------------------------------------------------------- add_definitions (${HDF_EXTRA_C_FLAGS}) -#----------------------------------------------------------------------------- -# Shared Libs -#----------------------------------------------------------------------------- -if (BUILD_SHARED_LIBS) - set (HL_BUILT_AS_DYNAMIC_LIB 1) -else (BUILD_SHARED_LIBS) - set (HL_BUILT_AS_STATIC_LIB 1) -endif (BUILD_SHARED_LIBS) #----------------------------------------------------------------------------- # List Source files diff --git a/hl/c++/examples/CMakeLists.txt b/hl/c++/examples/CMakeLists.txt index e3fc3ae..77a50bf 100644 --- a/hl/c++/examples/CMakeLists.txt +++ b/hl/c++/examples/CMakeLists.txt @@ -11,8 +11,8 @@ INCLUDE_DIRECTORIES (${HDF5_HL_CPP_SRC_DIR}/src) # Add in the examples for the Packet Table codes # -------------------------------------------------------------------- add_executable (ptExampleFL ${HDF5_HL_CPP_EXAMPLES_SOURCE_DIR}/ptExampleFL.cpp) -TARGET_NAMING (ptExampleFL ${LIB_TYPE}) -TARGET_C_PROPERTIES (ptExampleFL ${LIB_TYPE} " " " ") +TARGET_NAMING (ptExampleFL STATIC) +TARGET_C_PROPERTIES (ptExampleFL STATIC " " " ") target_link_libraries ( ptExampleFL ${HDF5_HL_CPP_LIB_TARGET} diff --git a/hl/c++/src/CMakeLists.txt b/hl/c++/src/CMakeLists.txt index 640cb2d..e37c5ba 100644 --- a/hl/c++/src/CMakeLists.txt +++ b/hl/c++/src/CMakeLists.txt @@ -10,19 +10,39 @@ INCLUDE_DIRECTORIES (${HDF5_HL_CPP_SRC_SOURCE_DIR}) set (HDF5_HL_CPP_SRCS ${HDF5_HL_CPP_SRC_SOURCE_DIR}/H5PacketTable.cpp) set (HDF5_HL_CPP_HDRS ${HDF5_HL_CPP_SRC_SOURCE_DIR}/H5PacketTable.h) -add_library (${HDF5_HL_CPP_LIB_TARGET} ${LIB_TYPE} ${HDF5_HL_CPP_SRCS}) -TARGET_C_PROPERTIES (${HDF5_HL_CPP_LIB_TARGET} ${LIB_TYPE} " " " ") +add_library (${HDF5_HL_CPP_LIB_TARGET} STATIC ${HDF5_HL_CPP_SRCS}) +TARGET_C_PROPERTIES (${HDF5_HL_CPP_LIB_TARGET} STATIC " " " ") target_link_libraries ( ${HDF5_HL_CPP_LIB_TARGET} ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET} ) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_CPP_LIB_TARGET}") -H5_SET_LIB_OPTIONS (${HDF5_HL_CPP_LIB_TARGET} ${HDF5_HL_CPP_LIB_NAME} ${LIB_TYPE}) +H5_SET_LIB_OPTIONS (${HDF5_HL_CPP_LIB_TARGET} ${HDF5_HL_CPP_LIB_NAME} STATIC) set_target_properties (${HDF5_HL_CPP_LIB_TARGET} PROPERTIES FOLDER libraries/hl INTERFACE_INCLUDE_DIRECTORIES "$/include>" ) +set (install_targets ${HDF5_HL_CPP_LIB_TARGET}) + +if (BUILD_SHARED_LIBS) + add_library (${HDF5_HL_CPP_LIBSH_TARGET} SHARED ${HDF5_HL_CPP_SRCS}) + TARGET_C_PROPERTIES (${HDF5_HL_CPP_LIBSH_TARGET} SHARED " " " ") + target_link_libraries ( + ${HDF5_HL_CPP_LIBSH_TARGET} + ${HDF5_HL_LIBSH_TARGET} + ${HDF5_LIBSH_TARGET} + ) + set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_CPP_LIBSH_TARGET}") + H5_SET_LIB_OPTIONS (${HDF5_HL_CPP_LIBSH_TARGET} ${HDF5_HL_CPP_LIB_NAME} SHARED) + set_target_properties (${HDF5_HL_CPP_LIBSH_TARGET} PROPERTIES + FOLDER libraries/hl + COMPILE_DEFINITIONS "H5_BUILT_AS_DYNAMIC_LIB" + INTERFACE_INCLUDE_DIRECTORIES "$/include>" + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB=1 + ) + set (install_targets ${install_targets} ${HDF5_HL_CPP_LIBSH_TARGET}) +endif (BUILD_SHARED_LIBS) #----------------------------------------------------------------------------- # Add file(s) to CMake Install @@ -41,16 +61,17 @@ install ( #----------------------------------------------------------------------------- if (HDF5_EXPORTED_TARGETS) if (BUILD_SHARED_LIBS) - INSTALL_TARGET_PDB (${HDF5_HL_CPP_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} hlcpplibraries) + INSTALL_TARGET_PDB (${HDF5_HL_CPP_LIBSH_TARGET} ${HDF5_INSTALL_BIN_DIR} hlcpplibraries) endif (BUILD_SHARED_LIBS) install ( TARGETS - ${HDF5_HL_CPP_LIB_TARGET} + ${install_targets} EXPORT ${HDF5_EXPORTED_TARGETS} LIBRARY DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT hlcpplibraries ARCHIVE DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT hlcpplibraries RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT hlcpplibraries + FRAMEWORK DESTINATION ${HDF5_INSTALL_FWRK_DIR} COMPONENT hlcpplibraries ) endif (HDF5_EXPORTED_TARGETS) diff --git a/hl/c++/test/CMakeLists.txt b/hl/c++/test/CMakeLists.txt index ff06b22..de5b363 100644 --- a/hl/c++/test/CMakeLists.txt +++ b/hl/c++/test/CMakeLists.txt @@ -16,8 +16,8 @@ INCLUDE_DIRECTORIES (${HDF5_HL_SRC_DIR}/test) INCLUDE_DIRECTORIES (${HDF5_CPP_SRC_DIR}/src) add_executable (hl_ptableTest ${HDF5_HL_CPP_TEST_SOURCE_DIR}/ptableTest.cpp) -TARGET_C_PROPERTIES (hl_ptableTest ${LIB_TYPE} " " " ") -TARGET_NAMING (hl_ptableTest ${LIB_TYPE}) +TARGET_C_PROPERTIES (hl_ptableTest STATIC " " " ") +TARGET_NAMING (hl_ptableTest STATIC) target_link_libraries ( hl_ptableTest ${HDF5_LIB_TARGET} diff --git a/hl/examples/CMakeLists.txt b/hl/examples/CMakeLists.txt index e264f75..f5e6f5e 100644 --- a/hl/examples/CMakeLists.txt +++ b/hl/examples/CMakeLists.txt @@ -28,8 +28,8 @@ set (examples foreach (example ${examples}) add_executable (hl_ex_${example} ${HDF5_HL_EXAMPLES_SOURCE_DIR}/${example}.c) - TARGET_NAMING (hl_ex_${example} ${LIB_TYPE}) - TARGET_C_PROPERTIES (hl_ex_${example} ${LIB_TYPE} " " " ") + TARGET_NAMING (hl_ex_${example} STATIC) + TARGET_C_PROPERTIES (hl_ex_${example} STATIC " " " ") target_link_libraries (hl_ex_${example} ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (hl_ex_${example} PROPERTIES FOLDER examples/hl) endforeach (example ${examples}) diff --git a/hl/fortran/examples/CMakeLists.txt b/hl/fortran/examples/CMakeLists.txt index bded2d9..87838a0 100644 --- a/hl/fortran/examples/CMakeLists.txt +++ b/hl/fortran/examples/CMakeLists.txt @@ -16,14 +16,14 @@ set (examples foreach (example ${examples}) add_executable (hl_f90_ex_${example} ${HDF5_HL_F90_EXAMPLES_SOURCE_DIR}/${example}.f90) - TARGET_NAMING (hl_f90_ex_${example} ${LIB_TYPE}) - TARGET_FORTRAN_PROPERTIES (hl_f90_ex_${example} ${LIB_TYPE} " " " ") + TARGET_NAMING (hl_f90_ex_${example} STATIC) + TARGET_FORTRAN_PROPERTIES (hl_f90_ex_${example} STATIC " " " ") target_link_libraries (hl_f90_ex_${example} ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET} ${HDF5_LIB_TARGET} ) - target_include_directories (hl_f90_ex_${example} PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}) + target_include_directories (hl_f90_ex_${example} PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) set_target_properties (hl_f90_ex_${example} PROPERTIES LINKER_LANGUAGE Fortran) set_target_properties (hl_f90_ex_${example} PROPERTIES FOLDER examples/hl/fortran) diff --git a/hl/fortran/src/CMakeLists.txt b/hl/fortran/src/CMakeLists.txt index 6e6e44a..9d110a8 100644 --- a/hl/fortran/src/CMakeLists.txt +++ b/hl/fortran/src/CMakeLists.txt @@ -2,12 +2,48 @@ cmake_minimum_required (VERSION 3.1.0) PROJECT(HDF5_HL_F90_SRC C CXX Fortran) #----------------------------------------------------------------------------- +# configure def file for shared libs on windows +if (WIN32) + if (BUILD_SHARED_LIBS) + if (MSVC) + configure_file (${HDF5_HL_F90_SRC_SOURCE_DIR}/hdf5_hl_fortrandll.def.in ${HDF5_HL_F90_SRC_BINARY_DIR}/hdf5_hl_fortrandll.def @ONLY) + endif (MSVC) + endif (BUILD_SHARED_LIBS) +endif (WIN32) + +#----------------------------------------------------------------------------- +# Generate the H5LT and H5TB REAL APIs +#----------------------------------------------------------------------------- + +add_executable (H5HL_buildiface + ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5HL_buildiface.F90 + ) + +if (WIN32 AND MSVC) + if (BUILD_SHARED_LIBS) + set_target_properties (H5HL_buildiface + PROPERTIES + COMPILE_FLAGS "/MT" + ) + endif (BUILD_SHARED_LIBS) + set_target_properties (H5HL_buildiface + PROPERTIES + LINK_FLAGS "/SUBSYSTEM:CONSOLE" + ) +endif (WIN32 AND MSVC) +set_target_properties (H5HL_buildiface PROPERTIES + LINKER_LANGUAGE Fortran + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} +) + +#----------------------------------------------------------------------------- # Setup include Directories #----------------------------------------------------------------------------- INCLUDE_DIRECTORIES ( ${HDF5_HL_SRC_DIR}/src ${HDF5_F90_SRC_DIR}/src ${HDF5_F90_BINARY_DIR} + ${CMAKE_Fortran_MODULE_DIRECTORY} ) #----------------------------------------------------------------------------- @@ -24,72 +60,135 @@ set_source_files_properties (${HDF5_HL_F90_C_SRCS} PROPERTIES LANGUAGE C) set (HDF5_HL_F90_HEADERS ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5LTf90proto.h) -add_library (${HDF5_HL_F90_C_LIB_TARGET} ${LIB_TYPE} ${HDF5_HL_F90_C_SRCS} ${HDF5_HL_F90_HEADERS}) -TARGET_C_PROPERTIES (${HDF5_HL_F90_C_LIB_TARGET} ${LIB_TYPE} " " " ") +add_library (${HDF5_HL_F90_C_LIB_TARGET} STATIC ${HDF5_HL_F90_C_SRCS} ${HDF5_HL_F90_HEADERS}) +TARGET_C_PROPERTIES (${HDF5_HL_F90_C_LIB_TARGET} STATIC " " " ") target_link_libraries (${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_F90_C_LIB_TARGET} ${HDF5_HL_LIB_TARGET}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_F90_C_LIB_TARGET}") -H5_SET_LIB_OPTIONS (${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_HL_F90_C_LIB_NAME} ${LIB_TYPE}) +H5_SET_LIB_OPTIONS (${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_HL_F90_C_LIB_NAME} STATIC) set_target_properties (${HDF5_HL_F90_C_LIB_TARGET} PROPERTIES FOLDER libraries/hl/fortran LINKER_LANGUAGE C INTERFACE_INCLUDE_DIRECTORIES "$/include>" ) +set (install_targets ${HDF5_HL_F90_C_LIB_TARGET}) + +if (BUILD_SHARED_LIBS) + add_library (${HDF5_HL_F90_C_LIBSH_TARGET} SHARED ${HDF5_HL_F90_C_SRCS} ${HDF5_HL_F90_HEADERS}) + TARGET_C_PROPERTIES (${HDF5_HL_F90_C_LIBSH_TARGET} SHARED " " " ") + target_link_libraries (${HDF5_HL_F90_C_LIBSH_TARGET} ${HDF5_F90_C_LIBSH_TARGET} ${HDF5_HL_LIBSH_TARGET}) + set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_F90_C_LIBSH_TARGET}") + H5_SET_LIB_OPTIONS (${HDF5_HL_F90_C_LIBSH_TARGET} ${HDF5_HL_F90_C_LIB_NAME} SHARED) + set_target_properties (${HDF5_HL_F90_C_LIBSH_TARGET} PROPERTIES + FOLDER libraries/hl/fortran + LINKER_LANGUAGE C + COMPILE_DEFINITIONS "H5_BUILT_AS_DYNAMIC_LIB" + INTERFACE_INCLUDE_DIRECTORIES "$/include>" + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB=1 + ) + set (install_targets ${install_targets} ${HDF5_HL_F90_C_LIBSH_TARGET}) +endif (BUILD_SHARED_LIBS) #----------------------------------------------------------------------------- # Fortran Modules #----------------------------------------------------------------------------- +set (HDF5_HL_F90_F_BASE_SRCS + ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5DSff.F90 + ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5TBff.F90 + ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5LTff.F90 + ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5IMff.F90 +) set (HDF5_HL_F90_F_SRCS - ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5DSff.f90 - ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5TBff.f90 - ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5LTff.f90 - ${HDF5_HL_F90_SRC_SOURCE_DIR}/H5IMff.f90 + ${HDF5_HL_F90_F_BASE_SRCS} + + # generated files + ${HDF5_HL_F90_SRC_BINARY_DIR}/H5LTff_gen.F90 + ${HDF5_HL_F90_SRC_BINARY_DIR}/H5TBff_gen.F90 ) + set_source_files_properties (${HDF5_HL_F90_F_SRCS} PROPERTIES LANGUAGE Fortran) -add_library (${HDF5_HL_F90_LIB_TARGET} ${LIB_TYPE} ${HDF5_HL_F90_F_SRCS}) -set (SHARED_LINK_FLAGS " ") -if (BUILD_SHARED_LIBS) - if (WIN32) - set_property (TARGET ${HDF5_HL_F90_LIB_TARGET} - APPEND PROPERTY COMPILE_DEFINITIONS - BUILD_HDF5_HL_DLL - ) - if (MSVC) - set (SHARED_LINK_FLAGS "/DLL") - endif (MSVC) - endif (WIN32) -endif (BUILD_SHARED_LIBS) -if (WIN32) - set_property (TARGET ${HDF5_HL_F90_LIB_TARGET} - APPEND PROPERTY COMPILE_DEFINITIONS - HDF5F90_WINDOWS - ) -endif (WIN32) -TARGET_FORTRAN_PROPERTIES (${HDF5_HL_F90_LIB_TARGET} ${LIB_TYPE} " " ${SHARED_LINK_FLAGS}) +set_source_files_properties ( + ${HDF5_HL_F90_SRC_BINARY_DIR}/H5LTff_gen.F90 + ${HDF5_HL_F90_SRC_BINARY_DIR}/H5TBff_gen.F90 + PROPERTIES GENERATED TRUE +) + +set (CMD $) +add_custom_target (H5HLgen ALL + COMMAND ${CMD} +#v3.2 BYPRODUCT ${HDF5_HL_F90_SRC_BINARY_DIR}/H5LTff_gen.F90 +#v3.2 ${HDF5_HL_F90_SRC_BINARY_DIR}/H5TBff_gen.F90 + WORKING_DIRECTORY ${HDF5_HL_F90_SRC_BINARY_DIR} + DEPENDS ${HDF5_HL_F90_F_BASE_SRCS} +) + +add_library (${HDF5_HL_F90_LIB_TARGET} STATIC ${HDF5_HL_F90_F_SRCS}) +TARGET_FORTRAN_PROPERTIES (${HDF5_HL_F90_LIB_TARGET} STATIC " " " ") target_link_libraries (${HDF5_HL_F90_LIB_TARGET} ${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_F90_LIB_TARGET}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_F90_LIB_TARGET}") -H5_SET_LIB_OPTIONS (${HDF5_HL_F90_LIB_TARGET} ${HDF5_HL_F90_LIB_NAME} ${LIB_TYPE}) +H5_SET_LIB_OPTIONS (${HDF5_HL_F90_LIB_TARGET} ${HDF5_HL_F90_LIB_NAME} STATIC) set_target_properties (${HDF5_HL_F90_LIB_TARGET} PROPERTIES FOLDER libraries/hl/fortran LINKER_LANGUAGE Fortran INTERFACE_INCLUDE_DIRECTORIES "$/include>" - Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY} + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/static ) +if (WIN32) + set_property (TARGET ${HDF5_HL_F90_LIB_TARGET} + APPEND PROPERTY COMPILE_DEFINITIONS "HDF5F90_WINDOWS" + ) +endif (WIN32) +set (install_targets ${install_targets} ${HDF5_HL_F90_LIB_TARGET}) + +if (BUILD_SHARED_LIBS) + add_library (${HDF5_HL_F90_LIBSH_TARGET} SHARED ${HDF5_HL_F90_F_SRCS}) + set (SHARED_LINK_FLAGS " ") + if (WIN32 AND MSVC) + set (SHARED_LINK_FLAGS "/DLL /DEF:${HDF5_HL_F90_SRC_BINARY_DIR}/hdf5_hl_fortrandll.def") + endif (WIN32 AND MSVC) + TARGET_FORTRAN_PROPERTIES (${HDF5_HL_F90_LIBSH_TARGET} SHARED " " ${SHARED_LINK_FLAGS}) + target_link_libraries (${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_HL_F90_C_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET}) + set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_F90_LIBSH_TARGET}") + H5_SET_LIB_OPTIONS (${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_HL_F90_LIB_NAME} SHARED) + set_target_properties (${HDF5_HL_F90_LIBSH_TARGET} PROPERTIES + FOLDER libraries/hl/fortran + LINKER_LANGUAGE Fortran + INTERFACE_INCLUDE_DIRECTORIES "$/include>" + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB=1 + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + ) + if (WIN32) + set_property (TARGET ${HDF5_HL_F90_LIBSH_TARGET} + APPEND PROPERTY COMPILE_DEFINITIONS "BUILD_HDF5_HL_DLL;HDF5F90_WINDOWS" + ) + endif (WIN32) + set (install_targets ${install_targets} ${HDF5_HL_F90_LIBSH_TARGET}) +endif (BUILD_SHARED_LIBS) #----------------------------------------------------------------------------- # Add file(s) to CMake Install #----------------------------------------------------------------------------- -if (WIN32) - set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/\${BUILD_TYPE}) -else (WIN32) - set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}) -endif (WIN32) +if (BUILD_SHARED_LIBS) + if (WIN32) + set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/shared/\${BUILD_TYPE}) + else (WIN32) + set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + endif (WIN32) +else (BUILD_SHARED_LIBS) + if (WIN32) + set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/static/\${BUILD_TYPE}) + else (WIN32) + set (MOD_BUILD_DIR ${CMAKE_Fortran_MODULE_DIRECTORY}/static) + endif (WIN32) +endif (BUILD_SHARED_LIBS) set (mod_files ${MOD_BUILD_DIR}/h5ds.mod ${MOD_BUILD_DIR}/h5tb.mod + ${MOD_BUILD_DIR}/h5tb_const.mod ${MOD_BUILD_DIR}/h5lt.mod + ${MOD_BUILD_DIR}/h5lt_const.mod ${MOD_BUILD_DIR}/h5im.mod ) @@ -107,18 +206,18 @@ install ( #----------------------------------------------------------------------------- if (HDF5_EXPORTED_TARGETS) if (BUILD_SHARED_LIBS) - INSTALL_TARGET_PDB (${HDF5_HL_F90_C_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} hlfortlibraries) - #INSTALL_TARGET_PDB (${HDF5_HL_F90_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} hlfortlibraries) + INSTALL_TARGET_PDB (${HDF5_HL_F90_C_LIBSH_TARGET} ${HDF5_INSTALL_BIN_DIR} hlfortlibraries) + #INSTALL_TARGET_PDB (${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_INSTALL_BIN_DIR} hlfortlibraries) endif (BUILD_SHARED_LIBS) - + install ( TARGETS - ${HDF5_HL_F90_C_LIB_TARGET} - ${HDF5_HL_F90_LIB_TARGET} + ${install_targets} EXPORT ${HDF5_EXPORTED_TARGETS} LIBRARY DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT hlfortlibraries ARCHIVE DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT hlfortlibraries RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT hlfortlibraries + FRAMEWORK DESTINATION ${HDF5_INSTALL_FWRK_DIR} COMPONENT hlfortlibraries ) endif (HDF5_EXPORTED_TARGETS) diff --git a/hl/fortran/test/CMakeLists.txt b/hl/fortran/test/CMakeLists.txt index 55fb987..a1d1386 100644 --- a/hl/fortran/test/CMakeLists.txt +++ b/hl/fortran/test/CMakeLists.txt @@ -7,39 +7,87 @@ PROJECT (HDF5_HL_FORTRAN_TESTS C CXX Fortran) INCLUDE_DIRECTORIES (${CMAKE_Fortran_MODULE_DIRECTORY} ${HDF5_F90_BINARY_DIR} ${HDF5_F90_SRC_DIR}/src) #-- Adding test for hl_f90_tstds -add_executable (hl_f90_tstds tstds.f90) -TARGET_NAMING (hl_f90_tstds ${LIB_TYPE}) -TARGET_FORTRAN_PROPERTIES (hl_f90_tstds ${LIB_TYPE} " " " ") +add_executable (hl_f90_tstds tstds.F90) +TARGET_NAMING (hl_f90_tstds STATIC) +TARGET_FORTRAN_PROPERTIES (hl_f90_tstds STATIC " " " ") target_link_libraries (hl_f90_tstds ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET}) -target_include_directories (hl_f90_tstds PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}) +target_include_directories (hl_f90_tstds PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) set_target_properties (hl_f90_tstds PROPERTIES LINKER_LANGUAGE Fortran) set_target_properties (hl_f90_tstds PROPERTIES FOLDER test/hl/fortran) +if (BUILD_SHARED_LIBS) + add_executable (hl_f90_tstds-shared tstds.F90) + TARGET_NAMING (hl_f90_tstds-shared SHARED) + TARGET_FORTRAN_PROPERTIES (hl_f90_tstds-shared SHARED " " " ") + target_link_libraries (hl_f90_tstds-shared ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET}) + target_include_directories (hl_f90_tstds-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + set_target_properties (hl_f90_tstds-shared PROPERTIES + LINKER_LANGUAGE Fortran + FOLDER test/hl/fortran + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + ) +endif (BUILD_SHARED_LIBS) #-- Adding test for hl_f90_tstlite -add_executable (hl_f90_tstlite tstlite.f90) -TARGET_NAMING (hl_f90_tstlite ${LIB_TYPE}) -TARGET_FORTRAN_PROPERTIES (hl_f90_tstlite ${LIB_TYPE} " " " ") +add_executable (hl_f90_tstlite tstlite.F90) +TARGET_NAMING (hl_f90_tstlite STATIC) +TARGET_FORTRAN_PROPERTIES (hl_f90_tstlite STATIC " " " ") target_link_libraries (hl_f90_tstlite ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET}) -target_include_directories (hl_f90_tstlite PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}) +target_include_directories (hl_f90_tstlite PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) set_target_properties (hl_f90_tstlite PROPERTIES LINKER_LANGUAGE Fortran) set_target_properties (hl_f90_tstlite PROPERTIES FOLDER test/hl/fortran) +if (BUILD_SHARED_LIBS) + add_executable (hl_f90_tstlite-shared tstlite.F90) + TARGET_NAMING (hl_f90_tstlite-shared SHARED) + TARGET_FORTRAN_PROPERTIES (hl_f90_tstlite-shared SHARED " " " ") + target_link_libraries (hl_f90_tstlite-shared ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET}) + target_include_directories (hl_f90_tstlite-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + set_target_properties (hl_f90_tstlite-shared PROPERTIES + LINKER_LANGUAGE Fortran + FOLDER test/hl/fortran + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + ) +endif (BUILD_SHARED_LIBS) #-- Adding test for hl_f90_tstimage -add_executable (hl_f90_tstimage tstimage.f90) -TARGET_NAMING (hl_f90_tstimage ${LIB_TYPE}) -TARGET_FORTRAN_PROPERTIES (hl_f90_tstimage ${LIB_TYPE} " " " ") +add_executable (hl_f90_tstimage tstimage.F90) +TARGET_NAMING (hl_f90_tstimage STATIC) +TARGET_FORTRAN_PROPERTIES (hl_f90_tstimage STATIC " " " ") target_link_libraries (hl_f90_tstimage ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET}) -target_include_directories (hl_f90_tstimage PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}) +target_include_directories (hl_f90_tstimage PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) set_target_properties (hl_f90_tstimage PROPERTIES LINKER_LANGUAGE Fortran) set_target_properties (hl_f90_tstimage PROPERTIES FOLDER test/hl/fortran) +if (BUILD_SHARED_LIBS) + add_executable (hl_f90_tstimage-shared tstimage.F90) + TARGET_NAMING (hl_f90_tstimage-shared SHARED) + TARGET_FORTRAN_PROPERTIES (hl_f90_tstimage-shared SHARED " " " ") + target_link_libraries (hl_f90_tstimage-shared ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET}) + target_include_directories (hl_f90_tstimage-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + set_target_properties (hl_f90_tstimage-shared PROPERTIES + LINKER_LANGUAGE Fortran + FOLDER test/hl/fortran + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + ) +endif (BUILD_SHARED_LIBS) #-- Adding test for hl_f90_tsttable -add_executable (hl_f90_tsttable tsttable.f90) -TARGET_NAMING (hl_f90_tsttable ${LIB_TYPE}) -TARGET_FORTRAN_PROPERTIES (hl_f90_tsttable ${LIB_TYPE} " " " ") +add_executable (hl_f90_tsttable tsttable.F90) +TARGET_NAMING (hl_f90_tsttable STATIC) +TARGET_FORTRAN_PROPERTIES (hl_f90_tsttable STATIC " " " ") target_link_libraries (hl_f90_tsttable ${HDF5_HL_F90_LIB_TARGET} ${HDF5_F90_LIB_TARGET}) -target_include_directories (hl_f90_tsttable PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}) +target_include_directories (hl_f90_tsttable PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/static) set_target_properties (hl_f90_tsttable PROPERTIES LINKER_LANGUAGE Fortran) set_target_properties (hl_f90_tsttable PROPERTIES FOLDER test/hl/fortran) +if (BUILD_SHARED_LIBS) + add_executable (hl_f90_tsttable-shared tsttable.F90) + TARGET_NAMING (hl_f90_tsttable-shared SHARED) + TARGET_FORTRAN_PROPERTIES (hl_f90_tsttable-shared SHARED " " " ") + target_link_libraries (hl_f90_tsttable-shared ${HDF5_HL_F90_LIBSH_TARGET} ${HDF5_F90_LIBSH_TARGET}) + target_include_directories (hl_f90_tsttable-shared PRIVATE ${CMAKE_Fortran_MODULE_DIRECTORY}/shared) + set_target_properties (hl_f90_tsttable-shared PROPERTIES + LINKER_LANGUAGE Fortran + FOLDER test/hl/fortran + Fortran_MODULE_DIRECTORY ${CMAKE_Fortran_MODULE_DIRECTORY}/shared + ) +endif (BUILD_SHARED_LIBS) include (CMakeTests.cmake) diff --git a/hl/fortran/test/CMakeTests.cmake b/hl/fortran/test/CMakeTests.cmake index 3676d24..38181bf 100644 --- a/hl/fortran/test/CMakeTests.cmake +++ b/hl/fortran/test/CMakeTests.cmake @@ -31,3 +31,34 @@ set_tests_properties (HL_FORTRAN_f90_tstimage PROPERTIES DEPENDS HL_FORTRAN_test add_test (NAME HL_FORTRAN_f90_tsttable COMMAND $) set_tests_properties (HL_FORTRAN_f90_tsttable PROPERTIES DEPENDS HL_FORTRAN_test-clear-objects) + +if (BUILD_SHARED_LIBS) + add_test ( + NAME HL_FORTRAN_test-shared-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + dsetf1.h5 + dsetf2.h5 + dsetf3.h5 + dsetf4.h5 + dsetf5.h5 + f1img.h5 + f1tab.h5 + tstds.h5 + ) + set_tests_properties (HL_FORTRAN_test-shared-clear-objects + PROPERTIES DEPENDS "HL_FORTRAN_f90_tsttable;HL_FORTRAN_f90_tstimage;HL_FORTRAN_f90_tstlite;HL_FORTRAN_f90_tstds" + ) + + add_test (NAME HL_FORTRAN_f90_tstds-shared COMMAND $) + set_tests_properties (HL_FORTRAN_f90_tstds-shared PROPERTIES DEPENDS HL_FORTRAN_test-shared-clear-objects) + + add_test (NAME HL_FORTRAN_f90_tstlite-shared COMMAND $) + set_tests_properties (HL_FORTRAN_f90_tstlite-shared PROPERTIES DEPENDS HL_FORTRAN_test-shared-clear-objects) + + add_test (NAME HL_FORTRAN_f90_tstimage-shared COMMAND $) + set_tests_properties (HL_FORTRAN_f90_tstimage-shared PROPERTIES DEPENDS HL_FORTRAN_test-shared-clear-objects) + + add_test (NAME HL_FORTRAN_f90_tsttable-shared COMMAND $) + set_tests_properties (HL_FORTRAN_f90_tsttable-shared PROPERTIES DEPENDS HL_FORTRAN_test-shared-clear-objects) +endif (BUILD_SHARED_LIBS) diff --git a/hl/src/CMakeLists.txt b/hl/src/CMakeLists.txt index 3c24e40..23943f9 100644 --- a/hl/src/CMakeLists.txt +++ b/hl/src/CMakeLists.txt @@ -1,12 +1,6 @@ cmake_minimum_required (VERSION 3.1.0) PROJECT (HDF5_HL_SRC) -#----------------------------------------------------------------------------- -# Shared Libs -#----------------------------------------------------------------------------- -if (BUILD_SHARED_LIBS) - set (HL_BUILT_AS_DYNAMIC_LIB 1) -endif (BUILD_SHARED_LIBS) #----------------------------------------------------------------------------- # List Source files @@ -33,15 +27,31 @@ set (HL_HEADERS ${HDF5_HL_SRC_SOURCE_DIR}/hdf5_hl.h ) -add_library (${HDF5_HL_LIB_TARGET} ${LIB_TYPE} ${HL_SRCS} ${HL_HEADERS}) -TARGET_C_PROPERTIES (${HDF5_HL_LIB_TARGET} ${LIB_TYPE} " " " ") +add_library (${HDF5_HL_LIB_TARGET} STATIC ${HL_SRCS} ${HL_HEADERS}) +TARGET_C_PROPERTIES (${HDF5_HL_LIB_TARGET} STATIC " " " ") target_link_libraries (${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET}) -H5_SET_LIB_OPTIONS (${HDF5_HL_LIB_TARGET} ${HDF5_HL_LIB_NAME} ${LIB_TYPE}) +H5_SET_LIB_OPTIONS (${HDF5_HL_LIB_TARGET} ${HDF5_HL_LIB_NAME} STATIC) set_target_properties (${HDF5_HL_LIB_TARGET} PROPERTIES FOLDER libraries/hl INTERFACE_INCLUDE_DIRECTORIES "$/include>" ) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_LIB_TARGET}") +set (install_targets ${HDF5_HL_LIB_TARGET}) + +if (BUILD_SHARED_LIBS) + add_library (${HDF5_HL_LIBSH_TARGET} SHARED ${HL_SRCS} ${HL_HEADERS}) + TARGET_C_PROPERTIES (${HDF5_HL_LIBSH_TARGET} SHARED " " " ") + target_link_libraries (${HDF5_HL_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + H5_SET_LIB_OPTIONS (${HDF5_HL_LIBSH_TARGET} ${HDF5_HL_LIB_NAME} SHARED) + set_target_properties (${HDF5_HL_LIBSH_TARGET} PROPERTIES + FOLDER libraries/hl + COMPILE_DEFINITIONS "H5_BUILT_AS_DYNAMIC_LIB" + INTERFACE_INCLUDE_DIRECTORIES "$/include>" + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB=1 + ) + set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_HL_LIBSH_TARGET}") + set (install_targets ${install_targets} ${HDF5_HL_LIBSH_TARGET}) +endif (BUILD_SHARED_LIBS) #----------------------------------------------------------------------------- # Add file(s) to CMake Install @@ -60,16 +70,17 @@ install ( #----------------------------------------------------------------------------- if (HDF5_EXPORTED_TARGETS) if (BUILD_SHARED_LIBS) - INSTALL_TARGET_PDB (${HDF5_HL_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} hllibraries) + INSTALL_TARGET_PDB (${HDF5_HL_LIBSH_TARGET} ${HDF5_INSTALL_BIN_DIR} hllibraries) endif (BUILD_SHARED_LIBS) install ( TARGETS - ${HDF5_HL_LIB_TARGET} + ${install_targets} EXPORT ${HDF5_EXPORTED_TARGETS} LIBRARY DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT hllibraries ARCHIVE DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT hllibraries RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT hllibraries + FRAMEWORK DESTINATION ${HDF5_INSTALL_FWRK_DIR} COMPONENT hllibraries ) endif (HDF5_EXPORTED_TARGETS) diff --git a/hl/test/CMakeLists.txt b/hl/test/CMakeLists.txt index 47383ce..916dcf3 100644 --- a/hl/test/CMakeLists.txt +++ b/hl/test/CMakeLists.txt @@ -22,8 +22,8 @@ INCLUDE_DIRECTORIES (${HDF5_TEST_SRC_DIR}) # -------------------------------------------------------------------- MACRO (HL_ADD_EXE hl_name) add_executable (hl_${hl_name} ${hl_name}.c) - TARGET_NAMING (hl_${hl_name} ${LIB_TYPE}) - TARGET_C_PROPERTIES (hl_${hl_name} ${LIB_TYPE} " " " ") + TARGET_NAMING (hl_${hl_name} STATIC) + TARGET_C_PROPERTIES (hl_${hl_name} STATIC " " " ") target_link_libraries (hl_${hl_name} ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET} @@ -32,6 +32,18 @@ MACRO (HL_ADD_EXE hl_name) set_target_properties (hl_${hl_name} PROPERTIES FOLDER test/hl) ENDMACRO (HL_ADD_EXE) +MACRO (HL_ADD_SHEXE hl_name) + add_executable (hl_${hl_name} ${hl_name}.c) + TARGET_NAMING (hl_${hl_name} SHARED) + TARGET_C_PROPERTIES (hl_${hl_name} SHARED " " " ") + target_link_libraries (hl_${hl_name} + ${HDF5_HL_LIBSH_TARGET} + ${HDF5_LIBSH_TARGET} + ${HDF5_TEST_LIBSH_TARGET} + ) + set_target_properties (hl_${hl_name} PROPERTIES FOLDER test/hl) +ENDMACRO (HL_ADD_SHEXE) + HL_ADD_EXE (test_ds) HL_ADD_EXE (test_dset_opt) HL_ADD_EXE (test_image) @@ -43,7 +55,7 @@ HL_ADD_EXE (test_table) # This executable is used to generate test files for the test_ds test. # It should only be run during development when new test files are needed # -------------------------------------------------------------------- -if (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) +if (HDF5_BUILD_GENERATORS) add_executable (hl_gen_test_ds gen_test_ds.c) TARGET_NAMING (hl_gen_test_ds STATIC) TARGET_C_PROPERTIES (hl_gen_test_ds STATIC " " " ") @@ -53,6 +65,6 @@ if (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) ${HDF5_TEST_LIB_TARGET} ) set_target_properties (hl_gen_test_ds PROPERTIES FOLDER test/hl/gen) -endif (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) +endif (HDF5_BUILD_GENERATORS) include (CMakeTests.cmake) diff --git a/hl/tools/CMakeLists.txt b/hl/tools/CMakeLists.txt index f58a513..73d1f22 100644 --- a/hl/tools/CMakeLists.txt +++ b/hl/tools/CMakeLists.txt @@ -18,8 +18,8 @@ INCLUDE_DIRECTORIES (${HDF5_TOOLS_SRC_DIR}/lib) INCLUDE_DIRECTORIES (${HDF5_HL_TOOLS_SOURCE_DIR}/gif2h5) add_executable (gif2h5 ${GIF2H5_SRCS}) -TARGET_NAMING (gif2h5 ${LIB_TYPE}) -TARGET_C_PROPERTIES (gif2h5 ${LIB_TYPE} " " " ") +TARGET_NAMING (gif2h5 STATIC) +TARGET_C_PROPERTIES (gif2h5 STATIC " " " ") target_link_libraries (gif2h5 ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) set_target_properties (gif2h5 PROPERTIES FOLDER tools/hl) @@ -29,8 +29,8 @@ set (hdf2gif_SRCS ${HDF5_HL_TOOLS_SOURCE_DIR}/gif2h5/hdfgifwr.c ) add_executable (h52gif ${hdf2gif_SRCS}) -TARGET_NAMING (h52gif ${LIB_TYPE}) -TARGET_C_PROPERTIES (h52gif ${LIB_TYPE} " " " ") +TARGET_NAMING (h52gif STATIC) +TARGET_C_PROPERTIES (h52gif STATIC " " " ") target_link_libraries (h52gif ${HDF5_HL_LIB_TARGET} ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) set_target_properties (h52gif PROPERTIES FOLDER tools/hl) @@ -40,7 +40,7 @@ if (BUILD_TESTING) # used in the CMake Build system as we rely on the test files that are # shipped with HDF5 source archives # -------------------------------------------------------------------- - if (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) + if (HDF5_BUILD_GENERATORS) add_executable (hl_h52gifgentest ${HDF5_HL_TOOLS_SOURCE_DIR}/gif2h5/h52gifgentst.c) TARGET_NAMING (hl_h52gifgentest STATIC) TARGET_C_PROPERTIES (hl_h52gifgentest STATIC " " " ") @@ -48,7 +48,7 @@ if (BUILD_TESTING) set_target_properties (hl_h52gifgentest PROPERTIES FOLDER generator/tools/hl) # add_test (NAME hl_h52gifgentest COMMAND $) - endif (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) + endif (HDF5_BUILD_GENERATORS) include (CMakeTests.cmake) endif (BUILD_TESTING) @@ -60,8 +60,5 @@ install ( TARGETS gif2h5 h52gif - RUNTIME DESTINATION - ${HDF5_INSTALL_BIN_DIR} - COMPONENT - hltoolsapplications + RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT hltoolsapplications ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 95be3f4..ee06669 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -44,6 +44,7 @@ IDE_GENERATED_PROPERTIES ("H5A" "${H5A_HDRS}" "${H5A_SRCS}" ) set (H5AC_SRCS ${HDF5_SRC_DIR}/H5AC.c + ${HDF5_SRC_DIR}/H5ACmpio.c ) set (H5AC_HDRS @@ -82,6 +83,7 @@ IDE_GENERATED_PROPERTIES ("H5B2" "${H5B2_HDRS}" "${H5B2_SRCS}" ) set (H5C_SRCS ${HDF5_SRC_DIR}/H5C.c + ${HDF5_SRC_DIR}/H5Cmpio.c ) set (H5C_HDRS ${HDF5_SRC_DIR}/H5Cpkg.h @@ -100,24 +102,19 @@ IDE_GENERATED_PROPERTIES ("H5CS" "${H5CS_HDRS}" "${H5CS_SRCS}" ) set (H5D_SRCS ${HDF5_SRC_DIR}/H5D.c - ${HDF5_SRC_DIR}/H5Dbtree2.c ${HDF5_SRC_DIR}/H5Dbtree.c ${HDF5_SRC_DIR}/H5Dchunk.c ${HDF5_SRC_DIR}/H5Dcompact.c ${HDF5_SRC_DIR}/H5Dcontig.c ${HDF5_SRC_DIR}/H5Ddbg.c ${HDF5_SRC_DIR}/H5Ddeprec.c - ${HDF5_SRC_DIR}/H5Dearray.c ${HDF5_SRC_DIR}/H5Defl.c - ${HDF5_SRC_DIR}/H5Dfarray.c ${HDF5_SRC_DIR}/H5Dfill.c ${HDF5_SRC_DIR}/H5Dint.c ${HDF5_SRC_DIR}/H5Dio.c ${HDF5_SRC_DIR}/H5Dlayout.c ${HDF5_SRC_DIR}/H5Dmpio.c - ${HDF5_SRC_DIR}/H5Dnone.c ${HDF5_SRC_DIR}/H5Doh.c - ${HDF5_SRC_DIR}/H5Dproxy.c ${HDF5_SRC_DIR}/H5Dscatgath.c ${HDF5_SRC_DIR}/H5Dselect.c ${HDF5_SRC_DIR}/H5Dtest.c @@ -198,7 +195,6 @@ set (H5FA_SRCS ${HDF5_SRC_DIR}/H5FAdblock.c ${HDF5_SRC_DIR}/H5FAdblkpage.c ${HDF5_SRC_DIR}/H5FAhdr.c - ${HDF5_SRC_DIR}/H5FAint.c ${HDF5_SRC_DIR}/H5FAstat.c ${HDF5_SRC_DIR}/H5FAtest.c ) @@ -261,7 +257,6 @@ set (H5FS_SRCS ${HDF5_SRC_DIR}/H5FS.c ${HDF5_SRC_DIR}/H5FScache.c ${HDF5_SRC_DIR}/H5FSdbg.c - ${HDF5_SRC_DIR}/H5FSint.c ${HDF5_SRC_DIR}/H5FSsection.c ${HDF5_SRC_DIR}/H5FSstat.c ${HDF5_SRC_DIR}/H5FStest.c @@ -310,7 +305,6 @@ set (H5HF_SRCS ${HDF5_SRC_DIR}/H5HFhdr.c ${HDF5_SRC_DIR}/H5HFhuge.c ${HDF5_SRC_DIR}/H5HFiblock.c - ${HDF5_SRC_DIR}/H5HFint.c ${HDF5_SRC_DIR}/H5HFiter.c ${HDF5_SRC_DIR}/H5HFman.c ${HDF5_SRC_DIR}/H5HFsection.c @@ -343,9 +337,7 @@ set (H5HL_SRCS ${HDF5_SRC_DIR}/H5HL.c ${HDF5_SRC_DIR}/H5HLcache.c ${HDF5_SRC_DIR}/H5HLdbg.c - ${HDF5_SRC_DIR}/H5HLdblk.c ${HDF5_SRC_DIR}/H5HLint.c - ${HDF5_SRC_DIR}/H5HLprfx.c ) set (H5HL_HDRS @@ -433,7 +425,6 @@ set (H5O_SRCS ${HDF5_SRC_DIR}/H5Odtype.c ${HDF5_SRC_DIR}/H5Oefl.c ${HDF5_SRC_DIR}/H5Ofill.c - ${HDF5_SRC_DIR}/H5Oflush.c ${HDF5_SRC_DIR}/H5Ofsinfo.c ${HDF5_SRC_DIR}/H5Oginfo.c ${HDF5_SRC_DIR}/H5Olayout.c @@ -444,13 +435,11 @@ set (H5O_SRCS ${HDF5_SRC_DIR}/H5Oname.c ${HDF5_SRC_DIR}/H5Onull.c ${HDF5_SRC_DIR}/H5Opline.c - ${HDF5_SRC_DIR}/H5Oproxy.c ${HDF5_SRC_DIR}/H5Orefcount.c ${HDF5_SRC_DIR}/H5Osdspace.c ${HDF5_SRC_DIR}/H5Oshared.c ${HDF5_SRC_DIR}/H5Oshmesg.c ${HDF5_SRC_DIR}/H5Ostab.c - ${HDF5_SRC_DIR}/H5Ostorage.c ${HDF5_SRC_DIR}/H5Otest.c ${HDF5_SRC_DIR}/H5Ounknown.c ) @@ -813,7 +802,7 @@ add_custom_command ( ) if (GENERATE_ERROR_HEADERS) - find_pacakge (Perl) + find_package (Perl) if (PERL_FOUND) add_custom_command ( OUTPUT ${HDF5_BINARY_DIR}/H5Edefin.h @@ -864,8 +853,8 @@ set_source_files_properties (${HDF5_BINARY_DIR}/H5version.h GENERATED) set (common_SRCS ${common_SRCS} ${HDF5_BINARY_DIR}/H5overflow.h) set_source_files_properties (${HDF5_BINARY_DIR}/H5overflow.h GENERATED) -add_library (${HDF5_LIB_TARGET} ${LIB_TYPE} ${common_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS}) -TARGET_C_PROPERTIES (${HDF5_LIB_TARGET} ${LIB_TYPE} " " " ") +add_library (${HDF5_LIB_TARGET} STATIC ${common_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS}) +TARGET_C_PROPERTIES (${HDF5_LIB_TARGET} STATIC " " " ") target_link_libraries (${HDF5_LIB_TARGET} ${LINK_LIBS}) if (NOT WIN32) target_link_libraries (${HDF5_LIB_TARGET} dl) @@ -874,7 +863,7 @@ if (H5_HAVE_PARALLEL AND MPI_C_FOUND) target_link_libraries (${HDF5_LIB_TARGET} ${MPI_C_LIBRARIES}) endif (H5_HAVE_PARALLEL AND MPI_C_FOUND) set_global_variable (HDF5_LIBRARIES_TO_EXPORT ${HDF5_LIB_TARGET}) -H5_SET_LIB_OPTIONS (${HDF5_LIB_TARGET} ${HDF5_LIB_NAME} ${LIB_TYPE}) +H5_SET_LIB_OPTIONS (${HDF5_LIB_TARGET} ${HDF5_LIB_NAME} STATIC) set_target_properties (${HDF5_LIB_TARGET} PROPERTIES FOLDER libraries INTERFACE_INCLUDE_DIRECTORIES "$/include>" @@ -887,6 +876,35 @@ if (HDF5_ENABLE_DEBUG_APIS) "H5Z_DEBUG;H5VM_DEBUG;H5T_DEBUG;H5S_DEBUG;H5P_DEBUG;H5O_DEBUG;H5MM_DEBUG;H5MF_DEBUG;H5I_DEBUG;H5HL_DEBUG;H5HG_DEBUG;H5G_DEBUG;H5F_DEBUG;H5E_DEBUG;H5D_DEBUG;H5B_DEBUG;H5AC_DEBUG" ) endif (HDF5_ENABLE_DEBUG_APIS) +set (install_targets ${HDF5_LIB_TARGET}) + +if (BUILD_SHARED_LIBS) + add_library (${HDF5_LIBSH_TARGET} SHARED ${common_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS}) + TARGET_C_PROPERTIES (${HDF5_LIBSH_TARGET} SHARED " " " ") + target_link_libraries (${HDF5_LIBSH_TARGET} ${LINK_SHARED_LIBS}) + if (NOT WIN32) + target_link_libraries (${HDF5_LIBSH_TARGET} dl) + endif (NOT WIN32) + if (H5_HAVE_PARALLEL AND MPI_C_FOUND) + target_link_libraries (${HDF5_LIBSH_TARGET} ${MPI_C_LIBRARIES}) + endif (H5_HAVE_PARALLEL AND MPI_C_FOUND) + set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_LIBSH_TARGET}") + H5_SET_LIB_OPTIONS (${HDF5_LIBSH_TARGET} ${HDF5_LIB_NAME} SHARED) + set_target_properties (${HDF5_LIBSH_TARGET} PROPERTIES + FOLDER libraries + COMPILE_DEFINITIONS "H5_BUILT_AS_DYNAMIC_LIB" + INTERFACE_INCLUDE_DIRECTORIES "$/include>" + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB=1 + ) + + if (HDF5_ENABLE_DEBUG_APIS) + set_property (TARGET ${HDF5_LIBSH_TARGET} + APPEND PROPERTY COMPILE_DEFINITIONS + "H5Z_DEBUG;H5VM_DEBUG;H5T_DEBUG;H5S_DEBUG;H5P_DEBUG;H5O_DEBUG;H5MM_DEBUG;H5MF_DEBUG;H5I_DEBUG;H5HL_DEBUG;H5HG_DEBUG;H5G_DEBUG;H5F_DEBUG;H5E_DEBUG;H5D_DEBUG;H5B_DEBUG;H5AC_DEBUG" + ) + endif (HDF5_ENABLE_DEBUG_APIS) + set (install_targets ${install_targets} ${HDF5_LIBSH_TARGET}) +endif (BUILD_SHARED_LIBS) #----------------------------------------------------------------------------- # Add file(s) to CMake Install @@ -907,16 +925,17 @@ endif (NOT HDF5_INSTALL_NO_DEVELOPMENT) #----------------------------------------------------------------------------- if (HDF5_EXPORTED_TARGETS) if (BUILD_SHARED_LIBS) - INSTALL_TARGET_PDB (${HDF5_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} libraries) + INSTALL_TARGET_PDB (${HDF5_LIBSH_TARGET} ${HDF5_INSTALL_BIN_DIR} libraries) endif (BUILD_SHARED_LIBS) - + install ( TARGETS - ${HDF5_LIB_TARGET} + ${install_targets} EXPORT ${HDF5_EXPORTED_TARGETS} LIBRARY DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT libraries ARCHIVE DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT libraries RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT libraries + FRAMEWORK DESTINATION ${HDF5_INSTALL_FWRK_DIR} COMPONENT libraries ) endif (HDF5_EXPORTED_TARGETS) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 651e4eb..c94b880 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -26,8 +26,8 @@ set (TEST_LIB_HEADERS ${HDF5_TEST_SOURCE_DIR}/h5test.h ) -add_library (${HDF5_TEST_LIB_TARGET} ${LIB_TYPE} ${TEST_LIB_SRCS} ${TEST_LIB_HEADERS}) -TARGET_C_PROPERTIES (${HDF5_TEST_LIB_TARGET} ${LIB_TYPE} " " " ") +add_library (${HDF5_TEST_LIB_TARGET} STATIC ${TEST_LIB_SRCS} ${TEST_LIB_HEADERS}) +TARGET_C_PROPERTIES (${HDF5_TEST_LIB_TARGET} STATIC " " " ") if (MSVC) target_link_libraries (${HDF5_TEST_LIB_TARGET} "ws2_32.lib") endif (MSVC) @@ -35,16 +35,34 @@ if (MINGW) target_link_libraries (${HDF5_TEST_LIB_TARGET} "wsock32.lib") endif (MINGW) target_link_libraries (${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) -H5_SET_LIB_OPTIONS (${HDF5_TEST_LIB_TARGET} ${HDF5_TEST_LIB_NAME} ${LIB_TYPE}) +H5_SET_LIB_OPTIONS (${HDF5_TEST_LIB_TARGET} ${HDF5_TEST_LIB_NAME} STATIC) set_target_properties (${HDF5_TEST_LIB_TARGET} PROPERTIES FOLDER libraries/test INTERFACE_INCLUDE_DIRECTORIES "$/include>" ) +if (BUILD_SHARED_LIBS) + add_library (${HDF5_TEST_LIBSH_TARGET} SHARED ${TEST_LIB_SRCS} ${TEST_LIB_HEADERS}) + TARGET_C_PROPERTIES (${HDF5_TEST_LIBSH_TARGET} SHARED " " " ") + if (MSVC) + target_link_libraries (${HDF5_TEST_LIBSH_TARGET} "ws2_32.lib") + endif (MSVC) + if (MINGW) + target_link_libraries (${HDF5_TEST_LIBSH_TARGET} "wsock32.lib") + endif (MINGW) + target_link_libraries (${HDF5_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + H5_SET_LIB_OPTIONS (${HDF5_TEST_LIBSH_TARGET} ${HDF5_TEST_LIB_NAME} SHARED) + set_target_properties (${HDF5_TEST_LIBSH_TARGET} PROPERTIES + FOLDER libraries/test + COMPILE_DEFINITIONS "H5_BUILT_AS_DYNAMIC_LIB" + INTERFACE_INCLUDE_DIRECTORIES "$/include>" + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB=1 + ) +endif (BUILD_SHARED_LIBS) + #----------------------------------------------------------------------------- # If plugin library tests can be tested #----------------------------------------------------------------------------- -if (BUILD_SHARED_LIBS) # make plugins dir file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/testdir1") file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/testdir2") @@ -67,12 +85,12 @@ if (BUILD_SHARED_LIBS) add_definitions (${HDF_EXTRA_C_FLAGS}) INCLUDE_DIRECTORIES (${HDF5_SRC_DIR}) - add_library (${HDF5_TEST_PLUGIN_LIB_TARGET} ${LIB_TYPE} ${HDF5_TEST_SOURCE_DIR}/${test_lib}.c) - TARGET_C_PROPERTIES (${HDF5_TEST_PLUGIN_LIB_TARGET} ${LIB_TYPE} " " " ") + add_library (${HDF5_TEST_PLUGIN_LIB_TARGET} SHARED ${HDF5_TEST_SOURCE_DIR}/${test_lib}.c) + TARGET_C_PROPERTIES (${HDF5_TEST_PLUGIN_LIB_TARGET} SHARED " " " ") target_link_libraries (${HDF5_TEST_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) H5_SET_LIB_OPTIONS ( ${HDF5_TEST_PLUGIN_LIB_TARGET} ${HDF5_TEST_PLUGIN_LIB_NAME} - ${LIB_TYPE} + SHARED HDF5_TEST_PLUGIN_LIB_NAME_RELEASE HDF5_TEST_PLUGIN_LIB_NAME_DEBUG ) @@ -85,7 +103,7 @@ if (BUILD_SHARED_LIBS) TARGET ${HDF5_TEST_PLUGIN_LIB_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different + ARGS -E copy_if_different "$" "${CMAKE_BINARY_DIR}/testdir1/$" ) @@ -98,12 +116,12 @@ if (BUILD_SHARED_LIBS) add_definitions (${HDF_EXTRA_C_FLAGS}) INCLUDE_DIRECTORIES (${HDF5_SRC_DIR}) - add_library (${HDF5_TEST_PLUGIN_LIB_TARGET} ${LIB_TYPE} ${HDF5_TEST_SOURCE_DIR}/${test_lib}.c) - TARGET_C_PROPERTIES (${HDF5_TEST_PLUGIN_LIB_TARGET} ${LIB_TYPE} " " " ") + add_library (${HDF5_TEST_PLUGIN_LIB_TARGET} SHARED ${HDF5_TEST_SOURCE_DIR}/${test_lib}.c) + TARGET_C_PROPERTIES (${HDF5_TEST_PLUGIN_LIB_TARGET} SHARED " " " ") target_link_libraries (${HDF5_TEST_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) H5_SET_LIB_OPTIONS ( ${HDF5_TEST_PLUGIN_LIB_TARGET} ${HDF5_TEST_PLUGIN_LIB_NAME} - ${LIB_TYPE} + SHARED HDF5_TEST_PLUGIN_LIB_NAME_RELEASE HDF5_TEST_PLUGIN_LIB_NAME_DEBUG ) @@ -116,12 +134,11 @@ if (BUILD_SHARED_LIBS) TARGET ${HDF5_TEST_PLUGIN_LIB_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different + ARGS -E copy_if_different "$" "${CMAKE_BINARY_DIR}/testdir2/$" ) endforeach (test_lib ${TEST2_PLUGIN_LIBS}) -endif (BUILD_SHARED_LIBS) set (testhdf5_SRCS ${HDF5_TEST_SOURCE_DIR}/testhdf5.c @@ -153,17 +170,31 @@ set (testhdf5_SRCS #-- Adding test for testhdf5 add_executable (testhdf5 ${testhdf5_SRCS}) -TARGET_NAMING (testhdf5 ${LIB_TYPE}) -TARGET_C_PROPERTIES (testhdf5 ${LIB_TYPE} " " " ") +TARGET_NAMING (testhdf5 STATIC) +TARGET_C_PROPERTIES (testhdf5 STATIC " " " ") target_link_libraries (testhdf5 ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (testhdf5 PROPERTIES FOLDER test) +if (BUILD_SHARED_LIBS) + add_executable (testhdf5-shared ${testhdf5_SRCS}) + TARGET_NAMING (testhdf5-shared SHARED) + TARGET_C_PROPERTIES (testhdf5-shared SHARED " " " ") + target_link_libraries (testhdf5-shared ${HDF5_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + set_target_properties (testhdf5-shared PROPERTIES FOLDER test) +endif (BUILD_SHARED_LIBS) MACRO (ADD_H5_EXE file) add_executable (${file} ${HDF5_TEST_SOURCE_DIR}/${file}.c) - TARGET_NAMING (${file} ${LIB_TYPE}) - TARGET_C_PROPERTIES (${file} ${LIB_TYPE} " " " ") + TARGET_NAMING (${file} STATIC) + TARGET_C_PROPERTIES (${file} STATIC " " " ") target_link_libraries (${file} ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (${file} PROPERTIES FOLDER test) + if (BUILD_SHARED_LIBS) + add_executable (${file}-shared ${HDF5_TEST_SOURCE_DIR}/${file}.c) + TARGET_NAMING (${file}-shared SHARED) + TARGET_C_PROPERTIES (${file}-shared SHARED " " " ") + target_link_libraries (${file}-shared ${HDF5_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + set_target_properties (${file}-shared PROPERTIES FOLDER test) + endif (BUILD_SHARED_LIBS) ENDMACRO (ADD_H5_EXE file) set (H5_TESTS @@ -236,24 +267,45 @@ endforeach (test ${H5_TESTS}) #-- Adding test for cache add_executable (cache ${HDF5_TEST_SOURCE_DIR}/cache.c ${HDF5_TEST_SOURCE_DIR}/cache_common.c) -TARGET_NAMING (cache ${LIB_TYPE}) -TARGET_C_PROPERTIES (cache ${LIB_TYPE} " " " ") +TARGET_NAMING (cache STATIC) +TARGET_C_PROPERTIES (cache STATIC " " " ") target_link_libraries (cache ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) set_target_properties (cache PROPERTIES FOLDER test) +if (BUILD_SHARED_LIBS) + add_executable (cache-shared ${HDF5_TEST_SOURCE_DIR}/cache.c ${HDF5_TEST_SOURCE_DIR}/cache_common.c) + TARGET_NAMING (cache-shared SHARED) + TARGET_C_PROPERTIES (cache-shared SHARED " " " ") + target_link_libraries (cache-shared ${HDF5_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + set_target_properties (cache-shared PROPERTIES FOLDER test) +endif (BUILD_SHARED_LIBS) #-- Adding test for cache_api add_executable (cache_api ${HDF5_TEST_SOURCE_DIR}/cache_api.c ${HDF5_TEST_SOURCE_DIR}/cache_common.c) -TARGET_NAMING (cache_api ${LIB_TYPE}) -TARGET_C_PROPERTIES (cache_api ${LIB_TYPE} " " " ") +TARGET_NAMING (cache_api STATIC) +TARGET_C_PROPERTIES (cache_api STATIC " " " ") target_link_libraries (cache_api ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) set_target_properties (cache_api PROPERTIES FOLDER test) +if (BUILD_SHARED_LIBS) + add_executable (cache_api-shared ${HDF5_TEST_SOURCE_DIR}/cache_api.c ${HDF5_TEST_SOURCE_DIR}/cache_common.c) + TARGET_NAMING (cache_api-shared SHARED) + TARGET_C_PROPERTIES (cache_api-shared SHARED " " " ") + target_link_libraries (cache_api-shared ${HDF5_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + set_target_properties (cache_api-shared PROPERTIES FOLDER test) +endif (BUILD_SHARED_LIBS) #-- Adding test for cache_tagging add_executable (cache_tagging ${HDF5_TEST_SOURCE_DIR}/cache_tagging.c ${HDF5_TEST_SOURCE_DIR}/cache_common.c) -TARGET_NAMING (cache_tagging ${LIB_TYPE}) -TARGET_C_PROPERTIES (cache_tagging ${LIB_TYPE} " " " ") +TARGET_NAMING (cache_tagging STATIC) +TARGET_C_PROPERTIES (cache_tagging STATIC " " " ") target_link_libraries (cache_tagging ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) set_target_properties (cache_tagging PROPERTIES FOLDER test) +if (BUILD_SHARED_LIBS) + add_executable (cache_tagging-shared ${HDF5_TEST_SOURCE_DIR}/cache_tagging.c ${HDF5_TEST_SOURCE_DIR}/cache_common.c) + TARGET_NAMING (cache_tagging-shared SHARED) + TARGET_C_PROPERTIES (cache_tagging-shared SHARED " " " ") + target_link_libraries (cache_tagging-shared ${HDF5_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + set_target_properties (cache_tagging-shared PROPERTIES FOLDER test) +endif (BUILD_SHARED_LIBS) #-- Adding test for ttsafe add_executable (ttsafe @@ -263,37 +315,71 @@ add_executable (ttsafe ${HDF5_TEST_SOURCE_DIR}/ttsafe_cancel.c ${HDF5_TEST_SOURCE_DIR}/ttsafe_acreate.c ) -TARGET_NAMING (ttsafe ${LIB_TYPE}) -TARGET_C_PROPERTIES (ttsafe ${LIB_TYPE} " " " ") +TARGET_NAMING (ttsafe STATIC) +TARGET_C_PROPERTIES (ttsafe STATIC " " " ") target_link_libraries (ttsafe ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) set_target_properties (ttsafe PROPERTIES FOLDER test) +if (BUILD_SHARED_LIBS) + add_executable (ttsafe-shared + ${HDF5_TEST_SOURCE_DIR}/ttsafe.c + ${HDF5_TEST_SOURCE_DIR}/ttsafe_dcreate.c + ${HDF5_TEST_SOURCE_DIR}/ttsafe_error.c + ${HDF5_TEST_SOURCE_DIR}/ttsafe_cancel.c + ${HDF5_TEST_SOURCE_DIR}/ttsafe_acreate.c + ) + TARGET_NAMING (ttsafe-shared SHARED) + TARGET_C_PROPERTIES (ttsafe-shared SHARED " " " ") + target_link_libraries (ttsafe-shared ${HDF5_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + set_target_properties (ttsafe-shared PROPERTIES FOLDER test) +endif (BUILD_SHARED_LIBS) #-- Adding test for err_compat if (HDF5_ENABLE_DEPRECATED_SYMBOLS) add_executable (err_compat ${HDF5_TEST_SOURCE_DIR}/err_compat.c) - TARGET_NAMING (err_compat ${LIB_TYPE}) - TARGET_C_PROPERTIES (err_compat ${LIB_TYPE} " " " ") + TARGET_NAMING (err_compat STATIC) + TARGET_C_PROPERTIES (err_compat STATIC " " " ") target_link_libraries (err_compat ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) set_target_properties (err_compat PROPERTIES FOLDER test) + if (BUILD_SHARED_LIBS) + add_executable (err_compat-shared ${HDF5_TEST_SOURCE_DIR}/err_compat.c) + TARGET_NAMING (err_compat-shared SHARED) + TARGET_C_PROPERTIES (err_compat-shared SHARED " " " ") + target_link_libraries (err_compat-shared ${HDF5_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + set_target_properties (err_compat-shared PROPERTIES FOLDER test) + endif (BUILD_SHARED_LIBS) endif (HDF5_ENABLE_DEPRECATED_SYMBOLS) #-- Adding test for error_test add_executable (error_test ${HDF5_TEST_SOURCE_DIR}/error_test.c) -TARGET_NAMING (error_test ${LIB_TYPE}) -TARGET_C_PROPERTIES (error_test ${LIB_TYPE} " " " ") +TARGET_NAMING (error_test STATIC) +TARGET_C_PROPERTIES (error_test STATIC " " " ") target_link_libraries (error_test ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) set_target_properties (error_test PROPERTIES FOLDER test) +if (BUILD_SHARED_LIBS) + add_executable (error_test-shared ${HDF5_TEST_SOURCE_DIR}/error_test.c) + TARGET_NAMING (error_test-shared SHARED) + TARGET_C_PROPERTIES (error_test-shared SHARED " " " ") + target_link_libraries (error_test-shared ${HDF5_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + set_target_properties (error_test-shared PROPERTIES FOLDER test) +endif (BUILD_SHARED_LIBS) #-- Adding test for links_env add_executable (links_env ${HDF5_TEST_SOURCE_DIR}/links_env.c) -TARGET_NAMING (links_env ${LIB_TYPE}) -TARGET_C_PROPERTIES (links_env ${LIB_TYPE} " " " ") +TARGET_NAMING (links_env STATIC) +TARGET_C_PROPERTIES (links_env STATIC " " " ") target_link_libraries (links_env ${HDF5_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) set_target_properties (links_env PROPERTIES FOLDER test) +if (BUILD_SHARED_LIBS) + add_executable (links_env-shared ${HDF5_TEST_SOURCE_DIR}/links_env.c) + TARGET_NAMING (links_env-shared SHARED) + TARGET_C_PROPERTIES (links_env-shared SHARED " " " ") + target_link_libraries (links_env-shared ${HDF5_TEST_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + set_target_properties (links_env-shared PROPERTIES FOLDER test) +endif (BUILD_SHARED_LIBS) #-- Adding test for libinfo set (GREP_RUNNER ${PROJECT_BINARY_DIR}/GrepRunner.cmake) -file (WRITE ${GREP_RUNNER} +file (WRITE ${GREP_RUNNER} "file (STRINGS \${TEST_PROGRAM} TEST_RESULT REGEX \"SUMMARY OF THE HDF5 CONFIGURATION\") if (\${TEST_RESULT} STREQUAL \"0\") message (FATAL_ERROR \"Failed: The output: \${TEST_RESULT} of \${TEST_PROGRAM} did not contain SUMMARY OF THE HDF5 CONFIGURATION\") @@ -312,6 +398,12 @@ if (BUILD_SHARED_LIBS) TARGET_C_PROPERTIES (plugin SHARED " " " ") target_link_libraries (plugin ${HDF5_TEST_PLUGIN_LIB_TARGET}) set_target_properties (plugin PROPERTIES FOLDER test) +else (BUILD_SHARED_LIBS) + add_executable (plugin ${HDF5_TEST_SOURCE_DIR}/plugin.c) + TARGET_NAMING (plugin STATIC) + TARGET_C_PROPERTIES (plugin STATIC " " " ") + target_link_libraries (plugin ${HDF5_TEST_PLUGIN_LIB_TARGET}) + set_target_properties (plugin PROPERTIES FOLDER test) endif (BUILD_SHARED_LIBS) include (CMakeTests.cmake) diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index c7803f6..5fe51ed 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -9,6 +9,12 @@ file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST") file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST/testfiles") file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST/testfiles/plist_files") +if (BUILD_SHARED_LIBS) + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST-shared") + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST-shared/testfiles") + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/H5TEST-shared/testfiles/plist_files") +endif (BUILD_SHARED_LIBS) + if (HDF5_TEST_VFD) set (VFD_LIST sec2 @@ -23,6 +29,9 @@ if (HDF5_TEST_VFD) endif (DIRECT_VFD) foreach (vfdtest ${VFD_LIST}) file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdtest}") + #if (BUILD_SHARED_LIBS) + # file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdtest}-shared") + #endif (BUILD_SHARED_LIBS) endforeach (vfdtest ${VFD_LIST}) endif (HDF5_TEST_VFD) @@ -35,25 +44,41 @@ set (HDF5_TEST_FILES foreach (h5_tfile ${HDF5_TEST_FILES}) set (dest "${PROJECT_BINARY_DIR}/H5TEST/${h5_tfile}") - #message (STATUS " Copying ${h5_tfile}") add_custom_command ( TARGET ${HDF5_TEST_LIB_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_TOOLS_SRC_DIR}/testfiles/${h5_tfile} ${dest} ) + if (BUILD_SHARED_LIBS) + set (dest "${PROJECT_BINARY_DIR}/H5TEST-shared/${h5_tfile}") + add_custom_command ( + TARGET ${HDF5_TEST_LIBSH_TARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${HDF5_TOOLS_SRC_DIR}/testfiles/${h5_tfile} ${dest} + ) + endif (BUILD_SHARED_LIBS) endforeach (h5_tfile ${HDF5_TEST_FILES}) if (HDF5_TEST_VFD) foreach (vfdtest ${VFD_LIST}) foreach (h5_tfile ${HDF5_TEST_FILES}) set (dest "${PROJECT_BINARY_DIR}/${vfdtest}/${h5_tfile}") - #message (STATUS " Copying ${h5_tfile}") add_custom_command ( TARGET ${HDF5_TEST_LIB_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_TOOLS_SRC_DIR}/testfiles/${h5_tfile} ${dest} ) + if (BUILD_SHARED_LIBS) + set (dest "${PROJECT_BINARY_DIR}/${vfdtest}-shared/${h5_tfile}") + add_custom_command ( + TARGET ${HDF5_TEST_LIBSH_TARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${HDF5_TOOLS_SRC_DIR}/testfiles/${h5_tfile} ${dest} + ) + endif (BUILD_SHARED_LIBS) endforeach (h5_tfile ${HDF5_TEST_FILES}) endforeach (vfdtest ${VFD_LIST}) endif (HDF5_TEST_VFD) @@ -71,25 +96,41 @@ set (HDF5_REFERENCE_FILES foreach (ref_file ${HDF5_REFERENCE_FILES}) set (dest "${PROJECT_BINARY_DIR}/H5TEST/${ref_file}") - #message (STATUS " Copying ${h5_file}") add_custom_command ( TARGET ${HDF5_TEST_LIB_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_TEST_SOURCE_DIR}/testfiles/${ref_file} ${dest} ) + if (BUILD_SHARED_LIBS) + set (dest "${PROJECT_BINARY_DIR}/H5TEST-shared/${ref_file}") + add_custom_command ( + TARGET ${HDF5_TEST_LIBSH_TARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${HDF5_TEST_SOURCE_DIR}/testfiles/${ref_file} ${dest} + ) + endif (BUILD_SHARED_LIBS) endforeach (ref_file ${HDF5_REFERENCE_FILES}) if (HDF5_TEST_VFD) foreach (vfdtest ${VFD_LIST}) foreach (ref_file ${HDF5_REFERENCE_FILES}) set (dest "${PROJECT_BINARY_DIR}/${vfdtest}/${ref_file}") - #message (STATUS " Copying ${h5_file}") add_custom_command ( TARGET ${HDF5_TEST_LIB_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_TEST_SOURCE_DIR}/testfiles/${ref_file} ${dest} ) + if (BUILD_SHARED_LIBS) + set (dest "${PROJECT_BINARY_DIR}/${vfdtest}-shared/${ref_file}") + add_custom_command ( + TARGET ${HDF5_TEST_LIB_TARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${HDF5_TEST_SOURCE_DIR}/testfiles/${ref_file} ${dest} + ) + endif (BUILD_SHARED_LIBS) endforeach (ref_file ${HDF5_REFERENCE_FILES}) endforeach (vfdtest ${VFD_LIST}) endif (HDF5_TEST_VFD) @@ -126,13 +167,21 @@ set (HDF5_REFERENCE_PLIST_FILES foreach (plistfile ${HDF5_REFERENCE_PLIST_FILES}) set (dest "${PROJECT_BINARY_DIR}/H5TEST/testfiles/plist_files/${plistfile}") - #message (STATUS " Copying ${plistfile} to ${dset}") add_custom_command ( TARGET ${HDF5_TEST_LIB_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_TEST_SOURCE_DIR}/testfiles/plist_files/${plistfile} ${dest} ) + if (BUILD_SHARED_LIBS) + set (dest "${PROJECT_BINARY_DIR}/H5TEST-shared/testfiles/plist_files/${plistfile}") + add_custom_command ( + TARGET ${HDF5_TEST_LIBSH_TARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${HDF5_TEST_SOURCE_DIR}/testfiles/plist_files/${plistfile} ${dest} + ) + endif (BUILD_SHARED_LIBS) endforeach (plistfile ${HDF5_REFERENCE_PLIST_FILES}) # -------------------------------------------------------------------- @@ -177,25 +226,41 @@ set (HDF5_REFERENCE_TEST_FILES foreach (h5_file ${HDF5_REFERENCE_TEST_FILES}) set (dest "${HDF5_TEST_BINARY_DIR}/H5TEST/${h5_file}") - #message (STATUS " Copying ${h5_file} to ${dest}") add_custom_command ( TARGET ${HDF5_TEST_LIB_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_TEST_SOURCE_DIR}/${h5_file} ${dest} ) + if (BUILD_SHARED_LIBS) + set (dest "${HDF5_TEST_BINARY_DIR}/H5TEST-shared/${h5_file}") + add_custom_command ( + TARGET ${HDF5_TEST_LIBSH_TARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${HDF5_TEST_SOURCE_DIR}/${h5_file} ${dest} + ) + endif (BUILD_SHARED_LIBS) endforeach (h5_file ${HDF5_REFERENCE_TEST_FILES}) if (HDF5_TEST_VFD) foreach (vfdtest ${VFD_LIST}) foreach (h5_file ${HDF5_REFERENCE_TEST_FILES}) set (dest "${HDF5_TEST_BINARY_DIR}/${vfdtest}/${h5_file}") - #message (STATUS " Copying ${h5_file} to ${dest}") add_custom_command ( TARGET ${HDF5_TEST_LIB_TARGET} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different ${HDF5_TEST_SOURCE_DIR}/${h5_file} ${dest} ) + if (BUILD_SHARED_LIBS) + set (dest "${HDF5_TEST_BINARY_DIR}/${vfdtest}-shared/${h5_file}") + add_custom_command ( + TARGET ${HDF5_TEST_LIB_TARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different ${HDF5_TEST_SOURCE_DIR}/${h5_file} ${dest} + ) + endif (BUILD_SHARED_LIBS) endforeach (h5_file ${HDF5_REFERENCE_TEST_FILES}) endforeach (vfdtest ${VFD_LIST}) endif (HDF5_TEST_VFD) @@ -258,6 +323,38 @@ else (HDF5_ENABLE_USING_MEMCHECKER) ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST ) + if (BUILD_SHARED_LIBS) + add_test ( + NAME H5TEST-shared-clear-testhdf5-objects + COMMAND ${CMAKE_COMMAND} + -E remove + coord.h5 + dtypes10.h5 + sys_file1 + tattr.h5 + tfile1.h5 + tfile2.h5 + tfile3.h5 + tfile4.h5 + tfile5.h5 + tfile6.h5 + tfile7.h5 + th5o_file + th5s1.h5 + tselect.h5 + tsohm.h5 + tsohm_dst.h5 + tsohm_src.h5 + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + add_test (NAME H5TEST-shared-testhdf5 COMMAND $) + set_tests_properties (H5TEST-shared-testhdf5 PROPERTIES + DEPENDS H5TEST-shared-clear-testhdf5-objects + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + endif (BUILD_SHARED_LIBS) endif (HDF5_ENABLE_USING_MEMCHECKER) ############################################################################## @@ -355,6 +452,97 @@ set_tests_properties (H5TEST-fheap PROPERTIES TIMEOUT 1800) set_tests_properties (H5TEST-testmeta PROPERTIES TIMEOUT 1800) set_tests_properties (H5TEST-big PROPERTIES TIMEOUT 1800) +if (BUILD_SHARED_LIBS) + # Remove any output file left over from previous test run + add_test ( + NAME H5TEST-shared-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + dt_arith1.h5 + dt_arith2.h5 + dtransform.h5 + dtypes3.h5 + dtypes4.h5 + dtypes5.h5 + efc0.h5 + efc1.h5 + efc2.h5 + efc3.h5 + efc4.h5 + efc5.h5 + extlinks16A00000.h5 + extlinks16A00001.h5 + extlinks16A00002.h5 + extlinks16B-b.h5 + extlinks16B-g.h5 + extlinks16B-l.h5 + extlinks16B-r.h5 + extlinks16B-s.h5 + extlinks19B00000.h5 + extlinks19B00001.h5 + extlinks19B00002.h5 + extlinks19B00003.h5 + extlinks19B00004.h5 + extlinks19B00005.h5 + extlinks19B00006.h5 + extlinks19B00007.h5 + extlinks19B00008.h5 + extlinks19B00009.h5 + extlinks19B00010.h5 + extlinks19B00011.h5 + extlinks19B00012.h5 + extlinks19B00013.h5 + extlinks19B00014.h5 + extlinks19B00015.h5 + extlinks19B00016.h5 + extlinks19B00017.h5 + extlinks19B00018.h5 + extlinks19B00019.h5 + extlinks19B00020.h5 + extlinks19B00021.h5 + extlinks19B00022.h5 + extlinks19B00023.h5 + extlinks19B00024.h5 + extlinks19B00025.h5 + extlinks19B00026.h5 + extlinks19B00027.h5 + extlinks19B00028.h5 + fheap.h5 + log_vfd_out.log + new_multi_file_v16-r.h5 + new_multi_file_v16-s.h5 + objcopy_ext.dat + testmeta.h5 + tstint1.h5 + tstint2.h5 + unregister_filter_1.h5 + unregister_filter_2.h5 + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + + foreach (test ${H5_TESTS}) + if (${test} STREQUAL "big" AND CYGWIN) + add_test ( + NAME H5TEST-shared-${test} + COMMAND ${CMAKE_COMMAND} -E echo "SKIP ${test}-shared" + ) + else (${test} STREQUAL "big" AND CYGWIN) + add_test (NAME H5TEST-shared-${test} COMMAND $) + endif (${test} STREQUAL "big" AND CYGWIN) + set_tests_properties (H5TEST-shared-${test} PROPERTIES + DEPENDS H5TEST-shared-clear-objects + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + endforeach (test ${H5_TESTS}) + + set_tests_properties (H5TEST-shared-flush2 PROPERTIES DEPENDS H5TEST-shared-flush1) + set_tests_properties (H5TEST-shared-fheap PROPERTIES TIMEOUT 1800) + set_tests_properties (H5TEST-shared-testmeta PROPERTIES TIMEOUT 1800) + set_tests_properties (H5TEST-shared-big PROPERTIES TIMEOUT 1800) +endif (BUILD_SHARED_LIBS) + ############################################################################## ############################################################################## ### A D D I T I O N A L T E S T S ### @@ -362,20 +550,22 @@ set_tests_properties (H5TEST-big PROPERTIES TIMEOUT 1800) ############################################################################## #-- Adding test for cache -add_test ( - NAME H5TEST-clear-cache-objects - COMMAND ${CMAKE_COMMAND} - -E remove - cache_test.h5 - WORKING_DIRECTORY - ${HDF5_TEST_BINARY_DIR}/H5TEST -) -add_test (NAME H5TEST-cache COMMAND $) -set_tests_properties (H5TEST-cache PROPERTIES - DEPENDS H5TEST-clear-cache-objects - ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST" - WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST -) +if (NOT CYGWIN) + add_test ( + NAME H5TEST-clear-cache-objects + COMMAND ${CMAKE_COMMAND} + -E remove + cache_test.h5 + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST + ) + add_test (NAME H5TEST-cache COMMAND $) + set_tests_properties (H5TEST-cache PROPERTIES + DEPENDS H5TEST-clear-cache-objects + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST;HDF5TestExpress=2" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST + ) +endif (NOT CYGWIN) #-- Adding test for cache_api add_test ( @@ -521,31 +711,186 @@ add_test ( ${HDF5_TEST_BINARY_DIR}/H5TEST ) -############################################################################## -### P L U G I N T E S T S -############################################################################## if (BUILD_SHARED_LIBS) + #-- Adding test for cache + if (NOT CYGWIN) + add_test ( + NAME H5TEST-shared-clear-cache-objects + COMMAND ${CMAKE_COMMAND} + -E remove + cache_test.h5 + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + add_test (NAME H5TEST-shared-cache COMMAND $) + set_tests_properties (H5TEST-shared-cache PROPERTIES + DEPENDS H5TEST-shared-clear-cache-objects + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared;HDF5TestExpress=2" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + endif (NOT CYGWIN) + + #-- Adding test for cache_api + add_test ( + NAME H5TEST-shared-clear-cache_api-objects + COMMAND ${CMAKE_COMMAND} + -E remove + cache_api_test.h5 + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + add_test (NAME H5TEST-shared-cache_api COMMAND $) + set_tests_properties (H5TEST-shared-cache_api PROPERTIES + DEPENDS H5TEST-shared-clear-cache_api-objects + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) - if (WIN32) - set (CMAKE_SEP "\;") - else (WIN32) - set (CMAKE_SEP ":") - endif (WIN32) + #-- Adding test for cache_tagging + add_test ( + NAME H5TEST-shared-clear-cache_tagging-objects + COMMAND ${CMAKE_COMMAND} + -E remove + tagging_test.h5 + tagging_ext_test.h5 + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + add_test (NAME H5TEST-shared-cache_tagging COMMAND $) + set_tests_properties (H5TEST-shared-cache_tagging PROPERTIES + DEPENDS H5TEST-shared-clear-cache_tagging-objects + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + + #-- Adding test for ttsafe + add_test ( + NAME H5TEST-shared-clear-ttsafe-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ttsafe_error.h5 + ttsafe_dcreate.h5 + ttsafe_cancel.h5 + ttsafe_acreate.h5 + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + add_test (NAME H5TEST-shared-ttsafe COMMAND $) + set_tests_properties (H5TEST-shared-ttsafe PROPERTIES + DEPENDS H5TEST-shared-clear-ttsafe-objects + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + + #-- Adding test for err_compat + if (HDF5_ENABLE_DEPRECATED_SYMBOLS) + add_test ( + NAME H5TEST-shared-clear-err_compat-objects + COMMAND ${CMAKE_COMMAND} + -E remove + err_compat.txt + err_compat.txt.err + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + add_test (NAME H5TEST-shared-err_compat COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_EXPECT=0" + -D "TEST_MASK_ERROR=true" + -D "TEST_OUTPUT=err_compat.txt" + -D "TEST_REFERENCE=err_compat_1" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST-shared" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5TEST-shared-err_compat PROPERTIES + DEPENDS H5TEST-shared-clear-err_compat-objects + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + endif (HDF5_ENABLE_DEPRECATED_SYMBOLS) + + #-- Adding test for error_test + add_test ( + NAME H5TEST-shared-clear-error_test-objects + COMMAND ${CMAKE_COMMAND} + -E remove + error_test.txt + error_test.txt.err + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + add_test (NAME H5TEST-shared-error_test COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_EXPECT=0" + -D "TEST_MASK_ERROR=true" + -D "TEST_OUTPUT=error_test.txt" + -D "TEST_REFERENCE=error_test_1" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST-shared" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5TEST-shared-error_test PROPERTIES + DEPENDS H5TEST-shared-clear-error_test-objects + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared;HDF5_PLUGIN_PRELOAD=::" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) - add_test (NAME H5PLUGIN-plugin COMMAND $) - set_tests_properties (H5PLUGIN-plugin PROPERTIES - ENVIRONMENT "HDF5_PLUGIN_PATH=${CMAKE_BINARY_DIR}/testdir1${CMAKE_SEP}${CMAKE_BINARY_DIR}/testdir2;srcdir=${HDF5_TEST_BINARY_DIR}" - WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR} + #-- Adding test for links_env + add_test ( + NAME H5TEST-shared-clear-links_env-objects + COMMAND ${CMAKE_COMMAND} + -E remove + links_env.txt + links_env.txt.err + extlinks_env0.h5 + extlinks_env1.h5 + tmp/extlinks_env1.h5 + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + add_test (NAME H5TEST-shared-links_env COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_ENV_VAR:STRING=HDF5_EXT_PREFIX" + -D "TEST_ENV_VALUE:STRING=.:tmp" + -D "TEST_EXPECT=0" + -D "TEST_OUTPUT=links_env.txt" + -D "TEST_REFERENCE=links_env.out" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST-shared" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) -else (BUILD_SHARED_LIBS) - message (STATUS " **** Plugins libraries must be built as shared libraries **** ") + set_tests_properties (H5TEST-shared-links_env PROPERTIES + DEPENDS H5TEST-shared-clear-links_env-objects + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/H5TEST-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/H5TEST-shared + ) + + #-- Adding test for libinfo add_test ( - NAME H5PLUGIN-SKIPPED - COMMAND ${CMAKE_COMMAND} -E echo "SKIP H5PLUGIN TESTING" + NAME H5TEST-shared-testlibinfo + COMMAND ${CMAKE_COMMAND} -D "TEST_PROGRAM=$" -P "${GREP_RUNNER}" + WORKING_DIRECTORY + ${HDF5_TEST_BINARY_DIR}/H5TEST-shared ) endif (BUILD_SHARED_LIBS) ############################################################################## +### P L U G I N T E S T S +############################################################################## +if (WIN32) + set (CMAKE_SEP "\;") +else (WIN32) + set (CMAKE_SEP ":") +endif (WIN32) + +add_test (NAME H5PLUGIN-plugin COMMAND $) +set_tests_properties (H5PLUGIN-plugin PROPERTIES + ENVIRONMENT "HDF5_PLUGIN_PATH=${CMAKE_BINARY_DIR}/testdir1${CMAKE_SEP}${CMAKE_BINARY_DIR}/testdir2;srcdir=${HDF5_TEST_BINARY_DIR}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR} +) + +############################################################################## ############################################################################## ### V F D T E S T S ### ############################################################################## @@ -560,7 +905,7 @@ if (HDF5_TEST_VFD) ohdr stab gheap - cache +# cache cache_api cache_tagging pool @@ -609,7 +954,7 @@ if (HDF5_TEST_VFD) unregister ) if (NOT CYGWIN) - set (H5_VFD_TESTS ${H5_VFD_TESTS} big) + set (H5_VFD_TESTS ${H5_VFD_TESTS} big cache) endif (NOT CYGWIN) MACRO (CHECK_VFD_TEST vfdtest vfdname resultcode) @@ -623,7 +968,7 @@ if (HDF5_TEST_VFD) -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${vfdtest}" + -D "TEST_OUTPUT=${vfdname}-${vfdtest}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) @@ -631,11 +976,34 @@ if (HDF5_TEST_VFD) ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) + if (BUILD_SHARED_LIBS) + add_test ( + NAME VFD-${vfdname}-${test}-shared + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VFD:STRING=${vfdname}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${vfdname}-${vfdtest}-shared" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}-shared" + -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" + ) + set_tests_properties (VFD-${vfdname}-${vfdtest}-shared PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname}-shared + ) + endif (BUILD_SHARED_LIBS) else (NOT BUILD_SHARED_LIBS AND NOT CMAKE_BUILD_TYPE MATCHES Debug) add_test ( NAME VFD-${vfdname}-${vfdtest} COMMAND ${CMAKE_COMMAND} -E echo "SKIP VFD-${vfdname}-${vfdtest}" ) + if (BUILD_SHARED_LIBS) + add_test ( + NAME VFD-${vfdname}-${test}-shared + COMMAND ${CMAKE_COMMAND} -E echo "SKIP VFD-${vfdname}-${vfdtest}-shared" + ) + endif (BUILD_SHARED_LIBS) endif(NOT BUILD_SHARED_LIBS AND NOT CMAKE_BUILD_TYPE MATCHES Debug) else (${vfdname} STREQUAL "multi" OR ${vfdname} STREQUAL "split") add_test ( @@ -645,7 +1013,7 @@ if (HDF5_TEST_VFD) -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${vfdtest}" + -D "TEST_OUTPUT=${vfdname}-${vfdtest}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) @@ -653,6 +1021,23 @@ if (HDF5_TEST_VFD) ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) + if (BUILD_SHARED_LIBS) + add_test ( + NAME VFD-${vfdname}-${test}-shared + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VFD:STRING=${vfdname}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${vfdname}-${vfdtest}-shared" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}-shared" + -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" + ) + set_tests_properties (VFD-${vfdname}-${vfdtest}-shared PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname}-shared + ) + endif (BUILD_SHARED_LIBS) endif (${vfdname} STREQUAL "multi" OR ${vfdname} STREQUAL "split") else (${vfdtest} STREQUAL "flush1" OR ${vfdtest} STREQUAL "flush2") add_test ( @@ -662,14 +1047,31 @@ if (HDF5_TEST_VFD) -D "TEST_ARGS:STRING=" -D "TEST_VFD:STRING=${vfdname}" -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${vfdtest}" + -D "TEST_OUTPUT=${vfdname}-${vfdtest}" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (VFD-${vfdname}-${vfdtest} PROPERTIES - ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}" + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname};HDF5TestExpress=2" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) + if (BUILD_SHARED_LIBS) + add_test ( + NAME VFD-${vfdname}-${vfdtest}-shared + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VFD:STRING=${vfdname}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${vfdname}-${vfdtest}-shared" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}-shared" + -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" + ) + set_tests_properties (VFD-${vfdname}-${vfdtest}-shared PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}-shared;HDF5TestExpress=2" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname}-shared + ) + endif (BUILD_SHARED_LIBS) endif (${vfdtest} STREQUAL "flush1" OR ${vfdtest} STREQUAL "flush2") ENDMACRO (CHECK_VFD_TEST vfdtest vfdname resultcode) @@ -679,42 +1081,82 @@ if (HDF5_TEST_VFD) CHECK_VFD_TEST (${test} ${vfdname} ${resultcode}) else (WIN32) add_test ( - NAME VFD-${vfdname}-${test} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$" - -D "TEST_ARGS:STRING=" - -D "TEST_VFD:STRING=${vfdname}" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${vfdname}-${test}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" - -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" + NAME VFD-${vfdname}-${test} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VFD:STRING=${vfdname}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${vfdname}-${test}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" + -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (VFD-${vfdname}-${test} PROPERTIES ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) + if (BUILD_SHARED_LIBS) + add_test ( + NAME VFD-${vfdname}-${test}-shared + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VFD:STRING=${vfdname}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${vfdname}-${test}-shared" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}-shared" + -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" + ) + set_tests_properties (VFD-${vfdname}-${test}-shared PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname}-shared + ) + endif (BUILD_SHARED_LIBS) endif (WIN32) endforeach (test ${H5_VFD_TESTS}) set_tests_properties (VFD-${vfdname}-flush2 PROPERTIES DEPENDS VFD-${vfdname}-flush1) set_tests_properties (VFD-${vfdname}-flush1 PROPERTIES TIMEOUT 10) set_tests_properties (VFD-${vfdname}-flush2 PROPERTIES TIMEOUT 10) + if (BUILD_SHARED_LIBS) + set_tests_properties (VFD-${vfdname}-flush2-shared PROPERTIES DEPENDS VFD-${vfdname}-flush1-shared) + set_tests_properties (VFD-${vfdname}-flush1-shared PROPERTIES TIMEOUT 10) + set_tests_properties (VFD-${vfdname}-flush2-shared PROPERTIES TIMEOUT 10) + endif (BUILD_SHARED_LIBS) if (HDF5_TEST_FHEAP_VFD) add_test ( - NAME VFD-${vfdname}-fheap - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$" - -D "TEST_ARGS:STRING=" - -D "TEST_VFD:STRING=${vfdname}" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${vfdname}-fheap" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" - -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" + NAME VFD-${vfdname}-fheap + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VFD:STRING=${vfdname}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${vfdname}-fheap" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" + -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" ) set_tests_properties (VFD-${vfdname}-fheap PROPERTIES TIMEOUT 1800 - ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}" + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname};HDF5TestExpress=2" WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname} ) + if (BUILD_SHARED_LIBS) + add_test ( + NAME VFD-${vfdname}-fheap-shared + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VFD:STRING=${vfdname}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${vfdname}-fheap-shared" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}-shared" + -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" + ) + set_tests_properties (VFD-${vfdname}-fheap-shared PROPERTIES + TIMEOUT 1800 + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${vfdname}-shared;HDF5TestExpress=2" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${vfdname}-shared + ) + endif (BUILD_SHARED_LIBS) endif (HDF5_TEST_FHEAP_VFD) ENDMACRO (ADD_VFD_TEST) @@ -731,7 +1173,7 @@ endif (HDF5_TEST_VFD) ############################################################################## ############################################################################## -if (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) +if (HDF5_BUILD_GENERATORS) MACRO (ADD_H5_GENERATOR genfile) add_executable (${genfile} ${HDF5_TEST_SOURCE_DIR}/${genfile}.c) TARGET_NAMING (${genfile} STATIC) @@ -767,4 +1209,4 @@ if (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) ADD_H5_GENERATOR (${gen}) endforeach (gen ${H5_GENERATORS}) -endif (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) +endif (HDF5_BUILD_GENERATORS) diff --git a/testpar/CMakeLists.txt b/testpar/CMakeLists.txt index b02c8e2..634afe3 100644 --- a/testpar/CMakeLists.txt +++ b/testpar/CMakeLists.txt @@ -28,15 +28,15 @@ set (testphdf5_SRCS #-- Adding test for testhdf5 add_executable (testphdf5 ${testphdf5_SRCS}) -TARGET_NAMING (testphdf5 ${LIB_TYPE}) -TARGET_C_PROPERTIES (testphdf5 ${LIB_TYPE} " " " ") +TARGET_NAMING (testphdf5 STATIC) +TARGET_C_PROPERTIES (testphdf5 STATIC " " " ") target_link_libraries (testphdf5 ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET} ${LINK_LIBS}) set_target_properties (testphdf5 PROPERTIES FOLDER test/par) MACRO (ADD_H5P_EXE file) add_executable (${file} ${HDF5_TEST_PAR_SOURCE_DIR}/${file}.c) - TARGET_NAMING (${file} ${LIB_TYPE}) - TARGET_C_PROPERTIES (${file} ${LIB_TYPE} " " " ") + TARGET_NAMING (${file} STATIC) + TARGET_C_PROPERTIES (${file} STATIC " " " ") target_link_libraries (${file} ${HDF5_TEST_LIB_TARGET} ${HDF5_LIB_TARGET} ${LINK_LIBS}) set_target_properties (${file} PROPERTIES FOLDER test/par) ENDMACRO (ADD_H5P_EXE file) diff --git a/tools/h5copy/CMakeLists.txt b/tools/h5copy/CMakeLists.txt index 7291197..63b9b5d 100644 --- a/tools/h5copy/CMakeLists.txt +++ b/tools/h5copy/CMakeLists.txt @@ -10,15 +10,15 @@ INCLUDE_DIRECTORIES (${HDF5_TOOLS_SRC_DIR}/lib) # Add the h5copy and test executables # -------------------------------------------------------------------- add_executable (h5copy ${HDF5_TOOLS_H5COPY_SOURCE_DIR}/h5copy.c) -TARGET_NAMING (h5copy ${LIB_TYPE}) -TARGET_C_PROPERTIES (h5copy ${LIB_TYPE} " " " ") +TARGET_NAMING (h5copy STATIC) +TARGET_C_PROPERTIES (h5copy STATIC " " " ") target_link_libraries (h5copy ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (h5copy PROPERTIES FOLDER tools) set (H5_DEP_EXECUTABLES h5copy) if (BUILD_TESTING) - if (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) + if (HDF5_BUILD_GENERATORS) add_executable (h5copygentest ${HDF5_TOOLS_H5COPY_SOURCE_DIR}/h5copygentest.c) TARGET_NAMING (h5copygentest STATIC) TARGET_C_PROPERTIES (h5copygentest STATIC " " " ") @@ -26,7 +26,7 @@ if (BUILD_TESTING) set_target_properties (h5copygentest PROPERTIES FOLDER generator/tools) #add_test (NAME h5copygentest COMMAND $) - endif (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) + endif (HDF5_BUILD_GENERATORS) include (CMakeTests.cmake) endif (BUILD_TESTING) @@ -46,8 +46,5 @@ endif (BUILD_TESTING) install ( TARGETS h5copy - RUNTIME DESTINATION - ${HDF5_INSTALL_BIN_DIR} - COMPONENT - toolsapplications + RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT toolsapplications ) diff --git a/tools/h5diff/CMakeLists.txt b/tools/h5diff/CMakeLists.txt index 39095a5..59a3241 100644 --- a/tools/h5diff/CMakeLists.txt +++ b/tools/h5diff/CMakeLists.txt @@ -13,8 +13,8 @@ add_executable (h5diff ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/h5diff_common.c ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/h5diff_main.c ) -TARGET_NAMING (h5diff ${LIB_TYPE}) -TARGET_C_PROPERTIES (h5diff ${LIB_TYPE} " " " ") +TARGET_NAMING (h5diff STATIC) +TARGET_C_PROPERTIES (h5diff STATIC " " " ") target_link_libraries (h5diff ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (h5diff PROPERTIES FOLDER tools) @@ -25,8 +25,8 @@ if (H5_HAVE_PARALLEL) ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/h5diff_common.c ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/ph5diff_main.c ) - TARGET_NAMING (ph5diff ${LIB_TYPE}) - TARGET_C_PROPERTIES (ph5diff ${LIB_TYPE} " " " ") + TARGET_NAMING (ph5diff STATIC) + TARGET_C_PROPERTIES (ph5diff STATIC " " " ") target_link_libraries (ph5diff ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (ph5diff PROPERTIES FOLDER tools) endif (H5_HAVE_PARALLEL) @@ -35,7 +35,7 @@ if (BUILD_TESTING) # -------------------------------------------------------------------- # Add the h5diff and test executables # -------------------------------------------------------------------- - if (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) + if (HDF5_BUILD_GENERATORS) add_executable (h5diffgentest ${HDF5_TOOLS_H5DIFF_SOURCE_DIR}/h5diffgentest.c) TARGET_NAMING (h5diffgentest STATIC) TARGET_C_PROPERTIES (h5diffgentest STATIC " " " ") @@ -43,7 +43,7 @@ if (BUILD_TESTING) set_target_properties (h5diffgentest PROPERTIES FOLDER generator/tools) #add_test (NAME h5diffgentest COMMAND $) - endif (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) + endif (HDF5_BUILD_GENERATORS) include (CMakeTests.cmake) @@ -64,10 +64,7 @@ endif (BUILD_TESTING) install ( TARGETS h5diff - RUNTIME DESTINATION - ${HDF5_INSTALL_BIN_DIR} - COMPONENT - toolsapplications + RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT toolsapplications ) if (H5_HAVE_PARALLEL) @@ -77,9 +74,6 @@ if (H5_HAVE_PARALLEL) install ( TARGETS ph5diff - RUNTIME DESTINATION - ${HDF5_INSTALL_BIN_DIR} - COMPONENT - toolsapplications + RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT toolsapplications ) endif (H5_HAVE_PARALLEL) diff --git a/tools/h5dump/CMakeLists.txt b/tools/h5dump/CMakeLists.txt index 7658c04..47ba7a8 100644 --- a/tools/h5dump/CMakeLists.txt +++ b/tools/h5dump/CMakeLists.txt @@ -14,8 +14,8 @@ add_executable (h5dump ${HDF5_TOOLS_H5DUMP_SOURCE_DIR}/h5dump_ddl.c ${HDF5_TOOLS_H5DUMP_SOURCE_DIR}/h5dump_xml.c ) -TARGET_NAMING (h5dump ${LIB_TYPE}) -TARGET_C_PROPERTIES (h5dump ${LIB_TYPE} " " " ") +TARGET_NAMING (h5dump STATIC) +TARGET_C_PROPERTIES (h5dump STATIC " " " ") target_link_libraries (h5dump ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (h5dump PROPERTIES FOLDER tools) @@ -25,7 +25,7 @@ if (BUILD_TESTING) # -------------------------------------------------------------------- # Add the h5dump test executable # -------------------------------------------------------------------- - if (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) + if (HDF5_BUILD_GENERATORS) add_executable (h5dumpgentest ${HDF5_TOOLS_H5DUMP_SOURCE_DIR}/h5dumpgentest.c) TARGET_NAMING (h5dumpgentest STATIC) TARGET_C_PROPERTIES (h5dumpgentest STATIC " " " ") @@ -33,7 +33,7 @@ if (BUILD_TESTING) set_target_properties (h5dumpgentest PROPERTIES FOLDER generator/tools) #add_test (NAME h5dumpgentest COMMAND $) - endif (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) + endif (HDF5_BUILD_GENERATORS) include (CMakeTests.cmake) @@ -57,8 +57,5 @@ endif (BUILD_TESTING) install ( TARGETS h5dump - RUNTIME DESTINATION - ${HDF5_INSTALL_BIN_DIR} - COMPONENT - toolsapplications + RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT toolsapplications ) diff --git a/tools/h5import/CMakeLists.txt b/tools/h5import/CMakeLists.txt index bf1515e..b885a76 100644 --- a/tools/h5import/CMakeLists.txt +++ b/tools/h5import/CMakeLists.txt @@ -10,8 +10,8 @@ INCLUDE_DIRECTORIES (${HDF5_TOOLS_SRC_DIR}/lib) # Add the h5import executables # -------------------------------------------------------------------- add_executable (h5import ${HDF5_TOOLS_H5IMPORT_SOURCE_DIR}/h5import.c) -TARGET_NAMING (h5import ${LIB_TYPE}) -TARGET_C_PROPERTIES (h5import ${LIB_TYPE} " " " ") +TARGET_NAMING (h5import STATIC) +TARGET_C_PROPERTIES (h5import STATIC " " " ") target_link_libraries (h5import ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) #set_target_properties (h5import PROPERTIES COMPILE_DEFINITIONS H5DEBUGIMPORT) set_target_properties (h5import PROPERTIES FOLDER tools) @@ -23,8 +23,8 @@ if (BUILD_TESTING) # Add the h5import executables # -------------------------------------------------------------------- add_executable (h5importtest ${HDF5_TOOLS_H5IMPORT_SOURCE_DIR}/h5importtest.c) - TARGET_NAMING (h5importtest ${LIB_TYPE}) - TARGET_C_PROPERTIES (h5importtest ${LIB_TYPE} " " " ") + TARGET_NAMING (h5importtest STATIC) + TARGET_C_PROPERTIES (h5importtest STATIC " " " ") target_link_libraries (h5importtest ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) set_target_properties (h5importtest PROPERTIES FOLDER tools) @@ -47,8 +47,5 @@ endif (BUILD_TESTING) install ( TARGETS h5import - RUNTIME DESTINATION - ${HDF5_INSTALL_BIN_DIR} - COMPONENT - toolsapplications + RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT toolsapplications ) diff --git a/tools/h5jam/CMakeLists.txt b/tools/h5jam/CMakeLists.txt index 4498132..c01f8f7 100644 --- a/tools/h5jam/CMakeLists.txt +++ b/tools/h5jam/CMakeLists.txt @@ -10,26 +10,26 @@ INCLUDE_DIRECTORIES (${HDF5_TOOLS_SRC_DIR}/lib) # Add the h5jam executables # -------------------------------------------------------------------- add_executable (h5jam ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/h5jam.c) -TARGET_NAMING (h5jam ${LIB_TYPE}) -TARGET_C_PROPERTIES (h5jam ${LIB_TYPE} " " " ") +TARGET_NAMING (h5jam STATIC) +TARGET_C_PROPERTIES (h5jam STATIC " " " ") target_link_libraries (h5jam ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (h5jam PROPERTIES FOLDER tools) add_executable (getub ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/getub.c) -TARGET_NAMING (getub ${LIB_TYPE}) -TARGET_C_PROPERTIES (getub ${LIB_TYPE} " " " ") +TARGET_NAMING (getub STATIC) +TARGET_C_PROPERTIES (getub STATIC " " " ") target_link_libraries (getub ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (getub PROPERTIES FOLDER tools) add_executable (tellub ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/tellub.c) -TARGET_NAMING (tellub ${LIB_TYPE}) -TARGET_C_PROPERTIES (tellub ${LIB_TYPE} " " " ") +TARGET_NAMING (tellub STATIC) +TARGET_C_PROPERTIES (tellub STATIC " " " ") target_link_libraries (tellub ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (tellub PROPERTIES FOLDER tools) add_executable (h5unjam ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/h5unjam.c) -TARGET_NAMING (h5unjam ${LIB_TYPE}) -TARGET_C_PROPERTIES (h5unjam ${LIB_TYPE} " " " ") +TARGET_NAMING (h5unjam STATIC) +TARGET_C_PROPERTIES (h5unjam STATIC " " " ") target_link_libraries (h5unjam ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (h5unjam PROPERTIES FOLDER tools) @@ -44,15 +44,15 @@ if (BUILD_TESTING) # -------------------------------------------------------------------- # Add the h5jam test executables # -------------------------------------------------------------------- - if (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) + if (HDF5_BUILD_GENERATORS) add_executable (h5jamgentest ${HDF5_TOOLS_H5JAM_SOURCE_DIR}/h5jamgentest.c) - TARGET_NAMING (h5jamgentest ${LIB_TYPE}) - TARGET_C_PROPERTIES (testhdf5 ${LIB_TYPE} " " " ") + TARGET_NAMING (h5jamgentest STATIC) + TARGET_C_PROPERTIES (testhdf5 STATIC " " " ") target_link_libraries (h5jamgentest ${HDF5_LIB_TARGET}) set_target_properties (h5jamgentest PROPERTIES FOLDER generator/tools) #add_test (NAME h5jamgentest COMMAND $) - endif (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) + endif (HDF5_BUILD_GENERATORS) include (CMakeTests.cmake) @@ -73,8 +73,5 @@ endif (BUILD_TESTING) install ( TARGETS h5jam h5unjam - RUNTIME DESTINATION - ${HDF5_INSTALL_BIN_DIR} - COMPONENT - toolsapplications + RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT toolsapplications ) diff --git a/tools/h5ls/CMakeLists.txt b/tools/h5ls/CMakeLists.txt index 984b36b..4e96db2 100644 --- a/tools/h5ls/CMakeLists.txt +++ b/tools/h5ls/CMakeLists.txt @@ -10,8 +10,8 @@ INCLUDE_DIRECTORIES (${HDF5_TOOLS_SRC_DIR}/lib) # Add the h5ls executable #----------------------------------------------------------------------------- add_executable (h5ls ${HDF5_TOOLS_H5LS_SOURCE_DIR}/h5ls.c) -TARGET_NAMING (h5ls ${LIB_TYPE}) -TARGET_C_PROPERTIES (h5ls ${LIB_TYPE} " " " ") +TARGET_NAMING (h5ls STATIC) +TARGET_C_PROPERTIES (h5ls STATIC " " " ") target_link_libraries (h5ls ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (h5ls PROPERTIES FOLDER tools) @@ -40,8 +40,5 @@ endif (BUILD_TESTING) install ( TARGETS h5ls - RUNTIME DESTINATION - ${HDF5_INSTALL_BIN_DIR} - COMPONENT - toolsapplications + RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT toolsapplications ) diff --git a/tools/h5repack/CMakeLists.txt b/tools/h5repack/CMakeLists.txt index 42d9f3d..7631ae8 100644 --- a/tools/h5repack/CMakeLists.txt +++ b/tools/h5repack/CMakeLists.txt @@ -21,8 +21,8 @@ set (REPACK_COMMON_SRCS ) add_executable (h5repack ${REPACK_COMMON_SRCS} ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repack_main.c) -TARGET_NAMING (h5repack ${LIB_TYPE}) -TARGET_C_PROPERTIES (h5repack ${LIB_TYPE} " " " ") +TARGET_NAMING (h5repack STATIC) +TARGET_C_PROPERTIES (h5repack STATIC " " " ") target_link_libraries (h5repack ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (h5repack PROPERTIES FOLDER tools) @@ -33,51 +33,49 @@ if (BUILD_TESTING) # Add h5Repack test executables # -------------------------------------------------------------------- add_executable (testh5repack_detect_szip ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/testh5repack_detect_szip.c) - TARGET_NAMING (testh5repack_detect_szip ${LIB_TYPE}) - TARGET_C_PROPERTIES (testh5repack_detect_szip ${LIB_TYPE} " " " ") + TARGET_NAMING (testh5repack_detect_szip STATIC) + TARGET_C_PROPERTIES (testh5repack_detect_szip STATIC " " " ") target_link_libraries (testh5repack_detect_szip ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) set_target_properties (testh5repack_detect_szip PROPERTIES FOLDER tools) add_executable (h5repacktest ${REPACK_COMMON_SRCS} ${HDF5_TOOLS_H5REPACK_SOURCE_DIR}/h5repacktst.c) - TARGET_NAMING (h5repacktest ${LIB_TYPE}) - TARGET_C_PROPERTIES (h5repacktest ${LIB_TYPE} " " " ") + TARGET_NAMING (h5repacktest STATIC) + TARGET_C_PROPERTIES (h5repacktest STATIC " " " ") target_link_libraries (h5repacktest ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) set_target_properties (h5repacktest PROPERTIES FOLDER tools) #----------------------------------------------------------------------------- # If plugin library tests can be tested #----------------------------------------------------------------------------- - if (BUILD_SHARED_LIBS) - set (HDF5_TOOL_PLUGIN_LIB_CORENAME "dynlibadd") - set (HDF5_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_CORENAME}") - set (HDF5_TOOL_PLUGIN_LIB_TARGET ${HDF5_TOOL_PLUGIN_LIB_CORENAME}) - add_definitions (${HDF_EXTRA_C_FLAGS}) - INCLUDE_DIRECTORIES (${HDF5_SRC_DIR}) + set (HDF5_TOOL_PLUGIN_LIB_CORENAME "dynlibadd") + set (HDF5_TOOL_PLUGIN_LIB_NAME "${HDF5_EXTERNAL_LIB_PREFIX}${HDF5_TOOL_PLUGIN_LIB_CORENAME}") + set (HDF5_TOOL_PLUGIN_LIB_TARGET ${HDF5_TOOL_PLUGIN_LIB_CORENAME}) + add_definitions (${HDF_EXTRA_C_FLAGS}) + INCLUDE_DIRECTORIES (${HDF5_SRC_DIR}) - add_library (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_rpk.c) - TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED " " " ") - target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) - H5_SET_LIB_OPTIONS ( - ${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TOOL_PLUGIN_LIB_NAME} - SHARED - HDF5_TOOL_PLUGIN_LIB_NAME_RELEASE - HDF5_TOOL_PLUGIN_LIB_NAME_DEBUG - ) + add_library (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED dynlib_rpk.c) + TARGET_C_PROPERTIES (${HDF5_TOOL_PLUGIN_LIB_TARGET} SHARED " " " ") + target_link_libraries (${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) + H5_SET_LIB_OPTIONS ( + ${HDF5_TOOL_PLUGIN_LIB_TARGET} ${HDF5_TOOL_PLUGIN_LIB_NAME} + SHARED + HDF5_TOOL_PLUGIN_LIB_NAME_RELEASE + HDF5_TOOL_PLUGIN_LIB_NAME_DEBUG + ) - # make plugins dir - file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") - #----------------------------------------------------------------------------- - # Copy plugin library to a plugins folder - #----------------------------------------------------------------------------- - add_custom_command ( - TARGET ${HDF5_TOOL_PLUGIN_LIB_TARGET} - POST_BUILD - COMMAND ${CMAKE_COMMAND} - ARGS -E copy_if_different + # make plugins dir + file (MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/plugins") + #----------------------------------------------------------------------------- + # Copy plugin library to a plugins folder + #----------------------------------------------------------------------------- + add_custom_command ( + TARGET ${HDF5_TOOL_PLUGIN_LIB_TARGET} + POST_BUILD + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different "$" "${CMAKE_BINARY_DIR}/plugins/$" - ) - endif (BUILD_SHARED_LIBS) + ) include (CMakeTests.cmake) @@ -98,8 +96,5 @@ endif (BUILD_TESTING) install ( TARGETS h5repack - RUNTIME DESTINATION - ${HDF5_INSTALL_BIN_DIR} - COMPONENT - toolsapplications + RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT toolsapplications ) diff --git a/tools/h5repack/CMakeTests.cmake b/tools/h5repack/CMakeTests.cmake index efaa6e5..dee97ed 100644 --- a/tools/h5repack/CMakeTests.cmake +++ b/tools/h5repack/CMakeTests.cmake @@ -992,16 +992,8 @@ ############################################################################## ### P L U G I N T E S T S ############################################################################## -if (BUILD_SHARED_LIBS) ADD_H5_UD_TEST (plugin_test 0 h5repack_layout.h5 -v -f UD=257,1,9) ADD_H5_UD_TEST (plugin_none 0 h5repack_layout.UD.h5 -v -f NONE) -else (BUILD_SHARED_LIBS) - message (STATUS " **** Plugins libraries must be built as shared libraries **** ") - add_test ( - NAME H5REPACK-plugin - COMMAND ${CMAKE_COMMAND} -E echo "SKIP H5PLUGIN TESTING" - ) -endif (BUILD_SHARED_LIBS) if (HDF5_TEST_VFD) # Run test with different Virtual File Driver diff --git a/tools/h5stat/CMakeLists.txt b/tools/h5stat/CMakeLists.txt index 5230693..71c4741 100644 --- a/tools/h5stat/CMakeLists.txt +++ b/tools/h5stat/CMakeLists.txt @@ -10,8 +10,8 @@ INCLUDE_DIRECTORIES (${HDF5_TOOLS_SRC_DIR}/lib) # Add the h5stat executables # -------------------------------------------------------------------- add_executable (h5stat ${HDF5_TOOLS_H5STAT_SOURCE_DIR}/h5stat.c) -TARGET_NAMING (h5stat ${LIB_TYPE}) -TARGET_C_PROPERTIES (h5stat ${LIB_TYPE} " " " ") +TARGET_NAMING (h5stat STATIC) +TARGET_C_PROPERTIES (h5stat STATIC " " " ") target_link_libraries (h5stat ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (h5stat PROPERTIES FOLDER tools) @@ -21,7 +21,7 @@ if (BUILD_TESTING) # -------------------------------------------------------------------- # Add the h5stat test executables # -------------------------------------------------------------------- - if (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) + if (HDF5_BUILD_GENERATORS) add_executable (h5stat_gentest ${HDF5_TOOLS_H5STAT_SOURCE_DIR}/h5stat_gentest.c) TARGET_NAMING (h5stat_gentest STATIC) TARGET_C_PROPERTIES (h5stat_gentest STATIC " " " ") @@ -29,7 +29,7 @@ if (BUILD_TESTING) set_target_properties (h5stat_gentest PROPERTIES FOLDER generator/tools) #add_test (NAME h5stat_gentest COMMAND $) - endif (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) + endif (HDF5_BUILD_GENERATORS) include (CMakeTests.cmake) endif (BUILD_TESTING) @@ -49,8 +49,5 @@ endif (BUILD_TESTING) install ( TARGETS h5stat - RUNTIME DESTINATION - ${HDF5_INSTALL_BIN_DIR} - COMPONENT - toolsapplications + RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT toolsapplications ) diff --git a/tools/lib/CMakeLists.txt b/tools/lib/CMakeLists.txt index dbd72cd..38c84a2 100644 --- a/tools/lib/CMakeLists.txt +++ b/tools/lib/CMakeLists.txt @@ -37,21 +37,43 @@ set (H5_TOOLS_LIB_HDRS ${HDF5_TOOLS_LIB_SOURCE_DIR}/h5diff.h ) -add_library (${HDF5_TOOLS_LIB_TARGET} ${LIB_TYPE} ${H5_TOOLS_LIB_SRCS} ${H5_TOOLS_LIB_HDRS}) -TARGET_C_PROPERTIES (${HDF5_TOOLS_LIB_TARGET} ${LIB_TYPE} " " " ") +add_library (${HDF5_TOOLS_LIB_TARGET} STATIC ${H5_TOOLS_LIB_SRCS} ${H5_TOOLS_LIB_HDRS}) +TARGET_C_PROPERTIES (${HDF5_TOOLS_LIB_TARGET} STATIC " " " ") target_link_libraries (${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_TOOLS_LIB_TARGET}") H5_SET_LIB_OPTIONS ( ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TOOLS_LIB_NAME} - ${LIB_TYPE} + STATIC HDF5_TOOLS_LIB_NAME_RELEASE HDF5_TOOLS_LIB_NAME_DEBUG ) -#set_target_properties (${HDF5_TOOLS_LIB_TARGET} PROPERTIES COMPILE_DEFINITIONS H5DIFF_DEBUG) set_target_properties (${HDF5_TOOLS_LIB_TARGET} PROPERTIES FOLDER libraries/tools INTERFACE_INCLUDE_DIRECTORIES "$/include>" ) +#set_property (TARGET ${HDF5_TOOLS_LIB_TARGET} APPEND PROPERTY COMPILE_DEFINITIONS H5DIFF_DEBUG) +set (install_targets ${HDF5_TOOLS_LIB_TARGET}) + +if (BUILD_SHARED_LIBS) + add_library (${HDF5_TOOLS_LIBSH_TARGET} SHARED ${H5_TOOLS_LIB_SRCS} ${H5_TOOLS_LIB_HDRS}) + TARGET_C_PROPERTIES (${HDF5_TOOLS_LIBSH_TARGET} SHARED " " " ") + target_link_libraries (${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_LIBSH_TARGET}) + set_global_variable (HDF5_LIBRARIES_TO_EXPORT "${HDF5_LIBRARIES_TO_EXPORT};${HDF5_TOOLS_LIBSH_TARGET}") + H5_SET_LIB_OPTIONS ( + ${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_TOOLS_LIB_NAME} + SHARED + HDF5_TOOLS_LIB_NAME_RELEASE + HDF5_TOOLS_LIB_NAME_DEBUG + ) + set_target_properties (${HDF5_TOOLS_LIBSH_TARGET} PROPERTIES + FOLDER libraries/tools + COMPILE_DEFINITIONS "H5_BUILT_AS_DYNAMIC_LIB" + INTERFACE_INCLUDE_DIRECTORIES "$/include>" + INTERFACE_COMPILE_DEFINITIONS H5_BUILT_AS_DYNAMIC_LIB=1 + ) + #set_property (TARGET ${HDF5_TOOLS_LIBSH_TARGET} APPEND PROPERTY COMPILE_DEFINITIONS H5DIFF_DEBUG) + set (install_targets ${install_targets} ${HDF5_TOOLS_LIBSH_TARGET}) +endif (BUILD_SHARED_LIBS) ############################################################################## ############################################################################## @@ -60,7 +82,7 @@ set_target_properties (${HDF5_TOOLS_LIB_TARGET} PROPERTIES ############################################################################## #----------------------------------------------------------------------------- -# Add file(s) to CMake Install +# Add file(s) to CMake Install #----------------------------------------------------------------------------- install ( FILES @@ -76,16 +98,17 @@ install ( #----------------------------------------------------------------------------- if (HDF5_EXPORTED_TARGETS) if (BUILD_SHARED_LIBS) - INSTALL_TARGET_PDB (${HDF5_TOOLS_LIB_TARGET} ${HDF5_INSTALL_BIN_DIR} toolslibraries) + INSTALL_TARGET_PDB (${HDF5_TOOLS_LIBSH_TARGET} ${HDF5_INSTALL_BIN_DIR} toolslibraries) endif (BUILD_SHARED_LIBS) - + install ( TARGETS - ${HDF5_TOOLS_LIB_TARGET} + ${install_targets} EXPORT ${HDF5_EXPORTED_TARGETS} LIBRARY DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT toolslibraries ARCHIVE DESTINATION ${HDF5_INSTALL_LIB_DIR} COMPONENT toolslibraries RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT toolslibraries + FRAMEWORK DESTINATION ${HDF5_INSTALL_FWRK_DIR} COMPONENT toolslibraries ) endif (HDF5_EXPORTED_TARGETS) diff --git a/tools/misc/CMakeLists.txt b/tools/misc/CMakeLists.txt index e0f94d0..d53cdc8 100644 --- a/tools/misc/CMakeLists.txt +++ b/tools/misc/CMakeLists.txt @@ -11,20 +11,20 @@ INCLUDE_DIRECTORIES (${HDF5_TOOLS_SRC_DIR}/lib) # -------------------------------------------------------------------- #-- Misc Executables add_executable (h5debug ${HDF5_TOOLS_MISC_SOURCE_DIR}/h5debug.c) -TARGET_NAMING (h5debug ${LIB_TYPE}) -TARGET_C_PROPERTIES (h5debug ${LIB_TYPE} " " " ") +TARGET_NAMING (h5debug STATIC) +TARGET_C_PROPERTIES (h5debug STATIC " " " ") target_link_libraries (h5debug ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) set_target_properties (h5debug PROPERTIES FOLDER tools) add_executable (h5repart ${HDF5_TOOLS_MISC_SOURCE_DIR}/h5repart.c) -TARGET_NAMING (h5repart ${LIB_TYPE}) -TARGET_C_PROPERTIES (h5repart ${LIB_TYPE} " " " ") +TARGET_NAMING (h5repart STATIC) +TARGET_C_PROPERTIES (h5repart STATIC " " " ") target_link_libraries (h5repart ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) set_target_properties (h5repart PROPERTIES FOLDER tools) add_executable (h5mkgrp ${HDF5_TOOLS_MISC_SOURCE_DIR}/h5mkgrp.c) -TARGET_NAMING (h5mkgrp ${LIB_TYPE}) -TARGET_C_PROPERTIES (h5mkgrp ${LIB_TYPE} " " " ") +TARGET_NAMING (h5mkgrp STATIC) +TARGET_C_PROPERTIES (h5mkgrp STATIC " " " ") target_link_libraries (h5mkgrp ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (h5mkgrp PROPERTIES FOLDER tools) @@ -45,18 +45,18 @@ if (BUILD_TESTING) # -------------------------------------------------------------------- # Add the misc test executables # -------------------------------------------------------------------- - if (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) + if (HDF5_BUILD_GENERATORS) add_executable (h5repart_gentest ${HDF5_TOOLS_MISC_SOURCE_DIR}/h5repart_gentest.c) TARGET_NAMING (h5repart_gentest STATIC) TARGET_C_PROPERTIES (h5repart_gentest STATIC " " " ") target_link_libraries (h5repart_gentest ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) set_target_properties (h5repart_gentest PROPERTIES FOLDER generator/tools) #add_test (NAME h5repart_gentest COMMAND $) - endif (HDF5_BUILD_GENERATORS AND NOT BUILD_SHARED_LIBS) + endif (HDF5_BUILD_GENERATORS) add_executable (h5repart_test ${HDF5_TOOLS_MISC_SOURCE_DIR}/repart_test.c) - TARGET_NAMING (h5repart_test ${LIB_TYPE}) - TARGET_C_PROPERTIES (h5repart_test ${LIB_TYPE} " " " ") + TARGET_NAMING (h5repart_test STATIC) + TARGET_C_PROPERTIES (h5repart_test STATIC " " " ") target_link_libraries (h5repart_test ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) set_target_properties (h5repart_test PROPERTIES FOLDER tools) @@ -80,8 +80,5 @@ endif (BUILD_TESTING) install ( TARGETS h5debug h5repart h5mkgrp - RUNTIME DESTINATION - ${HDF5_INSTALL_BIN_DIR} - COMPONENT - toolsapplications + RUNTIME DESTINATION ${HDF5_INSTALL_BIN_DIR} COMPONENT toolsapplications ) diff --git a/tools/perform/CMakeLists.txt b/tools/perform/CMakeLists.txt index 17b40fa..3a60a84 100644 --- a/tools/perform/CMakeLists.txt +++ b/tools/perform/CMakeLists.txt @@ -21,8 +21,8 @@ set (h5perf_serial_SRCS ${HDF5_PERFORM_SOURCE_DIR}/sio_engine.c ) add_executable (h5perf_serial ${h5perf_serial_SRCS}) -TARGET_NAMING (h5perf_serial ${LIB_TYPE}) -TARGET_C_PROPERTIES (h5perf_serial ${LIB_TYPE} " " " ") +TARGET_NAMING (h5perf_serial STATIC) +TARGET_C_PROPERTIES (h5perf_serial STATIC " " " ") target_link_libraries (h5perf_serial ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) set_target_properties (h5perf_serial PROPERTIES FOLDER perform) @@ -33,8 +33,8 @@ if (HDF5_BUILD_PERFORM_STANDALONE) ${HDF5_PERFORM_SOURCE_DIR}/sio_engine.c ) add_executable (h5perf_serial_alone ${h5perf_serial_alone_SRCS}) - TARGET_NAMING (h5perf_serial_alone ${LIB_TYPE}) - TARGET_C_PROPERTIES (h5perf_serial_alone ${LIB_TYPE} " " " ") + TARGET_NAMING (h5perf_serial_alone STATIC) + TARGET_C_PROPERTIES (h5perf_serial_alone STATIC " " " ") target_link_libraries (h5perf_serial_alone ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) set_target_properties (h5perf_serial_alone PROPERTIES FOLDER perform) set_property (TARGET h5perf_serial_alone @@ -47,8 +47,8 @@ set (chunk_SRCS ${HDF5_PERFORM_SOURCE_DIR}/chunk.c ) ADD_EXECUTABLE(chunk ${chunk_SRCS}) -TARGET_NAMING (chunk ${LIB_TYPE}) -TARGET_C_PROPERTIES (chunk ${LIB_TYPE} " " " ") +TARGET_NAMING (chunk STATIC) +TARGET_C_PROPERTIES (chunk STATIC " " " ") TARGET_LINK_LIBRARIES(chunk ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) set_target_properties (chunk PROPERTIES FOLDER perform) @@ -57,8 +57,8 @@ set (iopipe_SRCS ${HDF5_PERFORM_SOURCE_DIR}/iopipe.c ) add_executable (iopipe ${iopipe_SRCS}) -TARGET_NAMING (iopipe ${LIB_TYPE}) -TARGET_C_PROPERTIES (iopipe ${LIB_TYPE} " " " ") +TARGET_NAMING (iopipe STATIC) +TARGET_C_PROPERTIES (iopipe STATIC " " " ") target_link_libraries (iopipe ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) set_target_properties (iopipe PROPERTIES FOLDER perform) @@ -67,8 +67,8 @@ set (overhead_SRCS ${HDF5_PERFORM_SOURCE_DIR}/overhead.c ) add_executable (overhead ${overhead_SRCS}) -TARGET_NAMING (overhead ${LIB_TYPE}) -TARGET_C_PROPERTIES (overhead ${LIB_TYPE} " " " ") +TARGET_NAMING (overhead STATIC) +TARGET_C_PROPERTIES (overhead STATIC " " " ") target_link_libraries (overhead ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET}) set_target_properties (overhead PROPERTIES FOLDER perform) @@ -78,8 +78,8 @@ if (BUILD_TESTING) ${HDF5_PERFORM_SOURCE_DIR}/perf_meta.c ) add_executable (perf_meta ${perf_meta_SRCS}) - TARGET_NAMING (perf_meta ${LIB_TYPE}) - TARGET_C_PROPERTIES (perf_meta ${LIB_TYPE} " " " ") + TARGET_NAMING (perf_meta STATIC) + TARGET_C_PROPERTIES (perf_meta STATIC " " " ") target_link_libraries (perf_meta ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) set_target_properties (perf_meta PROPERTIES FOLDER perform) endif (BUILD_TESTING) @@ -89,8 +89,8 @@ set (zip_perf_SRCS ${HDF5_PERFORM_SOURCE_DIR}/zip_perf.c ) add_executable (zip_perf ${zip_perf_SRCS}) -TARGET_NAMING (zip_perf ${LIB_TYPE}) -TARGET_C_PROPERTIES (zip_perf ${LIB_TYPE} " " " ") +TARGET_NAMING (zip_perf STATIC) +TARGET_C_PROPERTIES (zip_perf STATIC " " " ") target_link_libraries (zip_perf ${HDF5_TOOLS_LIB_TARGET} ${HDF5_LIB_TARGET}) set_target_properties (zip_perf PROPERTIES FOLDER perform) @@ -101,8 +101,8 @@ if (H5_HAVE_PARALLEL AND BUILD_TESTING) ${HDF5_PERFORM_SOURCE_DIR}/pio_engine.c ) add_executable (h5perf ${h5perf_SRCS}) - TARGET_NAMING (h5perf ${LIB_TYPE}) - TARGET_C_PROPERTIES (h5perf ${LIB_TYPE} " " " ") + TARGET_NAMING (h5perf STATIC) + TARGET_C_PROPERTIES (h5perf STATIC " " " ") target_link_libraries (h5perf ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) set_target_properties (h5perf PROPERTIES FOLDER perform) @@ -113,8 +113,8 @@ if (H5_HAVE_PARALLEL AND BUILD_TESTING) ${HDF5_PERFORM_SOURCE_DIR}/pio_engine.c ) add_executable (h5perf_alone ${h5perf_alone_SRCS}) - TARGET_NAMING (h5perf_alone ${LIB_TYPE}) - TARGET_C_PROPERTIES (h5perf_alone ${LIB_TYPE} " " " ") + TARGET_NAMING (h5perf_alone STATIC) + TARGET_C_PROPERTIES (h5perf_alone STATIC " " " ") target_link_libraries (h5perf_alone ${HDF5_LIB_TARGET} ${HDF5_TOOLS_LIB_TARGET} ${HDF5_TEST_LIB_TARGET}) set_target_properties (h5perf_alone PROPERTIES FOLDER perform) set_property (TARGET h5perf_alone -- cgit v0.12