Append full Eigen include path to GTSAM_INCLUDE_DIR to dependent projects can find the same Eigen that GTSAM was configured with

release/4.3a0
cbeall3 2015-03-18 14:20:45 -04:00
parent f95acf4971
commit e565213c0f
2 changed files with 16 additions and 7 deletions

View File

@ -200,34 +200,39 @@ option(GTSAM_USE_SYSTEM_EIGEN "Find and use system-installed Eigen. If 'off', us
# Switch for using system Eigen or GTSAM-bundled Eigen # Switch for using system Eigen or GTSAM-bundled Eigen
if(GTSAM_USE_SYSTEM_EIGEN) if(GTSAM_USE_SYSTEM_EIGEN)
# Use generic Eigen include paths e.g. <Eigen/Core>
set(GTSAM_EIGEN_INCLUDE_PREFIX "")
find_package(Eigen3 REQUIRED) find_package(Eigen3 REQUIRED)
include_directories(AFTER "${EIGEN3_INCLUDE_DIR}") include_directories(AFTER "${EIGEN3_INCLUDE_DIR}")
# Use generic Eigen include paths e.g. <Eigen/Core>
set(GTSAM_EIGEN_INCLUDE_PREFIX "${EIGEN3_INCLUDE_DIR}")
# check if MKL is also enabled - can have one or the other, but not both! # check if MKL is also enabled - can have one or the other, but not both!
if(EIGEN_USE_MKL_ALL) if(EIGEN_USE_MKL_ALL)
message(FATAL_ERROR "MKL cannot be used together with system-installed Eigen, as MKL support relies on patches which are not yet in the system-installed Eigen. Disable either GTSAM_USE_SYSTEM_EIGEN or GTSAM_WITH_EIGEN_MKL") message(FATAL_ERROR "MKL cannot be used together with system-installed Eigen, as MKL support relies on patches which are not yet in the system-installed Eigen. Disable either GTSAM_USE_SYSTEM_EIGEN or GTSAM_WITH_EIGEN_MKL")
endif() endif()
else() else()
# Use bundled Eigen include path. # Use bundled Eigen include path.
set(GTSAM_EIGEN_INCLUDE_PREFIX "gtsam/3rdparty/Eigen/")
# Clear any variables set by FindEigen3 # Clear any variables set by FindEigen3
if(EIGEN3_INCLUDE_DIR) if(EIGEN3_INCLUDE_DIR)
set(EIGEN3_INCLUDE_DIR NOTFOUND CACHE STRING "" FORCE) set(EIGEN3_INCLUDE_DIR NOTFOUND CACHE STRING "" FORCE)
endif() endif()
# Add the bundled version of eigen to the include path so that it can still be included # Add the bundled version of eigen to the include path so that it can still be included
# with #include <Eigen/Core> # with #include <Eigen/Core>
include_directories(BEFORE ${GTSAM_EIGEN_INCLUDE_PREFIX}) include_directories(BEFORE "gtsam/3rdparty/Eigen/")
# set full path, to be used by external projects
# this will be added to GTSAM_INCLUDE_DIR by gtsam_extra.cmake.in
set(GTSAM_EIGEN_INCLUDE_PREFIX "${CMAKE_INSTALL_PREFIX}/include/gtsam/3rdparty/Eigen/")
endif() endif()
# Write Eigen include file with the paths for either the system Eigen or the GTSAM-bundled Eigen # Write Eigen include file with the paths for either the system Eigen or the GTSAM-bundled Eigen
configure_file(gtsam/3rdparty/gtsam_eigen_includes.h.in gtsam/3rdparty/gtsam_eigen_includes.h) #configure_file(gtsam/3rdparty/gtsam_eigen_includes.h.in gtsam/3rdparty/gtsam_eigen_includes.h)
# Install the configuration file for Eigen # Install the configuration file for Eigen
install(FILES ${PROJECT_BINARY_DIR}/gtsam/3rdparty/gtsam_eigen_includes.h DESTINATION include/gtsam/3rdparty) #install(FILES ${PROJECT_BINARY_DIR}/gtsam/3rdparty/gtsam_eigen_includes.h DESTINATION include/gtsam/3rdparty)
############################################################################### ###############################################################################
# Global compile options # Global compile options

View File

@ -13,6 +13,10 @@ if("@GTSAM_USE_TBB@")
list(APPEND GTSAM_INCLUDE_DIR "@TBB_INCLUDE_DIRS@") list(APPEND GTSAM_INCLUDE_DIR "@TBB_INCLUDE_DIRS@")
endif() endif()
# Append Eigen include path, set in top-level CMakeLists.txt to either
# system-eigen, or GTSAM eigen path
list(APPEND GTSAM_INCLUDE_DIR "@GTSAM_EIGEN_INCLUDE_PREFIX@")
if("@GTSAM_USE_EIGEN_MKL@") if("@GTSAM_USE_EIGEN_MKL@")
list(APPEND GTSAM_INCLUDE_DIR "@MKL_INCLUDE_DIR@") list(APPEND GTSAM_INCLUDE_DIR "@MKL_INCLUDE_DIR@")
endif() endif()