[CMake] preventing redundant compilations

Alexander Neundorf a.neundorf-work at gmx.net
Wed Mar 18 19:05:14 EDT 2009


On Wednesday 18 March 2009, Denis Scherbakov wrote:
> You could do the following:
>
> ADD_LIBRARY(intermediate STATIC a.cpp)
>
> ADD_LIBRARY(foo b.cpp)
> TARGET_LINK_LIBRARIES(foo intermediate)
>
> ADD_LIBRARY(bar c.cpp)
> TARGET_LINK_LIBRARIES(bar intermediate)

That's not portable if bar and foo are shared libraries.
See it as a feature that cmake recognizes that these files have to be compiled 
separately for separate targets, since separate targets may have other 
compile flags etc, so may need different object files.

Alex


More information about the CMake mailing list