Рефакторинг подключения pvs-studio

This commit is contained in:
Andrei Astafev 2021-12-20 11:34:41 +03:00
parent eabd2c4b31
commit fa8fdfac66

View File

@ -5,11 +5,12 @@ else()
endif() endif()
function(myx_cmake_analyze_pvs_studio target) function(myx_cmake_analyze_pvs_studio target)
if(EXISTS PVS_STUDIO_BIN_PATH AND EXISTS PVS_STUDIO_CONVERTER_PATH)
set(options) set(options)
set(oneValueArgs CHECKS) set(oneValueArgs CHECKS)
set(multiValueArgs) set(multiValueArgs)
if(NOT TARGET myx-cmake-analyze-pvs-studio) if(NOT TARGET myx-cmake-analyze-pvs-studio)
set(PVS_STUDIO_HEADER "${CMAKE_BINARY_DIR}/include/myx_cmake_pvs_studio_header.hpp") set(PVS_STUDIO_HEADER "${CMAKE_BINARY_DIR}/include/myx_cmake_pvs_studio_header_p.hpp")
file(WRITE ${PVS_STUDIO_HEADER} file(WRITE ${PVS_STUDIO_HEADER}
"#ifndef MYX_CMAKE_PVS_STUDIO_HEADER_HPP_\n" "#ifndef MYX_CMAKE_PVS_STUDIO_HEADER_HPP_\n"
"#define MYX_CMAKE_PVS_STUDIO_HEADER_HPP_\n" "#define MYX_CMAKE_PVS_STUDIO_HEADER_HPP_\n"
@ -37,11 +38,12 @@ function(myx_cmake_analyze_pvs_studio target)
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() endif()
else()
message(STATUS "MyxCMake: pvs-studio-analyzer not found.")
endif()
endfunction() endfunction()