89 lines
2.9 KiB
CMake
89 lines
2.9 KiB
CMake
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}/SyntaxCheck.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()
|
||
|
||
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 ${__iter} MATCHES ".*_shared$" ) AND
|
||
(NOT ${__iter} MATCHES ".*_static$" )
|
||
)
|
||
myxx_analyze_pvs_studio(${__iter})
|
||
if(MYXX_CMAKE_CLANG_TIDY_FIX)
|
||
myxx_analyze_clang_tidy(${__iter} FIX)
|
||
else()
|
||
myxx_analyze_clang_tidy(${__iter})
|
||
endif()
|
||
|
||
if(MYXX_CMAKE_CLANG_TIDY_NAMING_FIX)
|
||
myxx_analyze_clang_tidy_naming(${__iter} FIX)
|
||
else()
|
||
myxx_analyze_clang_tidy_naming(${__iter})
|
||
endif()
|
||
|
||
if(MYXX_CMAKE_CLANG_CHECK_FIX)
|
||
myxx_analyze_clang_check(${__iter} FIX)
|
||
else()
|
||
myxx_analyze_clang_check(${__iter})
|
||
endif()
|
||
|
||
if(MYXX_CMAKE_CLAZY_FIX)
|
||
myxx_analyze_clazy(${__iter} FIX)
|
||
else()
|
||
myxx_analyze_clazy(${__iter})
|
||
endif()
|
||
|
||
if(NOT ${__target_type} STREQUAL "INTERFACE_LIBRARY")
|
||
myxx_code_coverage(${__iter})
|
||
myxx_add_sanitizers(${__iter})
|
||
endif()
|
||
endif()
|
||
|
||
endforeach()
|
||
endfunction(myxx)
|
||
|
||
cmake_policy(POP)
|