extend BundleUtilites with TargetBundle
Assume we want to install an executable foo which links to a library, for example Boost::filesystem. The current usage of fixup_bundle for this executable on a Windows system looks like this:
install(CODE "include(BundleUtilities)\n fixup_bundle(\"${CMAKE_INSTALL_PREFIX}/bin/foo.exe\" \"\" \"${Boost_LIBRARY_DIRS}\")")
This small example shows in my opinion some drawbacks:
- It works with (and relies on) variables instead of targets. Modern cmake transports properties inside the targets.
- The use has to consider the transitive linking of shared libraries. But this information is already contained in the targets.
- The fixup_bundle has to search the target libraries. But there are two properties on the windows platform which handle the libraries. These are IMPORTED_IMPLIB and IMPORTED_LOCATION. If we work on targets, we could use this information.
With these drawbacks in mind, I would like to propose the extension "BundleTarget" with the function
setBundle(targ dest [toIgnore])
We would specify the target and, in analogy to the install command, the destination relative to the CMAKE_INSTALL_PREFIX. The last parameter toIgnore allows to ignore some dependency.
My aim is to unify the bundling process on Windows (and possibly on Mac at the same time?). It is clear to me, that the function is far away from optimal and would serve as a starting point only.