Permalink
Browse files

fix Eigen use as ExtProject

  • Loading branch information...
jlblancoc committed Nov 10, 2018
1 parent 18c75e5 commit 51db96140de18cded0daca8393e9b60b59b4bd46
Showing with 24 additions and 16 deletions.
  1. +23 −11 cmakemodules/script_eigen.cmake
  2. +1 −5 libs/math/CMakeLists.txt
@@ -28,18 +28,34 @@ if (EIGEN_USE_EMBEDDED_VERSION)
mark_as_advanced(EIGEN_EMBEDDED_INCLUDE_DIR)

set(MRPT_EIGEN_INCLUDE_DIR "${EIGEN_EMBEDDED_INCLUDE_DIR}")
# define interface lib for Eigen3:
add_library(Eigen INTERFACE)
add_dependencies(Eigen EP_eigen3)
export(
TARGETS Eigen
FILE "${CMAKE_BINARY_DIR}/Eigen-config.cmake"
)
install(TARGETS Eigen EXPORT Eigen-targets)
install(
EXPORT Eigen-targets
DESTINATION ${this_lib_dev_INSTALL_PREFIX}share/mrpt
)
target_include_directories(Eigen
SYSTEM # omit warnings for these hdrs
INTERFACE
$<BUILD_INTERFACE:${EIGEN_EMBEDDED_INCLUDE_DIR}>
$<BUILD_INTERFACE:${EIGEN_EMBEDDED_INCLUDE_DIR}/unsupported>
# $<INSTALL_INTERFACE:include/Eigen>
)
add_library(Eigen3::Eigen ALIAS Eigen)

elseif(Eigen3_FOUND)
# Use system version
set(MRPT_EIGEN_INCLUDE_DIR "${EIGEN3_INCLUDE_DIR}")
else()
message(FATAL_ERROR "eigen3 is required to build MRPT! Either install it and set EIGEN3_DIR or enable the variable EIGEN_USE_EMBEDDED_VERSION to automatically download it now.")
endif()

include_directories("${MRPT_EIGEN_INCLUDE_DIR}")
if(EXISTS "${MRPT_EIGEN_INCLUDE_DIR}/unsupported/")
include_directories("${MRPT_EIGEN_INCLUDE_DIR}/unsupported/")
endif()

# Create variables just for the final summary of the configuration (see bottom of this file):
set(CMAKE_MRPT_HAS_EIGEN 1) # Always, it's a fundamental dep.!

@@ -52,10 +68,6 @@ else()
set(CMAKE_MRPT_HAS_EIGEN_SYSTEM 1)
endif()

# Add directories as "-isystem" to avoid warnings with :
set(AUX_EIGEN_INCL_DIR ${MRPT_EIGEN_INCLUDE_DIR})
ADD_DIRECTORIES_AS_ISYSTEM(AUX_EIGEN_INCL_DIR)

# Detect Eigen version (just to show it in the CMake config summary)
set(EIGEN_VER_H "${MRPT_EIGEN_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h")
if (EXISTS ${EIGEN_VER_H})
@@ -76,5 +88,5 @@ if (EXISTS ${EIGEN_VER_H})

if($ENV{VERBOSE})
message(STATUS "Eigen version detected: ${MRPT_EIGEN_VERSION}")
endif($ENV{VERBOSE})
endif (EXISTS ${EIGEN_VER_H})
endif()
endif ()
@@ -54,11 +54,7 @@ if(BUILD_mrpt-math)
endif()

# eigen3:
if (EIGEN_USE_EMBEDDED_VERSION)
target_link_libraries(mrpt-math PUBLIC EP_eigen3)
else()
target_link_libraries(mrpt-math PUBLIC Eigen3::Eigen)
endif()
target_link_libraries(mrpt-math PUBLIC Eigen3::Eigen)


if (NOT "${SuiteSparse_LIBRARIES}" STREQUAL "")

0 comments on commit 51db961

Please sign in to comment.