[CMake] Is there really no way in CMake to retrieve the objects file for a target?

Emmanuel Blot eblot.ml at gmail.com
Tue Oct 28 06:59:55 EDT 2014


Hi,

I need to tweak object files for a target before linking them to the
final executable.

I'm striving for retrieving the file object paths for a target:

ADD_LIBRARY(tgt OBJECT file1.c file2.S)

1. $<TARGET_OBJECTS:tgt> is not available from
ADD_CUSTOM_COMMAND/ADD_CUSTOM_TARGET

2. Actual object paths could be deduced from the source file name, but
it seems difficult to predict the actual path when source files are
relative to the current directory: ".." is replaced with "__" for
example.

3. GET_TARGET_PROPERTY(var tgt SOURCES) provides absolute source
paths, which makes source to object file path computation impossible,
because of the ".." to "__" automatic replacement

This seems so convoluted that I guess I'm missing the proper way to
properly add an intermediate step between the compilation and link
stages, but I keep failing to find any useful advice from Google and
the mailing list.

Thanks,
Manu.


More information about the CMake mailing list