2022-10-05 14:12:28 +00:00
|
|
|
|
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()
|
|
|
|
|
|
2022-10-06 18:07:22 +00:00
|
|
|
|
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)
|
2022-10-05 14:12:28 +00:00
|
|
|
|
|
2022-10-07 05:03:56 +00:00
|
|
|
|
include(${MYXX_CMAKE_LIB_DIR}/WarningFlags.cmake)
|
2022-10-23 16:40:51 +00:00
|
|
|
|
include(${MYXX_CMAKE_LIB_DIR}/SyntaxCheck.cmake)
|
2022-10-06 04:57:47 +00:00
|
|
|
|
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)
|
|
|
|
|
|
2022-10-06 18:07:22 +00:00
|
|
|
|
include(${MYXX_CMAKE_LIB_DIR}/pvs-studio/PVS-Studio.cmake)
|
2022-10-06 04:57:47 +00:00
|
|
|
|
include(${MYXX_CMAKE_LIB_DIR}/AnalyzePvsStudio.cmake)
|
2022-10-05 14:12:28 +00:00
|
|
|
|
|
|
|
|
|
function(myxx)
|
2022-10-06 20:51:33 +00:00
|
|
|
|
# Свойство 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()
|
2022-10-05 14:12:28 +00:00
|
|
|
|
|
2022-10-19 13:59:18 +00:00
|
|
|
|
if(NOT ${PROJECT_BINARY_DIR} STREQUAL ${CMAKE_BINARY_DIR})
|
|
|
|
|
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 ${__target_type} STREQUAL "INTERFACE_LIBRARY") AND
|
|
|
|
|
(NOT ${__iter} MATCHES ".*_shared$" ) AND
|
|
|
|
|
(NOT ${__iter} MATCHES ".*_static$" )
|
2022-10-07 05:03:56 +00:00
|
|
|
|
)
|
2022-10-19 13:59:18 +00:00
|
|
|
|
myxx_code_coverage(${__iter})
|
2024-03-28 07:08:29 +00:00
|
|
|
|
if(MYXX_CMAKE_CLANG_TIDY_FIX)
|
|
|
|
|
myxx_analyze_clang_tidy(${__iter})
|
|
|
|
|
endif()
|
|
|
|
|
if(MYXX_CMAKE_CLANG_TIDY_NAMING_FIX)
|
|
|
|
|
myxx_analyze_clang_tidy_naming(${__iter})
|
|
|
|
|
endif()
|
|
|
|
|
if(MYXX_CMAKE_CLANG_CHECK_FIX)
|
|
|
|
|
myxx_analyze_clang_check(${__iter})
|
|
|
|
|
endif()
|
2022-10-07 08:22:07 +00:00
|
|
|
|
if(MYXX_CMAKE_CLAZY_FIX)
|
2022-10-19 13:59:18 +00:00
|
|
|
|
myxx_analyze_clazy(${__iter} FIX)
|
2022-10-07 08:22:07 +00:00
|
|
|
|
else()
|
2022-10-19 13:59:18 +00:00
|
|
|
|
myxx_analyze_clazy(${__iter})
|
2022-10-07 08:22:07 +00:00
|
|
|
|
endif()
|
2022-10-19 13:59:18 +00:00
|
|
|
|
myxx_analyze_pvs_studio(${__iter})
|
|
|
|
|
myxx_add_sanitizers(${__iter})
|
2022-10-05 14:12:28 +00:00
|
|
|
|
endif()
|
|
|
|
|
endforeach()
|
|
|
|
|
endfunction(myxx)
|
|
|
|
|
|
|
|
|
|
cmake_policy(POP)
|