[CMake] Multiple executables sharing object files

David Cole david.cole at kitware.com
Wed Dec 19 15:52:17 EST 2007


Compilation time is only multiplied if you are specifying the same source
file in multiple targets. If you are seeing a 2x difference, then you must
have *all* of your source files listed twice. Shouldn't this only be for a
few of your source files at most?

I would argue that it's better to be correct, if a bit slower, than it is to
have a chance of being subtly incorrect and wasting hours figuring out the
subtlety. I bet you have never spent hours or days figuring out that you
should not have been re-using an .obj file, but should have recompiled it
with the flags to match the rest of the library. I have, so I appreciate
CMake's default choice in this case.


On 12/19/07, Joël Schaerer <Joel.Schaerer at insa-lyon.fr> wrote:
>
> Quoting David Cole <david.cole at kitware.com>:
>
> > One other very good reason, too:
> > Same target may have two source files of the exact same name, but they
> exist
> > in different directories (Abc/Object.cxx and Def/Object.cxx). In that
> case,
> > the object files will be further hidden in subdirectories to avoid two
> files
> > in the "object files directory" from having a name collision.
>
> Does that really justify multiplying compilation time by 2 or more?
> Who would want multiple files with the same name in the same project
> anyways? Plus, you could very well create a tree structure in the
> build directory.
>
> I must be missing something but I really don't get how compiling
> things multiple times for nothing could seem acceptable.
>
> >
> >
> > On 12/19/07, Alexander Neundorf <a.neundorf-work at gmx.net> wrote:
> >>
> >> On Wednesday 19 December 2007, you wrote:
> >> ...
> >> > Yeah, you could even create one static library per executable...
> >> > Awesome! What was the problem with putting all the object files in
> the
> >> > same directory, again? Shouldn't that be an option, at least? It
> would
> >> > be SO much easier than all the dirty hacks I'm being proposed...
> >>
> >> Different targets may be compiled with different compiler flags,
> defines,
> >> etc.
> >> So the object files for the same source files can differ. This is used
> in
> >> some projects.
> >>
> >> Alex
> >> _______________________________________________
> >> CMake mailing list
> >> CMake at cmake.org
> >> http://www.cmake.org/mailman/listinfo/cmake
> >>
> >
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20071219/789c2a05/attachment.html


More information about the CMake mailing list