[CMake] multiple project hsaring the same files.

Amitha Perera perera at cs.rpi.edu
Wed Sep 28 09:19:26 EDT 2005


A simple extension to allow object files to be shared is to allow .o
files to be added to the library directly. So:

ADD_LIBRARY( A file.c )
ADD_LIBRARY( B file.c )

would cause file.c to be compiled twice.

ADD_LIBRARY( A file.c )
ADD_LIBRARY( B file.o )

would cause libB to reuse the existing .o file.

ADD_LIBRARY( A file.c )
ADD_LIBRARY( B file.o )
ADD_LIBRARY( C file.o )

would cause the object file to be reused twice.

ADD_LIBRARY( A file.c )
ADD_LIBRARY( B file.c )
ADD_LIBRARY( C file.o )

is ambiguious, and is flagged as an error.

To get more exotic, maybe some syntax for disambiguating in the
latter case:

ADD_LIBRARY( A file.c )
ADD_LIBRARY( B file.c )
ADD_LIBRARY( C {B}file.o )

would cause libC to use the file.o generated for libB.

It'll probably be difficult to come up with a clean implementation for
reusing object files generated by a different CMakeLists.txt file, so
probably that should not be allowed.

Amitha.


More information about the CMake mailing list