简体   繁体   中英

How can I tell PVS-Studio to ignore all of the files in a third party library when using CMake on Linux

I am using PVS-Studio with CMake on Linux. I recently added a third party library to my project.

PVS-Studio is flagging possible issues in the header files for the third party library. How do I go about telling PVS-Studio to ignore the entire third party library when analyzing my code? When using PVS-Studio with Visual Studio on Windows I was able to do this with the PVS-Studio extension inside Visual Studio. On Linux I don't have that.

I've attached my CMakeLists.txt file to this project (it is pretty simple) plus the list of warnings emitted by PVS-Studio.

CMakeLists.txt

cmake_minimum_required(VERSION 3.15.0)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall")
project(my_project)
include_directories($ENV{HOME}/code/repo/other/GSL/include)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
set(proj_srcs main.cpp notes.txt)
add_executable(${PROJECT_NAME} ${proj_srcs})
include($ENV{HOME}/code/repo/other/pvs-studio-cmake-examples/PVS-Studio.cmake)
pvs_studio_add_target(TARGET ALL COMPILE_COMMANDS OUTPUT FORMAT errorfile)

Warnings

.../other/GSL/include/gsl/multi_span:663:1: warning: V547 Expression is always true.
.../other/GSL/include/gsl/multi_span:1163:1: warning: V560 A part of conditional expression is always true: totalSize <= (9223372036854775807L).
.../other/GSL/include/gsl/string_span:118:1: warning: V547 Expression 'cur != nullptr' is always true.

Thanks,

David

You can use this parameter:

-e [DIR], --exclude-path [DIR]
   Directory whose files are not necessary to check

CMakeLists.txt:

pvs_studio_add_target(TARGET ALL
                      COMPILE_COMMANDS
                      OUTPUT FORMAT errorfile
                      ARGS -e /path/to/third/party -e /path/to/tests)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM