vcpkg/ports/flann/fix-dependency-hdf5.patch
Long Huan bc4b12f517
[flann] Fix missing hdf5 dependency in flann-config.cmake (#22153)
* add find_package hdf5 in flann-config.cmake

* update versions

* Update flann.json

Co-authored-by: Lily Wang <v-lilywang@microsoft.com>
2022-01-20 13:49:58 -08:00

68 lines
2.0 KiB
Diff

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7ff331a..155cabe 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -75,11 +75,18 @@ if (NOT PYTHON_EXECUTABLE)
endif()
endif()
+if (WITH_HDF5)
find_hdf5()
-if (NOT HDF5_FOUND)
- message(WARNING "hdf5 library not found, some tests will not be run")
+if (NOT hdf5_FOUND)
+ message(ERROR "hdf5 library not found")
else()
- include_directories(${HDF5_INCLUDE_DIR})
+ if (TARGET hdf5::hdf5-shared)
+ link_libraries(hdf5::hdf5-shared)
+ elseif (TARGET hdf5::hdf5-static)
+ link_libraries(hdf5::hdf5-static)
+ endif()
+ set(PKG_EXTERNAL_DEPS "${PKG_EXTERNAL_DEPS} hdf5")
+endif()
endif()
if (USE_MPI OR HDF5_IS_PARALLEL)
diff --git a/cmake/flann_utils.cmake b/cmake/flann_utils.cmake
index 8aef8e0..747414f 100644
--- a/cmake/flann_utils.cmake
+++ b/cmake/flann_utils.cmake
@@ -21,21 +21,8 @@ endmacro(DISSECT_VERSION)
# workaround a FindHDF5 bug
macro(find_hdf5)
- find_package(HDF5)
-
- set( HDF5_IS_PARALLEL FALSE )
- foreach( _dir ${HDF5_INCLUDE_DIRS} )
- if( EXISTS "${_dir}/H5pubconf.h" )
- file( STRINGS "${_dir}/H5pubconf.h"
- HDF5_HAVE_PARALLEL_DEFINE
- REGEX "HAVE_PARALLEL 1" )
- if( HDF5_HAVE_PARALLEL_DEFINE )
- set( HDF5_IS_PARALLEL TRUE )
- endif()
- endif()
- endforeach()
- set( HDF5_IS_PARALLEL ${HDF5_IS_PARALLEL} CACHE BOOL
- "HDF5 library compiled with parallel IO support" )
+ find_package(hdf5 CONFIG)
+ set(HDF5_IS_PARALLEL ${HDF5_ENABLE_PARALLEL})
mark_as_advanced( HDF5_IS_PARALLEL )
endmacro(find_hdf5)
diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in
index e8bb3f766..ad33998d9 100644
--- a/cmake/Config.cmake.in
+++ b/cmake/Config.cmake.in
@@ -4,6 +4,7 @@
include(CMakeFindDependencyMacro)
# Find lz4. This will create 'lz4::lz4' target
find_dependency(lz4)
+find_package(hdf5 REQUIRED)
include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
check_required_components("flann")