[CMake] Target usage requirements for shared libraries

Walter Gray chrysalisx at gmail.com
Thu Jul 17 23:01:50 EDT 2014


Hi there!
I've got a question I can't seem to find a good answer to: What is the 
idiomatic way in CMake 3.0 to handle bundling shared libraries? I've 
exhausted my google-fu and all of the examples seem to be from before 
CMake 3 was released. None of them take any advantage of 3.0's new and 
IMO much more elegant target usage requirements paradigm, and there 
doesn't really seem to be consensus on what the best way to handle this 
problem is.

Given some application <app> and some library <upstreamlib> with a 
header, static, and shared library components (.h, .lib, and .dll on 
windows), it seems like there should be some way to write a definition 
for an interface library such that by writing target_link_library(<app> 
<upstreamlib>), the appropriate shared libraries are copied to the exe 
directory (or in some way made accessible) either via a special custom 
target, a post build step, or install time.  Static libraries and 
headers are handled this way, so why not shared libraries too? Am I just 
being naive?

Thanks for your help.
-Walter


More information about the CMake mailing list