[CMake] static library dependences in MSVC

William A. Hoffman billlist at nycap.rr.com
Tue Aug 1 11:05:15 EDT 2006


At 02:48 AM 8/1/2006, David Purton wrote:
>Hi,
>
>I have a project that has a number of interdependent libraries and and
>then applications that depend on them. Because of the way I distribute
>the applications I build everything statically.
>
>I notice that when you generate makefiles, dependencies between the
>libraries seem to be handled well. So if I change a header in one
>library, then those libraries that include this header get rebuilt, then
>any apps depending on all rebuilt libraries get rebuilt, etc.
>
>However, this doesn't work with Visual Studio. I see that there is a
>line in cmGlobalVisualStudio71Generator.cxx that looks like this:
>
>  if (target.GetType() != cmTarget::STATIC_LIBRARY)
>  {
>    // do dependency stuff
>  }
>
>So of course the dependency info is not included in the sln file for my
>static libraries.
>
>
>My questions are:
>
>1) Why is this done this way?
>
>2) Will bad things happen if I take the 'if' statement out?

This should still work.   At some point the static libraries will 
have executables that use them.   If you build ALL_BUILD then everything
will be up-to date.  If you build an executable that uses the static 
libraries everything will be up-to date.  The only thing that will happen
is when you build a static library that uses another static library it will
only build the one library.  I think in some versions of VS adding the depend
makes it link the libraries into each other.

-Bill



More information about the CMake mailing list