aboutsummaryrefslogtreecommitdiff
path: root/vcpkg/ports/flann
diff options
context:
space:
mode:
Diffstat (limited to 'vcpkg/ports/flann')
-rw-r--r--vcpkg/ports/flann/fix-dep-lz4.patch72
-rw-r--r--vcpkg/ports/flann/fix-dependency-hdf5.patch56
-rw-r--r--vcpkg/ports/flann/portfile.cmake47
-rw-r--r--vcpkg/ports/flann/vcpkg.json32
4 files changed, 207 insertions, 0 deletions
diff --git a/vcpkg/ports/flann/fix-dep-lz4.patch b/vcpkg/ports/flann/fix-dep-lz4.patch
new file mode 100644
index 0000000..fb951ed
--- /dev/null
+++ b/vcpkg/ports/flann/fix-dep-lz4.patch
@@ -0,0 +1,72 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 5fd73ba..ff357f2 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -155,8 +155,8 @@ if (BUILD_CUDA_LIB)
+ endif(CUDA_FOUND)
+ endif(BUILD_CUDA_LIB)
+
+-find_package(PkgConfig REQUIRED)
+-pkg_check_modules(LZ4 REQUIRED liblz4)
++find_package(lz4 CONFIG REQUIRED)
++set(LZ4_LINK_LIBRARIES lz4::lz4)
+ include_directories(${LZ4_INCLUDE_DIRS})
+
+ #set the C/C++ include path to the "include" directory
+diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in
+index 6b95a71..d78c74a 100644
+--- a/cmake/Config.cmake.in
++++ b/cmake/Config.cmake.in
+@@ -1,5 +1,10 @@
+ @PACKAGE_INIT@
+
++include(CMakeFindDependencyMacro)
++find_dependency(lz4 CONFIG)
++if(@WITH_HDF5@)
++ find_dependency(HDF5 CONFIG)
++endif()
+ include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake")
+ check_required_components("flann")
+
+diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt
+index 7603abc..cb31f6f 100644
+--- a/src/cpp/CMakeLists.txt
++++ b/src/cpp/CMakeLists.txt
+@@ -24,7 +24,9 @@ target_link_libraries(flann_cpp ${LZ4_LINK_LIBRARIES})
+ # export lz4 headers, so that MSVC to creates flann_cpp.lib
+ set_target_properties(flann_cpp PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS YES)
+
+-set(flann_install_targets flann_cpp)
++if (NOT CMAKE_BUILD_STATIC_LIBS)
++ set(flann_install_targets flann_cpp)
++endif()
+
+ if (BUILD_CUDA_LIB)
+ SET(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-DFLANN_USE_CUDA;-Xcudafe \"--diag_suppress=partial_override\" ;-gencode=arch=compute_52,code=\"sm_52,compute_52\";-gencode=arch=compute_61,code=\"sm_61,compute_61\"")
+@@ -45,9 +47,12 @@ if (BUILD_CUDA_LIB)
+ endif()
+
+ cuda_add_library(flann_cuda SHARED ${CU_SOURCES})
+- list(APPEND flann_install_targets flann_cuda)
+- set_property(TARGET flann_cpp PROPERTY COMPILE_DEFINITIONS FLANN_USE_CUDA)
++ if (NOT CMAKE_BUILD_STATIC_LIBS)
++ list(APPEND flann_install_targets flann_cuda)
++ set_property(TARGET flann_cpp PROPERTY COMPILE_DEFINITIONS FLANN_USE_CUDA)
++ endif()
+ set_property(TARGET flann_cpp_s PROPERTY COMPILE_DEFINITIONS FLANN_STATIC FLANN_USE_CUDA)
++
+ else()
+ set_property(TARGET flann_cpp_s PROPERTY COMPILE_DEFINITIONS FLANN_STATIC)
+ endif()
+@@ -94,8 +99,9 @@ if (BUILD_C_BINDINGS)
+
+ add_library(flann SHARED ${C_SOURCES})
+ target_link_libraries(flann ${LZ4_LINK_LIBRARIES})
+- list(APPEND flann_install_targets flann)
+-
++ if (NOT CMAKE_BUILD_STATIC_LIBS)
++ list(APPEND flann_install_targets flann)
++ endif()
+ if(MINGW AND OPENMP_FOUND)
+ target_link_libraries(flann gomp)
+ endif()
diff --git a/vcpkg/ports/flann/fix-dependency-hdf5.patch b/vcpkg/ports/flann/fix-dependency-hdf5.patch
new file mode 100644
index 0000000..1d5e6ee
--- /dev/null
+++ b/vcpkg/ports/flann/fix-dependency-hdf5.patch
@@ -0,0 +1,56 @@
+diff --git a/CMakeLists.txt b/CMakeLists.txt
+index 9f1dbcb74..5587c896e 100644
+--- a/CMakeLists.txt
++++ b/CMakeLists.txt
+@@ -77,11 +77,19 @@ if (NOT PYTHON_EXECUTABLE)
+ endif()
+ endif()
+
+-find_hdf5()
++if (WITH_HDF5)
++find_package(HDF5 CONFIG REQUIRED)
+ if (NOT HDF5_FOUND)
+- message(WARNING "hdf5 library not found, some tests will not be run")
++ 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")
++ set(CMAKE_EXTERNAL_DEPS "find_dependency(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/vcpkg/ports/flann/portfile.cmake b/vcpkg/ports/flann/portfile.cmake
new file mode 100644
index 0000000..ad84dc0
--- /dev/null
+++ b/vcpkg/ports/flann/portfile.cmake
@@ -0,0 +1,47 @@
+#the port uses inside the CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS, which is discouraged by vcpkg.
+
+vcpkg_from_github(
+ OUT_SOURCE_PATH SOURCE_PATH
+ REPO flann-lib/flann
+ REF f9caaf609d8b8cb2b7104a85cf59eb92c275a25d
+ SHA512 14cd7d3249109ce66c43258f8b9d158efa3b57f654708e76751290eba25e2cb7fc8044a1d882c6b24d0cda1a8b206709acdb5338086ca1f2d60fef35f0fa85be
+ HEAD_REF master
+ PATCHES
+ fix-dependency-hdf5.patch
+ fix-dep-lz4.patch
+)
+
+vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
+ FEATURES
+ hdf5 WITH_HDF5
+ cuda BUILD_CUDA_LIB
+)
+if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
+ set(LINK_STATIC ON)
+else()
+ set(LINK_STATIC OFF)
+endif()
+
+vcpkg_cmake_configure(
+ SOURCE_PATH ${SOURCE_PATH}
+ DISABLE_PARALLEL_CONFIGURE
+ OPTIONS ${FEATURE_OPTIONS}
+ -DBUILD_EXAMPLES=OFF
+ -DBUILD_TESTS=OFF
+ -DBUILD_DOC=OFF
+ -DBUILD_PYTHON_BINDINGS=OFF
+ -DBUILD_MATLAB_BINDINGS=OFF
+ -DUSE_OPENMP=OFF
+ -DCMAKE_BUILD_STATIC_LIBS=${LINK_STATIC}
+ OPTIONS_DEBUG
+ -DCMAKE_DEBUG_POSTFIX=d
+)
+
+vcpkg_cmake_install()
+vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/${PORT})
+
+file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
+# Handle copyright
+vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/COPYING")
+
+vcpkg_fixup_pkgconfig()
diff --git a/vcpkg/ports/flann/vcpkg.json b/vcpkg/ports/flann/vcpkg.json
new file mode 100644
index 0000000..f5bcef3
--- /dev/null
+++ b/vcpkg/ports/flann/vcpkg.json
@@ -0,0 +1,32 @@
+{
+ "name": "flann",
+ "version-date": "2022-10-28",
+ "description": "Fast Library for Approximate Nearest Neighbors",
+ "homepage": "https://github.com/mariusmuja/flann",
+ "license": "BSD-3-Clause",
+ "dependencies": [
+ "lz4",
+ {
+ "name": "vcpkg-cmake",
+ "host": true
+ },
+ {
+ "name": "vcpkg-cmake-config",
+ "host": true
+ }
+ ],
+ "features": {
+ "cuda": {
+ "description": "CUDA support for FLANN",
+ "dependencies": [
+ "cuda"
+ ]
+ },
+ "hdf5": {
+ "description": "Build with hdf5",
+ "dependencies": [
+ "hdf5"
+ ]
+ }
+ }
+}