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

Updated for latest macosx #470

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ endif(BUILD_CUDA_LIB)

find_package(PkgConfig REQUIRED)
pkg_check_modules(LZ4 REQUIRED liblz4)
include_directories(${LZ4_INCLUDE_DIRS})

#set the C/C++ include path to the "include" directory
include_directories(BEFORE ${PROJECT_SOURCE_DIR}/src/cpp)
Expand Down
10 changes: 7 additions & 3 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
add_custom_target(examples ALL)

# Only use GNU-specific linker commands for the GNU compiler
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_LINK_WHAT_YOU_USE TRUE)
endif()

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 ${LZ4_LINK_LIBRARIES})
target_link_libraries(flann_example_c flann)
set_target_properties(flann_example_c PROPERTIES COMPILE_FLAGS -std=c99)

Expand All @@ -15,7 +19,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 ${LZ4_LINK_LIBRARIES})
target_link_libraries(flann_example_cpp ${HDF5_LIBRARIES} flann_cpp)
if (HDF5_IS_PARALLEL)
target_link_libraries(flann_example_cpp ${MPI_LIBRARIES})
Expand All @@ -27,7 +31,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 ${LZ4_LINK_LIBRARIES})
target_link_libraries(flann_example_mpi flann_cpp ${HDF5_LIBRARIES} ${MPI_LIBRARIES} ${Boost_LIBRARIES})

add_dependencies(examples flann_example_mpi)
Expand Down
13 changes: 9 additions & 4 deletions src/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ 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})
target_link_libraries(flann_cpp_s ${LZ4_LINK_LIBRARIES})
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
set_target_properties(flann_cpp_s PROPERTIES COMPILE_FLAGS -fPIC)
endif()
set_property(TARGET flann_cpp_s PROPERTY COMPILE_DEFINITIONS FLANN_STATIC FLANN_USE_CUDA)

# Only use GNU-specific linker commands for the GNU compiler
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_LINK_WHAT_YOU_USE TRUE)
endif()

if (BUILD_CUDA_LIB)
SET(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS};-DFLANN_USE_CUDA")
if(CMAKE_COMPILER_IS_GNUCC)
Expand Down Expand Up @@ -43,7 +48,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)
target_link_libraries(flann_cpp ${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 @@ -81,7 +86,7 @@ endif()

if (BUILD_C_BINDINGS)
add_library(flann_s STATIC ${C_SOURCES})
target_link_libraries(flann_s -Wl,--push-state,--no-as-needed ${LZ4_LIBRARIES} -Wl,--pop-state)
target_link_libraries(flann_s ${LZ4_LINK_LIBRARIES})
if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
set_target_properties(flann_s PROPERTIES COMPILE_FLAGS -fPIC)
endif()
Expand All @@ -93,7 +98,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 -Wl,--push-state,--no-as-needed ${LZ4_LIBRARIES} -Wl,--pop-state)
target_link_libraries(flann ${LZ4_LINK_LIBRARIES})

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