MantisBT - CMake
View Issue Details
0015952CMakeCMakepublic2016-02-03 20:132016-06-10 14:31
Chaoren Lin 
Kitware Robot 
normalminoralways
closedmoved 
CMake 3.4.2 
 
0015952: '$' becomes '$$' in compile_commands.json
If your compile command contains a '$' character, it'll be incorrectly emitted as '$$' in compile_commands.json if CMAKE_EXPORT_COMPILE_COMMANDS is enabled.
1) extract example.zip
2) cd example && cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=True .
3) make VERBOSE=1
4) see that the compile command is

/usr/bin/cc -DFOO="\"\$\"" -o CMakeFiles/foo.dir/foo.c.o -c /tmp/cmake/foo.c

5) open up compile_commands.json
6) see

"command": "/usr/bin/cc -DFOO=\"\\\"\\$$\\\"\" -o CMakeFiles/foo.dir/foo.c.o -c /tmp/cmake/foo.c"

which is wrong, since it should be $ instead of $$.
No tags attached.
zip example.zip (457) 2016-02-03 20:13
https://public.kitware.com/Bug/file/5626/example.zip
Issue History
2016-02-03 20:13Chaoren LinNew Issue
2016-02-03 20:13Chaoren LinFile Added: example.zip
2016-02-04 08:36Brad KingNote Added: 0040439
2016-06-10 14:29Kitware RobotNote Added: 0042932
2016-06-10 14:29Kitware RobotStatusnew => resolved
2016-06-10 14:29Kitware RobotResolutionopen => moved
2016-06-10 14:29Kitware RobotAssigned To => Kitware Robot
2016-06-10 14:31Kitware RobotStatusresolved => closed

Notes
(0040439)
Brad King   
2016-02-04 08:36   
The compile commands are generated here:

 https://cmake.org/gitweb?p=cmake.git;a=blob;f=Source/cmMakefileTargetGenerator.cxx;hb=v3.4.3#l638 [^]

Trace from there to see where it gets the values. Some of the code paths may be meant for generating Makefile content and is applying the relevant escapes.
(0042932)
Kitware Robot   
2016-06-10 14:29   
Resolving issue as `moved`.

This issue tracker is no longer used. Further discussion of this issue may take place in the current CMake Issues page linked in the banner at the top of this page.