Skip to content
Snippets Groups Projects
Commit 6993dd94 authored by Simon Praetorius's avatar Simon Praetorius
Browse files

Allow nanoflann and alglib to be external packages

parent feda220f
No related branches found
No related tags found
1 merge request!2Allow nanoflann and alglib to be external packages
......@@ -23,9 +23,11 @@ include(FeatureSummary)
dune_project()
option(ENABLE_NANOFLANN "Use KDTree search tree from nanoflann." ON)
option(DOWNLOAD_NANOFLANN "Download and build nanoflann library." OFF)
add_feature_info(ENABLE_NANOFLANN ENABLE_NANOFLANN "Use KDTree search tree from nanoflann.")
option(ENABLE_ALGLIB "Use ALGLIB to implement the LM constrained least-squares solver." ON)
option(DOWNLOAD_ALGLIB "Download and build ALGLIB library." OFF)
add_feature_info(ENABLE_ALGLIB ENABLE_ALGLIB "Use ALGLIB to implement the LM constrained least-squares solver.")
# provide external packages
......@@ -59,5 +61,8 @@ add_subdirectory(src)
add_subdirectory(dune)
add_subdirectory(doc)
# write contents into DUNE_CUSTOM_PKG_CONFIG_SECTION
string(JOIN "\n" DUNE_CUSTOM_PKG_CONFIG_SECTION ${DUNE_MESHDIST_PACKAGE_DEPENDENCIES})
# finalize the dune project, e.g. generating config.h etc.
finalize_dune_project()
include(FetchContent)
set(_find_dependencies)
if(ENABLE_NANOFLANN)
if(NOT nanoflann_SOURCE_DIR)
if(DOWNLOAD_NANOFLANN)
set(NANOFLANN_BUILD_EXAMPLES OFF CACHE BOOL "Do not build examples for nanoflann" FORCE)
set(NANOFLANN_BUILD_TESTS OFF CACHE BOOL "Do not build tests for nanoflann" FORCE)
FetchContent_Declare(nanoflann # name of the content
......@@ -12,22 +13,25 @@ if(ENABLE_NANOFLANN)
if(NOT nanoflann_POPULATED)
FetchContent_Populate(nanoflann)
endif()
endif()
file(GLOB NANOFLANN_HEADERS CONFIGURE_DEPENDS "${nanoflann_SOURCE_DIR}/include/*.hpp")
file(GLOB NANOFLANN_HEADERS CONFIGURE_DEPENDS "${nanoflann_SOURCE_DIR}/include/*.hpp")
# Create a library from the source files
dune_add_library(nanoflann INTERFACE
EXPORT_NAME nanoflann NAMESPACE nanoflann::)
target_include_directories(nanoflann INTERFACE
$<BUILD_INTERFACE:${nanoflann_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/nanoflann>)
install(FILES ${NANOFLANN_HEADERS}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/nanoflann" )
# Create a library from the source files
dune_add_library(nanoflann INTERFACE
EXPORT_NAME nanoflann NAMESPACE nanoflann::)
target_include_directories(nanoflann INTERFACE
$<BUILD_INTERFACE:${nanoflann_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}/nanoflann>)
install(FILES ${NANOFLANN_HEADERS}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/nanoflann" )
else()
find_package(nanoflann 1.6 REQUIRED)
list(APPEND _find_dependencies "find_dependency(nanoflann 1.6)")
endif()
endif()
if(ENABLE_ALGLIB)
if(NOT alglib_SOURCE_DIR)
if(DOWNLOAD_ALGLIB)
FetchContent_Declare(alglib
URL https://www.alglib.net/translator/re/alglib-4.03.0.cpp.gpl.tgz
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
......@@ -35,17 +39,23 @@ if(ENABLE_ALGLIB)
${CMAKE_COMMAND} -E create_symlink <SOURCE_DIR>/src <SOURCE_DIR>/alglib
)
FetchContent_MakeAvailable(alglib)
file(GLOB ALGLIB_HEADERS CONFIGURE_DEPENDS "${alglib_SOURCE_DIR}/src/*.hpp")
file(GLOB ALGLIB_SOURCES CONFIGURE_DEPENDS "${alglib_SOURCE_DIR}/src/*.cpp")
# Create a library from the source files
dune_add_library(alglib SOURCES ${ALGLIB_SOURCES}
EXPORT_NAME alglib NAMESPACE alglib::)
target_include_directories(alglib PUBLIC
$<BUILD_INTERFACE:${alglib_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
install(FILES ${ALGLIB_HEADERS}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/alglib" )
else()
find_package(alglib 4.0 REQUIRED)
list(APPEND _find_dependencies "find_dependency(alglib 4.0)")
endif()
endif()
file(GLOB ALGLIB_HEADERS CONFIGURE_DEPENDS "${alglib_SOURCE_DIR}/src/*.hpp")
file(GLOB ALGLIB_SOURCES CONFIGURE_DEPENDS "${alglib_SOURCE_DIR}/src/*.cpp")
# Create a library from the source files
dune_add_library(alglib SOURCES ${ALGLIB_SOURCES}
EXPORT_NAME alglib NAMESPACE alglib::)
target_include_directories(alglib PUBLIC
$<BUILD_INTERFACE:${alglib_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
install(FILES ${ALGLIB_HEADERS}
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/alglib" )
endif()
\ No newline at end of file
set(DUNE_MESHDIST_PACKAGE_DEPENDENCIES "${_find_dependencies}" PARENT_SCOPE)
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment