Обновление модуля PVS-Studio
This commit is contained in:
parent
366902c0a3
commit
06f7013273
42
MyxCMake/thirdparty/PVS-Studio.cmake
vendored
42
MyxCMake/thirdparty/PVS-Studio.cmake
vendored
@ -3,7 +3,7 @@
|
|||||||
#
|
#
|
||||||
# Version 12
|
# Version 12
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 2.8.12)
|
cmake_minimum_required(VERSION 3.0.0)
|
||||||
cmake_policy(SET CMP0054 NEW)
|
cmake_policy(SET CMP0054 NEW)
|
||||||
|
|
||||||
if (PVS_STUDIO_AS_SCRIPT)
|
if (PVS_STUDIO_AS_SCRIPT)
|
||||||
@ -32,6 +32,7 @@ if (PVS_STUDIO_AS_SCRIPT)
|
|||||||
endif ()
|
endif ()
|
||||||
endforeach ()
|
endforeach ()
|
||||||
|
|
||||||
|
file(REMOVE "${PVS_STUDIO_LOG_FILE}")
|
||||||
execute_process(COMMAND ${PVS_STUDIO_COMMAND} ${additional_args}
|
execute_process(COMMAND ${PVS_STUDIO_COMMAND} ${additional_args}
|
||||||
RESULT_VARIABLE result
|
RESULT_VARIABLE result
|
||||||
OUTPUT_VARIABLE output
|
OUTPUT_VARIABLE output
|
||||||
@ -58,10 +59,14 @@ function (pvs_studio_log TEXT)
|
|||||||
endfunction ()
|
endfunction ()
|
||||||
|
|
||||||
function (pvs_studio_relative_path VAR ROOT FILEPATH)
|
function (pvs_studio_relative_path VAR ROOT FILEPATH)
|
||||||
|
if (WIN32)
|
||||||
|
STRING(REGEX REPLACE "\\\\" "/" ROOT ${ROOT})
|
||||||
|
STRING(REGEX REPLACE "\\\\" "/" FILEPATH ${FILEPATH})
|
||||||
|
endif()
|
||||||
set("${VAR}" "${FILEPATH}" PARENT_SCOPE)
|
set("${VAR}" "${FILEPATH}" PARENT_SCOPE)
|
||||||
if ("${FILEPATH}" MATCHES "^/.*$" OR "${FILEPATH}" MATCHES "^.:/.*$")
|
if (IS_ABSOLUTE "${FILEPATH}")
|
||||||
file(RELATIVE_PATH RPATH "${ROOT}" "${FILEPATH}")
|
file(RELATIVE_PATH RPATH "${ROOT}" "${FILEPATH}")
|
||||||
if (NOT "${RPATH}" MATCHES "^\\.\\..*$")
|
if (NOT IS_ABSOLUTE "${RPATH}")
|
||||||
set("${VAR}" "${RPATH}" PARENT_SCOPE)
|
set("${VAR}" "${RPATH}" PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
@ -96,7 +101,7 @@ macro (pvs_studio_append_flags_from_property CXX C DIR PREFIX)
|
|||||||
endmacro ()
|
endmacro ()
|
||||||
|
|
||||||
macro (pvs_studio_append_standard_flag FLAGS STANDARD)
|
macro (pvs_studio_append_standard_flag FLAGS STANDARD)
|
||||||
if ("${STANDARD}" MATCHES "^(99|11|14|17)$")
|
if ("${STANDARD}" MATCHES "^(99|11|14|17|20)$")
|
||||||
if ("${PVS_STUDIO_PREPROCESSOR}" MATCHES "gcc|clang")
|
if ("${PVS_STUDIO_PREPROCESSOR}" MATCHES "gcc|clang")
|
||||||
list(APPEND "${FLAGS}" "-std=c++${STANDARD}")
|
list(APPEND "${FLAGS}" "-std=c++${STANDARD}")
|
||||||
endif ()
|
endif ()
|
||||||
@ -205,8 +210,9 @@ function (pvs_studio_analyze_file SOURCE SOURCE_DIR BINARY_DIR)
|
|||||||
|
|
||||||
string(REPLACE ";" "$<SEMICOLON>" cmdline "${cmdline}")
|
string(REPLACE ";" "$<SEMICOLON>" cmdline "${cmdline}")
|
||||||
set(pvscmd "${CMAKE_COMMAND}"
|
set(pvscmd "${CMAKE_COMMAND}"
|
||||||
-D PVS_STUDIO_AS_SCRIPT=TRUE
|
-D "PVS_STUDIO_AS_SCRIPT=TRUE"
|
||||||
-D "PVS_STUDIO_COMMAND=${cmdline}"
|
-D "PVS_STUDIO_COMMAND=${cmdline}"
|
||||||
|
-D "PVS_STUDIO_LOG_FILE=${LOG}"
|
||||||
-P "${PVS_STUDIO_SCRIPT}"
|
-P "${PVS_STUDIO_SCRIPT}"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -513,10 +519,14 @@ function (pvs_studio_add_target)
|
|||||||
if ("${PVS_STUDIO_FORMAT}" STREQUAL "")
|
if ("${PVS_STUDIO_FORMAT}" STREQUAL "")
|
||||||
set(PVS_STUDIO_FORMAT "errorfile")
|
set(PVS_STUDIO_FORMAT "errorfile")
|
||||||
endif ()
|
endif ()
|
||||||
|
set(converter_no_help "")
|
||||||
|
if (PVS_STUDIO_HIDE_HELP)
|
||||||
|
set(converter_no_help "--noHelpMessages")
|
||||||
|
endif()
|
||||||
list(APPEND COMMANDS
|
list(APPEND COMMANDS
|
||||||
COMMAND "${CMAKE_COMMAND}" -E remove -f "${PVS_STUDIO_LOG}.pvs.raw"
|
COMMAND "${CMAKE_COMMAND}" -E remove -f "${PVS_STUDIO_LOG}.pvs.raw"
|
||||||
COMMAND "${CMAKE_COMMAND}" -E rename "${PVS_STUDIO_LOG}" "${PVS_STUDIO_LOG}.pvs.raw"
|
COMMAND "${CMAKE_COMMAND}" -E rename "${PVS_STUDIO_LOG}" "${PVS_STUDIO_LOG}.pvs.raw"
|
||||||
COMMAND "${PVS_STUDIO_CONVERTER}" "${PVS_STUDIO_CONVERTER_ARGS}" -t "${PVS_STUDIO_FORMAT}" "${PVS_STUDIO_LOG}.pvs.raw" -o "${PVS_STUDIO_LOG}" -a "${PVS_STUDIO_MODE}"
|
COMMAND "${PVS_STUDIO_CONVERTER}" "${PVS_STUDIO_CONVERTER_ARGS}" ${converter_no_help} -t "${PVS_STUDIO_FORMAT}" "${PVS_STUDIO_LOG}.pvs.raw" -o "${PVS_STUDIO_LOG}" -a "${PVS_STUDIO_MODE}"
|
||||||
)
|
)
|
||||||
if(NOT PVS_STUDIO_KEEP_COMBINED_PLOG)
|
if(NOT PVS_STUDIO_KEEP_COMBINED_PLOG)
|
||||||
list(APPEND COMMANDS COMMAND "${CMAKE_COMMAND}" -E remove -f "${PVS_STUDIO_LOG}.pvs.raw")
|
list(APPEND COMMANDS COMMAND "${CMAKE_COMMAND}" -E remove -f "${PVS_STUDIO_LOG}.pvs.raw")
|
||||||
@ -544,9 +554,7 @@ function (pvs_studio_add_target)
|
|||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
if (PVS_STUDIO_OUTPUT)
|
if (PVS_STUDIO_OUTPUT)
|
||||||
if (PVS_STUDIO_HIDE_HELP AND NOT WIN32)
|
if (WIN32)
|
||||||
set(COMMANDS COMMAND grep -v " error: Help:" ${PVS_STUDIO_LOG} 1>&2 || exit 0)
|
|
||||||
elseif (WIN32)
|
|
||||||
set(COMMANDS COMMAND type "${PVS_STUDIO_LOG}" 1>&2)
|
set(COMMANDS COMMAND type "${PVS_STUDIO_LOG}" 1>&2)
|
||||||
else ()
|
else ()
|
||||||
set(COMMANDS COMMAND cat "${PVS_STUDIO_LOG}" 1>&2)
|
set(COMMANDS COMMAND cat "${PVS_STUDIO_LOG}" 1>&2)
|
||||||
@ -555,9 +563,25 @@ function (pvs_studio_add_target)
|
|||||||
set(COMMANDS "")
|
set(COMMANDS "")
|
||||||
endif ()
|
endif ()
|
||||||
|
|
||||||
|
set(props_file "${CMAKE_BINARY_DIR}/${PVS_STUDIO_TARGET}.user.props")
|
||||||
|
file(WRITE "${props_file}" [=[
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||||
|
<ImportGroup Label="PropertySheets">
|
||||||
|
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||||
|
</ImportGroup>
|
||||||
|
<ItemDefinitionGroup>
|
||||||
|
<CustomBuild>
|
||||||
|
<BuildInParallel>true</BuildInParallel>
|
||||||
|
</CustomBuild>
|
||||||
|
</ItemDefinitionGroup>
|
||||||
|
</Project>
|
||||||
|
]=])
|
||||||
|
|
||||||
add_custom_target("${PVS_STUDIO_TARGET}" ${ALL} ${COMMANDS}
|
add_custom_target("${PVS_STUDIO_TARGET}" ${ALL} ${COMMANDS}
|
||||||
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
|
WORKING_DIRECTORY "${CMAKE_BINARY_DIR}"
|
||||||
DEPENDS ${PVS_STUDIO_DEPENDS} "${PVS_STUDIO_LOG}")
|
DEPENDS ${PVS_STUDIO_DEPENDS} "${PVS_STUDIO_LOG}")
|
||||||
|
set_target_properties("${PVS_STUDIO_TARGET}" PROPERTIES VS_USER_PROPS "${props_file}")
|
||||||
|
|
||||||
# A workaround to add implicit dependencies of source files from include directories
|
# A workaround to add implicit dependencies of source files from include directories
|
||||||
set_target_properties("${PVS_STUDIO_TARGET}" PROPERTIES INCLUDE_DIRECTORIES "${inc_path}")
|
set_target_properties("${PVS_STUDIO_TARGET}" PROPERTIES INCLUDE_DIRECTORIES "${inc_path}")
|
||||||
|
Loading…
Reference in New Issue
Block a user