vcpkg/ports/ismrmrd/optional_hdf5_dependency.patch
Phil Christensen 10014faad7
[ismrmrd] make optional hdf5 dependency explicit (#5757)
* [ismrmrd] make optional hdf5 dependency explicit

This port will behave differently in the CI build depending on if hdf5 was installed
before it.  Make the hdf5 dependency explicit so it will behave consistently.
2019-03-20 23:39:56 -07:00

78 lines
3.2 KiB
Diff

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 456d4f4..3c235f2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,7 @@ set (ISMRMRD_CMAKE_DIR ${PROJECT_SOURCE_DIR}/cmake CACHE PATH
# command line options
option(USE_SYSTEM_PUGIXML "Use pugixml installed on the system" OFF)
+option(USE_HDF5_DATASET_SUPPORT "Use HDF5 library for dataset support" OFF)
# and include it to the search list
list(APPEND CMAKE_MODULE_PATH ${ISMRMRD_CMAKE_DIR})
@@ -91,18 +92,23 @@ endif()
set(ISMRMRD_VERSION_STRING ${ISMRMRD_VERSION_MAJOR}.${ISMRMRD_VERSION_MINOR}.${ISMRMRD_VERSION_PATCH})
set(ISMRMRD_SOVERSION ${ISMRMRD_VERSION_MAJOR}.${ISMRMRD_VERSION_MINOR})
-# Find HDF5 for dataset support
-find_package(HDF5 1.8 COMPONENTS C)
-
-if (HDF5_FOUND)
- set (ISMRMRD_DATASET_SUPPORT true)
- set (ISMRMRD_DATASET_SOURCES libsrc/dataset.c libsrc/dataset.cpp)
- set (ISMRMRD_DATASET_INCLUDE_DIR ${HDF5_C_INCLUDE_DIR})
- set (ISMRMRD_DATASET_LIBRARIES ${HDF5_LIBRARIES})
-else (HDF5_FOUND)
+if (USE_HDF5_DATASET_SUPPORT)
+ # Find HDF5 for dataset support
+ find_package(HDF5 1.8 COMPONENTS C)
+
+ if (HDF5_FOUND)
+ set (ISMRMRD_DATASET_SUPPORT true)
+ set (ISMRMRD_DATASET_SOURCES libsrc/dataset.c libsrc/dataset.cpp)
+ set (ISMRMRD_DATASET_INCLUDE_DIR ${HDF5_C_INCLUDE_DIR})
+ set (ISMRMRD_DATASET_LIBRARIES ${HDF5_LIBRARIES})
+ elseif (USE_HDF5_DATASET_SUPPORT)
+ set (ISMRMRD_DATASET_SUPPORT false)
+ # Dataset and file support was explicitly requested, force failure rather than succeed without support.
+ message (FATAL_ERROR "HDF5 not found. Dataset and file support unavailable!")
+ endif (HDF5_FOUND)
+else (USE_HDF5_DATASET_SUPPORT)
set (ISMRMRD_DATASET_SUPPORT false)
- message (WARNING "HDF5 not found. Dataset and file support unavailable!")
-endif (HDF5_FOUND)
+endif (USE_HDF5_DATASET_SUPPORT)
# Generate the version.h header file
find_package(Git)
@@ -127,7 +133,7 @@ install(FILES ${CMAKE_BINARY_DIR}/include/ismrmrd/version.h DESTINATION include/
# --- Main Library (begin) ----
# in windows, install the HDF5 dependencies
-if (HDF5_FOUND AND WIN32 AND ISMRMRD_INSTALL_DEPENDENCIES)
+if (USE_HDF5_DATASET_SUPPORT AND WIN32 AND ISMRMRD_INSTALL_DEPENDENCIES)
if(DEFINED ENV{HDF5_ROOT})
set(HDF5_BIN_DIR $ENV{HDF5_ROOT}/bin)
else (DEFINED ENV{HDF5_ROOT})
@@ -135,7 +141,7 @@ if (HDF5_FOUND AND WIN32 AND ISMRMRD_INSTALL_DEPENDENCIES)
endif (DEFINED ENV{HDF5_ROOT})
message("Install hdf5 libraries from ${HDF5_BIN_DIR} ")
install( DIRECTORY ${HDF5_BIN_DIR} DESTINATION bin/.. FILES_MATCHING PATTERN "*.dll" )
-endif (HDF5_FOUND AND WIN32 AND ISMRMRD_INSTALL_DEPENDENCIES)
+endif (USE_HDF5_DATASET_SUPPORT AND WIN32 AND ISMRMRD_INSTALL_DEPENDENCIES)
# include directories for main library
set(ISMRMRD_TARGET_INCLUDE_DIRS
@@ -199,9 +205,9 @@ install(FILES cmake/FindIsmrmrd.cmake cmake/FindFFTW3.cmake DESTINATION share/is
add_subdirectory(doc)
add_subdirectory(utilities)
-if (HDF5_FOUND)
+if (USE_HDF5_DATASET_SUPPORT)
add_subdirectory(examples/c)
-endif (HDF5_FOUND)
+endif (USE_HDF5_DATASET_SUPPORT)
# TODO: make this work on Windows
if (NOT WIN32)