Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compilation against a static iDynTree fails as no one defines Eigen3::Eigen imported target #1065

Open
traversaro opened this issue Apr 12, 2023 · 1 comment

Comments

@traversaro
Copy link
Member

@Nicogene experienced the following problem when compiling against a static version of iDynTree:

Severity    Code    Description    Project    File    Line    Suppression State
Error        CMake Error at C:/Users/ngenesio/robotology/install/lib/cmake/iDynTree/iDynTreeTargets.cmake:61 (set_target_properties):
  The link interface of target "iDynTree::idyntree-core" contains:

 

    Eigen3::Eigen

 

  but the target was not found.  Possible reasons include:

 

    * There is a typo in the target name.
    * A find_package call is missing for an IMPORTED target.
    * An ALIAS target is missing.        C:/Users/ngenesio/robotology/install/lib/cmake/iDynTree/iDynTreeTargets.cmake    61    
    * 

The problem is that we are linking Eigen3::Eigen as PRIVATE in several place, and when a library is compiled as static the PRIVATE target links are promoted to PUBLIC . This would make sense if Eigen3 was itself a non-header library, but given that Eigen3::Eigen is an header-only library, no Eigen3 is actually necessary. To avoid that, we should only include the headers of Eigen3::Eigen, without linking it directly, see https://discourse.cmake.org/t/add-only-library-headers-during-target-link-libraries/2973 for a similar use case.

A function that plays a similar role is onnxruntime_add_include_to_target from https://github.com/microsoft/onnxruntime/blob/d49a8de9b1db3486246e65700380e1eb8e7d581d/cmake/CMakeLists.txt#L940 .

@traversaro
Copy link
Member Author

traversaro commented Aug 22, 2023

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant