Ninja: Use as dependency file <objectDir/SourceName>.d if needed.
<objectDir/SourceName>.d
if needed
Use a dependency file name like Motivation
gcov, lcov
I have a particular problem with the cmake generated output file naming conventions (like myfile.cpp.o, myfile.cpp.gcno, ....).
These naming conventions creating trouble for me to run gcov *.cpp
properly
with my -o /objdir option (I had to copy them in the same directory without
the .ccp extensions every time!).
see https://cmake.org/pipermail/cmake/2012-August/051628.html
Ancient cross compiler
The C compiler test fails because CMake insists on createing testCCompiler.c.r30 and there doesn't seem to be way to tell it to not include the source file name extension (here: .c) into the object file name.
However, the linker takes the first dot as extension (I know that this is horribly broken) and only takes files that have ".r30" as extension. ".c.r30" is an illegal extension.
see https://cmake.org/pipermail/cmake/2008-April/021057.html
More proprietary compilers
Ninja generator sets the name to objectpath.d::
''cmGlobalNinjaGenerator::EncodeDepfileSpace(objectFileName + ".d");''
WindRiver sets the dependency file name to objectDir/SourceName.d, so the ".obj" in "DEP_FILE = path/BaseName.c.obj.d" must be renamed!
see https://cmake.org/pipermail/cmake/2014-October/058963.html
GHS compiler too
Wenn using the Ninja generator to build with GHS compiler for Integrity targets, we have the same problem. We can NOT control the name of the generated dependency ".d" file while compile step!
"DEP_FILE = path/BaseName.d" has to be used!
see https://cmake.org/pipermail/cmake-developers/2018-January/030532.html
Solution
If we really want to avoid the extension we can set the undocumented internal implementation detail variable::
set(CMAKE_C_OUTPUT_EXTENSION_REPLACE 1)
set(CMAKE_CXX_OUTPUT_EXTENSION_REPLACE 1)
set(CMAKE_C_DEPFILE_EXTENSION_REPLACE 1)
set(CMAKE_CXX_DEPFILE_EXTENSION_REPLACE 1)
some time after the project() command call that enables the C and CXX languages.
Patch needed
Change the Nina generator at
void cmNinjaTargetGenerator::WriteObjectBuildStatement()
Caveat
As the variables are internal details this will not be guaranteed to work in the future!
Topic-rename: ninja-depfile-name