Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[flann]Upgrade version to 1.9.1 and fix build error. #6931

Merged
merged 4 commits into from
Jun 24, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ports/flann/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: flann
Version: jan2019
Version: 1.9.1
Homepage: https://github.com/mariusmuja/flann
Build-Depends: lz4
Description: Fast Library for Approximate Nearest Neighbors
109 changes: 37 additions & 72 deletions ports/flann/fix_targets.patch → ports/flann/fix-build-error.patch
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f4b94d2..e55195b 100644
index f4b94d2..7ff331a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -146,9 +146,6 @@ if (BUILD_CUDA_LIB)
@@ -146,8 +146,7 @@ if (BUILD_CUDA_LIB)
endif(CUDA_FOUND)
endif(BUILD_CUDA_LIB)

-find_package(PkgConfig REQUIRED)
-pkg_check_modules(LZ4 REQUIRED liblz4)
-
+find_package(lz4 REQUIRED)

#set the C/C++ include path to the "include" directory
include_directories(BEFORE ${PROJECT_SOURCE_DIR}/src/cpp)

diff --git a/cmake/Config.cmake.in b/cmake/Config.cmake.in
index 6b95a71..2c95b6e 100644
index 6b95a71..778aec4 100644
--- a/cmake/Config.cmake.in
+++ b/cmake/Config.cmake.in
@@ -3,3 +3,5 @@
Expand All @@ -22,8 +22,9 @@ index 6b95a71..2c95b6e 100644

+include(CMakeFindDependencyMacro)
+find_dependency(lz4)
\ No newline at end of file
diff --git a/cmake/flann_utils.cmake b/cmake/flann_utils.cmake
index afe4742..0cf8289 100644
index afe4742..8aef8e0 100644
--- a/cmake/flann_utils.cmake
+++ b/cmake/flann_utils.cmake
@@ -1,8 +1,7 @@
Expand All @@ -37,26 +38,8 @@ index afe4742..0cf8289 100644
endmacro(GET_OS_INFO)


@@ -27,7 +26,7 @@ macro(find_hdf5)
set( HDF5_IS_PARALLEL FALSE )
foreach( _dir ${HDF5_INCLUDE_DIRS} )
if( EXISTS "${_dir}/H5pubconf.h" )
- file( STRINGS "${_dir}/H5pubconf.h"
+ file( STRINGS "${_dir}/H5pubconf.h"
HDF5_HAVE_PARALLEL_DEFINE
REGEX "HAVE_PARALLEL 1" )
if( HDF5_HAVE_PARALLEL_DEFINE )
@@ -106,7 +105,7 @@ endmacro(flann_add_pyunit)

macro(flann_download_test_data _name _md5)
string(REPLACE "/" "_" _dataset_name dataset_${_name})
-
+
add_custom_target(${_dataset_name}
COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/bin/download_checkmd5.py http://people.cs.ubc.ca/~mariusm/uploads/FLANN/datasets/${_name} ${TEST_OUTPUT_PATH}/${_name} ${_md5}
VERBATIM)
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index 3f4655a..918b94a 100644
index 3f4655a..bc1d758 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -1,9 +1,10 @@
Expand Down Expand Up @@ -89,19 +72,19 @@ index 3f4655a..918b94a 100644
target_link_libraries(flann_example_mpi flann_cpp ${HDF5_LIBRARIES} ${MPI_LIBRARIES} ${Boost_LIBRARIES})

add_dependencies(examples flann_example_mpi)
@@ -36,7 +37,3 @@ if (HDF5_FOUND)
else()
message("hdf5 library not found, not compiling flann_example.cpp")
endif()
-
-
-
-
diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt
index b30f3da..1535d37 100644
index b421abb..78f9a64 100644
--- a/src/cpp/CMakeLists.txt
+++ b/src/cpp/CMakeLists.txt
@@ -8,12 +8,13 @@ file(GLOB_RECURSE C_SOURCES flann.cpp)
@@ -1,6 +1,6 @@
#include_directories(${CMAKE_SOURCE_DIR}/include algorithms ext util nn .)

-add_definitions(-D_FLANN_VERSION=${FLANN_VERSION})
+add_definitions(-D_FLANN_VERSION=${FLANN_VERSION} -std=c++11)

configure_file(${CMAKE_CURRENT_SOURCE_DIR}/flann/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/flann/config.h)

@@ -8,12 +8,11 @@ file(GLOB_RECURSE C_SOURCES flann.cpp)
file(GLOB_RECURSE CPP_SOURCES flann_cpp.cpp)
file(GLOB_RECURSE CU_SOURCES *.cu)

Expand All @@ -112,16 +95,14 @@ index b30f3da..1535d37 100644
-endif()
-set_property(TARGET flann_cpp_s PROPERTY COMPILE_DEFINITIONS FLANN_STATIC FLANN_USE_CUDA)
+find_package(lz4 REQUIRED)
+
+set(CMAKE_POSITION_INDEPENDENT_CODE ON)
+
+add_library(flann_cpp STATIC ${CPP_SOURCES})
+target_link_libraries(flann_cpp PRIVATE lz4::lz4)
+set_property(TARGET flann_cpp PROPERTY COMPILE_DEFINITIONS FLANN_STATIC)

if (BUILD_CUDA_LIB)
SET(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-DFLANN_USE_CUDA")
@@ -25,48 +26,11 @@ if (BUILD_CUDA_LIB)
@@ -25,45 +24,9 @@ if (BUILD_CUDA_LIB)
else()
set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};" )
endif()
Expand Down Expand Up @@ -169,46 +150,27 @@ index b30f3da..1535d37 100644
+ set_property(TARGET flann_cpp PROPERTY COMPILE_DEFINITIONS FLANN_USE_CUDA)
endif()

-
if (USE_MPI AND HDF5_IS_PARALLEL)
add_executable(flann_mpi_server flann/mpi/flann_mpi_server.cpp)
target_link_libraries(flann_mpi_server flann_cpp ${HDF5_LIBRARIES} ${MPI_LIBRARIES} ${Boost_LIBRARIES})
@@ -80,31 +44,9 @@ endif()

@@ -80,6 +43,7 @@ endif()


if (BUILD_C_BINDINGS)
- add_library(flann_s STATIC ${C_SOURCES})
- target_link_libraries(flann_cpp -Wl,--push-state,--no-as-needed ${LZ4_LIBRARIES} -Wl,--pop-state)
- if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
- set_target_properties(flann_s PROPERTIES COMPILE_FLAGS -fPIC)
- endif()
- set_property(TARGET flann_s PROPERTY COMPILE_DEFINITIONS FLANN_STATIC)
-
- if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCC)
- add_library(flann SHARED "")
- set_target_properties(flann PROPERTIES LINKER_LANGUAGE CXX)
- target_link_libraries(flann -Wl,-whole-archive flann_s -Wl,-no-whole-archive)
- else()
- add_library(flann SHARED ${C_SOURCES})
- target_link_libraries(flann_cpp -Wl,--push-state,--no-as-needed ${LZ4_LIBRARIES} -Wl,--pop-state)
-
- if(MINGW AND OPENMP_FOUND)
- target_link_libraries(flann gomp)
- endif()
- endif()
-
- set_target_properties(flann PROPERTIES
- VERSION ${FLANN_VERSION}
- SOVERSION ${FLANN_SOVERSION}
- DEFINE_SYMBOL FLANN_EXPORTS
- )
+ if (0)
add_library(flann_s STATIC ${C_SOURCES})
target_link_libraries(flann_s -Wl,--push-state,--no-as-needed ${LZ4_LIBRARIES} -Wl,--pop-state)
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
@@ -105,6 +69,10 @@ if (BUILD_C_BINDINGS)
SOVERSION ${FLANN_SOVERSION}
DEFINE_SYMBOL FLANN_EXPORTS
)
+ endif()
+ add_library(flann STATIC ${C_SOURCES})
+ target_link_libraries(flann PRIVATE lz4::lz4)
+ set_property(TARGET flann PROPERTY COMPILE_DEFINITIONS FLANN_STATIC)
endif()

