diff --git a/Makefile b/Makefile index 541ee03..55f6049 100644 --- a/Makefile +++ b/Makefile @@ -3,9 +3,9 @@ TOP_DIR:=$(shell pwd) BUILD_DIR:=$(TOP_DIR)/build DEB_DIR:=$(BUILD_DIR)/deb/myxx-cmake-$(V) -all: update_version deb pack +all: v deb pack -update_version: +v: sed -i "s/CMake.*REQUIRED/CMake $V REQUIRED/" $(TOP_DIR)/README.md sed -i "s/VERSION \".*\"/VERSION \"$V\"/" $(TOP_DIR)/MyxxCMake/MyxxCMakeConfigVersion.cmake sed -i "s/VERSION .* LANG/VERSION $V LANG/" $(TOP_DIR)/debian/CMakeLists.txt diff --git a/MyxxCMake/MyxxCMakeConfig.cmake b/MyxxCMake/MyxxCMakeConfig.cmake index 6ac8c91..1dc4332 100644 --- a/MyxxCMake/MyxxCMakeConfig.cmake +++ b/MyxxCMake/MyxxCMakeConfig.cmake @@ -7,8 +7,18 @@ if(NOT MyxCMake_DIR) message(FATAL_ERROR "MyxxCMake library required MyxCMake to work") endif() -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) -set(MYXX_CMAKE_LIB_DIR "${MYXX_CMAKE_SOURCE_DIR}/lib" CACHE PATH "") +set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "Verbose build output" FORCE) +set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable generation of compile_commands.json" FORCE) + +set(MYXX_CMAKE_LIB_DIR "${MYXX_CMAKE_SOURCE_DIR}/lib") + +set(MYXX_CMAKE_SANITIZERS_DIR "${MYXX_CMAKE_LIB_DIR}/sanitizers") +if(IS_DIRECTORY "${MYXX_CMAKE_SANITIZERS_DIR}") + if(NOT ${MYXX_CMAKE_SANITIZERS_DIR} IN_LIST CMAKE_MODULE_PATH) + list(INSERT CMAKE_MODULE_PATH 0 "${MYXX_CMAKE_SANITIZERS_DIR}") + endif() +endif() +find_package(Sanitizers REQUIRED) include(${MYXX_CMAKE_LIB_DIR}/Coverage.cmake) include(${MYXX_CMAKE_LIB_DIR}/AnalyzeApplyReplacements.cmake) @@ -16,8 +26,7 @@ include(${MYXX_CMAKE_LIB_DIR}/AnalyzeClangTidy.cmake) include(${MYXX_CMAKE_LIB_DIR}/AnalyzeClangCheck.cmake) include(${MYXX_CMAKE_LIB_DIR}/AnalyzeClazy.cmake) -include(${MYXX_CMAKE_SOURCE_DIR}/sanitizers/FindSanitizers.cmake) -include(${MYXX_CMAKE_SOURCE_DIR}/pvs-studio/PVS-Studio.cmake) +include(${MYXX_CMAKE_LIB_DIR}/pvs-studio/PVS-Studio.cmake) include(${MYXX_CMAKE_LIB_DIR}/AnalyzePvsStudio.cmake) function(myxx) @@ -31,6 +40,7 @@ function(myxx) myxx_analyze_clang_check(${iter}) myxx_analyze_clazy(${iter}) myxx_analyze_pvs_studio(${iter}) + myxx_add_sanitizers(${iter}) endif() endforeach() endfunction(myxx) diff --git a/MyxxCMake/MyxxCMakeConfigVersion.cmake b/MyxxCMake/MyxxCMakeConfigVersion.cmake index dd3bb38..313e412 100644 --- a/MyxxCMake/MyxxCMakeConfigVersion.cmake +++ b/MyxxCMake/MyxxCMakeConfigVersion.cmake @@ -1,4 +1,4 @@ -set(MYXX_CMAKE_PACKAGE_VERSION "2.0.1") +set(MYXX_CMAKE_PACKAGE_VERSION "2.0.2") if(MYXX_CMAKE_PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) set(PACKAGE_VERSION_COMPATIBLE FALSE) else() diff --git a/MyxxCMake/lib/AnalyzePvsStudio.cmake b/MyxxCMake/lib/AnalyzePvsStudio.cmake index 335680e..a37617b 100644 --- a/MyxxCMake/lib/AnalyzePvsStudio.cmake +++ b/MyxxCMake/lib/AnalyzePvsStudio.cmake @@ -1,54 +1,59 @@ find_program(PVS_STUDIO_ANALYZER_EXE pvs-studio-analyzer) find_program(PVS_STUDIO_CONVERTER_EXE plog-converter) +if(${CMAKE_VERSION} VERSION_LESS "3.17.0") + set(MYXX_CMAKE_LIB_PVS_DIR_BACKPORT ${CMAKE_CURRENT_LIST_DIR}) +endif() + function(myxx_analyze_pvs_studio target) - if(PVS_STUDIO_ANALYZER_EXE) + if(${CMAKE_VERSION} VERSION_LESS "3.17.0") + set(CMAKE_CURRENT_FUNCTION_LIST_DIR ${MYXX_CMAKE_LIB_PVS_DIR_BACKPORT}) + endif() + if(NOT PVS_STUDIO_ANALYZER_EXE) message(STATUS "MyxxCMake: pvs-studio-analyzer not found.") return() endif() - if(PVS_STUDIO_CONVERTER_EXE) + if(NOT PVS_STUDIO_CONVERTER_EXE) message(STATUS "MyxxCMake: pvs-studio-converter not found.") return() endif() - - if(TARGET myx-cmake-analyze-pvs-studio) - return() + if(NOT TARGET myxx-analyze-pvs-studio) + add_custom_target(myxx-analyze-pvs-studio) endif() set(options) - set(oneValueArgs CHECKS) - set(multiValueArgs) + set(oneValueArgs HEADER MODE) + set(multiValueArgs ARGS) cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) - 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") + if(NOT ARG_HEADER) + set(ARG_HEADER ${CMAKE_CURRENT_FUNCTION_LIST_DIR}/pvs-studio/pvs_studio.hpp.in) + endif() - pvs_studio_add_target(TARGET myx-cmake-analyze-pvs-studio - LOG - COMPILE_COMMANDS + if(NOT ARG_MODE) + set(ARG_MODE "GA:1,2,3;64:1,2,3;OP:1,2,3;CS:1,2,3;OWASP:1,2,3") + endif() + + pvs_studio_add_target(TARGET ${target}-analyze-pvs-studio + ANALYZE ${target} HIDE_HELP - OUTPUT FORMAT errorfile - ARGS --exclude-path ${CMAKE_CURRENT_BINARY_DIR}/${target}_autogen - MODE GA:1,2,3;64:1;OP:1,2;CS:1,2) + OUTPUT + FORMAT errorfile + ARGS --exclude-path ${CMAKE_CURRENT_BINARY_DIR} ${ARG_ARGS} + MODE ${ARG_MODE}) - get_target_property(__target_type ${target} TYPE) - if(${__target_type} STREQUAL INTERFACE_LIBRARY) - set(__target_type INTERFACE) + get_target_property(target_type ${target} TYPE) + if(${target_type} STREQUAL INTERFACE_LIBRARY) + set(target_type INTERFACE) else() - set(__target_type PRIVATE) + set(target_type PRIVATE) endif() if(MSVC) - target_compile_options(${target} BEFORE ${__target_type} /FI ${PVS_STUDIO_HEADER}) + target_compile_options(${target} BEFORE ${target_type} /FI ${ARG_HEADER}) else() # GCC/Clang - target_compile_options(${target} BEFORE ${__target_type} -include ${PVS_STUDIO_HEADER}) + target_compile_options(${target} BEFORE ${target_type} -include ${ARG_HEADER}) endif() - 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(${target}-analyze-pvs-studio ${target}) + add_dependencies(myxx-analyze-pvs-studio ${target}-analyze-pvs-studio) endfunction() diff --git a/MyxxCMake/lib/Coverage.cmake b/MyxxCMake/lib/Coverage.cmake index 9c40f71..95658c8 100644 --- a/MyxxCMake/lib/Coverage.cmake +++ b/MyxxCMake/lib/Coverage.cmake @@ -10,30 +10,32 @@ function(myxx_code_coverage target) return() endif() - if(CMAKE_CXX_COMPILER_IS_GCC) - target_compile_options(${target} PUBLIC "--coverage") - set_property( - TARGET ${target} - APPEND_STRING - PROPERTY LINK_FLAGS " --coverage") + set(options) + set(oneValueArgs) + set(multiValueArgs EXCLUDE) + cmake_parse_arguments(ARG "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + set_property(TARGET ${target} APPEND PROPERTY + COMPILE_OPTIONS --coverage) + set_property(TARGET ${target} APPEND PROPERTY LINK_FLAGS --coverage) endif() - if(CMAKE_CXX_COMPILER_IS_CLANG) - target_compile_options(${target} PUBLIC "-fprofile-instr-generate -fcoverage-mapping") - set_property( - TARGET ${target} - APPEND_STRING - PROPERTY LINK_FLAGS " --coverage") + if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + set_property(TARGET ${target} APPEND PROPERTY + COMPILE_OPTIONS -fprofile-instr-generate -fcoverage-mapping) + set_property(TARGET ${target} APPEND PROPERTY LINK_FLAGS --coverage) endif() if(LCOV_EXE) add_custom_target(${target}-coverage WORKING_DIRECTORY ${CMAKE_BINARY_DIR} - COMMAND ${LCOV_EXE} --test-name ${target} --output "${target}.lcov" --capture + COMMAND ${LCOV_EXE} --test-name ${target} --output "${target}.lcov" + --capture --no-external --base-directory ${CMAKE_SOURCE_DIR} - --directory ${CMAKE_BINARY_DIR}) + --directory ${CMAKE_BINARY_DIR} --exclude "/usr/\\\*" - --exclude "${CMAKE_BINARY_DIR}/\\\*" + --exclude "${CMAKE_BINARY_DIR}/\\\*") add_dependencies(${target}-coverage ${target}) if(GENHTML_EXE) diff --git a/MyxxCMake/pvs-studio/PVS-Studio.cmake b/MyxxCMake/lib/pvs-studio/PVS-Studio.cmake similarity index 100% rename from MyxxCMake/pvs-studio/PVS-Studio.cmake rename to MyxxCMake/lib/pvs-studio/PVS-Studio.cmake diff --git a/MyxxCMake/lib/pvs-studio/pvs_studio.hpp.in b/MyxxCMake/lib/pvs-studio/pvs_studio.hpp.in new file mode 100644 index 0000000..ebfa52e --- /dev/null +++ b/MyxxCMake/lib/pvs-studio/pvs_studio.hpp.in @@ -0,0 +1,9 @@ +// -*- C++ -*- +#ifndef PVS_STUDIO_HPP_ +#define PVS_STUDIO_HPP_ + +#pragma once + +//-V813_MINSIZE=33 + +#endif // PVS_STUDIO_HPP_ diff --git a/MyxxCMake/sanitizers/FindASan.cmake b/MyxxCMake/lib/sanitizers/FindASan.cmake similarity index 100% rename from MyxxCMake/sanitizers/FindASan.cmake rename to MyxxCMake/lib/sanitizers/FindASan.cmake diff --git a/MyxxCMake/sanitizers/FindCFI.cmake b/MyxxCMake/lib/sanitizers/FindCFI.cmake similarity index 100% rename from MyxxCMake/sanitizers/FindCFI.cmake rename to MyxxCMake/lib/sanitizers/FindCFI.cmake diff --git a/MyxxCMake/sanitizers/FindLeakSan.cmake b/MyxxCMake/lib/sanitizers/FindLeakSan.cmake similarity index 100% rename from MyxxCMake/sanitizers/FindLeakSan.cmake rename to MyxxCMake/lib/sanitizers/FindLeakSan.cmake diff --git a/MyxxCMake/sanitizers/FindMSan.cmake b/MyxxCMake/lib/sanitizers/FindMSan.cmake similarity index 100% rename from MyxxCMake/sanitizers/FindMSan.cmake rename to MyxxCMake/lib/sanitizers/FindMSan.cmake diff --git a/MyxxCMake/sanitizers/FindSS.cmake b/MyxxCMake/lib/sanitizers/FindSS.cmake similarity index 100% rename from MyxxCMake/sanitizers/FindSS.cmake rename to MyxxCMake/lib/sanitizers/FindSS.cmake diff --git a/MyxxCMake/sanitizers/FindSanitizers.cmake b/MyxxCMake/lib/sanitizers/FindSanitizers.cmake similarity index 89% rename from MyxxCMake/sanitizers/FindSanitizers.cmake rename to MyxxCMake/lib/sanitizers/FindSanitizers.cmake index 53d1b27..3a6201e 100644 --- a/MyxxCMake/sanitizers/FindSanitizers.cmake +++ b/MyxxCMake/lib/sanitizers/FindSanitizers.cmake @@ -32,13 +32,13 @@ if(DEFINED Sanitizers_FIND_QUIETLY) set(FIND_QUIETLY_FLAG "QUIET") endif() -find_package(ASan ${FIND_QUIETLY_FLAG}) -find_package(TSan ${FIND_QUIETLY_FLAG}) -find_package(MSan ${FIND_QUIETLY_FLAG}) -find_package(UBSan ${FIND_QUIETLY_FLAG}) -find_package(LeakSan ${FIND_QUIETLY_FLAG}) -find_package(CFI ${FIND_QUIETLY_FLAG}) -find_package(SS ${FIND_QUIETLY_FLAG}) +find_package(ASan REQUIRED ${FIND_QUIETLY_FLAG}) +find_package(TSan REQUIRED ${FIND_QUIETLY_FLAG}) +find_package(MSan REQUIRED ${FIND_QUIETLY_FLAG}) +find_package(UBSan REQUIRED ${FIND_QUIETLY_FLAG}) +find_package(LeakSan REQUIRED ${FIND_QUIETLY_FLAG}) +find_package(CFI REQUIRED ${FIND_QUIETLY_FLAG}) +find_package(SS REQUIRED ${FIND_QUIETLY_FLAG}) function(sanitizer_add_blacklist_file FILE) if(NOT IS_ABSOLUTE ${FILE}) @@ -49,7 +49,7 @@ function(sanitizer_add_blacklist_file FILE) sanitizer_check_compiler_flags("-fsanitize-blacklist=${FILE}" "SanitizerBlacklist" "SanBlist") endfunction() -function(add_sanitizers ...) +function(myxx_add_sanitizers ...) # If no sanitizer is enabled, return immediately. if(NOT (SANITIZE_ADDRESS @@ -106,4 +106,4 @@ function(add_sanitizers ...) add_sanitize_ss(${TARGET}) endif() endforeach() -endfunction(add_sanitizers) +endfunction(myxx_add_sanitizers) diff --git a/MyxxCMake/sanitizers/FindTSan.cmake b/MyxxCMake/lib/sanitizers/FindTSan.cmake similarity index 100% rename from MyxxCMake/sanitizers/FindTSan.cmake rename to MyxxCMake/lib/sanitizers/FindTSan.cmake diff --git a/MyxxCMake/sanitizers/FindUBSan.cmake b/MyxxCMake/lib/sanitizers/FindUBSan.cmake similarity index 100% rename from MyxxCMake/sanitizers/FindUBSan.cmake rename to MyxxCMake/lib/sanitizers/FindUBSan.cmake diff --git a/MyxxCMake/sanitizers/asan-wrapper b/MyxxCMake/lib/sanitizers/asan-wrapper similarity index 100% rename from MyxxCMake/sanitizers/asan-wrapper rename to MyxxCMake/lib/sanitizers/asan-wrapper diff --git a/MyxxCMake/sanitizers/sanitize-helpers.cmake b/MyxxCMake/lib/sanitizers/sanitize-helpers.cmake similarity index 100% rename from MyxxCMake/sanitizers/sanitize-helpers.cmake rename to MyxxCMake/lib/sanitizers/sanitize-helpers.cmake diff --git a/README.md b/README.md index 5e40df7..74892cb 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ эту библиотеку. Для подключения функций необходимо в конце описания проекта -(после описания целей, для которых нужно применить правила) +(после создания целей, для которых нужно применить правила) добавить строки: ```cmake diff --git a/VERSION b/VERSION index 38f77a6..e9307ca 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -2.0.1 +2.0.2 diff --git a/debian/CMakeLists.txt b/debian/CMakeLists.txt index 0bbbac5..90d72ff 100644 --- a/debian/CMakeLists.txt +++ b/debian/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.6 FATAL_ERROR) -project(myxx-cmake VERSION 2.0.1 LANGUAGES) +project(myxx-cmake VERSION 2.0.2 LANGUAGES) include(GNUInstallDirs) file(WRITE ${CMAKE_SOURCE_DIR}/MyxxCMake/MyxxCMakeConfigVersion.cmake diff --git a/debian/changelog b/debian/changelog index 543aa8e..9970128 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -myxx-cmake (2.0.1) unstable; urgency=medium +myxx-cmake (2.0.2) unstable; urgency=medium * New version.