I am trying to make a function, addLibrary
, that takes any sort of library and will call target_link_libraries
on it and then find the path to that library and copy that library into a release folder. I am currently using find_library
to find the path to that library. This works fine, except when I call addLibrary
on imported targets, such as addLibrary(Qt5::Widgets)
. This will fail because find_library
doesn't work on imported targets. I want to have an if case that checks if the library passed is an imported target. If so, then it has to recursively find what are the INTERFACE_LINK_LIBRARIES
of each target, find the location of said target, and then copy that file into my release folder. I found a way that uses INTERFACE_LINK_LIBRARIES
and IMPORTED_LOCATION
, but it is rather complicated.
Are you aware of a simple way to recursively resolve the linked interfaces with a certain imported target and get the paths to each of these files?
In my use case, I would like to call addLibrary(Qt5::Widgets)
and add libQt5Widgets.so, libQt5Gui.so, and libQt5Core.so to my release folder.