[CMake] Changing object file names

Emmanuel Blot eblot.ml at gmail.com
Tue Apr 8 04:37:17 EDT 2014


Hi,

Is there a way, in CMake, to change the pattern of the output object
files - that is for each .c compiled, the name of the output binary .o
files.
I'm not refering to the file extension, nor any library name for which
I already found answers in CMake doc, but the basename.

The issue I'm facing is that several existing libraries used the same
name for source files, and when archived into the same final library
(.a), the names of both object file collide. I cannot really keep both
.a files for several reasons.

The idea would be to add a prefix to each object file based on the
original library name, to avoid collision, that is:

liba/x.c  -> liba_x.o
liba/y.c  -> liba_y.o
libb/x.c  -> libb_x.o
libb/y.c  -> libb_y.o

final.a <-- liba_x.o, libb_x.o, libb_x.o, libb_y.o

I cannot / do not want to change the name of the source files, to ease
upstream merge.

What would be the best way to change the name of the output object
files with CMake?

Thanks,
Manu


More information about the CMake mailing list