<div class="gmail_quote">On Wed, Mar 18, 2009 at 7:05 PM, Alexander Neundorf <span dir="ltr"><<a href="mailto:a.neundorf-work@gmx.net">a.neundorf-work@gmx.net</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im">On Wednesday 18 March 2009, Denis Scherbakov wrote:<br>
> You could do the following:<br>
><br>
> ADD_LIBRARY(intermediate STATIC a.cpp)<br>
><br>
> ADD_LIBRARY(foo b.cpp)<br>
> TARGET_LINK_LIBRARIES(foo intermediate)<br>
><br>
> ADD_LIBRARY(bar c.cpp)<br>
> TARGET_LINK_LIBRARIES(bar intermediate)<br>
<br>
</div>That's not portable if bar and foo are shared libraries.<br>
See it as a feature that cmake recognizes that these files have to be compiled<br>
separately for separate targets, since separate targets may have other<br>
compile flags etc, so may need different object files.<br></blockquote><div><br>In theory the Makefile generator could be adapted to share object files across targets provided all the compilation flags are the same. This would obviously take time and introduce additional complexity. It would also be of limited benefit since usually source files are not compiled in more than one library or executable.<br>
<br>Also, in theory you could reuse object files compiled for a shared library (with -fPIC) in static libraries (on certain platforms). Since preprocessor definitions usually always change per target when using shared libraries due to export definitions, however, this would also be of limited benefit.<br>
</div></div><br>-- <br>Philip Lowman<br>