target_link_libraries not callable from other directory scopes
In contrast to the other target_*
functions, target_link_libraries
is the only one that requires to be called in the same directory in which its target has been created (see https://cmake.org/cmake/help/latest/command/target_link_libraries.html).
According to this nice post (https://crascit.com/2016/01/31/enhanced-source-file-handling-with-target_sources/), relaxing this limitation would help to further promote modern usage of CMake to users, without relying on the workaround based on include
.
A similar request has also been posted here (https://public.kitware.com/pipermail/cmake/2012-November/052874.html), but has not received any comment or answer.
So are there any technical limitations inside CMake's target system that prevent linking from other directories?