From fa8fdfac663fa0551ab257a6d8c6400c688ada26 Mon Sep 17 00:00:00 2001 From: Andrey Astafyev Date: Mon, 20 Dec 2021 11:34:41 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A0=D0=B5=D1=84=D0=B0=D0=BA=D1=82=D0=BE?= =?UTF-8?q?=D1=80=D0=B8=D0=BD=D0=B3=20=D0=BF=D0=BE=D0=B4=D0=BA=D0=BB=D1=8E?= =?UTF-8?q?=D1=87=D0=B5=D0=BD=D0=B8=D1=8F=20pvs-studio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../MyxCMakeCodeAnalyzePvsStudio.cmake | 56 ++++++++++--------- 1 file changed, 29 insertions(+), 27 deletions(-) diff --git a/MyxCMake/modules/MyxCMakeCodeAnalyzePvsStudio.cmake b/MyxCMake/modules/MyxCMakeCodeAnalyzePvsStudio.cmake index 1756389..b157eca 100644 --- a/MyxCMake/modules/MyxCMakeCodeAnalyzePvsStudio.cmake +++ b/MyxCMake/modules/MyxCMakeCodeAnalyzePvsStudio.cmake @@ -5,17 +5,18 @@ else() endif() function(myx_cmake_analyze_pvs_studio target) - set(options) - set(oneValueArgs CHECKS) - set(multiValueArgs) - if(NOT TARGET myx-cmake-analyze-pvs-studio) - set(PVS_STUDIO_HEADER "${CMAKE_BINARY_DIR}/include/myx_cmake_pvs_studio_header.hpp") - file(WRITE ${PVS_STUDIO_HEADER} - "#ifndef MYX_CMAKE_PVS_STUDIO_HEADER_HPP_\n" - "#define MYX_CMAKE_PVS_STUDIO_HEADER_HPP_\n" - "#pragma once\n" - "//-V813_MINSIZE=33\n" - "#endif // MYX_CMAKE_PVS_STUDIO_HEADER_HPP_\n") + if(EXISTS PVS_STUDIO_BIN_PATH AND EXISTS PVS_STUDIO_CONVERTER_PATH) + set(options) + set(oneValueArgs CHECKS) + set(multiValueArgs) + if(NOT TARGET myx-cmake-analyze-pvs-studio) + set(PVS_STUDIO_HEADER "${CMAKE_BINARY_DIR}/include/myx_cmake_pvs_studio_header_p.hpp") + file(WRITE ${PVS_STUDIO_HEADER} + "#ifndef MYX_CMAKE_PVS_STUDIO_HEADER_HPP_\n" + "#define MYX_CMAKE_PVS_STUDIO_HEADER_HPP_\n" + "#pragma once\n" + "//-V813_MINSIZE=33\n" + "#endif // MYX_CMAKE_PVS_STUDIO_HEADER_HPP_\n") pvs_studio_add_target(TARGET myx-cmake-analyze-pvs-studio CONFIG ${PVS_STUDIO_CONFIG} @@ -26,22 +27,23 @@ function(myx_cmake_analyze_pvs_studio target) ARGS --exclude-path ${CMAKE_CURRENT_BINARY_DIR}/${target}_autogen MODE GA:1,2,3;64:1;OP:1,2;CS:1,2) - get_target_property(__target_type ${target} TYPE) - if(${__target_type} STREQUAL INTERFACE_LIBRARY) - set(__target_type INTERFACE) - else() - set(__target_type PRIVATE) - endif() - if(MSVC) - target_compile_options(${target} BEFORE ${__target_type} /FI ${PVS_STUDIO_HEADER}) - else() # GCC/Clang - target_compile_options(${target} BEFORE ${__target_type} -include ${PVS_STUDIO_HEADER}) - endif() - endif() + get_target_property(__target_type ${target} TYPE) + if(${__target_type} STREQUAL INTERFACE_LIBRARY) + set(__target_type INTERFACE) + else() + set(__target_type PRIVATE) + endif() + if(MSVC) + target_compile_options(${target} BEFORE ${__target_type} /FI ${PVS_STUDIO_HEADER}) + else() # GCC/Clang + target_compile_options(${target} BEFORE ${__target_type} -include ${PVS_STUDIO_HEADER}) + 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}) - get_target_property(__target_source_dir "${target}" SOURCE_DIR) - pvs_studio_analyze_target("${target}" "${__target_source_dir}") + add_dependencies(myx-cmake-analyze-pvs-studio ${target}) + get_target_property(__target_source_dir "${target}" SOURCE_DIR) + pvs_studio_analyze_target("${target}" "${__target_source_dir}") + endif() + else() + message(STATUS "MyxCMake: pvs-studio-analyzer not found.") endif() endfunction()