Browse Source

Add Eigen3 requirement to package configuration

In package configuration file:
1. Look for Eigen3::Eigen target. If not present:
2. use find_package(Eigen3) to look for Eigen3. On failure:
3. Use pkg_check_modules to look for Eigen3. (Eigen provided a
   pkg-config file).
If neither of the three options succeed, find_package(libigl) will fail
with an error message.


Former-commit-id: e777d220fc1fd60c1cca0e0efb6884455f16a364
Stefan Reinhold 7 years ago
parent
commit
eb6ffec8d5
1 changed files with 20 additions and 1 deletions
  1. 20 1
      shared/cmake/libigl-config.cmake.in

+ 20 - 1
shared/cmake/libigl-config.cmake.in

@@ -3,7 +3,26 @@
 include(${CMAKE_CURRENT_LIST_DIR}/libigl-export.cmake)
 include(${CMAKE_CURRENT_LIST_DIR}/libigl-export.cmake)
 
 
 if (TARGET igl::core)
 if (TARGET igl::core)
-  set(libigl_core_FOUND TRUE)
+  if (NOT TARGET Eigen3::Eigen)
+    find_package(Eigen3 QUIET)
+    if (NOT Eigen3_FOUND)
+      # try with PkgCOnfig
+      find_package(PkgConfig REQUIRED)
+      pkg_check_modules(Eigen3 QUIET IMPORTED_TARGET eigen3)
+    endif()
+
+    if (NOT Eigen3_FOUND)
+      message(FATAL_ERROR "Could not find required dependency Eigen3")
+      set(libigl_core_FOUND FALSE)
+    else()
+      target_link_libraries(igl::core INTERFACE PkgConfig::Eigen3)
+      set(libigl_core_FOUND TRUE)
+    endif()
+  else()
+    target_link_libraries(igl::core INTERFACE Eigen3::Eigen)
+    set(libigl_core_FOUND TRUE)
+  endif()
+
 endif()
 endif()
 
 
 check_required_components(libigl)
 check_required_components(libigl)