[cmake-developers] Cannot control the name of dependfile set in Ninja generator

Claus Klein claus.klein at arcormail.de
Thu Jan 18 16:14:19 EST 2018


Hi all,
I have problems to send and see this mail at the list? Please can you check what goes wrong?
There was a mail with this issue a view years ago, but without a real result:
https://cmake.org/pipermail/cmake/2014-October/058963.html <https://cmake.org/pipermail/cmake/2014-October/058963.html>
quote:
————————————————————————————————————————————-
Ninja generator sets the name to objectpath.d
            cmGlobalNinjaGenerator::EncodeDepfileSpace(objectFileName + ".d");

WindRiver sets the dep file name to objectDir/SourceName.d, so the ".obj" in "DEP_FILE = path/BaseName.c.obj.d" must be removed
Armcc just uses base name in the same directory as the command runs, "BaseName.d".  -depend_dir= can be used to control the directory for C but not asm.

The workaround is to patch the generated build.ninja

A proper solution is using new variables similar to above. (Just examples, not figured out <ARCH> etc)

WindRiver (not added to CMake):
SET (CMAKE_<LANG>_<COMPILER_ID>_DEPFILE_PATTERN <OBJECT_DIR>/<SOURCE_FILE_NAME>.d )

Armcc (RVDS patch exists for CMake):
SET (CMAKE_DEPFILE_FLAGS_C -depend_dir=<OBJECT_FULL_DIR> --depend_format=unix)
SET (CMAKE_C_ARMCC_DEPFILE_PATTERN <OBJECT_FULL_DIR>/<SOURCE_BASE_NAME>.d )
SET (CMAKE_DEPFILE_FLAGS_ASM --depend_format=unix)
SET (CMAKE_ASM_ARMCC_DEPFILE_PATTERN <SOURCE_BASE_NAME>.d )

Note: <OBJECT> is replaced in CMAKE_C_ARMCC_DEPFILE_PATTERN (but adding a semicolon), but not <OBJECT_DIR> (as that is evaluated after FLAGS/DEFINES) so it is a little more than just add new variables.
The workaround for armcc could therefore not use CMAKE_DEPFILE_FLAGS_C, the -depend_dir flag was added to normal FLAGS
———————————————————————————————-

I have the same problem with a GHS compiler. We can’t control the name of the generated *.d file while compile step.
My questions are:

1.) Is ist possible to change the object or/and the dependency file name generated for ninja?

2.) Why generates cmake the objectname as sourcefilename.{c,cpp}.obj?

I would expect to build the name as GNU make do, something like that:
DEP:=$(SRC:.cpp=.d)
OBJ:=$(SRC:.cpp=.obj)

Claus Klein




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake-developers/attachments/20180118/ead5a68e/attachment.html>


More information about the cmake-developers mailing list