Skip to content

Commit

Permalink
look for valid nanoflann in system
Browse files Browse the repository at this point in the history
  • Loading branch information
j042 committed Nov 15, 2023
1 parent 6dac152 commit 1bf4ba5
Showing 1 changed file with 17 additions and 8 deletions.
25 changes: 17 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.12)
project(napf VERSION 0.0.0 LANGUAGES CXX)

if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
Expand All @@ -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
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third_party>
$<INSTALL_INTERFACE:${incl_dest}>)

# try to use installed nanoflann.
# else, include the one in the third_party
find_package(nanoflann QUIET)
if(nanoflann_FOUND AND nanoflann_VERSION VERSION_GREATER_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
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third_party>
$<INSTALL_INTERFACE:${incl_dest}>)
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 ***")
Expand Down

0 comments on commit 1bf4ba5

Please sign in to comment.