[CMake] Fake dependencies of executables to static libs

Paul Smith paul at mad-scientist.net
Thu Apr 4 02:13:15 EDT 2019


On Thu, 2019-04-04 at 06:56 +0100, Stephan Menzel wrote:
> add_library(mylib STATIC mysources)
> add_excecutable(mytest mytest.cpp)
> target_link_libraries(mytest mylib)
> 
> Now although I don't understand the exact reasons behind that, over
> the years came to accept that depedencies between the lib and the
> resulting artifcats are not working. Like, when I change a source
> file to mylib, the lib will get rebuilt but the resulting test tool
> won't be relinked.

This is definitely not true, as stated.  I feel like I must be missing
something about your stated environment because this is really basic,
fundamental CMake behavior, which has always worked.

If in your environment you are not seeing executables rebuilt when
libraries they depend on are updated, then there is something more
complex about it than the straightforward case you provide above.

Rather than try to find a workaround it would be better to find the
root cause.  If you can provide a sample setup that behaves as you
describe perhaps we could explain what's happening.

Also please let us know which version of CMake you're using.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190404/96ee1d7d/attachment.html>


More information about the CMake mailing list