集成 PVS-Studio 和 CMake
Integrating PVS-Studio and CMake
我使用Windows10、QtCreator 4.7.1、CMake 3.11.4(Ninja、CodeBlocks)、MSVC 2017。尝试将PVS-Studio集成到CMake项目中。
cmake_minimum_required(VERSION 3.10)
project(tst CXX)
add_executable(${PROJECT_NAME} main.cpp)
include(PVS-Studio.cmake)
pvs_studio_add_target(
TARGET ${PROJECT_NAME}.analyze ALL
OUTPUT FORMAT errorfile
ANALYZE ${PROJECT_NAME}
BIN "C:/Program Files (x86)/PVS-Studio/x64/PVS-Studio.exe")
我收到错误
[3/6 4.2/sec] Generating PVS-Studio.cfg
[4/6 5.1/sec] Analyzing CXX file main.cpp
FAILED: PVS-Studio/main.cpp.plog
cmd.exe /C "cd /D D:\work\v2.0\ui_tools\build-tst-Desktop_Qt_5_11_2_MSVC2017_64bit-u041eu0442u043bu0430u0434u043au0430 && "C:\Program Files\CMake\bin\cmake.exe" -E make_directory D:/work/v2.0/ui_tools/build-tst-Desktop_Qt_5_11_2_MSVC2017_64bit-u041eu0442u043bu0430u0434u043au0430/PVS-Studio && "C:\Program Files\CMake\bin\cmake.exe" -E remove_directory D:/work/v2.0/ui_tools/build-tst-Desktop_Qt_5_11_2_MSVC2017_64bit-u041eu0442u043bu0430u0434u043au0430/PVS-Studio/main.cpp.plog && "C:\Program Files\CMake\bin\cmake.exe" -D PVS_STUDIO_AS_SCRIPT=TRUE -D "PVS_STUDIO_COMMAND=C:/Program Files (x86)/PVS-Studio/x64/PVS-Studio.exe;analyze;--output-file;D:/work/v2.0/ui_tools/build-tst-Desktop_Qt_5_11_2_MSVC2017_64bit-u041eu0442u043bu0430u0434u043au0430/PVS-Studio/main.cpp.plog;--source-file;D:/work/v2.0/ui_tools/tst/main.cpp;--dep-file;D:/work/v2.0/ui_tools/build-tst-Desktop_Qt_5_11_2_MSVC2017_64bit-u041eu0442u043bu0430u0434u043au0430/PVS-Studio/main.cpp.plog.d;--dep-file-target;PVS-Studio/main.cpp.plog;--cfg;D:/work/v2.0/ui_tools/build-tst-Desktop_Qt_5_11_2_MSVC2017_64bit-u041eu0442u043bu0430u0434u043au0430/PVS-Studio.cfg;--platform;x64;--preprocessor;visualcpp;--cxx;C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/HostX86/x64/cl.exe;--cc;C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/HostX86/x64/cl.exe;--cl-params;;;-DPVS_STUDIO;D:/work/v2.0/ui_tools/tst/main.cpp" -P D:/work/v2.0/ui_tools/tst/PVS-Studio.cmake"
CMake Error at D:/work/v2.0/ui_tools/tst/PVS-Studio.cmake:46 (message):
Incorrect parameter syntax: An unknown parameter is present in the command
line: dep-file.
知道要做什么吗?
在您的 CMake 集成代码中,'BIN' 参数应指向 'CompilerCommandsAnalyzer.exe' 工具(在 Windows 下)而不是 'PVS-Studio.exe' C++ 分析器核心。
但是,PVS-Studio CMake 模块对 Windows 的支持将在 PVS-Studio 6.26 中可用,预计将在几天内发布。当前的 6.25 版本缺少此工具。
请检查您的 PVS-Studio 安装文件夹中是否有 'CompilerCommandsAnalyzer.exe'(默认为 'c:\Program Files (x86)\PVS-Studio\')。如果您没有,请写信给我们 support@viva64.com,这样我们就可以给您一个预发布版本来试用。或者您可以等待 6.26 版本,它很快就会发布。
我使用Windows10、QtCreator 4.7.1、CMake 3.11.4(Ninja、CodeBlocks)、MSVC 2017。尝试将PVS-Studio集成到CMake项目中。
cmake_minimum_required(VERSION 3.10)
project(tst CXX)
add_executable(${PROJECT_NAME} main.cpp)
include(PVS-Studio.cmake)
pvs_studio_add_target(
TARGET ${PROJECT_NAME}.analyze ALL
OUTPUT FORMAT errorfile
ANALYZE ${PROJECT_NAME}
BIN "C:/Program Files (x86)/PVS-Studio/x64/PVS-Studio.exe")
我收到错误
[3/6 4.2/sec] Generating PVS-Studio.cfg
[4/6 5.1/sec] Analyzing CXX file main.cpp
FAILED: PVS-Studio/main.cpp.plog
cmd.exe /C "cd /D D:\work\v2.0\ui_tools\build-tst-Desktop_Qt_5_11_2_MSVC2017_64bit-u041eu0442u043bu0430u0434u043au0430 && "C:\Program Files\CMake\bin\cmake.exe" -E make_directory D:/work/v2.0/ui_tools/build-tst-Desktop_Qt_5_11_2_MSVC2017_64bit-u041eu0442u043bu0430u0434u043au0430/PVS-Studio && "C:\Program Files\CMake\bin\cmake.exe" -E remove_directory D:/work/v2.0/ui_tools/build-tst-Desktop_Qt_5_11_2_MSVC2017_64bit-u041eu0442u043bu0430u0434u043au0430/PVS-Studio/main.cpp.plog && "C:\Program Files\CMake\bin\cmake.exe" -D PVS_STUDIO_AS_SCRIPT=TRUE -D "PVS_STUDIO_COMMAND=C:/Program Files (x86)/PVS-Studio/x64/PVS-Studio.exe;analyze;--output-file;D:/work/v2.0/ui_tools/build-tst-Desktop_Qt_5_11_2_MSVC2017_64bit-u041eu0442u043bu0430u0434u043au0430/PVS-Studio/main.cpp.plog;--source-file;D:/work/v2.0/ui_tools/tst/main.cpp;--dep-file;D:/work/v2.0/ui_tools/build-tst-Desktop_Qt_5_11_2_MSVC2017_64bit-u041eu0442u043bu0430u0434u043au0430/PVS-Studio/main.cpp.plog.d;--dep-file-target;PVS-Studio/main.cpp.plog;--cfg;D:/work/v2.0/ui_tools/build-tst-Desktop_Qt_5_11_2_MSVC2017_64bit-u041eu0442u043bu0430u0434u043au0430/PVS-Studio.cfg;--platform;x64;--preprocessor;visualcpp;--cxx;C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/HostX86/x64/cl.exe;--cc;C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Tools/MSVC/14.15.26726/bin/HostX86/x64/cl.exe;--cl-params;;;-DPVS_STUDIO;D:/work/v2.0/ui_tools/tst/main.cpp" -P D:/work/v2.0/ui_tools/tst/PVS-Studio.cmake"
CMake Error at D:/work/v2.0/ui_tools/tst/PVS-Studio.cmake:46 (message):
Incorrect parameter syntax: An unknown parameter is present in the command
line: dep-file.
知道要做什么吗?
在您的 CMake 集成代码中,'BIN' 参数应指向 'CompilerCommandsAnalyzer.exe' 工具(在 Windows 下)而不是 'PVS-Studio.exe' C++ 分析器核心。
但是,PVS-Studio CMake 模块对 Windows 的支持将在 PVS-Studio 6.26 中可用,预计将在几天内发布。当前的 6.25 版本缺少此工具。
请检查您的 PVS-Studio 安装文件夹中是否有 'CompilerCommandsAnalyzer.exe'(默认为 'c:\Program Files (x86)\PVS-Studio\')。如果您没有,请写信给我们 support@viva64.com,这样我们就可以给您一个预发布版本来试用。或者您可以等待 6.26 版本,它很快就会发布。