Skip to content

Commit

Permalink
Merge pull request #399 from jspricke/remove_lz4
Browse files Browse the repository at this point in the history
Use system version of liblz4
  • Loading branch information
mariusmuja authored Jan 22, 2019
2 parents 033b05b + df3fc59 commit b6902aa
Show file tree
Hide file tree
Showing 9 changed files with 15 additions and 2,801 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ if (BUILD_CUDA_LIB)
endif(CUDA_FOUND)
endif(BUILD_CUDA_LIB)

find_package(PkgConfig REQUIRED)
pkg_check_modules(LZ4 REQUIRED liblz4)

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

Expand Down
2 changes: 1 addition & 1 deletion cmake/flann.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ Name: @PROJECT_NAME@
Description: @PKG_DESC@
Version: @FLANN_VERSION@
Requires: @PKG_EXTERNAL_DEPS@
Libs: -L${libdir} -lflann -lflann_cpp
Libs: -L${libdir} @LZ4_STATIC_LDFLAGS@ -lflann -lflann_cpp
Cflags: -I${includedir}

3 changes: 3 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ add_custom_target(examples ALL)

if (BUILD_C_BINDINGS)
add_executable(flann_example_c flann_example.c)
target_link_libraries(flann_example_c -Wl,--push-state,--no-as-needed ${LZ4_LIBRARIES} -Wl,--pop-state)
target_link_libraries(flann_example_c flann)
set_target_properties(flann_example_c PROPERTIES COMPILE_FLAGS -std=c99)

Expand All @@ -14,6 +15,7 @@ if (HDF5_FOUND)
include_directories(${HDF5_INCLUDE_DIR})

add_executable(flann_example_cpp flann_example.cpp)
target_link_libraries(flann_example_cpp -Wl,--push-state,--no-as-needed ${LZ4_LIBRARIES} -Wl,--pop-state)
target_link_libraries(flann_example_cpp ${HDF5_LIBRARIES} flann_cpp)
if (HDF5_IS_PARALLEL)
target_link_libraries(flann_example_cpp ${MPI_LIBRARIES})
Expand All @@ -25,6 +27,7 @@ if (HDF5_FOUND)

if (USE_MPI AND HDF5_IS_PARALLEL)
add_executable(flann_example_mpi flann_example_mpi.cpp)
target_link_libraries(flann_example_mpi -Wl,--push-state,--no-as-needed ${LZ4_LIBRARIES} -Wl,--pop-state)
target_link_libraries(flann_example_mpi flann_cpp ${HDF5_LIBRARIES} ${MPI_LIBRARIES} ${Boost_LIBRARIES})

add_dependencies(examples flann_example_mpi)
Expand Down
8 changes: 6 additions & 2 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@ add_definitions(-D_FLANN_VERSION=${FLANN_VERSION})

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

file(GLOB_RECURSE C_SOURCES flann.cpp lz4.c lz4hc.c)
file(GLOB_RECURSE CPP_SOURCES flann_cpp.cpp lz4.c lz4hc.c)
file(GLOB_RECURSE C_SOURCES flann.cpp)
file(GLOB_RECURSE CPP_SOURCES flann_cpp.cpp)
file(GLOB_RECURSE CU_SOURCES *.cu)

add_library(flann_cpp_s STATIC ${CPP_SOURCES})
target_link_libraries(flann_cpp_s ${LZ4_LIBRARIES})
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
set_target_properties(flann_cpp_s PROPERTIES COMPILE_FLAGS -fPIC)
endif()
Expand Down Expand Up @@ -42,6 +43,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCC)
endif()
else()
add_library(flann_cpp SHARED ${CPP_SOURCES})
target_link_libraries(flann_cpp -Wl,--push-state,--no-as-needed ${LZ4_LIBRARIES} -Wl,--pop-state)
# export lz4 headers, so that MSVC to creates flann_cpp.lib
set_target_properties(flann_cpp PROPERTIES WINDOWS_EXPORT_ALL_SYMBOLS YES)
if (BUILD_CUDA_LIB)
Expand Down Expand Up @@ -79,6 +81,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()
Expand All @@ -90,6 +93,7 @@ if (BUILD_C_BINDINGS)
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)
Expand Down
Loading

0 comments on commit b6902aa

Please sign in to comment.