how to build generated sources in parallel with out linking them together?

Brad King brad.king at kitware.com
Thu Feb 22 00:21:48 CET 2007


Thiago Macieira wrote:
> Since that's just an empty file and will produce hardly any symbols, 
> there's no need to link.

One solution is to build the sources in a static library.  The archiver
does not care about symbol resolution since it does not really link
anything:

ADD_LIBRARY(check_compile STATIC src1.cxx src2.cxx)

In order to avoid the time actually spent archiving you can remove the
object files from the link rule:

STRING(REGEX REPLACE "<OBJECTS[^>]*>" ""
       CMAKE_CXX_CREATE_STATIC_LIBRARY
       "${CMAKE_CXX_CREATE_STATIC_LIBRARY}")

which causes the target to be created as an empty archive for all the
Makefile generators.  This should be done in its own subdirectory though
so that the link rule is not broken for other directories.

For the VS IDE generators there does not seem to be a way to compile
sources without archiving them, but since the objects contain only a few
symbols they should not be too big.

-Brad


More information about the Kde-buildsystem mailing list