cmake_policy(PUSH) cmake_policy(SET CMP0057 NEW) # IN_LIST operator get_filename_component(MYXX_CMAKE_SOURCE_DIR "${CMAKE_CURRENT_LIST_FILE}" DIRECTORY) if(NOT MyxCMake_DIR) message(FATAL_ERROR "MyxxCMake library required MyxCMake to work") endif() 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}/WarningFlags.cmake) include(${MYXX_CMAKE_LIB_DIR}/Coverage.cmake) include(${MYXX_CMAKE_LIB_DIR}/AnalyzeApplyReplacements.cmake) include(${MYXX_CMAKE_LIB_DIR}/AnalyzeClangTidy.cmake) include(${MYXX_CMAKE_LIB_DIR}/AnalyzeClangCheck.cmake) include(${MYXX_CMAKE_LIB_DIR}/AnalyzeClazy.cmake) include(${MYXX_CMAKE_LIB_DIR}/pvs-studio/PVS-Studio.cmake) include(${MYXX_CMAKE_LIB_DIR}/AnalyzePvsStudio.cmake) function(myxx) # Свойство BUILDSYSTEM_TARGETS доступно в CMake только с версии 3.7 # Более старые конфигурации придётся настраивать вручную if(${CMAKE_VERSION} VERSION_LESS "3.7.0") myx_message_warning("MyxxCMake: automated setup is only available for CMake 3.7+") return() endif() get_property(targets DIRECTORY ${CMAKE_BINARY_DIR} PROPERTY BUILDSYSTEM_TARGETS) foreach(iter ${targets}) get_target_property(target_type ${iter} TYPE) if((NOT ${target_type} STREQUAL "UTILITY") AND (NOT ${iter} MATCHES ".*_shared$" ) AND (NOT ${iter} MATCHES ".*_static$" ) ) myxx_code_coverage(${iter}) myxx_analyze_clang_tidy(${iter}) myxx_analyze_clang_tidy_naming(${iter}) myxx_analyze_clang_check(${iter}) if(MYXX_CMAKE_CLAZY_FIX) myxx_analyze_clazy(${iter} FIX) else() myxx_analyze_clazy(${iter}) endif() myxx_analyze_pvs_studio(${iter}) myxx_add_sanitizers(${iter}) endif() endforeach() endfunction(myxx) cmake_policy(POP)