myxx/MyxxCMake/MyxxCMakeConfig.cmake

64 lines
2.3 KiB
CMake
Raw Normal View History

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-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-06 20:51:33 +00:00
get_property(targets DIRECTORY ${CMAKE_BINARY_DIR} PROPERTY BUILDSYSTEM_TARGETS)
foreach(iter ${targets})
2022-10-05 14:12:28 +00:00
get_target_property(target_type ${iter} TYPE)
2022-10-07 05:03:56 +00:00
if((NOT ${target_type} STREQUAL "UTILITY") AND
(NOT ${iter} MATCHES ".*_shared$" ) AND
(NOT ${iter} MATCHES ".*_static$" )
)
2022-10-06 04:57:47 +00:00
myxx_code_coverage(${iter})
2022-10-05 14:12:28 +00:00
myxx_analyze_clang_tidy(${iter})
2022-10-15 07:12:14 +00:00
myxx_analyze_clang_tidy_naming(${iter})
2022-10-06 04:57:47 +00:00
myxx_analyze_clang_check(${iter})
2022-10-07 08:22:07 +00:00
if(MYXX_CMAKE_CLAZY_FIX)
myxx_analyze_clazy(${iter} FIX)
else()
myxx_analyze_clazy(${iter})
endif()
2022-10-06 04:57:47 +00:00
myxx_analyze_pvs_studio(${iter})
2022-10-06 18:07:22 +00:00
myxx_add_sanitizers(${iter})
2022-10-05 14:12:28 +00:00
endif()
endforeach()
endfunction(myxx)
cmake_policy(POP)