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 ***")