From b1c2e0174b5cdc20470354b308ff6c2cd2a883d3 Mon Sep 17 00:00:00 2001 From: Jose Luis Blanco Claraco Date: Tue, 6 Oct 2020 22:58:42 +0200 Subject: [PATCH] Use system eigen3 only if first quietly found. --- cmake/handle_eigen.cmake | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/cmake/handle_eigen.cmake b/cmake/handle_eigen.cmake index 4aaf4f2ef..69111303d 100644 --- a/cmake/handle_eigen.cmake +++ b/cmake/handle_eigen.cmake @@ -1,6 +1,22 @@ ############################################################################### # Option for using system Eigen or GTSAM-bundled Eigen +# Default: Use system Eigen if it's present: +find_package(Eigen3 QUIET) +if (Eigen3_FOUND) + set(SYS_EIGEN3_DEFAULT_ ON) +else() + set(SYS_EIGEN3_DEFAULT_ OFF) +endif() +option(GTSAM_USE_SYSTEM_EIGEN "Find and use system-installed Eigen. If 'off', use the one bundled with GTSAM" ${SYS_EIGEN3_DEFAULT_}) +unset(SYS_EIGEN3_DEFAULT_) + +if(NOT GTSAM_USE_SYSTEM_EIGEN) + # This option only makes sense if using the embedded copy of Eigen, it is + # used to decide whether to *install* the "unsupported" module: + option(GTSAM_WITH_EIGEN_UNSUPPORTED "Install Eigen's unsupported modules" OFF) +endif() + # Switch for using system Eigen or GTSAM-bundled Eigen if(GTSAM_USE_SYSTEM_EIGEN) find_package(Eigen3 REQUIRED)