Hdf5 cmake (#18937)

* Switch hdf5 package from autotools to cmake.

* Add variant for building with zlib, default to ON.

* Update for format requirements.

* Format change.

* Fix breakage from last merge from develop.
Switch szip to use libaec (unrestricted encryption).
Remove 'static' variant:  static libs will only be installed when
~shared.

* Improve args based on suggestions from pull request.

* Update code URL to github.com
Add/modify 4 depends_on lines to fix running "spack graph --deptype=link hdf5".

* Remove trailing whitespace.

* Remove dependencies added solely to make "spack greph --type=link" work.

* Add new version HDF5 1.8.22.

* Remove unnecessary java_check.

* Fix whitespace for style checks.

* Reverted zlib version dependency to 1.1.2:.
zlib variant removed.
api version default renamed "default".

* Remove blank line.

* Whitespace corrections.

* iRemoved unnecessary 'debug' variant.

* Fix typo in version number in conflict for '+szip'.

* Set default for tools variant to True.
Remove patch functions dependent on 'libtool' file that cmake doesn't
produce.

* Remove line to set ONLY_SHARED_LIBS to true.
Add post_install code to install only one version of tools with shared
linkage and original tool names.

* Remove trailing white space and import of glob package not used.

* Leave BUILD_TESTING set to default which is ON.

* Remove  post_install code to install only one version of tools because
some dependent packages running tests in e4s testing are using
h5diff-shared.  Keep both tools versions for now.

* No longer need to import os.
This commit is contained in:
Larry Knox 2021-06-28 14:42:54 -05:00 committed by GitHub
parent 9a9b5dee2e
commit cc20dbf645
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 765 additions and 99 deletions

View file

@ -48,7 +48,7 @@ packages:
rpc: [libtirpc] rpc: [libtirpc]
scalapack: [netlib-scalapack, amdscalapack] scalapack: [netlib-scalapack, amdscalapack]
sycl: [hipsycl] sycl: [hipsycl]
szip: [libszip, libaec] szip: [libaec, libszip]
tbb: [intel-tbb] tbb: [intel-tbb]
unwind: [libunwind] unwind: [libunwind]
uuid: [util-linux-uuid, libuuid] uuid: [util-linux-uuid, libuuid]

View file

@ -0,0 +1,90 @@
diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt
index 8608c67..4b1a2d6 100644
--- a/c++/src/CMakeLists.txt
+++ b/c++/src/CMakeLists.txt
@@ -209,7 +209,11 @@ install (
)
if (NOT WIN32 AND NOT MINGW)
- set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER})
+ if (HDF5_ENABLE_PARALLEL AND MPI_CXX_FOUND)
+ set (_PKG_CONFIG_COMPILER ${MPI_CXX_COMPILER})
+ else ()
+ set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER})
+ endif ()
configure_file (
${HDF_RESOURCES_DIR}/libh5cc.in
${HDF5_BINARY_DIR}/CMakeFiles/h5c++
${HDF5_BINARY_DIR}/CMakeFiles/h5fc
diff --git a/hl/c++/src/CMakeLists.txt b/hl/c++/src/CMakeLists.txt
index 1eac9fe..e488656 100644
--- a/hl/c++/src/CMakeLists.txt
+++ b/hl/c++/src/CMakeLists.txt
@@ -120,7 +120,11 @@ install (
)
if (NOT WIN32 AND NOT MINGW)
- set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER})
+ if (HDF5_ENABLE_PARALLEL AND MPI_CXX_FOUND)
+ set (_PKG_CONFIG_COMPILER ${MPI_CXX_COMPILER})
+ else ()
+ set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER})
+ endif ()
configure_file (
${HDF_RESOURCES_DIR}/libh5cc.in
${HDF5_BINARY_DIR}/CMakeFiles/h5hlc++
diff --git a/hl/src/CMakeLists.txt b/hl/src/CMakeLists.txt
index 785bdcf..427424e 100644
--- a/hl/src/CMakeLists.txt
+++ b/hl/src/CMakeLists.txt
@@ -152,7 +152,11 @@ install (
)
if (NOT WIN32 AND NOT MINGW)
- set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER})
+ if (HDF5_ENABLE_PARALLEL AND MPI_C_FOUND)
+ set (_PKG_CONFIG_COMPILER ${MPI_C_COMPILER})
+ else ()
+ set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER})
+ endif ()
configure_file (
${HDF_RESOURCES_DIR}/libh5cc.in
${HDF5_BINARY_DIR}/CMakeFiles/h5hlcc
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 329a2dc..97019fa 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1282,7 +1282,11 @@ install (
)
if (NOT WIN32)
- set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER})
+ if (HDF5_ENABLE_PARALLEL AND MPI_C_FOUND)
+ set (_PKG_CONFIG_COMPILER ${MPI_C_COMPILER})
+ else ()
+ set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER})
+ endif ()
configure_file (
${HDF_RESOURCES_DIR}/libh5cc.in
${HDF5_BINARY_DIR}/CMakeFiles/h5cc
@@ -1294,6 +1298,20 @@ if (NOT WIN32)
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
COMPONENT libraries
)
+ if (HDF5_ENABLE_PARALLEL AND MPI_C_FOUND)
+ #legacy requires a different name
+ configure_file (
+ ${HDF_RESOURCES_DIR}/libh5cc.in
+ ${HDF5_BINARY_DIR}/CMakeFiles/h5pcc
+ @ONLY
+ )
+ install (
+ FILES ${HDF5_BINARY_DIR}/CMakeFiles/h5pcc
+ DESTINATION ${HDF5_INSTALL_BIN_DIR}
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+ COMPONENT libraries
+ )
+ endif ()
endif ()
#-----------------------------------------------------------------------------

