Skip to content

Commit f49d93e

Browse files
[CMake] fix HDF5 version number in STIRConfig.cmake
We now only require version major.minor for HDF5, as HDF5_VERSION could otherwise contain extra patch info, causing problems with find_package(STIR). Fixes #1557
1 parent 19bfec5 commit f49d93e

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -290,6 +290,8 @@ endforeach()
290290
set(STIR_REGISTRIES ${INSTALLED_STIR_REGISTRIES})
291291

292292
# New create STIRConfig.cmake
293+
# First strip patch info from HDF5_VERSION, as on some systems it might be set as x.y.z-something, which causes problems for find_package.
294+
string(REGEX MATCH "^([0-9]+)\\.([0-9]+)" HDF5_VERSION_FOR_CONFIG "${HDF5_VERSION}")
293295
CONFIGURE_PACKAGE_CONFIG_FILE(
294296
src/cmake/STIRConfig.cmake.in
295297
"${CMAKE_BINARY_DIR}/STIRConfig.cmake"

src/cmake/STIRConfig.cmake.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ if (@HDF5_FOUND@)
9999
# We try to work-around this by first looking for both C and CXX, and then only for CXX.
100100
# Note that this only solves the problem if in the "client" code,
101101
# find_package(STIR) is called BEFORE find_package(HDF5)
102-
find_package(HDF5 @HDF5_VERSION@ QUIET COMPONENTS C CXX)
102+
find_package(HDF5 @HDF5_VERSION_FOR_CONFIG@ QUIET COMPONENTS C CXX)
103103
endif()
104-
find_package(HDF5 @HDF5_VERSION@ REQUIRED COMPONENTS CXX )
104+
find_package(HDF5 @HDF5_VERSION_FOR_CONFIG@ REQUIRED COMPONENTS CXX )
105105

106106
set(STIR_BUILT_WITH_HDF5 TRUE)
107107
endif()

0 commit comments

Comments
 (0)