Skip to content

Commit

Permalink
Merge pull request flann-lib#2 from fizyr-forks/link-lz4
Browse files Browse the repository at this point in the history
Ensure LZ4 is added to the interface link libraries of shared libraries.
  • Loading branch information
tkircher authored Oct 24, 2021
2 parents 8706330 + c9572a4 commit 8846154
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ 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_LINK_LIBRARIES})
target_link_libraries(flann_cpp_s PUBLIC ${LZ4_LINK_LIBRARIES})
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
set_target_properties(flann_cpp_s PROPERTIES COMPILE_FLAGS -fPIC)
endif()
Expand All @@ -33,6 +33,7 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCC)
add_library(flann_cpp SHARED dummy.c)
set_target_properties(flann_cpp PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(flann_cpp -Wl,-whole-archive flann_cpp_s -Wl,-no-whole-archive)
target_link_libraries(flann_cpp PUBLIC ${LZ4_LINK_LIBRARIES})

if (BUILD_CUDA_LIB)
cuda_add_library(flann_cuda SHARED dummy.c)
Expand All @@ -42,7 +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 ${LZ4_LINK_LIBRARIES})
target_link_libraries(flann_cpp PUBLIC ${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)
if (BUILD_CUDA_LIB)
Expand Down Expand Up @@ -90,9 +91,10 @@ if (BUILD_C_BINDINGS)
add_library(flann SHARED dummy.c)
set_target_properties(flann PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(flann -Wl,-whole-archive flann_s -Wl,-no-whole-archive)
target_link_libraries(flann PUBLIC ${LZ4_LINK_LIBRARIES})
else()
add_library(flann SHARED ${C_SOURCES})
target_link_libraries(flann ${LZ4_LINK_LIBRARIES})
target_link_libraries(flann PUBLIC ${LZ4_LINK_LIBRARIES})

if(MINGW AND OPENMP_FOUND)
target_link_libraries(flann gomp)
Expand Down

0 comments on commit 8846154

Please sign in to comment.