[CMake] Get compiler command line (or json compilation database) for a target

Roman Popov ripopov at gmail.com
Mon Jul 30 03:12:22 EDT 2018


Hi all,

How can I get a full compiler command line for a given target in CMakeLists
project? I want to run Clang-based tool on some targets (using CTest), and
it requires same options as used during compilation.

I know there is CMAKE_EXPORT_COMPILE_COMMANDS but it is not taget-specific.

There is a similar question on stackoverflow:
https://stackoverflow.com/questions/35808209/get-full-c-compiler-command-line
Here author suggets to use get_target_property on a target.  I've tried
this, but it does not work when some properties are inherited from
libraries (for example include paths).

Do you have any ideas?

Thanks,
Roman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20180730/fa2a03e3/attachment.html>


More information about the CMake mailing list