From f0118cb260f16a6e415580cc3c7491800afc14b5 Mon Sep 17 00:00:00 2001 From: Jaewook Lee Date: Wed, 15 Nov 2023 16:57:37 +0100 Subject: [PATCH] look for valid nanoflann in system --- CMakeLists.txt | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 15a4a36..99618c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,18 +22,27 @@ set(TARGETS_EXPORT_NAME "${PROJECT_NAME}Targets") set(namespace "${PROJECT_NAME}::") # sources -set(CXX_HEADERS src/napf.hpp third_party/nanoflann.hpp) +set(CXX_HEADERS src/napf.hpp) # Interface Library, since it's header only lib add_library(napf INTERFACE) add_library(napf::napf ALIAS napf) -target_include_directories(napf - INTERFACE - $ - $ - $) + +# try to use installed nanoflann. +# else, include the one in the third_party +find_package(nanoflann QUIET) +if(nanoflann_FOUND AND nanoflann_VERSION VERSION_GREATOR_EQUAL "1.5.0") + message("nanoflann found - napf will link to nanoflann found in system.") + target_link_libraries(napf INTERFACE nanoflann::nanoflann) +else() + set(CXX_HEADERS ${CXX_HEADERS} third_party/nanoflann.hpp) + target_include_directories(napf + INTERFACE + $ + $ + $) +endif() target_compile_features(napf INTERFACE cxx_std_11) -#target_compile_options(napf PRIVATE -O3) # everyone can enjoy optimization if(BUILD_FORTRAN_MODULE) message("*** building additional fortran module ***")