[CMake] Help debug crazy Windows MSVC issue

Paul Smith paul at mad-scientist.net
Mon Feb 17 08:23:33 EST 2014


Thanks Hendrk.  It's good to know I'm not crazy or overlooking something
simple, even if the answer is not what I wanted.

I did some other experimentation last night and I'll followup with some
results, which may be interesting.

Can anyone tell me how to get the Visual Studio output to show complete
command lines, including switches, for the compiler and linker?  The
equivalent to "make VERBOSE=1"?  All the searching I've done suggests
starting Visual Studio and invoking the build from there after tweaking
some configuration, but I'm running via a remote terminal and using
devenv to start the build.  Is there no way to do this without building
from inside VS?


On Mon, 2014-02-17 at 10:20 +0100, Hendrk Sattler wrote:
> The DEPENDS above should be a MAIN_DEPENDENCY (not sure if that
> actually changes anything)

Unfortunately in my real situation, a single invocation of the generator
actually builds 43 different source and header files, and its input is a
similar (but not one-for-one) number of files.  So there's no obvious
MAIN_DEPENDENCY.  I don't think it matters, based on my reading of the
cmake docs.

My situation is even more complicated because the generator itself is a
Java program that needs to be built, by cmake, before it can be invoked
to generate the files.

> The custom target gains you nothing. The problem here are actually the
> tools: Visual Studio 10 totally relies on the custom build tool to
> protect itself when run in parallel.

Just to be clear, VS 2012 would behave the same way right?  We have had
on our project plans migrating there; if it might fix this problem we
could re-evaluate priorities.  But I expect that wouldn't matter.

> It will run the generator as many times as the bar.cpp is mentioned in
> different targets, even in parallel if that is enabled. And that's
> what you see.

That's a critical bit of information, and does indeed jibe with what I'm
seeing and what I discovered after I sent my last email.  I'll follow up
with some notes.

> Solutions:
> a) Add "cmake -E copy_if_different" to bar-static.cpp and
> bar-shared.cpp and use those (means: use generated leaf files only in
> one target).
> or
> b) Switch off the parallel (target) building in the Visual Studio 
> options (this will still generate the files multiple times)
> or
> c) Use jom (and NMake Makefiles generator)

If it were up to me I'd switch to using UNIX Makefiles and install GNU
make on the Windows systems, just because it's a known quantity (that
seems to work).  Unfortunately there are a few people who use Visual
Studio as development environments and they certainly want CMake to
generate the project files for them.



More information about the CMake mailing list