Skip to content

Commit

Permalink
Simplified CMake installation and moved to using the new CMake depend…
Browse files Browse the repository at this point in the history
…ency provider mechanism

* Deprecated the H5PP_PACKAGE_MANAGER flag
* Deprecated CPM and Fetch modes
* For automatic dependency installation, use the CMake dependency provider mechanism (requires at least CMake 3.24):
   https://cmake.org/cmake/help/latest/guide/using-dependencies/index.html#dependency-providers
 To enable, run
   cmake -DCMAKE_PROJECT_TOP_LEVEL_INCLUDES= ...
 pointing to either
   (1) <h5pp-source>/cmake/conan_dependency_provider/conan_provider.cmake (to let conan install libraries)
   (2) <h5pp-source>/cmake/cmake_dependency_provider/cmake_provider.cmake (to let cmake install libraries)
 Alternatively, use a bundled CMake Presets for similar effect. To list presets, run:
   cmake --list-presets
  • Loading branch information
DavidAce committed May 31, 2023
1 parent a668e21 commit d6080ac
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 33 deletions.
4 changes: 2 additions & 2 deletions cmake/h5ppDeps.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ endif()

# HDF5 must be found either way, so set it to required
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.19)
find_dependency(HDF5 1.8...1.13.2 COMPONENTS C HL REQUIRED)
find_dependency(HDF5 1.8...1.14.1 COMPONENTS C HL REQUIRED)
else()
# h5pp is compatible with 1.8 to 1.13.2, however, builds from source will reject
# h5pp is compatible with 1.8 to 1.14, however, builds from source will reject
# new versions if we set the version to 1.8 (minimum) here.
find_dependency(HDF5 COMPONENTS C HL REQUIRED)
endif()
Expand Down
32 changes: 1 addition & 31 deletions cmake/h5ppVars.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,45 +4,15 @@ option(H5PP_ENABLE_FMT "Enables the {fmt} formatting library"
option(H5PP_ENABLE_SPDLOG "Enables Spdlog for logging h5pp internal info" @H5PP_ENABLE_SPDLOG@)
option(H5PP_ENABLE_MPI "Enables use of MPI (work in progress)" @H5PP_ENABLE_MPI@)

set(H5PP_PACKAGE_MANAGER @H5PP_PACKAGE_MANAGER@ CACHE STRING "Package manager for external dependencies")
set(H5PP_DEPS_INSTALL_DIR @H5PP_DEPS_INSTALL_DIR@ CACHE STRING "Install directory for h5pp dependencies")
list(APPEND CMAKE_PREFIX_PATH @H5PP_DEPS_INSTALL_DIR@ @CMAKE_INSTALL_PREFIX@)
list(APPEND CMAKE_PREFIX_PATH @CMAKE_INSTALL_PREFIX@)
list(REMOVE_DUPLICATES CMAKE_PREFIX_PATH)

if(H5PP_ENABLE_SPDLOG)
set(H5PP_ENABLE_FMT ON CACHE INTERNAL "H5PP_ENABLE_SPDLOG:ON implies H5PP_ENABLE_FMT:ON)" FORCE)
endif()

# Make an "enum" for valid package managers: find cmake fetch find-or-cmake conan
set(H5PP_PACKAGE_MANAGERS_VALID none find fetch cmake cpm find-or-fetch find-or-cmake find-or-cpm conan)
set_property(CACHE H5PP_PACKAGE_MANAGER PROPERTY STRINGS ${H5PP_PACKAGE_MANAGERS_VALID})
if (NOT H5PP_PACKAGE_MANAGER IN_LIST H5PP_PACKAGE_MANAGERS_VALID)
message(FATAL_ERROR "H5PP_PACKAGE_MANAGER must be one of ${H5PP_PACKAGE_MANAGERS_VALID}")
endif ()


if(H5PP_PACKAGE_MANAGER MATCHES "cmake|cpm|fetch")
if(NOT DEFINED HDF5_ROOT)
set(HDF5_ROOT @HDF5_ROOT@)
endif()
if(NOT DEFINED SZIP_ROOT)
set(SZIP_ROOT @SZIP_ROOT@)
endif()
if(NOT DEFINED ZLIB_ROOT)
set(ZLIB_ROOT @ZLIB_ROOT@)
endif()
if(NOT DEFINED ZLIB_LIBRARY)
# This is to make sure we find the same library (static/shared) as found during h5pp and hdf5 installation
set(ZLIB_LIBRARY @ZLIB_LIBRARY@)
set(ZLIB_INCLUDE_DIR @ZLIB_INCLUDE_DIR@)
endif()
endif()


mark_as_advanced(H5PP_ENABLE_EIGEN3)
mark_as_advanced(H5PP_ENABLE_FMT)
mark_as_advanced(H5PP_ENABLE_SPDLOG)
mark_as_advanced(H5PP_ENABLE_MPI)
mark_as_advanced(H5PP_DEPS_INSTALL_DIR)
mark_as_advanced(H5PP_PACKAGE_MANAGER)
mark_as_advanced(H5PP_PACKAGE_MANAGERS_VALID)

0 comments on commit d6080ac

Please sign in to comment.