CMAKE_EXPORT_COMPILE_COMMANDS, compile_commands.json content

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

CMAKE_EXPORT_COMPILE_COMMANDS, compile_commands.json content

Martin Weber-2
Hi all,

in the generated compile_commands.json, what are the quoting rules in the
command fields?
Apart from the fact that a quotation mark in json inside a value has to be
escaped as *\"*, do the arguments in the command-field follow the shell-
escape rules or do they reflect the arguments passed to exec(1).

Seeing a line in my compile_commands.json starting with

"command": "/usr/bin/c++ -Dprojectname_ROOT_DIR=\\\"/home/username/workspace/

is confusing. What exactly is the value of macro projectname_ROOT_DIR here? A
string literal?

OTOH, the same line has


which I do recognize as a macro value of string literal type.

Background: My tool tries to get the macro definition from the  
compile_commands.json file [1]



Cd wrttn wtht vwls s mch trsr.


Powered by

Please keep messages on-topic and check the CMake FAQ at:

Kitware offers various services to support the CMake community. For more information on each offering, please visit:

CMake Support:
CMake Consulting:
CMake Training Courses:

Visit other Kitware open-source projects at

Follow this link to subscribe/unsubscribe: