Рефакторинг подключения pvs-studio
This commit is contained in:
parent
eabd2c4b31
commit
fa8fdfac66
@ -5,17 +5,18 @@ else()
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
function(myx_cmake_analyze_pvs_studio target)
|
function(myx_cmake_analyze_pvs_studio target)
|
||||||
set(options)
|
if(EXISTS PVS_STUDIO_BIN_PATH AND EXISTS PVS_STUDIO_CONVERTER_PATH)
|
||||||
set(oneValueArgs CHECKS)
|
set(options)
|
||||||
set(multiValueArgs)
|
set(oneValueArgs CHECKS)
|
||||||
if(NOT TARGET myx-cmake-analyze-pvs-studio)
|
set(multiValueArgs)
|
||||||
set(PVS_STUDIO_HEADER "${CMAKE_BINARY_DIR}/include/myx_cmake_pvs_studio_header.hpp")
|
if(NOT TARGET myx-cmake-analyze-pvs-studio)
|
||||||
file(WRITE ${PVS_STUDIO_HEADER}
|
set(PVS_STUDIO_HEADER "${CMAKE_BINARY_DIR}/include/myx_cmake_pvs_studio_header_p.hpp")
|
||||||
"#ifndef MYX_CMAKE_PVS_STUDIO_HEADER_HPP_\n"
|
file(WRITE ${PVS_STUDIO_HEADER}
|
||||||
"#define MYX_CMAKE_PVS_STUDIO_HEADER_HPP_\n"
|
"#ifndef MYX_CMAKE_PVS_STUDIO_HEADER_HPP_\n"
|
||||||
"#pragma once\n"
|
"#define MYX_CMAKE_PVS_STUDIO_HEADER_HPP_\n"
|
||||||
"//-V813_MINSIZE=33\n"
|
"#pragma once\n"
|
||||||
"#endif // MYX_CMAKE_PVS_STUDIO_HEADER_HPP_\n")
|
"//-V813_MINSIZE=33\n"
|
||||||
|
"#endif // MYX_CMAKE_PVS_STUDIO_HEADER_HPP_\n")
|
||||||
|
|
||||||
pvs_studio_add_target(TARGET myx-cmake-analyze-pvs-studio
|
pvs_studio_add_target(TARGET myx-cmake-analyze-pvs-studio
|
||||||
CONFIG ${PVS_STUDIO_CONFIG}
|
CONFIG ${PVS_STUDIO_CONFIG}
|
||||||
@ -26,22 +27,23 @@ function(myx_cmake_analyze_pvs_studio target)
|
|||||||
ARGS --exclude-path ${CMAKE_CURRENT_BINARY_DIR}/${target}_autogen
|
ARGS --exclude-path ${CMAKE_CURRENT_BINARY_DIR}/${target}_autogen
|
||||||
MODE GA:1,2,3;64:1;OP:1,2;CS:1,2)
|
MODE GA:1,2,3;64:1;OP:1,2;CS:1,2)
|
||||||
|
|
||||||
get_target_property(__target_type ${target} TYPE)
|
get_target_property(__target_type ${target} TYPE)
|
||||||
if(${__target_type} STREQUAL INTERFACE_LIBRARY)
|
if(${__target_type} STREQUAL INTERFACE_LIBRARY)
|
||||||
set(__target_type INTERFACE)
|
set(__target_type INTERFACE)
|
||||||
else()
|
else()
|
||||||
set(__target_type PRIVATE)
|
set(__target_type PRIVATE)
|
||||||
endif()
|
endif()
|
||||||
if(MSVC)
|
if(MSVC)
|
||||||
target_compile_options(${target} BEFORE ${__target_type} /FI ${PVS_STUDIO_HEADER})
|
target_compile_options(${target} BEFORE ${__target_type} /FI ${PVS_STUDIO_HEADER})
|
||||||
else() # GCC/Clang
|
else() # GCC/Clang
|
||||||
target_compile_options(${target} BEFORE ${__target_type} -include ${PVS_STUDIO_HEADER})
|
target_compile_options(${target} BEFORE ${__target_type} -include ${PVS_STUDIO_HEADER})
|
||||||
endif()
|
endif()
|
||||||
endif()
|
|
||||||
|
|
||||||
if(EXISTS PVS_STUDIO_BIN_PATH AND EXISTS PVS_STUDIO_CONVERTER_PATH AND TARGET myx-cmake-analyze-pvs-studio)
|
add_dependencies(myx-cmake-analyze-pvs-studio ${target})
|
||||||
add_dependencies(myx-cmake-analyze-pvs-studio ${target})
|
get_target_property(__target_source_dir "${target}" SOURCE_DIR)
|
||||||
get_target_property(__target_source_dir "${target}" SOURCE_DIR)
|
pvs_studio_analyze_target("${target}" "${__target_source_dir}")
|
||||||
pvs_studio_analyze_target("${target}" "${__target_source_dir}")
|
endif()
|
||||||
|
else()
|
||||||
|
message(STATUS "MyxCMake: pvs-studio-analyzer not found.")
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
Loading…
Reference in New Issue
Block a user