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

Support installing imported targets #420

Open
aminya opened this issue Oct 20, 2022 · 2 comments
Open

Support installing imported targets #420

aminya opened this issue Oct 20, 2022 · 2 comments

Comments

@aminya
Copy link

aminya commented Oct 20, 2022

Hi, I am the developer of project options that uses install_basic_package_files from ycm internally for its package_project functionality.

I have noticed that ycm fails to install IMPORTED targets. I have written a patch that detects such imported targets and installs them as a FILE instead of a TARGET.

However, this still fails when calling the export function. This is because when the install(TARGETS ... EXPORT ...) is not called, no export exists.

I am wondering if we can handle this corner case.

See this for more information

CMake Error at build/_deps/_ycm-src/modules/InstallBasicPackageFiles.cmake:660 (export):
  export Export set "test" not found.
Call Stack (most recent call first):
  build/_deps/_project_options-src/src/PackageProject.cmake:217 (install_basic_package_files)
  CMakeLists.txt:36 (package_project)
@traversaro
Copy link
Member

Hello @aminya, thanks for the feedback!

I have noticed that ycm fails to install IMPORTED targets.

This is the case, and I think it is actually due to CMake not being able to install IMPORTED targets.
This is kind of "by design" (I think), as tipically imported targets are defined in downstream packages by calling find_dependency . To explain with an example, let's say that you are using YCM's install_basic_package_files in a package called PackageA, that is using an imported target DepA::DepA defined by the call to find_package(DepA). The typical way to make sure that if a downstream projects calls find_package(PackageA) it also gets DepA::DepA is to insert a call to find_dependency(DepA) in the PackageAConfig.cmake file. In the context of install_basic_package_files, this is done by passing DepA in the DEPENDENCIES argument.
This is done as in general the relative position of the install prefixes of DepA and PackageA may be different between the machine in which you are building PackageA and the machine in which you are consuming PackageA.

However, if you need to install IMPORTED targets probably you have a different use case, can you explain it, so it would be easier to find a solution? Thanks!

@aminya
Copy link
Author

aminya commented Oct 22, 2022

Hi, thanks for the explanation.

My use-case is wrapping a pre-built library generated by another build system so it can be used from CMake. The one way CMake allows defining such libraries is imported targets. I have given an example here in the pull request description under the "How to test" section:
aminya/project_options#167

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

2 participants