diff options
author | Jean-Christophe Fillion-Robin <jchris.fillionr@kitware.com> | 2018-09-07 15:50:19 -0400 |
---|---|---|
committer | Antonio Sánchez <cantonios@google.com> | 2022-02-13 21:22:14 +0000 |
commit | 02f420012a169ed9267a8a78083aaa588e713353 (patch) | |
tree | 5803b81af1886e093ff78094b855bc918a92dc63 | |
parent | d45ac54008bc2b42d7079abdf63b839dbe3bf2fa (diff) | |
download | eigen-upstream-3.3.tar.gz |
[PATCH] cmake: Support source include with add_subdirectory andupstream-3.3
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(-)
(cherry picked from commit 2cbd9dd49806d686a40841b6d888a83c816efccf)
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | cmake/Eigen3Config.cmake.in | 4 |
2 files changed, 4 insertions, 1 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index dbb9bcf22..49dbf5385 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -540,6 +540,7 @@ if (NOT CMAKE_VERSION VERSION_LESS 3.0) # Imported target support add_library (eigen INTERFACE) + add_library (Eigen3::Eigen ALIAS eigen) target_compile_definitions (eigen INTERFACE ${EIGEN_DEFINITIONS}) target_include_directories (eigen INTERFACE diff --git a/cmake/Eigen3Config.cmake.in b/cmake/Eigen3Config.cmake.in index c5c546887..0a1ac61c9 100644 --- a/cmake/Eigen3Config.cmake.in +++ b/cmake/Eigen3Config.cmake.in @@ -3,7 +3,9 @@ @PACKAGE_INIT@ -include ("${CMAKE_CURRENT_LIST_DIR}/Eigen3Targets.cmake") +if (NOT TARGET eigen) + include ("${CMAKE_CURRENT_LIST_DIR}/Eigen3Targets.cmake") +endif () # Legacy variables, do *not* use. May be removed in the future. |