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

Fix solve cmake error with cmake >= 3.11 using a dummy file #457

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ if (BUILD_CUDA_LIB)
set_property(TARGET flann_cuda_s PROPERTY COMPILE_DEFINITIONS FLANN_STATIC)
endif()

file(WRITE ${CMAKE_CURRENT_SOURCE_DIR}/dummy_source_file_for_shared_lib.cpp)
if(CMAKE_SYSTEM_NAME STREQUAL "Linux" AND CMAKE_COMPILER_IS_GNUCC)
add_library(flann_cpp SHARED "")
add_library(flann_cpp SHARED dummy_source_file_for_shared_lib.cpp)
set_target_properties(flann_cpp PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(flann_cpp -Wl,-whole-archive flann_cpp_s -Wl,-no-whole-archive)

if (BUILD_CUDA_LIB)
cuda_add_library(flann_cuda SHARED "")
cuda_add_library(flann_cuda SHARED dummy_source_file_for_shared_lib.cpp)
set_target_properties(flann_cuda PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(flann_cuda -Wl,-whole-archive flann_cuda_s -Wl,-no-whole-archive)
set_property(TARGET flann_cpp_s PROPERTY COMPILE_DEFINITIONS FLANN_USE_CUDA)
Expand Down Expand Up @@ -88,7 +89,7 @@ if (BUILD_C_BINDINGS)
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 "")
add_library(flann SHARED dummy_source_file_for_shared_lib.cpp)
set_target_properties(flann PROPERTIES LINKER_LANGUAGE CXX)
target_link_libraries(flann -Wl,-whole-archive flann_s -Wl,-no-whole-archive)
else()
Expand Down