[CMake] Reusing an already built object

Alexander Neundorf a.neundorf-work at gmx.net
Tue Oct 13 13:55:52 EDT 2009


On Tuesday 13 October 2009, Naram Qashat wrote:
> Say I have a main executable and a number of shared libraries that rely on
> that executable.  Say I have a certain C++ source that is required to be
> built by not only the main executable, but also every single shared library
> (the source in question is a Windows-specific file to handle memory
> allocations).  I have found that when using a Visual Studio generator,
> CMake causes the source file to be rebuilt for every single shared library,
> causing an increase in build time.  Is there an easy way to have the object
> file not be rebuilt every single time, but be reused for all the shared
> libraries?  

No, it's a feature.
You may use different compile flags etc. for your different targets, so you 
may get different object files.

You may hack around that by creating a static library, figuring out the path 
to the object files and then link these object files directly to your targets 
(or something like that, but I've never done that and I don't recommend it).

Alex




More information about the CMake mailing list