View file

@ -0,0 +1,104 @@
diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt
index 39f0f3a..9dc69d6 100644
--- a/c++/src/CMakeLists.txt
+++ b/c++/src/CMakeLists.txt
@@ -196,7 +196,11 @@ install (
)
if (NOT WIN32 AND NOT MINGW)
- set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER})
+ if (HDF5_ENABLE_PARALLEL AND MPI_CXX_FOUND)
+ set (_PKG_CONFIG_COMPILER ${MPI_CXX_COMPILER})
+ else ()
+ set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER})
+ endif ()
configure_file (
${HDF_RESOURCES_DIR}/libh5cc.in
${HDF5_BINARY_DIR}/CMakeFiles/h5c++
diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt
index b5d1a60..22ed7fb 100644
--- a/fortran/src/CMakeLists.txt
+++ b/fortran/src/CMakeLists.txt
@@ -533,7 +533,11 @@ install (
)
if (NOT WIN32 AND NOT MINGW)
- set (_PKG_CONFIG_COMPILER ${CMAKE_Fortran_COMPILER})
+ if (HDF5_ENABLE_PARALLEL AND MPI_Fortran_FOUND)
+ set (_PKG_CONFIG_COMPILER ${MPI_Fortran_COMPILER})
+ else ()
+ set (_PKG_CONFIG_COMPILER ${CMAKE_Fortran_COMPILER})
+ endif ()
configure_file (
${HDF_RESOURCES_DIR}/libh5cc.in
${HDF5_BINARY_DIR}/CMakeFiles/h5fc
diff --git a/hl/c++/src/CMakeLists.txt b/hl/c++/src/CMakeLists.txt
index 866f372..6abd376 100644
--- a/hl/c++/src/CMakeLists.txt
+++ b/hl/c++/src/CMakeLists.txt
@@ -109,7 +109,11 @@ install (
)
if (NOT WIN32 AND NOT MINGW)
- set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER})
+ if (HDF5_ENABLE_PARALLEL AND MPI_CXX_FOUND)
+ set (_PKG_CONFIG_COMPILER ${MPI_CXX_COMPILER})
+ else ()
+ set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER})
+ endif ()
configure_file (
${HDF_RESOURCES_DIR}/libh5cc.in
${HDF5_BINARY_DIR}/CMakeFiles/h5hlc++
diff --git a/hl/src/CMakeLists.txt b/hl/src/CMakeLists.txt
index 55d84c7..857a390 100644
--- a/hl/src/CMakeLists.txt
+++ b/hl/src/CMakeLists.txt
@@ -133,7 +133,11 @@ install (
)
if (NOT WIN32 AND NOT MINGW)
- set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER})
+ if (HDF5_ENABLE_PARALLEL AND MPI_C_FOUND)
+ set (_PKG_CONFIG_COMPILER ${MPI_C_COMPILER})
+ else ()
+ set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER})
+ endif ()
configure_file (
${HDF_RESOURCES_DIR}/libh5cc.in
${HDF5_BINARY_DIR}/CMakeFiles/h5hlcc
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index f582056..d7ddee4 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1272,7 +1272,11 @@ install (
)
if (NOT WIN32)
- set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER})
+ if (HDF5_ENABLE_PARALLEL AND MPI_C_FOUND)
+ set (_PKG_CONFIG_COMPILER ${MPI_C_COMPILER})
+ else ()
+ set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER})
+ endif ()
configure_file (
${HDF_RESOURCES_DIR}/libh5cc.in
${HDF5_BINARY_DIR}/CMakeFiles/h5cc
@@ -1284,4 +1288,18 @@ if (NOT WIN32)
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
COMPONENT libraries
)
+ if (HDF5_ENABLE_PARALLEL AND MPI_C_FOUND)
+ #legacy requires a different name
+ configure_file (
+ ${HDF_RESOURCES_DIR}/libh5cc.in
+ ${HDF5_BINARY_DIR}/CMakeFiles/h5pcc
+ @ONLY
+ )
+ install (
+ FILES ${HDF5_BINARY_DIR}/CMakeFiles/h5pcc
+ DESTINATION ${HDF5_INSTALL_BIN_DIR}
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+ COMPONENT libraries
+ )
+ endif ()
endif ()

View file

