pvs-studio

Integrating PVS-Studio and CMake


I use Windows 10, QtCreator 4.7.1, CMake 3.11.4 (Ninja, CodeBlocks), MSVC 2017. Try to integrate PVS-Studio to CMake project.

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")

I get error

[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.

Any idea what to do?


Solution

  • In your CMake integration code, the 'BIN' parameter should point to the 'CompilerCommandsAnalyzer.exe' tool (under Windows) instead of the 'PVS-Studio.exe' C++ analyzer core.

    However, PVS-Studio CMake module support for Windows will become available in PVS-Studio 6.26, which is expected to be released in a couple of days. The current 6.25 release is missing this tool.

    Please check whether you have the 'CompilerCommandsAnalyzer.exe' inside your PVS-Studio installation folder ('c:\Program Files (x86)\PVS-Studio\' by default). If you do not have it, please write us at support@viva64.com, so we can give you a pre-release version to try. Or you can just wait for a 6.26 release which will become available quite soon.