如何指定与CMAKE_CXX_CLANG_TIDY变量一起使用的其他参数 [英] How can I specify additional arguments for use with CMAKE_CXX_CLANG_TIDY variable
问题描述
我正在尝试使用 clang-tidy 与< a href = https://cmake.org/cmake/help/v3.6/variable/CMAKE_LANG_CLANG_TIDY.html rel = nofollow noreferrer> cmake ,我想通过 -check
参数。我尝试在调用cmake时添加 -DCMAKE_CXX_CLANG_TIDY = / usr / local / opt / llvm38 / bin / clang-tidy-3.8; -checks = *
makefile命令最终看起来像这样:
I'm trying to use make use of clang-tidy integration with cmake and I'd like to pass the -check
argument. I've tried adding -DCMAKE_CXX_CLANG_TIDY="/usr/local/opt/llvm38/bin/clang-tidy-3.8;-checks=*"
when invoking cmake, but my makefile commands end-up looking like:
/usr/local/Cellar/cmake/3.6.2/bin/cmake- E __run_iwyu --tidy = / usr / local / opt / llvm38 / bin / clang-tidy-3.8; -checks = * --source = / Users / ellery / work / ....
换句话说,它看起来像是;;分隔的args不会被解析。我还尝试将目标属性 CXX_CLANG_TIDY
直接设置为具有相同值的目标,并且得到相同的行为。
in other words, it seems like the ; separated args are not being parsed apart. I've also tried setting the target property CXX_CLANG_TIDY
directly on my target with the same value and I get the same behavior.
有人通过cmake成功调用 clang-tidy
以及其他args吗?
Has anyone succesfully invoked clang-tidy
with additional args through cmake?
推荐答案
它在cmake 3.7.2和clang-tidy 4.0中可以正常工作。
It works as expected with cmake 3.7.2 and clang-tidy 4.0.
例如直接在命令行上指定:
E.g. directly specifying on the command line:
cmake -DCMAKE_CXX_CLANG_TIDY="clang-tidy;-style=file;-checks=*"
或在CMakeLists.txt中:
or in the CMakeLists.txt:
set(CMAKE_CXX_CLANG_TIDY "clang-tidy;-style=file;-checks=*")
您必须确保 clang-tidy
参数正确,否则似乎会无声地失败。
You have to make sure that the clang-tidy
arguments are correct, otherwise it seems to fail silently.
这篇关于如何指定与CMAKE_CXX_CLANG_TIDY变量一起使用的其他参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!