[CMake] Get compiler command line (or json compilation database) for a target
Roman Popov
ripopov at gmail.com
Tue Jul 31 12:47:04 EDT 2018
After day of googling I've found a solution that almost works for me.
There is a CXX_CLANG_TIDY property that enables clang-tidy on a target.
https://cmake.org/cmake/help/v3.12/prop_tgt/LANG_CLANG_TIDY.html
But I can replace clang-tidy with my own Clang-based tool:
set(CLANG_TIDY_EXE ${MY_CLANG_BASED_TOOL} )
set(DO_CLANG_TIDY "${CLANG_TIDY_EXE}" " --my-additional-options")
set_target_properties(
my_exe_target PROPERTIES
CXX_CLANG_TIDY "${DO_CLANG_TIDY}"
)
The only drawback is that my tool will be run together with my_exe_target
build. And I want to run it as a separate build target.
https://stackoverflow.com/questions/51618307/how-to-run-clang-based-tool-as-a-separate-cmake-target
пн, 30 июл. 2018 г. в 0:12, Roman Popov <ripopov at gmail.com>:
> 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/20180731/43e8e856/attachment.html>
More information about the CMake
mailing list