瀏覽代碼

Fix igl common cmake config (#1097)

* Set libigl_common_FOUND if arget is OK

In libigl-config.cmake.in only libigl_core_FOUND was set, resulting in
an error if the user requested the igl::common feature, see #1077

* Replace target_link_libraries with set_target_properties

Otherwise cmake complains that the targets igl::core and igl::common are
not built by the current project.

* Also install .c files
Stefan Reinhold 6 年之前
父節點
當前提交
c65e487996
共有 2 個文件被更改,包括 26 次插入2 次删除
  1. 25 2
      cmake/libigl-config.cmake.in
  2. 1 0
      cmake/libigl.cmake

+ 25 - 2
cmake/libigl-config.cmake.in

@@ -15,15 +15,38 @@ if (TARGET igl::core)
       message(FATAL_ERROR "Could not find required dependency Eigen3")
       set(libigl_core_FOUND FALSE)
     else()
-      target_link_libraries(igl::core INTERFACE PkgConfig::Eigen3)
+      set_target_properties(igl::core PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::Eigen3)
       set(libigl_core_FOUND TRUE)
     endif()
   else()
-    target_link_libraries(igl::core INTERFACE Eigen3::Eigen)
+    set_target_properties(igl::core PROPERTIES INTERFACE_LINK_LIBRARIES Eigen3::Eigen)
     set(libigl_core_FOUND TRUE)
   endif()
 
 endif()
 
+if (TARGET igl::common)
+  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_common_FOUND FALSE)
+    else()
+      set_target_properties(igl::common PROPERTIES INTERFACE_LINK_LIBRARIES PkgConfig::Eigen3)
+      set(libigl_common_FOUND TRUE)
+    endif()
+  else()
+    set_target_properties(igl::common PROPERTIES INTERFACE_LINK_LIBRARIES Eigen3::Eigen)
+    set(libigl_common_FOUND TRUE)
+  endif()
+
+endif()
+
 check_required_components(libigl)
 

+ 1 - 0
cmake/libigl.cmake

@@ -452,6 +452,7 @@ function(install_dir_files dir_name)
   if(NOT LIBIGL_USE_STATIC_LIBRARY)
     file(GLOB public_sources
       ${CMAKE_CURRENT_SOURCE_DIR}/include/igl${subpath}/*.cpp
+      ${CMAKE_CURRENT_SOURCE_DIR}/include/igl${subpath}/*.c
     )
   endif()
   list(APPEND files_to_install ${public_sources})