summarylogtreecommitdiffstats
path: root/005-fix-eigen5.patch
blob: 3ed93d5bb19fd0551394f007914fdb2ab8f9bb21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
From 692ef5ecea850e8de349ba2e2119257300bd0da9 Mon Sep 17 00:00:00 2001
From: Andrej730 <azhilenkov@gmail.com>
Date: Thu, 20 Nov 2025 20:01:56 +0500
Subject: [PATCH] cmake - fix error finding `Eigen::Eigen` target #7390

`EIgen::Eigen` target used in #7340 for linking exists only if there's a cmake config, while there are cases when there's just include directory. Added same name interface target to mimic config.
---
 cmake/CMakeLists.txt   | 20 +++-----------------
 cmake/FindEigen3.cmake | 27 +++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 17 deletions(-)
 create mode 100644 cmake/FindEigen3.cmake

diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt
index 821ceed891b..1cb01a814e2 100644
--- a/cmake/CMakeLists.txt
+++ b/cmake/CMakeLists.txt
@@ -200,7 +200,6 @@ endif()
 
 UNIFY_ENVVARS_AND_CACHE(BOOST_ROOT)
 UNIFY_ENVVARS_AND_CACHE(BOOST_LIBRARYDIR)
-UNIFY_ENVVARS_AND_CACHE(EIGEN_DIR)
 
 if(NOT MINIMAL_BUILD)
     UNIFY_ENVVARS_AND_CACHE(PYTHON_INCLUDE_DIR)
@@ -640,25 +640,11 @@ endif()
 endif(MSVC)

- 
-# Ensure other dependencies are provided.
-if(NOT EXISTS "${EIGEN_DIR}")
-    find_package(Eigen3 CONFIG)
-    if(Eigen3_DIR)
-        message(STATUS "Eigen3: found config at '${Eigen3_DIR}'.")
-    else()
-        message(
-            FATAL_ERROR
-            "EIGEN_DIR is not provided or provided folder doesn't exist (current value: '${EIGEN_DIR}'). "
-            "Also couldn't find Eigen3 as a package."
-        )
-    endif()
-    link_libraries(Eigen3::Eigen)
-endif()
-
+find_package(Eigen3 REQUIRED)
+link_libraries(Eigen3::Eigen)
 
 include_directories(${INCLUDE_DIRECTORIES} ${OCC_INCLUDE_DIR} ${OPENCOLLADA_INCLUDE_DIRS}
 	${Boost_INCLUDE_DIRS} ${LIBXML2_INCLUDE_DIR} ${JSON_INCLUDE_DIR} ${HDF5_INCLUDE_DIRS}
-    ${EIGEN_DIR} ${CGAL_INCLUDE_DIR} ${GMP_INCLUDE_DIR} ${MPFR_INCLUDE_DIR} ${USD_INCLUDE_DIR}
+    ${CGAL_INCLUDE_DIR} ${GMP_INCLUDE_DIR} ${MPFR_INCLUDE_DIR} ${USD_INCLUDE_DIR}
     ${TBB_INCLUDE_DIR}
 )
 
diff --git a/cmake/FindEigen3.cmake b/cmake/FindEigen3.cmake
new file mode 100644
index 00000000000..e886310e894
--- /dev/null
+++ b/cmake/FindEigen3.cmake
@@ -0,0 +1,27 @@
+#
+# Input variables:
+# - `EIGEN_DIR`
+# If input variables are not specified, try to find Eigen3 config.
+# Input variables could also be provided as environment variables.
+#
+# Output targets:
+# - `Eigen3::Eigen`
+
+UNIFY_ENVVARS_AND_CACHE(EIGEN_DIR)
+
+if(EXISTS "${EIGEN_DIR}")
+    # Mimic Eigen3Config.cmake target.
+    add_library(Eigen3::Eigen INTERFACE IMPORTED)
+    target_include_directories(Eigen3::Eigen INTERFACE "${EIGEN_DIR}")
+else()
+    find_package(Eigen3 CONFIG)
+    if(Eigen3_DIR)
+        message(STATUS "Eigen3: found config at '${Eigen3_DIR}'.")
+    else()
+        message(
+            FATAL_ERROR
+            "EIGEN_DIR is not provided or provided folder doesn't exist (current value: '${EIGEN_DIR}'). "
+            "Also couldn't find Eigen3 as a package."
+        )
+    endif()
+endif()