@ -0,0 +1,362 @@
diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt
index 9b9b745..3f05fa0 100644
--- a/c++/src/CMakeLists.txt
+++ b/c++/src/CMakeLists.txt
@@ -178,7 +178,11 @@ install (
)
if (NOT WIN32)
- set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER})
+ if (HDF5_ENABLE_PARALLEL AND MPI_CXX_FOUND)
+ set (_PKG_CONFIG_COMPILER ${MPI_CXX_COMPILER})
+ else ()
+ set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER})
+ endif ()
configure_file (
${HDF_RESOURCES_DIR}/libh5cc.in
${HDF5_BINARY_DIR}/CMakeFiles/h5c++
diff --git a/config/cmake_ext_mod/FindSZIP.cmake b/config/cmake_ext_mod/FindSZIP.cmake
index 699be85..846a3d1 100644
--- a/config/cmake_ext_mod/FindSZIP.cmake
+++ b/config/cmake_ext_mod/FindSZIP.cmake
@@ -5,140 +5,112 @@
# This file is part of HDF5. The full HDF5 copyright notice, including
# terms governing use, modification, and redistribution, is contained in
# the COPYING file, which can be found at the root of the source code
-# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases.
+# distribution tree, or in https://www.hdfgroup.org/licenses.
# If you do not have access to either file, you may request a copy from
# help@hdfgroup.org.
#
+#########################################################################
+
+# - Derived from the FindTiff.cmake and FindJPEG.cmake that is included with cmake
+# FindSZIP
-# - 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..." )
+# Imported targets
+##################
-############################################
+# This module defines the following :prop_tgt:`IMPORTED` targets:
#
-# Check the existence of the libraries.
+# SZIP::SZIP
+# The SZIP library, if found.
#
-############################################
-# 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
-#########################################################################
+# Result variables
+###################
-macro (SZIP_ADJUST_LIB_VARS basename)
- if (${basename}_INCLUDE_DIR)
+# This module will set the following variables in your project:
- # 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 ()
+# SZIP_FOUND, true if the SZIP headers and libraries were found.
+# SZIP_INCLUDE_DIR, the directory containing the SZIP headers.
+# SZIP_INCLUDE_DIRS, the directory containing the SZIP headers.
+# SZIP_LIBRARIES, libraries to link against to use SZIP.
- # 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 ()
- 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 ()
- # 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 ()
- set (${basename}_LIBRARIES optimized ${${basename}_LIBRARY_RELEASE} debug ${${basename}_LIBRARY_DEBUG})
- endif ()
+# Cache variables
+#################
- set (${basename}_LIBRARY ${${basename}_LIBRARY} CACHE FILEPATH "The ${basename} library")
+# The following variables may also be set:
- if (${basename}_LIBRARY)
- set (${basename}_FOUND 1)
- endif ()
- endif ()
+# SZIP_LIBRARY, where to find the SZIP library.
+# SZIP_LIBRARY_DEBUG - Debug version of SZIP library
+# SZIP_LIBRARY_RELEASE - Release Version of SZIP library
- # Make variables changeble to the advanced user
- MARK_AS_ADVANCED (${basename}_LIBRARY ${basename}_LIBRARY_RELEASE ${basename}_LIBRARY_DEBUG ${basename}_INCLUDE_DIR )
-endmacro ()
-
-
-# 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 ()
- set (SZIP_SEARCH_DEBUG_NAMES "sz_d")
- set (SZIP_SEARCH_RELEASE_NAMES "sz;szip")
-endif ()
+# message (STATUS "Finding SZIP library and headers..." )
+#########################################################################
-# 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 ()
- get_filename_component (SZIP_LIBRARY_PATH ${SZIP_LIBRARY_RELEASE} PATH)
- set (SZIP_LIB_DIR ${SZIP_LIBRARY_PATH})
- endif ()
-else ()
- set (SZIP_FOUND 0)
- set (SZIP_LIBRARIES)
- set (SZIP_INCLUDE_DIRS)
-endif ()
+
+find_path(SZIP_INCLUDE_DIR szlib.h)
+
+set(szip_names ${SZIP_NAMES} sz szip szip-static libsz libszip libszip-static)
+foreach(name ${szip_names})
+ list (APPEND szip_names_debug "${name}d")
+endforeach()
+
+if(NOT SZIP_LIBRARY)
+ find_library(SZIP_LIBRARY_RELEASE NAMES ${szip_names})
+ find_library(SZIP_LIBRARY_DEBUG NAMES ${szip_names_debug})
+ include(SelectLibraryConfigurations)
+ select_library_configurations(SZIP)
+ mark_as_advanced(SZIP_LIBRARY_RELEASE SZIP_LIBRARY_DEBUG)
+endif()
+unset(szip_names)
+unset(szip_names_debug)
+
+if(SZIP_INCLUDE_DIR AND EXISTS "${SZIP_INCLUDE_DIR}/SZconfig.h")
+ file(STRINGS "${SZIP_INCLUDE_DIR}/SZconfig.h" szip_version_str
+ REGEX "^#define[\t ]+SZIP_PACKAGE_VERSION[\t ]+.*")
+
+ string(REGEX REPLACE "^#define[\t ]+SZIP_PACKAGE_VERSION[\t ]+([0-9]+).*"
+ "\\1" SZIP_VERSION "${szip_version_str}")
+ unset(szip_version_str)
+endif()
+
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(SZIP
+ REQUIRED_VARS SZIP_LIBRARY SZIP_INCLUDE_DIR
+ VERSION_VAR SZIP_VERSION)
+
+if(SZIP_FOUND)
+ set(SZIP_LIBRARIES ${SZIP_LIBRARY})
+ set(SZIP_INCLUDE_DIRS "${SZIP_INCLUDE_DIR}")
+
+ if(NOT TARGET SZIP::SZIP)
+ add_library(SZIP::SZIP UNKNOWN IMPORTED)
+ if(SZIP_INCLUDE_DIRS)
+ set_target_properties(SZIP::SZIP PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES "${SZIP_INCLUDE_DIRS}")
+ endif()
+ if(EXISTS "${SZIP_LIBRARY}")
+ set_target_properties(SZIP::SZIP PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES "C"
+ IMPORTED_LOCATION "${SZIP_LIBRARY}")
+ endif()
+ if(EXISTS "${SZIP_LIBRARY_RELEASE}")
+ set_property(TARGET SZIP::SZIP APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS RELEASE)
+ set_target_properties(SZIP::SZIP PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_RELEASE "C"
+ IMPORTED_LOCATION_RELEASE "${SZIP_LIBRARY_RELEASE}")
+ endif()
+ if(EXISTS "${SZIP_LIBRARY_DEBUG}")
+ set_property(TARGET SZIP::SZIP APPEND PROPERTY
+ IMPORTED_CONFIGURATIONS DEBUG)
+ set_target_properties(SZIP::SZIP PROPERTIES
+ IMPORTED_LINK_INTERFACE_LANGUAGES_DEBUG "C"
+ IMPORTED_LOCATION_DEBUG "${SZIP_LIBRARY_DEBUG}")
+ endif()
+ endif()
+endif()
+
+mark_as_advanced(SZIP_LIBRARY SZIP_INCLUDE_DIR)
# Report the results.
if (NOT SZIP_FOUND)
@@ -146,36 +118,12 @@ if (NOT SZIP_FOUND)
"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}")
+ if (CMAKE_VERSION VERSION_GREATER_EQUAL "3.15.0")
+ message (VERBOSE "${SZIP_DIR_MESSAGE}")
+ endif ()
else ()
if (SZIP_FIND_REQUIRED)
message (FATAL_ERROR "SZip was NOT found and is Required by this project")
endif ()
endif ()
endif ()
-
-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 ()
-
-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 ()
diff --git a/hl/c++/src/CMakeLists.txt b/hl/c++/src/CMakeLists.txt
index 7949b73..a633bdd 100644
--- a/hl/c++/src/CMakeLists.txt
+++ b/hl/c++/src/CMakeLists.txt
@@ -102,7 +102,11 @@ install (
)
if (NOT WIN32)
- set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER})
+ if (HDF5_ENABLE_PARALLEL AND MPI_CXX_FOUND)
+ set (_PKG_CONFIG_COMPILER ${MPI_CXX_COMPILER})
+ else ()
+ set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER})
+ endif ()
configure_file (
${HDF_RESOURCES_DIR}/libh5cc.in
${HDF5_BINARY_DIR}/CMakeFiles/h5hlc++
diff --git a/hl/src/CMakeLists.txt b/hl/src/CMakeLists.txt
index d570265..e652ed3 100644
--- a/hl/src/CMakeLists.txt
+++ b/hl/src/CMakeLists.txt
@@ -118,7 +118,11 @@ install (
)
if (NOT WIN32)
- set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER})
+ if (HDF5_ENABLE_PARALLEL AND MPI_C_FOUND)
+ set (_PKG_CONFIG_COMPILER ${MPI_C_COMPILER})
+ else ()
+ set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER})
+ endif ()
configure_file (
${HDF_RESOURCES_DIR}/libh5cc.in
${HDF5_BINARY_DIR}/CMakeFiles/h5hlcc
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4d2f1bc..39cfbca 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -820,7 +820,11 @@ install (
)
if (NOT WIN32)
- set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER})
+ if (HDF5_ENABLE_PARALLEL AND MPI_C_FOUND)
+ set (_PKG_CONFIG_COMPILER ${MPI_C_COMPILER})
+ else ()
+ set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER})
+ endif ()
configure_file (
${HDF_RESOURCES_DIR}/libh5cc.in
${HDF5_BINARY_DIR}/CMakeFiles/h5cc
@@ -832,4 +836,18 @@ if (NOT WIN32)
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
COMPONENT libraries
)
+ if (HDF5_ENABLE_PARALLEL AND MPI_C_FOUND)
+ #legacy requires a different name
+ configure_file (
+ ${HDF_RESOURCES_DIR}/libh5cc.in
+ ${HDF5_BINARY_DIR}/CMakeFiles/h5pcc
+ @ONLY
+ )
+ install (
+ FILES ${HDF5_BINARY_DIR}/CMakeFiles/h5pcc
+ DESTINATION ${HDF5_INSTALL_BIN_DIR}
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+ COMPONENT libraries
+ )
+ endif ()
endif ()

