flann-1.9.1-system-lz4.patch 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. From: Jochen Sprickerhof <git@jochen.sprickerhof.de>
  2. Date: Sun, 14 Oct 2018 00:25:05 +0200
  3. Subject: Use system version of liblz4
  4. Also make sure that flann_cpp is linked against LZ4.
  5. ---
  6. CMakeLists.txt | 3 +++
  7. cmake/flann.pc.in | 2 +-
  8. examples/CMakeLists.txt | 3 +++
  9. src/cpp/CMakeLists.txt | 8 ++++++--
  10. src/cpp/flann/util/serialization.h | 4 ++--
  11. 5 files changed, 15 insertions(+), 5 deletions(-)
  12. diff --git a/CMakeLists.txt b/CMakeLists.txt
  13. index a01fb7a..995e54e 100644
  14. --- a/CMakeLists.txt
  15. +++ b/CMakeLists.txt
  16. @@ -142,6 +142,9 @@ if (BUILD_CUDA_LIB)
  17. endif(CUDA_FOUND)
  18. endif(BUILD_CUDA_LIB)
  19. +find_package(PkgConfig REQUIRED)
  20. +pkg_check_modules(LZ4 REQUIRED liblz4)
  21. +
  22. #set the C/C++ include path to the "include" directory
  23. include_directories(BEFORE ${PROJECT_SOURCE_DIR}/src/cpp)
  24. diff --git a/cmake/flann.pc.in b/cmake/flann.pc.in
  25. index 82eee5e..07b8d64 100644
  26. --- a/cmake/flann.pc.in
  27. +++ b/cmake/flann.pc.in
  28. @@ -8,6 +8,6 @@ Name: @PROJECT_NAME@
  29. Description: @PKG_DESC@
  30. Version: @FLANN_VERSION@
  31. Requires: @PKG_EXTERNAL_DEPS@
  32. -Libs: -L${libdir} -lflann -lflann_cpp
  33. +Libs: -L${libdir} @LZ4_STATIC_LDFLAGS@ -lflann -lflann_cpp
  34. Cflags: -I${includedir}
  35. diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
  36. index e9fef04..2b2bb9d 100644
  37. --- a/examples/CMakeLists.txt
  38. +++ b/examples/CMakeLists.txt
  39. @@ -3,6 +3,7 @@ add_custom_target(examples ALL)
  40. if (BUILD_C_BINDINGS)
  41. add_executable(flann_example_c flann_example.c)
  42. + target_link_libraries(flann_example_c -Wl,--push-state,--no-as-needed ${LZ4_LIBRARIES} -Wl,--pop-state)
  43. target_link_libraries(flann_example_c flann)
  44. set_target_properties(flann_example_c PROPERTIES COMPILE_FLAGS -std=c99)
  45. @@ -14,6 +15,7 @@ if (HDF5_FOUND)
  46. include_directories(${HDF5_INCLUDE_DIRS})
  47. add_executable(flann_example_cpp flann_example.cpp)
  48. + target_link_libraries(flann_example_cpp -Wl,--push-state,--no-as-needed ${LZ4_LIBRARIES} -Wl,--pop-state)
  49. target_link_libraries(flann_example_cpp ${HDF5_LIBRARIES} flann_cpp)
  50. if (HDF5_IS_PARALLEL)
  51. target_link_libraries(flann_example_cpp ${MPI_LIBRARIES})
  52. @@ -25,6 +27,7 @@ if (HDF5_FOUND)
  53. if (USE_MPI AND HDF5_IS_PARALLEL)
  54. add_executable(flann_example_mpi flann_example_mpi.cpp)
  55. + target_link_libraries(flann_example_mpi -Wl,--push-state,--no-as-needed ${LZ4_LIBRARIES} -Wl,--pop-state)
  56. target_link_libraries(flann_example_mpi flann_cpp ${HDF5_LIBRARIES} ${MPI_LIBRARIES} ${Boost_LIBRARIES})
  57. add_dependencies(examples flann_example_mpi)
  58. diff --git a/src/cpp/CMakeLists.txt b/src/cpp/CMakeLists.txt
  59. index b453b27..5c4f693 100644
  60. --- a/src/cpp/CMakeLists.txt
  61. +++ b/src/cpp/CMakeLists.txt
  62. @@ -4,11 +4,12 @@ add_definitions(-D_FLANN_VERSION=${FLANN_VERSION})
  63. configure_file(${CMAKE_CURRENT_SOURCE_DIR}/flann/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/flann/config.h)
  64. -file(GLOB_RECURSE C_SOURCES flann.cpp lz4.c lz4hc.c)
  65. -file(GLOB_RECURSE CPP_SOURCES flann_cpp.cpp lz4.c lz4hc.c)
  66. +file(GLOB_RECURSE C_SOURCES flann.cpp)
  67. +file(GLOB_RECURSE CPP_SOURCES flann_cpp.cpp)
  68. file(GLOB_RECURSE CU_SOURCES *.cu)
  69. add_library(flann_cpp_s STATIC ${CPP_SOURCES})
  70. +target_link_libraries(flann_cpp_s ${LZ4_LIBRARIES})
  71. if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
  72. set_target_properties(flann_cpp_s PROPERTIES COMPILE_FLAGS -fPIC)
  73. endif()
  74. @@ -42,6 +43,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCC)
  75. endif()
  76. else()
  77. add_library(flann_cpp SHARED ${CPP_SOURCES})
  78. + target_link_libraries(flann_cpp -Wl,--push-state,--no-as-needed ${LZ4_LIBRARIES} -Wl,--pop-state)
  79. if (BUILD_CUDA_LIB)
  80. cuda_add_library(flann_cuda SHARED ${CPP_SOURCES})
  81. set_property(TARGET flann_cpp PROPERTY COMPILE_DEFINITIONS FLANN_USE_CUDA)
  82. @@ -77,6 +79,7 @@ endif()
  83. if (BUILD_C_BINDINGS)
  84. add_library(flann_s STATIC ${C_SOURCES})
  85. + target_link_libraries(flann_cpp -Wl,--push-state,--no-as-needed ${LZ4_LIBRARIES} -Wl,--pop-state)
  86. if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
  87. set_target_properties(flann_s PROPERTIES COMPILE_FLAGS -fPIC)
  88. endif()
  89. @@ -88,6 +91,7 @@ if (BUILD_C_BINDINGS)
  90. target_link_libraries(flann -Wl,-whole-archive flann_s -Wl,-no-whole-archive)
  91. else()
  92. add_library(flann SHARED ${C_SOURCES})
  93. + target_link_libraries(flann_cpp -Wl,--push-state,--no-as-needed ${LZ4_LIBRARIES} -Wl,--pop-state)
  94. if(MINGW AND OPENMP_FOUND)
  95. target_link_libraries(flann gomp)
  96. diff --git a/src/cpp/flann/util/serialization.h b/src/cpp/flann/util/serialization.h
  97. index d731021..cdc2e5e 100644
  98. --- a/src/cpp/flann/util/serialization.h
  99. +++ b/src/cpp/flann/util/serialization.h
  100. @@ -6,8 +6,8 @@
  101. #include <cstdlib>
  102. #include <cstring>
  103. #include <stdio.h>
  104. -#include "flann/ext/lz4.h"
  105. -#include "flann/ext/lz4hc.h"
  106. +#include <lz4.h>
  107. +#include <lz4hc.h>
  108. namespace flann