[CMake] cmake output file naming

Brad King brad.king at kitware.com
Fri Aug 17 09:22:11 EDT 2012


On 8/17/2012 5:03 AM, Sumit Adhikari wrote:
> I have particular problem with the cmake generated output file naming
> conventions (like myfile.cpp.o, myfile.cpp.gcno, ....).

Object file names are computed in a deterministic manner
based only on the source file name and location.  The
object name must not conflict with that computed from any
other source file.  In order to handle

 add_executable(foo foo.c foo.cpp)

the object name must include the source extension.

The implementation is here:

 http://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmLocalGenerator.cxx;hb=v2.8.9#l2857

If you really want to avoid the extension you can set the
undocumented internal implementation detail variable:

 set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)
 set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)

some time after the project() command call that enables
the C and CXX languages.  As the variables are internal
details this will not be guaranteed to work in the future.

> These naming conventions creating trouble for me to run gcov *.cpp
> properly with my -o /objdir option

How does "*.cpp" match ".cpp.o"?

-Brad


More information about the CMake mailing list