View file

@ -0,0 +1,121 @@
diff --git a/c++/src/CMakeLists.txt b/c++/src/CMakeLists.txt
index 65d1d43..9e4bf24 100644
--- a/c++/src/CMakeLists.txt
+++ b/c++/src/CMakeLists.txt
@@ -211,7 +211,11 @@ install (
)
if (NOT WIN32 AND NOT MINGW)
- set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER})
+ if (HDF5_ENABLE_PARALLEL AND MPI_CXX_FOUND)
+ set (_PKG_CONFIG_COMPILER ${MPI_CXX_COMPILER})
+ else ()
+ set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER})
+ endif ()
configure_file (
${HDF_RESOURCES_DIR}/libh5cc.in
${HDF5_BINARY_DIR}/CMakeFiles/h5c++
diff --git a/fortran/src/CMakeLists.txt b/fortran/src/CMakeLists.txt
index dd03439..f58dde9 100644
--- a/fortran/src/CMakeLists.txt
+++ b/fortran/src/CMakeLists.txt
@@ -595,7 +595,11 @@ install (
)
if (NOT WIN32 AND NOT MINGW)
- set (_PKG_CONFIG_COMPILER ${CMAKE_Fortran_COMPILER})
+ if (HDF5_ENABLE_PARALLEL AND MPI_Fortran_FOUND)
+ set (_PKG_CONFIG_COMPILER ${MPI_Fortran_COMPILER})
+ else ()
+ set (_PKG_CONFIG_COMPILER ${CMAKE_Fortran_COMPILER})
+ endif ()
configure_file (
${HDF_RESOURCES_DIR}/libh5cc.in
${HDF5_BINARY_DIR}/CMakeFiles/h5fc
diff --git a/hl/c++/src/CMakeLists.txt b/hl/c++/src/CMakeLists.txt
index 1eac9fe..e488656 100644
--- a/hl/c++/src/CMakeLists.txt
+++ b/hl/c++/src/CMakeLists.txt
@@ -120,7 +120,11 @@ install (
)
if (NOT WIN32 AND NOT MINGW)
- set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER})
+ if (HDF5_ENABLE_PARALLEL AND MPI_CXX_FOUND)
+ set (_PKG_CONFIG_COMPILER ${MPI_CXX_COMPILER})
+ else ()
+ set (_PKG_CONFIG_COMPILER ${CMAKE_CXX_COMPILER})
+ endif ()
configure_file (
${HDF_RESOURCES_DIR}/libh5cc.in
${HDF5_BINARY_DIR}/CMakeFiles/h5hlc++
diff --git a/hl/fortran/src/CMakeLists.txt b/hl/fortran/src/CMakeLists.txt
index b309e92..c889736 100644
--- a/hl/fortran/src/CMakeLists.txt
+++ b/hl/fortran/src/CMakeLists.txt
@@ -260,7 +260,11 @@ install (
)
if (NOT WIN32 AND NOT MINGW)
- set (_PKG_CONFIG_COMPILER ${CMAKE_Fortran_COMPILER})
+ if (HDF5_ENABLE_PARALLEL AND MPI_Fortran_FOUND)
+ set (_PKG_CONFIG_COMPILER ${MPI_Fortran_COMPILER})
+ else ()
+ set (_PKG_CONFIG_COMPILER ${CMAKE_Fortran_COMPILER})
+ endif ()
configure_file (
${HDF_RESOURCES_DIR}/libh5cc.in
${HDF5_BINARY_DIR}/CMakeFiles/h5hlfc
diff --git a/hl/src/CMakeLists.txt b/hl/src/CMakeLists.txt
index cc5aca5..d07f354 100644
--- a/hl/src/CMakeLists.txt
+++ b/hl/src/CMakeLists.txt
@@ -148,7 +148,11 @@ install (
)
if (NOT WIN32 AND NOT MINGW)
- set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER})
+ if (HDF5_ENABLE_PARALLEL AND MPI_C_FOUND)
+ set (_PKG_CONFIG_COMPILER ${MPI_C_COMPILER})
+ else ()
+ set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER})
+ endif ()
configure_file (
${HDF_RESOURCES_DIR}/libh5cc.in
${HDF5_BINARY_DIR}/CMakeFiles/h5hlcc
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 217c55d..521d3fd 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1129,7 +1129,11 @@ install (
)
if (NOT WIN32)
- set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER})
+ if (HDF5_ENABLE_PARALLEL AND MPI_C_FOUND)
+ set (_PKG_CONFIG_COMPILER ${MPI_C_COMPILER})
+ else ()
+ set (_PKG_CONFIG_COMPILER ${CMAKE_C_COMPILER})
+ endif ()
configure_file (
${HDF_RESOURCES_DIR}/libh5cc.in
${HDF5_BINARY_DIR}/CMakeFiles/h5cc
@@ -1141,4 +1145,18 @@ if (NOT WIN32)
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
COMPONENT libraries
)
+ if (HDF5_ENABLE_PARALLEL AND MPI_C_FOUND)
+ #legacy requires a different name
+ configure_file (
+ ${HDF_RESOURCES_DIR}/libh5cc.in
+ ${HDF5_BINARY_DIR}/CMakeFiles/h5pcc
+ @ONLY
+ )
+ install (
+ FILES ${HDF5_BINARY_DIR}/CMakeFiles/h5pcc
+ DESTINATION ${HDF5_INSTALL_BIN_DIR}
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+ COMPONENT libraries
+ )
+ endif ()
endif ()

