Skip to content

Commit

Permalink
Removed version range handling from find_package calls to support a w…
Browse files Browse the repository at this point in the history
…ider version range
  • Loading branch information
DavidAce committed May 31, 2023
1 parent f17d3fe commit 2442a8c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 14 deletions.
19 changes: 16 additions & 3 deletions cmake/SetupDependencies.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,29 @@ elseif(H5PP_USE_FLOAT128)
endif()



# Start finding the dependencies
if(H5PP_ENABLE_EIGEN3)
find_package(Eigen3 3.3 REQUIRED)
find_package(Eigen3 REQUIRED)
if(EIGEN3_VERSION AND EIGEN3_VERSION VERSION_LESS 3.3)
message(FATAL_ERROR "H5PP_ENABLE_EIGEN3: Found version ${EIGEN3_VERSION} < 3.3 required by h5pp")
endif()
target_link_libraries(deps INTERFACE Eigen3::Eigen)
target_compile_definitions(deps INTERFACE H5PP_USE_EIGEN3)
endif()
if(H5PP_ENABLE_FMT)
find_package(fmt 6.1.2 REQUIRED)
find_package(fmt REQUIRED)
if(FMT_VERSION AND FMT_VERSION VERSION_LESS 6.1.2)
message(FATAL_ERROR "H5PP_ENABLE_FMT: Found version ${FMT_VERSION} < 6.1.2 required by h5pp")
endif()
target_link_libraries(deps INTERFACE fmt::fmt)
target_compile_definitions(deps INTERFACE H5PP_USE_FMT)
endif()
if(H5PP_ENABLE_SPDLOG)
find_package(spdlog 1.5.0 REQUIRED)
find_package(spdlog REQUIRED)
if(SPDLOG_VERSION AND SPDLOG_VERSION VERSION_LESS 1.5.0)
message(FATAL_ERROR "H5PP_ENABLE_SPDLOG: Found version ${SPDLOG_VERSION} < 1.5.0 required by h5pp")
endif()
target_link_libraries(deps INTERFACE spdlog::spdlog)
target_compile_definitions(deps INTERFACE H5PP_USE_SPDLOG)
endif()
Expand All @@ -59,6 +69,9 @@ endif()
find_package(ZLIB QUIET)
find_package(SZIP QUIET)
find_package(HDF5 COMPONENTS C HL REQUIRED)
if(HDF5_VERSION AND HDF5_VERSION VERSION_LESS 1.8)
message(FATAL_ERROR "Found version ${HDF5_VERSION} < 1.8 required by h5pp")
endif()
include(cmake/HDF5TargetUtils.cmake)
h5pp_get_modern_hdf5_target_name()
target_link_libraries(deps INTERFACE HDF5::HDF5)
Expand Down
16 changes: 5 additions & 11 deletions cmake/h5ppDeps.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ if(std::filesystem IN_LIST H5PP_LINK_LIBRARIES)
endif()

if (H5PP_ENABLE_EIGEN3 OR Eigen3::Eigen IN_LIST H5PP_LINK_LIBRARIES)
find_dependency(Eigen3 3.3 REQUIRED)
find_dependency(Eigen3 REQUIRED)
if(TARGET Eigen3 AND NOT TARGET Eigen3::Eigen)
add_library(Eigen3::Eigen ALIAS Eigen3)
endif()
Expand All @@ -32,7 +32,7 @@ if (H5PP_ENABLE_EIGEN3 OR Eigen3::Eigen IN_LIST H5PP_LINK_LIBRARIES)
endif()

if (H5PP_ENABLE_FMT OR fmt::fmt IN_LIST H5PP_LINK_LIBRARIES)
find_dependency(fmt 6.1.2 REQUIRED)
find_dependency(fmt REQUIRED)
if(TARGET fmt AND NOT TARGET fmt::fmt)
add_library(fmt::fmt ALIAS fmt)
endif()
Expand All @@ -43,7 +43,7 @@ if (H5PP_ENABLE_FMT OR fmt::fmt IN_LIST H5PP_LINK_LIBRARIES)
endif()

if (H5PP_ENABLE_SPDLOG OR spdlog::spdlog IN_LIST H5PP_LINK_LIBRARIES)
find_dependency(spdlog 1.5.0 REQUIRED)
find_dependency(spdlog REQUIRED)
if(TARGET spdlog AND NOT TARGET spdlog::spdlog)
add_library(spdlog::spdlog ALIAS spdlog)
endif()
Expand All @@ -54,14 +54,8 @@ if (H5PP_ENABLE_SPDLOG OR spdlog::spdlog IN_LIST H5PP_LINK_LIBRARIES)
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.14.1 COMPONENTS C HL REQUIRED)
else()
# 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()

# Also, we don't impose any version requirement here: h5pp is compatible with 1.8 to 1.14.
find_dependency(HDF5 COMPONENTS C HL REQUIRED)

if(HDF5_FOUND AND HDF5::HDF5 IN_LIST H5PP_LINK_LIBRARIES)
include(${CMAKE_CURRENT_LIST_DIR}/HDF5TargetUtils.cmake)
Expand Down

0 comments on commit 2442a8c

Please sign in to comment.