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

CMake Imrovements #227

Merged
merged 2 commits into from
Dec 26, 2023
Merged
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
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ endif()

# Set relative install directories
set(INSTALL_INCLUDE_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
set(INSTALL_CMAKE_DIR "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake/")
set(INSTALL_CMAKE_DIR "${CMAKE_INSTALL_DATADIR}/cmake/${PROJECT_NAME}")
set(INSTALL_COPYRIGHT_DIR "${CMAKE_INSTALL_DOCDIR}")
if(NOT DEFINED PKGCONFIG_INSTALL_DIR)
set(PKGCONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
Expand All @@ -84,7 +84,7 @@ target_include_directories(nanoflann
install(TARGETS nanoflann
EXPORT nanoflannTargets)

# Since 2023-March, the parallel KD tree construction feature
# Since 2023-March, the parallel KD tree construction feature
# needs pthreads for gcc:
find_package(Threads)
target_link_libraries(nanoflann INTERFACE Threads::Threads)
Expand All @@ -100,6 +100,7 @@ endif()

# Tests
option(NANOFLANN_BUILD_TESTS "Build unit tests" ON)
option(NANOFLANN_USE_SYSTEM_GTEST "Use system GTest dependency" OFF)
if(NANOFLANN_BUILD_TESTS)
enable_testing()
add_subdirectory(tests)
Expand Down
10 changes: 8 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ if(MSVC)
add_definitions(-D_VARIADIC_MAX=10)
endif(MSVC)

if(NOT TARGET gtest)
if(NANOFLANN_USE_SYSTEM_GTEST)
find_package(GTest REQUIRED)
else()
# Treat this directory as "system" to ignore pedantic warnings.
if(CMAKE_COMPILER_IS_GNUCXX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -isystem gtest-1.8.0/include")
Expand Down Expand Up @@ -37,4 +39,8 @@ ADD_TEST(unit_tests_run ${EXECUTABLE_OUTPUT_PATH}/unit_tests)
set_tests_properties(unit_tests_run PROPERTIES DEPENDS unit_tests_build)

# Add the required libraries for linking:
TARGET_LINK_LIBRARIES(unit_tests mygtest nanoflann)
if(NANOFLANN_USE_SYSTEM_GTEST)
target_link_libraries(unit_tests GTest::gtest nanoflann)
else()
target_link_libraries(unit_tests mygtest nanoflann)
endif()