2019-06-15 14:54:40 +00:00
|
|
|
function(add_pvs_check)
|
|
|
|
list(GET ARGN 0 _target)
|
2019-02-15 21:00:53 +00:00
|
|
|
|
2019-06-26 08:46:53 +00:00
|
|
|
if (CMAKE_EXPORT_COMPILE_COMMANDS)
|
|
|
|
include(PVS-Studio)
|
|
|
|
find_program(PVS_STUDIO_ANALYZER_EXE NAMES pvs-studio-analyzer)
|
|
|
|
if(PVS_STUDIO_ANALYZER_EXE)
|
2019-06-27 02:18:29 +00:00
|
|
|
if(NOT TARGET pvs-check)
|
|
|
|
add_custom_target(pvs-check)
|
|
|
|
endif()
|
2019-06-26 08:46:53 +00:00
|
|
|
pvs_studio_add_target(TARGET pvs-check-${_target}
|
|
|
|
DEPENDS ${_target}
|
|
|
|
COMPILE_COMMANDS
|
|
|
|
HIDE_HELP
|
|
|
|
OUTPUT FORMAT errorfile
|
2019-06-27 02:06:46 +00:00
|
|
|
CONFIG "${CMAKE_BINARY_DIR}/PVS-Studio-${_target}.cfg"
|
2019-06-26 08:46:53 +00:00
|
|
|
CFG_TEXT "analysis-mode=29"
|
|
|
|
MODE GA:1,2,3;64:1;OP:1,2;CS:1,2)
|
2019-06-27 02:18:29 +00:00
|
|
|
add_dependencies(pvs-check pvs-check-${_target})
|
2019-06-26 08:46:53 +00:00
|
|
|
else()
|
|
|
|
message(WARNING "PVS-Studio is not found")
|
|
|
|
endif()
|
2019-02-15 21:00:53 +00:00
|
|
|
else()
|
2019-06-26 08:46:53 +00:00
|
|
|
message(WARNING "Option CMAKE_EXPORT_COMPILE_COMMANDS is not set. PVS checks will be disabled.")
|
2019-02-15 21:00:53 +00:00
|
|
|
endif()
|
2019-06-15 14:54:40 +00:00
|
|
|
endfunction()
|
2019-02-15 21:00:53 +00:00
|
|
|
|