if(WIN32)
@@ -118,9 +60,9 @@ endif(WIN32)
@@ -118,9 +86,9 @@ endif(WIN32)


install (
Expand All @@ -220,7 +182,7 @@ index b30f3da..1535d37 100644
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${FLANN_LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${FLANN_LIB_INSTALL_DIR}
@@ -128,9 +70,9 @@ install (
@@ -128,9 +96,9 @@ install (

if (BUILD_CUDA_LIB)
install (
Expand All @@ -232,12 +194,15 @@ index b30f3da..1535d37 100644
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${FLANN_LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${FLANN_LIB_INSTALL_DIR}
@@ -139,7 +81,7 @@ endif()
@@ -139,9 +107,9 @@ endif()

if (BUILD_C_BINDINGS)
install (
- TARGETS flann flann_s
+ TARGETS flann
EXPORT ${targets_export_name}
INCLUDES DESTINATION include
- INCLUDES DESTINATION include
+ INCLUDES DESTINATION ${FLANN_INCLUDE_INSTALL_DIR}
RUNTIME DESTINATION bin
LIBRARY DESTINATION ${FLANN_LIB_INSTALL_DIR}
ARCHIVE DESTINATION ${FLANN_LIB_INSTALL_DIR}
7 changes: 3 additions & 4 deletions ports/flann/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@ vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO mariusmuja/flann
REF aa40936816f4feaa714d3a09f92a495da017d95c
SHA512 f6f2e75f4ce4bc4bc4cc1feab27fe683b8a5f9f5dcea35de4df5136a683b5dff5e68776008821a16ccf1a52a9807cb053c0062deba4fe121948248acd52864ef
REF 1d04523268c388dabf1c0865d69e1b638c8c7d9d
SHA512 61e322222c2daa0b9677095e5ca231cba7c305ce754ad8e659eee350111c1e04351181c3af04e45ab6e5c9edea49c7b9ec6499bb0dbc080b87af36eb11c6ef7c
HEAD_REF master
PATCHES
fix_targets.patch
PATCHES fix-build-error.patch
)

vcpkg_configure_cmake(
Expand Down