Open aminya opened 2 years ago
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!
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: https://github.com/aminya/project_options/pull/167
Hi, I am the developer of project options that uses
install_basic_package_files
from ycm internally for itspackage_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 aFILE
instead of aTARGET
.However, this still fails when calling the
export
function. This is because when theinstall(TARGETS ... EXPORT ...)
is not called, no export exists.I am wondering if we can handle this corner case.
See this for more information