在编译嵌入式目标时,我使用CMake运行clang-tidy。
if(CLANG_TIDY)
set(CMAKE_CXX_CLANG_TIDY "clang-tidy")
endif()
CMake自动设置正确的驱动程序模式:
--tidy="clang-tidy;--extra-arg-before=--driver-mode=g++"
但由于这是一个嵌入式目标,它有一些clang-tydy无法识别的参数。
我希望它能正常编译,并且clang-ticky会使用编译数据库来lint代码。
是否缺少设置?
完整的错误消息如下:
/cmake/bin/cmake -E __run_co_compile --tidy="clang-tidy;--extra-arg-before=--driver-mode=g++" --source=/workspaces/project/Core/Src/src/factorial.cpp -- /opt/gcc-arm-none-eabi/bin/arm-none-eabi-g++ -DARM_MATH_CM4 -DARM_MATH_MATRIX_CHECK -DARM_MATH_ROUNDING -DSTM32H723xx -DUSE_HAL_DRIVER -I/workspaces/project/Core/Inc -I/workspaces/project/Core/Src/src -I/workspaces/project/Drivers/CMSIS/Device/ST/STM32H7xx/Include -I/workspaces/project/Drivers/CMSIS/Include -I/workspaces/project/Drivers/STM32H7xx_HAL_Driver/Inc/Legacy -I/workspaces/project/Drivers/STM32H7xx_HAL_Driver/Inc -g -mcpu=cortex-m7 -ffunction-sections -fdata-sections -fno-common -fmessage-length=0 -mfloat-abi=hard -mfpu=fpv4-sp-d16 -Og -g -std=c++20 -MD -MT CMakeFiles/project.elf.dir/Core/Src/src/factorial.cpp.obj -MF CMakeFiles/project.elf.dir/Core/Src/src/factorial.cpp.obj.d -o CMakeFiles/project.elf.dir/Core/Src/src/factorial.cpp.obj -c /workspaces/project/Core/Src/src/factorial.cpp
[build] error: argument unused during compilation: '-mcpu=cortex-m7' [clang-diagnostic-unused-command-line-argument,-warnings-as-errors]
[build] error: argument unused during compilation: '-mfloat-abi=hard' [clang-diagnostic-unused-command-line-argument,-warnings-as-errors]
[build] error: argument unused during compilation: '-mfpu=fpv4-sp-d16' [clang-diagnostic-unused-command-line-argument,-warnings-as-errors]
[build] 4 warnings generated.
[build] Suppressed 2 warnings (1 in non-user code, 1 NOLINT).
[build] Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
[build] 3 warnings treated as errors
1条答案
按热度按时间wdebmtf21#
你可能想在安静模式下运行clang-ticky,但是它也会忽略其他警告。