[CMake] Remove Source Suffix from Object

Yanbo Zhu (yanbzhu) yanbzhu at cisco.com
Wed Sep 3 11:10:02 EDT 2014


Environment: Centos 64bit

Question is: Currently, the makefiles generated by cmake generate object files that contains the source suffix (.c, .cpp), for example do_stuff.c gets compiled to do_stuff.c.o. How do I change it so that cmake generates makefiles that generates do_stuff.o (without the .c)

Some Background:
I’m trying to set up a project to generate code coverage. The issue I’m running into now is that the .gcno and .gcda files that are generated at compile and runtime contain the source file suffixes. For Example:

Cmake generates a makefile to compile do_stuff.c. When I run make, it generates do_stuff.c.o. This then generates do_stuff.c.gcno. When I run the unit test, it generates do_stuff.c.gcda.

On the surface, this isn’t a problem. However, we are using cobertura, which uses gcov, which assumes that the the coverage file names do not contain the suffix. That is, it wants do_stuff.gcda and do_stuff.gcno. By default, gcovr cannot find any coverage or run files, and so the code coverage is broken.

If I manually run the compile command and set the –o to do_stuff.o (as opposed to do_stuff.c.o) it all works as expected.

I can think of some linux script hacks that I can run to do all sorts of softlink magic to get it to work, but ideally I’d like to fix this within cmake.

Thank you,
-Dave


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20140903/1c5c91ce/attachment.html>


More information about the CMake mailing list