Is there a way to print a list the filenames for the libraries linked into a target via the target_link_libraries command
or even better, have all a target's dependencies copied to a specific folder?
Is there a way to print a list the filenames for the libraries linked into a target via the target_link_libraries command
or even better, have all a target's dependencies copied to a specific folder?
Actually not(*).
However, you can use a cmake variable to collect the name of the libraries that you want to link (using the
set( ...
or thelist(APPEND ...
command), and then use this variable in yourtarget_link_libraries
command:The same variable can also be used to create your copy commands (for example using this custom target)
(*) A similar question was asked here, and it got no definitive answer.
I realise this doesn't fully answer the question with regards doing it within cmake, but I faced a similar problem and thought I should share my solution.
First, in your source directory ("project"):
Then, use graphviz to create a dot file, as in this answer:
Then, strip out the dependencies from the graph for your target (let's call it "foo"):
Now, remove the clutter:
Well, all linked libraries to a given target TARGET are in the build.../CMakeFiles/TARGET.dir/link.txt.
For instance, TARGET=dirac.x,
There will be a large number of linked libraries: