compile_commands.json broken with @ characters
What's the problem?
The Unix Makefiles generator removes any occurrences of the character
@ from the compile command. In our case, this is a problem because some of our workspaces contain this sign and hence the resulting
compile_commands.json is faulty. (Jenkins is implemented in a way that if multiple jobs run on the same worker node, it will create additional workspaces with the suffix
@2, and so on.
In our setup, only the compile_commands.json is affected, not any of the other generated files.
How to reproduce?
The problem occurred with:
- CMake V3.17
- A workspace with a
@in the name
- On a windows host (probably unrelated)
- During Crosscompiling for an embedded target (probably unrelated)
Where does it come from?
The code responsible for removing the character was introduced in !2648 (merged), when trying to resolve #17482 (closed).
The motivation of this changeset was to remove the non-json-conformant response file syntax from the compile commands. However, for my usecase, it also modifies my filepaths, because
CMAKE_START_TEMP_FILE evaluates to
CMAKE_END_TEMP_FILE evaluates to
As far as I can tell, this behaviour was first introduced in
v3.14.0 and persists since then.
I am not sure how to solve it. The original problem ticket only talks about NMake files, so it might be a solution to check the generator type and only remove the characters for NMake. Or do Unix Makefiles support some kind of response file aswell?
Alternatively the check could be extended to only search for occurances of
@ (space or tab before the character). I wasn't able to figure out though, where the default for
CMAKE_START_TEMP_FILE is set.