[CMake] Copying shared libraries in a post-build step

Tim Blechmann tim at klingt.org
Wed Dec 10 05:36:32 EST 2014


>     > This sounds more like an install phase... to bring the whole package
>     > together in one appropriate place.
>     >
>     > if( WIN32 )
>     > INSTALL( TARGET <target> RUNTIME DESTINATION bin LIBRARY DESTINATION bin
>     > ARCHIVE DESTINATION lib )
>     > else( WIN32 )
>     > INSTALL( TARGET <target> RUNTIME DESTINATION bin LIBRARY DESTINATION lib
>     > ARCHIVE DESTINATION lib )
>     > endif( WIN32 )
> 
>     on unixy platforms, shared libraries can be resolved using rpaths. on
>     windows this is not the case: if you link a dll into an executable the
>     executable will not run, unless the dll can be resolved at startup time.
>     the is typically done by placing he dll next to the exe.
> 
>     the install step is a possible workaround, but in my experience this
>     implies that you have to run the install script in order to debug the
>     binary, which is pretty inconvenient.
> 
> No more inconvenient than building any other target... from the command
> line cmake --build . <--target install / instead of blank>;

a: typically you don't want to build the complete project, but only the
binary you want to debug (install requires all). depending on the size
of your project, this can be a big issue.

b: in msvc, you cannot debug by right-click on the target -> debug ->
start new instance.



More information about the CMake mailing list