View file

@ -6,10 +6,8 @@
import shutil import shutil
import sys import sys
from spack.util.environment import is_system_path
class Hdf5(CMakePackage):
class Hdf5(AutotoolsPackage):
"""HDF5 is a data model, library, and file format for storing and managing """HDF5 is a data model, library, and file format for storing and managing
data. It supports an unlimited variety of datatypes, and is designed for data. It supports an unlimited variety of datatypes, and is designed for
flexible and efficient I/O and for high volume and complex data. flexible and efficient I/O and for high volume and complex data.
@ -19,20 +17,18 @@ class Hdf5(AutotoolsPackage):
url = "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.7/src/hdf5-1.10.7.tar.gz" url = "https://support.hdfgroup.org/ftp/HDF5/releases/hdf5-1.10/hdf5-1.10.7/src/hdf5-1.10.7.tar.gz"
list_url = "https://support.hdfgroup.org/ftp/HDF5/releases" list_url = "https://support.hdfgroup.org/ftp/HDF5/releases"
list_depth = 3 list_depth = 3
git = "https://bitbucket.hdfgroup.org/scm/hdffv/hdf5.git" git = "https://github.com/HDFGroup/hdf5.git"
maintainers = ['lrknox'] maintainers = ['lrknox', 'brtnfld', 'byrnHDF', 'ChristopherHogan', 'epourmal',
'gheber', 'hyoklee', 'lkurz', 'soumagne']
test_requires_compiler = True test_requires_compiler = True
# We rely on the *.la files to be removed and, therefore, do not try to make
# sure that they are correct. The following is a precaution against someone
# blindly changing the value to True, either here or in the baseclass.
install_libtool_archives = False
version('develop', branch='develop') version('develop', branch='develop')
version('develop-1.12', branch='hdf5_1_12')
version('develop-1.10', branch='hdf5_1_10')
version('develop-1.8', branch='hdf5_1_8')
version('1.12.0', sha256='a62dcb276658cb78e6795dd29bf926ed7a9bc4edf6e77025cd2c689a8f97c17a') version('1.12.0', sha256='a62dcb276658cb78e6795dd29bf926ed7a9bc4edf6e77025cd2c689a8f97c17a')
# HDF5 1.12 broke API compatibility, so we currently prefer the latest # HDF5 1.12 broke API compatibility, so we currently prefer the latest
# 1.10 release. packages that want later versions of HDF5 should specify, # 1.10 release. packages that want later versions of HDF5 should specify,
# e.g., depends_on("hdf5@1.12:") to get 1.12 or higher. # e.g., depends_on("hdf5@1.12:") to get 1.12 or higher.
@ -58,8 +54,6 @@ class Hdf5(AutotoolsPackage):
version('1.8.12', sha256='b5cccea850096962b5fd9e96f22c4f47d2379224bb41130d9bc038bb6c37dfcb') version('1.8.12', sha256='b5cccea850096962b5fd9e96f22c4f47d2379224bb41130d9bc038bb6c37dfcb')
version('1.8.10', sha256='4813b79c5fb8701a625b9924b8203bc7154a77f9b826ad4e034144b4056a160a') version('1.8.10', sha256='4813b79c5fb8701a625b9924b8203bc7154a77f9b826ad4e034144b4056a160a')
variant('debug', default=False,
description='Builds a debug version of the library')
variant('shared', default=True, variant('shared', default=True,
description='Builds a shared version of the library') description='Builds a shared version of the library')
@ -69,32 +63,39 @@ class Hdf5(AutotoolsPackage):
variant('java', default=False, description='Enable Java support') variant('java', default=False, description='Enable Java support')
variant('threadsafe', default=False, variant('threadsafe', default=False,
description='Enable thread-safe capabilities') description='Enable thread-safe capabilities')
variant('tools', default=True, description='Enable building tools')
variant('mpi', default=True, description='Enable MPI support') variant('mpi', default=True, description='Enable MPI support')
variant('szip', default=False, description='Enable szip support') variant('szip', default=False, description='Enable szip support')
variant('pic', default=True, variant('pic', default=True,
description='Produce position-independent code (for shared libs)') description='Produce position-independent code (for shared libs)')
# Build HDF5 with API compaitibility. # Build HDF5 with API compatibility.
variant('api', default='none', description='choose api compatibility', values=('none', 'v114', 'v112', 'v110', 'v18', 'v16'), multi=False) variant('api', default='default', description='Choose api compatibility for earlier version', values=('default', 'v114', 'v112', 'v110', 'v18', 'v16'), multi=False)
conflicts('api=v114', when='@1.6:1.12.99', msg='v114 is not compatible with this release') conflicts('api=v114', when='@1.6:1.12.99', msg='v114 is not compatible with this release')
conflicts('api=v112', when='@1.6:1.10.99', msg='v112 is not compatible with this release') conflicts('api=v112', when='@1.6:1.10.99', msg='v112 is not compatible with this release')
conflicts('api=v110', when='@1.6:1.8.99', msg='v110 is not compatible with this release') conflicts('api=v110', when='@1.6:1.8.99', msg='v110 is not compatible with this release')
conflicts('api=v18', when='@1.6:1.6.99', msg='v18 is not compatible with this release') conflicts('api=v18', when='@1.6:1.6.99', msg='v18 is not compatible with this release')
depends_on('autoconf', type='build', when='@develop') depends_on('cmake@3.12:')
depends_on('automake', type='build', when='@develop')
depends_on('libtool', type='build', when='@develop')
depends_on('m4', type='build', when='@develop')
depends_on('mpi', when='+mpi') depends_on('mpi', when='+mpi')
depends_on('java', when='+java') depends_on('java', type=('build', 'run'), when='+java')
# numactl does not currently build on darwin # numactl does not currently build on darwin
if sys.platform != 'darwin': if sys.platform != 'darwin':
depends_on('numactl', when='+mpi+fortran') depends_on('numactl', when='+mpi+fortran')
depends_on('szip', when='+szip') depends_on('szip', when='+szip')
depends_on('zlib@1.1.2:') depends_on('zlib@1.1.2:')
# The Java wrappers and associated libhdf5_java library
# were first available in 1.10
conflicts('+java', when='@:1.9')
# The Java wrappers cannot be built without shared libs.
conflicts('+java', when='~shared')
# Earlier versions of HDF5 will not correctly find szip without the patches
# in the <version>_cmake.patch files
conflicts('+szip', when='@:1.8.19,1.9.0:1.10.5')
# There are several officially unsupported combinations of the features: # There are several officially unsupported combinations of the features:
# 1. Thread safety is not guaranteed via high-level C-API but in some cases # 1. Thread safety is not guaranteed via high-level C-API but in some cases
# it works. # it works.
@ -138,7 +139,7 @@ class Hdf5(AutotoolsPackage):
# Disable MPI C++ interface when C++ is disabled, otherwise downstream # Disable MPI C++ interface when C++ is disabled, otherwise downstream
# libraries fail to link; see https://github.com/spack/spack/issues/12586 # libraries fail to link; see https://github.com/spack/spack/issues/12586
patch('h5public-skip-mpicxx.patch', when='@:1.8.21,1.10.0:1.10.5+mpi~cxx', patch('h5public-skip-mpicxx.patch', when='@1.8.10:1.8.21,1.10.0:1.10.5+mpi~cxx',
sha256='b61e2f058964ad85be6ee5ecea10080bf79e73f83ff88d1fa4b602d00209da9c') sha256='b61e2f058964ad85be6ee5ecea10080bf79e73f83ff88d1fa4b602d00209da9c')
# Fixes BOZ literal constant error when compiled with GCC 10. # Fixes BOZ literal constant error when compiled with GCC 10.
@ -151,6 +152,15 @@ class Hdf5(AutotoolsPackage):
# based on Libtool 2.4.6. # based on Libtool 2.4.6.
patch('nag.mpi.libtool.patch', when='@1.8.18:%nag+fortran+mpi+shared') patch('nag.mpi.libtool.patch', when='@1.8.18:%nag+fortran+mpi+shared')
patch('1.12.0_cmake.patch', when='@1.12.0',
sha256='e5b3bc2eecb693e88ce084dfceb35fdce68a0749945173c4bff7cf29fa81de4c')
patch('1.10.7_cmake.patch', when='@1.10.6:1.10.7',
sha256='dd9491bbe833b13929cb14b52137f7f44a539b4bfc89fc31e6e50a36e3e1b171')
patch('1.8.22_cmake.patch', when='@1.8.22',
sha256='2ca847df0f4aa24e8fe9aa7f156d48aae505a0226ca8df5d3e9b21d8087035bd')
patch('1.8.21_cmake.patch', when='@1.8.21',
sha256='b6a39255b2cc4fdf5767969a3f0cf83fc278b1750221b55ad48352a6ee3e4071')
# The argument 'buf_size' of the C function 'h5fget_file_image_c' is # The argument 'buf_size' of the C function 'h5fget_file_image_c' is
# declared as intent(in) though it is modified by the invocation. As a # declared as intent(in) though it is modified by the invocation. As a
# result, aggressive compilers such as Fujitsu's may do a wrong # result, aggressive compilers such as Fujitsu's may do a wrong
@ -190,11 +200,6 @@ def flag_handler(self, name, flags):
return (None, None, flags) return (None, None, flags)
@when('@develop')
def autoreconf(self, spec, prefix):
autogen = Executable('./autogen.sh')
autogen()
@property @property
def libs(self): def libs(self):
"""HDF5 can be queried for the following parameters: """HDF5 can be queried for the following parameters:
@ -202,6 +207,7 @@ def libs(self):
- "hl": high-level interface - "hl": high-level interface
- "cxx": C++ APIs - "cxx": C++ APIs
- "fortran": Fortran APIs - "fortran": Fortran APIs
- "java": Java APIs
:return: list of matching libraries :return: list of matching libraries
""" """
@ -213,11 +219,12 @@ def libs(self):
# to the libraries needed # to the libraries needed
query2libraries = { query2libraries = {
tuple(): ['libhdf5'], tuple(): ['libhdf5'],
('cxx', 'fortran', 'hl'): [ ('cxx', 'fortran', 'hl', 'java'): [
'libhdf5hl_fortran', 'libhdf5hl_fortran',
'libhdf5_hl_cpp', 'libhdf5_hl_cpp',
'libhdf5_hl', 'libhdf5_hl',
'libhdf5_fortran', 'libhdf5_fortran',
'libhdf5_java',
'libhdf5', 'libhdf5',
], ],
('cxx', 'hl'): [ ('cxx', 'hl'): [
@ -247,6 +254,10 @@ def libs(self):
('fortran',): [ ('fortran',): [
'libhdf5_fortran', 'libhdf5_fortran',
'libhdf5', 'libhdf5',
],
('java',): [
'libhdf5_java',
'libhdf5',
] ]
} }
@ -258,104 +269,82 @@ def libs(self):
libraries, root=self.prefix, shared=shared, recursive=True libraries, root=self.prefix, shared=shared, recursive=True
) )
@run_before('configure') @run_before('cmake')
def fortran_check(self): def fortran_check(self):
if '+fortran' in self.spec and not self.compiler.fc: if '+fortran' in self.spec and not self.compiler.fc:
msg = 'cannot build a Fortran variant without a Fortran compiler' msg = 'cannot build a Fortran variant without a Fortran compiler'
raise RuntimeError(msg) raise RuntimeError(msg)
def with_or_without_szip(self, activated): def cmake_args(self):
return '--{0}-szlib'.format('with' if activated else 'without') spec = self.spec
def configure_args(self):
# Always enable this option. This does not actually enable any # Always enable this option. This does not actually enable any
# features: it only *allows* the user to specify certain # features: it only *allows* the user to specify certain
# combinations of other arguments. Enabling it just skips a # combinations of other arguments. Enabling it just skips a
# sanity check in configure, so this doesn't merit a variant. # sanity check in configure, so this doesn't merit a variant.
extra_args = ['--enable-unsupported', args = [
'--enable-symbols=yes'] self.define('ALLOW_UNSUPPORTED', True),
self.define('HDF5_ENABLE_Z_LIB_SUPPORT', True),
self.define_from_variant('HDF5_ENABLE_SZIP_SUPPORT', 'szip'),
self.define_from_variant('BUILD_SHARED_LIBS', 'shared'),
self.define_from_variant('HDF5_ENABLE_PARALLEL', 'mpi'),
self.define_from_variant('HDF5_ENABLE_THREADSAFE', 'threadsafe'),
self.define_from_variant('HDF5_BUILD_HL_LIB', 'hl'),
self.define_from_variant('HDF5_BUILD_CPP_LIB', 'cxx'),
self.define_from_variant('HDF5_BUILD_FORTRAN', 'fortran'),
self.define_from_variant('HDF5_BUILD_JAVA', 'java'),
self.define_from_variant('HDF5_BUILD_TOOLS', 'tools')
]
# Do not specify the prefix of zlib if it is in a system directory if '+szip' in spec:
# (see https://github.com/spack/spack/pull/21900). args.append(self.define('HDF5_ENABLE_SZIP_ENCODING', True))
zlib_prefix = self.spec['zlib'].prefix
extra_args.append('--with-zlib={0}'.format(
'yes' if is_system_path(zlib_prefix) else zlib_prefix))
extra_args += self.enable_or_disable('threadsafe') api = spec.variants['api'].value
extra_args += self.enable_or_disable('cxx') if api != 'default':
extra_args += self.enable_or_disable('hl') args.append(self.define('DEFAULT_API_VERSION', api))
extra_args += self.enable_or_disable('fortran')
extra_args += self.enable_or_disable('java')
extra_args += self.with_or_without('szip')
api = self.spec.variants['api'].value # The variable CMAKE_POSITION_INDEPENDENT_CODE is set to True by default in
if api != 'none': # HDF5 Cmake code; this should insure that it is off if '~pic' in spec. The
extra_args.append('--with-default-api-version=' + api) # flags that were previously set for '+pic' in the Autotools version are kept
# in case CMake doesn't set them as expected. Both the 'pic' variant and the
# CMAKE_POSITION_INDEPENDENT_CODE variable are True by default, but '~pic'
# should disable them both.
args.append(self.define_from_variant('CMAKE_POSITION_INDEPENDENT_CODE', 'pic'))
if '+pic' in spec:
# use global spack compiler flags
_flags = self.compiler.cc_pic_flag
_flags += " " + ' '.join(spec.compiler_flags['cflags'])
args.append('CFLAGS={0}'.format(_flags))
if self.spec.satisfies('@1.10:'): if '+cxx' in spec:
if '+debug' in self.spec: _flags = self.compiler.cxx_pic_flag
extra_args.append('--enable-build-mode=debug') _flags += " " + ' '.join(spec.compiler_flags['cxxflags'])
else: args.append('CXXFLAGS={0}'.format(_flags))
extra_args.append('--enable-build-mode=production')
else:
if '+debug' in self.spec:
extra_args.append('--enable-debug=all')
else:
extra_args.append('--enable-production')
# '--enable-fortran2003' no longer exists as of version 1.10.0 if '+fortran' in spec:
if '+fortran' in self.spec: _flags = self.compiler.fc_pic_flag
extra_args.append('--enable-fortran2003') _flags += " " + ' '.join(spec.compiler_flags['fflags'])
else: args.append('FCFLAGS={0}'.format(_flags))
extra_args.append('--disable-fortran2003')
if '+shared' in self.spec:
extra_args.append('--enable-shared')
else:
extra_args.append('--disable-shared')
extra_args.append('--enable-static-exec')
# Fujitsu Compiler does not add Fortran runtime in rpath. # Fujitsu Compiler does not add Fortran runtime in rpath.
if '+fortran %fj' in self.spec: if '+fortran %fj' in spec:
extra_args.append('LDFLAGS=-lfj90i -lfj90f -lfjsrcinfo -lelf') args.append('LDFLAGS=-lfj90i -lfj90f -lfjsrcinfo -lelf')
if '+mpi' in self.spec: if '+mpi' in spec:
# The HDF5 configure script warns if cxx and mpi are enabled # The HDF5 configure script warns if cxx and mpi are enabled
# together. There doesn't seem to be a real reason for this, except # together. There doesn't seem to be a real reason for this, except
# that parts of the MPI interface are not accessible via the C++ # that parts of the MPI interface are not accessible via the C++
# interface. Since they are still accessible via the C interface, # interface. Since they are still accessible via the C interface,
# this is not actually a problem. # this is not actually a problem.
extra_args += ['--enable-parallel', args.append('CC=%s' % self.spec['mpi'].mpicc)
'CC=%s' % self.spec['mpi'].mpicc]
if '+cxx' in self.spec: if '+cxx' in self.spec:
extra_args.append('CXX=%s' % self.spec['mpi'].mpicxx) args.append('CXX=%s' % self.spec['mpi'].mpicxx)
if '+fortran' in self.spec: if '+fortran' in self.spec:
extra_args.append('FC=%s' % self.spec['mpi'].mpifc) args.append('FC=%s' % self.spec['mpi'].mpifc)
return extra_args return args
@run_after('configure')
def patch_postdeps(self):
if '@:1.8.14' in self.spec:
# On Ubuntu14, HDF5 1.8.12 (and maybe other versions)
# mysteriously end up with "-l -l" in the postdeps in the
# libtool script. Patch this by removing the spurious -l's.
filter_file(
r'postdeps="([^"]*)"',
lambda m: 'postdeps="%s"' % ' '.join(
arg for arg in m.group(1).split(' ') if arg != '-l'),
'libtool')
@run_after('configure')
def patch_libtool(self):
"""AOCC support for HDF5"""
if '%aocc' in self.spec:
filter_file(
r'\$wl-soname \$wl\$soname',
r'-fuse-ld=ld -Wl,-soname,\$soname',
'libtool', string=True)
@run_after('install') @run_after('install')
@on_package_attributes(run_tests=True) @on_package_attributes(run_tests=True)