Missing target Eigen in module ui
While testing this library with latest release to date v6.34.0 I faced a problem with the module ui
Due to linking the dependent target imgui to Eigen https://github.com/adobe/lagrange/blob/b3f4080cf039c043d7024a78b0a3e42ea1379dec/modules/ui/CMakeLists.txt#L37-L37
which is not explicitly loaded above https://github.com/adobe/lagrange/blob/b3f4080cf039c043d7024a78b0a3e42ea1379dec/modules/ui/CMakeLists.txt#L23-L36
It produced an error for me when relying on internal lagrange find_package for finding my vcpkg Eigen, probably due to scope issue. Adding it explicitly above solves the problem. lagrange_find_package(Eigen3 REQUIRED)
At this stage Eigen3::Eigen should be available indirectly from other targets (e.g. pulled by lagrange::io and lagrange::core). I suspect your setup is only not defining a GLOBAL IMPORTED target for Eigen3::Eigen which is why you feel the need to include the call to lagrange_find_package(Eigen3) right before usage.
Can you share a bit more about your vcpkg project setup and how you're trying to setup Eigen in particular? Are you using LAGRANGE_USE_FIND_PACKAGE?
I would have expected so too because other targets link to it. I only declare eigen in the vcpkg.json manifest, but do not call find_package(Eigen3) preemptively in the root CMakeLists before including/fetching lagrange.
OpenVDB is brought into global scope from the volume module https://github.com/adobe/lagrange/blob/b3f4080cf039c043d7024a78b0a3e42ea1379dec/modules/volume/CMakeLists.txt#L17
but not the core dependencies
https://github.com/adobe/lagrange/blob/b3f4080cf039c043d7024a78b0a3e42ea1379dec/modules/core/CMakeLists.txt#L79-L82
Adding a GLOBAL to lagrange_find_package(Eigen3 REQUIRED) also solves the initial problem.
Everything points to a scope issue, as the find_package targets are only reachable locally (even if they are forwarded through library linking).
Ok I see. We don't officially support vcpkg yet, as it's not a configuration we are actively testing for. Right now you have a couple of options:
- Explicitly disable
LAGRANGE_USE_FIND_PACKAGE(the default is set here based on whether vcpkg is enabled or not, even though we don't test this config in our CI). The downside is Lagrange will pull dependencies that are not provided by the parent project without going through vcpkg. - Pull Eigen before including Lagrange (using
find_package(Eigen3 REQUIRED GLOBAL)beforeadd_subdirectory(lagrange)) - Patch Lagrange to add missing
GLOBALkeywords where needed and submit a PR for it. It'll take some time before we officially support vcpkg but in the meantime feel free to contribute patches that work for you.
Currently I am following option 2 for myself, calling find_package(Eigen3 REQUIRED) before FetchContent lagrange, but it is not a great solution as it is order dependent and depends on user knowledge.
The files for a minimal reproducible example are attached: