find_package use
This commit allows the sources of the project to be included in a parent
project CMakeLists.txt and support use of "find_package(Eigen3 CONFIG REQUIRED)"
Here is an example allowing to test the changes. It is not particularly
useful in itself. This change will allow to support one of the scenario
allowing to create custom 3D Slicer application bundling associated plugins.
/tmp/eigen-git-mirror # Eigen sources
/tmp/test/CMakeLists.txt:
cmake_minimum_required(VERSION 3.12)
project(test)
add_subdirectory("/tmp/eigen-git-mirror" "eigen-git-mirror")
find_package(Eigen3 CONFIG REQUIRED)
and configuring it using:
mkdir /tmp/test-build && cd $_
cmake \
-DCMAKE_FIND_PACKAGE_NO_PACKAGE_REGISTRY:BOOL=1 \
-DEigen3_DIR:PATH=/tmp/test-build/eigen-git-mirror \
/tmp/test
Co-authored-by: Pablo Hernandez <pablo.hernandez@kitware.com>
---
CMakeLists.txt | 1 +
cmake/Eigen3Config.cmake.in | 4 +++-
2 files changed, 4 insertions(+), 1 deletion(-)
24 lines
802 B
CMake
24 lines
802 B
CMake
# This file exports the Eigen3::Eigen CMake target which should be passed to the
|
|
# target_link_libraries command.
|
|
|
|
@PACKAGE_INIT@
|
|
|
|
if (NOT TARGET eigen)
|
|
include ("${CMAKE_CURRENT_LIST_DIR}/Eigen3Targets.cmake")
|
|
endif ()
|
|
|
|
# Legacy variables, do *not* use. May be removed in the future.
|
|
|
|
set (EIGEN3_FOUND 1)
|
|
set (EIGEN3_USE_FILE "${CMAKE_CURRENT_LIST_DIR}/UseEigen3.cmake")
|
|
|
|
set (EIGEN3_DEFINITIONS "@EIGEN_DEFINITIONS@")
|
|
set (EIGEN3_INCLUDE_DIR "@PACKAGE_EIGEN_INCLUDE_DIR@")
|
|
set (EIGEN3_INCLUDE_DIRS "@PACKAGE_EIGEN_INCLUDE_DIR@")
|
|
set (EIGEN3_ROOT_DIR "@PACKAGE_EIGEN_ROOT_DIR@")
|
|
|
|
set (EIGEN3_VERSION_STRING "@EIGEN_VERSION_STRING@")
|
|
set (EIGEN3_VERSION_MAJOR "@EIGEN_VERSION_MAJOR@")
|
|
set (EIGEN3_VERSION_MINOR "@EIGEN_VERSION_MINOR@")
|
|
set (EIGEN3_VERSION_PATCH "@EIGEN_VERSION_PATCH@")
|