[CMake] Fake dependencies of executables to static libs

Stephan Menzel stephan.menzel at gmail.com
Thu Apr 4 03:16:54 EDT 2019


Hello Paul and Shoaib,

I'm answering to the both of you.

On Thu, Apr 4, 2019 at 7:13 AM Paul Smith <paul at mad-scientist.net> wrote:

> 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.
>

First of all, thanks for the information. I was not aware that this is
supposed to work. As I said, I've been struggling with this issue for years
now and I recall posting this to this list too but the only explanation I
ever found was something along the lines of "dependencies would exist to
objects inside the lib, not the lib as it is a static archive". But I'm
pulling this out of my 'memory' now, nothing to rely on. All I remembered
is that this is not supposed to work. But now you say the opposite, which
gives me a little hope.


> 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.
>

I have seen this in two major projects I have been working on in the last
years. Both were Linux and Windows, MSVC 14 and 15 on Windows. And I do
believe the issue is on Windows. I am not sure which CMake version I have
seen this first on. Let's make it 3.10.x cause this was when I posted this
to the list last time but by then I was already having the problem for a
longer time.

Today I am using CMake version 3.13.2 but I have been using many different
versions up to this one.

Both projects were large but not huge, having about 10 - 15 targets plus
additional 50 unit tests plus another 5 test tools. Unfortunately I cannot
publish the projects themselves but one that I currently see the issue with
is mredis (https://github.com/MrMoose/mredis) which, among others, is
pulled in as a submodule. C++ only, some protobuf code generation is
involved but not in the targets that I'm talking about.

Since the issue has been persisting for so long now, the projects and
CMakeLists have substantially changed many times, so it's really hard to
come up with something I would consider 'strange' or 'different' as a
possible explanation.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190404/2ec12c22/attachment.html>


More information about the CMake mailing list