Merge pull request #13337 from sergiud:eigen-cross-compile

* added support for Eigen cross-compilation

* cmake: fix Eigen detection
This commit is contained in:
Sergiu Deitsch 2019-05-20 20:05:42 +02:00 committed by Alexander Alekhin
parent 447116a93c
commit bc4b2d521c
2 changed files with 61 additions and 13 deletions

View File

@ -253,8 +253,8 @@ OCV_OPTION(WITH_CUBLAS "Include NVidia Cuda Basic Linear Algebra Subprograms (BL
OCV_OPTION(WITH_NVCUVID "Include NVidia Video Decoding library support" WITH_CUDA
VISIBLE_IF WITH_CUDA
VERIFY HAVE_NVCUVID)
OCV_OPTION(WITH_EIGEN "Include Eigen2/Eigen3 support" (NOT CV_DISABLE_OPTIMIZATION)
VISIBLE_IF NOT WINRT AND NOT CMAKE_CROSSCOMPILING
OCV_OPTION(WITH_EIGEN "Include Eigen2/Eigen3 support" (NOT CV_DISABLE_OPTIMIZATION AND NOT CMAKE_CROSSCOMPILING)
VISIBLE_IF NOT WINRT
VERIFY HAVE_EIGEN)
OCV_OPTION(WITH_VFW "Include Video for Windows support (deprecated, consider using MSMF)" OFF
VISIBLE_IF WIN32

View File

@ -40,19 +40,67 @@ To eliminate this warning remove WITH_CUDA=ON CMake configuration option.
endif(WITH_CUDA)
# --- Eigen ---
if(WITH_EIGEN)
find_path(EIGEN_INCLUDE_PATH "Eigen/Core"
PATHS /usr/local /opt /usr $ENV{EIGEN_ROOT}/include ENV ProgramFiles ENV ProgramW6432
PATH_SUFFIXES include/eigen3 include/eigen2 Eigen/include/eigen3 Eigen/include/eigen2
DOC "The path to Eigen3/Eigen2 headers"
CMAKE_FIND_ROOT_PATH_BOTH)
if(WITH_EIGEN AND NOT HAVE_EIGEN)
find_package(Eigen3 QUIET)
if(EIGEN_INCLUDE_PATH)
ocv_include_directories(${EIGEN_INCLUDE_PATH})
ocv_parse_header("${EIGEN_INCLUDE_PATH}/Eigen/src/Core/util/Macros.h" EIGEN_VERSION_LINES EIGEN_WORLD_VERSION EIGEN_MAJOR_VERSION EIGEN_MINOR_VERSION)
set(HAVE_EIGEN 1)
if(Eigen3_FOUND)
if(TARGET Eigen3::Eigen)
# Use Eigen3 imported target if possible
list(APPEND OPENCV_LINKER_LIBS Eigen3::Eigen)
set(HAVE_EIGEN 1)
else()
if(DEFINED EIGEN3_INCLUDE_DIRS)
set(EIGEN_INCLUDE_PATH ${EIGEN3_INCLUDE_DIRS})
set(HAVE_EIGEN 1)
elseif(DEFINED EIGEN3_INCLUDE_DIR)
set(EIGEN_INCLUDE_PATH ${EIGEN3_INCLUDE_DIR})
set(HAVE_EIGEN 1)
endif()
endif()
if(HAVE_EIGEN)
if(DEFINED EIGEN3_WORLD_VERSION) # CMake module
set(EIGEN_WORLD_VERSION ${EIGEN3_WORLD_VERSION})
set(EIGEN_MAJOR_VERSION ${EIGEN3_MAJOR_VERSION})
set(EIGEN_MINOR_VERSION ${EIGEN3_MINOR_VERSION})
else() # Eigen config file
set(EIGEN_WORLD_VERSION ${EIGEN3_VERSION_MAJOR})
set(EIGEN_MAJOR_VERSION ${EIGEN3_VERSION_MINOR})
set(EIGEN_MINOR_VERSION ${EIGEN3_VERSION_PATCH})
endif()
endif()
endif()
endif(WITH_EIGEN)
if(NOT HAVE_EIGEN)
if(NOT EIGEN_INCLUDE_PATH OR NOT EXISTS "${EIGEN_INCLUDE_PATH}")
set(__find_paths "")
set(__find_path_extra_options "")
if(NOT CMAKE_CROSSCOMPILING)
list(APPEND __find_paths /opt)
endif()
if(DEFINED ENV{EIGEN_ROOT})
set(__find_paths "$ENV{EIGEN_ROOT}/include")
list(APPEND __find_path_extra_options NO_DEFAULT_PATH)
else()
set(__find_paths ENV ProgramFiles ENV ProgramW6432)
endif()
find_path(EIGEN_INCLUDE_PATH "Eigen/Core"
PATHS ${__find_paths}
PATH_SUFFIXES include/eigen3 include/eigen2 Eigen/include/eigen3 Eigen/include/eigen2
DOC "The path to Eigen3/Eigen2 headers"
${__find_path_extra_options}
)
endif()
if(EIGEN_INCLUDE_PATH AND EXISTS "${EIGEN_INCLUDE_PATH}")
ocv_parse_header("${EIGEN_INCLUDE_PATH}/Eigen/src/Core/util/Macros.h" EIGEN_VERSION_LINES EIGEN_WORLD_VERSION EIGEN_MAJOR_VERSION EIGEN_MINOR_VERSION)
set(HAVE_EIGEN 1)
endif()
endif()
endif()
if(HAVE_EIGEN)
if(EIGEN_INCLUDE_PATH AND EXISTS "${EIGEN_INCLUDE_PATH}")
ocv_include_directories(SYSTEM ${EIGEN_INCLUDE_PATH})
endif()
endif()
# --- Clp ---
# Ubuntu: sudo apt-get install coinor-libclp-dev coinor-libcoinutils-dev