[CMake] retrieve the path of an object file

Michael Hertling mhertling at online.de
Fri Jan 14 09:59:30 EST 2011


On 01/14/2011 12:17 PM, Andrea Galeazzi wrote:
> Given a source file (path/foo.c),  does CMake provide a way to retrieve 
> the obj file path/filename generate by the compiler?

With the Makefile generators, you might use the RULE_LAUNCH properties
to intercept the compiling/linking phase, including to influence where
the object files are written to and read from, but this is of limited
portability, error-prone and should be considered only in very special
cases, see [1]. Alternatively, you could try to rewrite variables like
CMAKE_<LANG>_COMPILE_OBJECT and friends to achieve your goal, but the
same objections apply here, too, cf. [2].

Regards,

Michael

[1] http://www.mail-archive.com/cmake@cmake.org/msg29622.html
[2] http://www.mail-archive.com/cmake@cmake.org/msg31533.html


More information about the CMake mailing list