I would have expected the following to work recursively through the target dependency hierarchy:
add_executable(myexec ...)
target_link_library (
myexec
PRIVATE some_library_created_via_target)
install (
TARGETS myexec
RUNTIME_DEPENDENCIES
DESTINATION ./bin
COMPONENT myexec)
So when I call
cmake --install builddir --component myexec
I would expect following result:
ls bin
myexec
some_library_created_via_target.so
But what I get is:
ls bin
myexec
libc.so
and some other libraries which I expect to be part of the operating system
shure, myexec
dependes on stdc.so
but that is not what I need to be installed. I need the some_library_created_via_target.so
file installed along with my myexec
file.
The following works though (here I list all dependencies in the TARGETS list, not only myexec
):
add_executable(myexec ...)
target_link_library (
myexec
PRIVATE some_library_created_via_target)
install (
TARGETS myexec some_library_created_via_target
DESTINATION ./bin
COMPONENT myexec)
This solution is unsatisfactory because if the target dependency hierarchy is deep, then I do not easily see which targets I have to add to install(TARGETS ...)
Is there another way?