From 5481159f95296193b1accd525bcafaa0617c03ce Mon Sep 17 00:00:00 2001 From: Varun Agrawal Date: Thu, 28 Dec 2023 09:31:08 -0500 Subject: [PATCH] Link to cephes from gtsam --- CMakeLists.txt | 1 + cmake/HandleCephes.cmake | 47 ++++++++++++++++++++++++++++++++++++++++ gtsam/CMakeLists.txt | 3 +++ 3 files changed, 51 insertions(+) create mode 100644 cmake/HandleCephes.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 16848a721..8e0497f8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -72,6 +72,7 @@ include(cmake/HandleCCache.cmake) # ccache include(cmake/HandleCPack.cmake) # CPack include(cmake/HandleEigen.cmake) # Eigen3 include(cmake/HandleMetis.cmake) # metis +include(cmake/HandleCephes.cmake) # cephes include(cmake/HandleMKL.cmake) # MKL include(cmake/HandleOpenMP.cmake) # OpenMP include(cmake/HandlePerfTools.cmake) # Google perftools diff --git a/cmake/HandleCephes.cmake b/cmake/HandleCephes.cmake new file mode 100644 index 000000000..6ef406987 --- /dev/null +++ b/cmake/HandleCephes.cmake @@ -0,0 +1,47 @@ +# ############################################################################## +# Cephes library + +# For both system or bundle version, a cmake target "cephes-gtsam-if" is defined +# (interface library) + +option( + GTSAM_USE_SYSTEM_CEPHES + "Find and use system-installed cephes. If 'off', use the one bundled with GTSAM" + OFF) + +if(GTSAM_USE_SYSTEM_CEPHES) + # # Debian package: libmetis-dev + + # find_path(METIS_INCLUDE_DIR metis.h REQUIRED) find_library(METIS_LIBRARY + # metis REQUIRED) + + # if(METIS_INCLUDE_DIR AND METIS_LIBRARY) mark_as_advanced(METIS_INCLUDE_DIR) + # mark_as_advanced(METIS_LIBRARY) + + # add_library(cephes-gtsam-if INTERFACE) + # target_include_directories(cephes-gtsam-if BEFORE INTERFACE + # ${METIS_INCLUDE_DIR} # gtsam_unstable/partition/FindSeparator-inl.h uses + # internal metislib.h API # via extern "C" + # $ + # $ ) + # target_link_libraries(cephes-gtsam-if INTERFACE ${METIS_LIBRARY}) endif() + +else() + # Bundled version: + add_subdirectory(${GTSAM_SOURCE_DIR}/gtsam/3rdparty/cephes) + + list(APPEND GTSAM_EXPORTED_TARGETS cephes-gtsam) + set(GTSAM_EXPORTED_TARGETS + "${GTSAM_EXPORTED_TARGETS}" + PARENT_SCOPE) + + add_library(cephes-gtsam-if INTERFACE) + target_link_libraries(cephes-gtsam-if INTERFACE cephes-gtsam) + +endif() + +list(APPEND GTSAM_EXPORTED_TARGETS cephes-gtsam-if) +install( + TARGETS cephes-gtsam-if + EXPORT GTSAM-exports + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) diff --git a/gtsam/CMakeLists.txt b/gtsam/CMakeLists.txt index e35f5aada..1fc8e4570 100644 --- a/gtsam/CMakeLists.txt +++ b/gtsam/CMakeLists.txt @@ -110,6 +110,9 @@ if(GTSAM_SUPPORT_NESTED_DISSECTION) list(APPEND GTSAM_ADDITIONAL_LIBRARIES metis-gtsam-if) endif() +# Link to cephes library +list(APPEND GTSAM_ADDITIONAL_LIBRARIES cephes-gtsam-if) + # Versions set(gtsam_version ${GTSAM_VERSION_STRING}) set(gtsam_soversion ${GTSAM_VERSION_MAJOR})