Compare commits
9 Commits
5e600ab490
...
f1ebe75238
Author | SHA1 | Date | |
---|---|---|---|
f1ebe75238 | |||
b89987fa82 | |||
a3cfaf458a | |||
87572438e4 | |||
e4ec257b11 | |||
9ff6a41c5a | |||
b3ad740ab8 | |||
cfad412b21 | |||
8b2fa4fd64 |
@@ -175,7 +175,7 @@ with section("markup"):
|
||||
with section("lint"):
|
||||
|
||||
# a list of lint codes to disable
|
||||
disabled_codes = ['C0113']
|
||||
disabled_codes = ['C0111','C0113']
|
||||
|
||||
# regular expression pattern describing valid function names
|
||||
function_pattern = '[0-9a-z_]+'
|
||||
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -1,3 +0,0 @@
|
||||
[submodule "thirdparty/sanitizers"]
|
||||
path = thirdparty/sanitizers
|
||||
url = ../../f1x1t/cmake-sanitizers
|
@@ -1,5 +1,7 @@
|
||||
cmake_policy(SET CMP0057 NEW)
|
||||
|
||||
option(CMLIB_ENABLE_WARNING_FLAGS "Enable autodetected warning flags" ON)
|
||||
|
||||
# Добавление конфигурации для профилирования
|
||||
if(CMAKE_CONFIGURATION_TYPES)
|
||||
if(NOT "Profile" IN_LIST CMAKE_CONFIGURATION_TYPES)
|
||||
@@ -35,7 +37,8 @@ if(CMAKE_BUILD_TYPE STREQUAL Profile)
|
||||
CACHE STRING "" FORCE)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} ${_gcc_profile_flags}"
|
||||
CACHE STRING "" FORCE)
|
||||
set(CMAKE_STATIC_LINKER_FLAGS_PROFILE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE}" CACHE STRING "" FORCE)
|
||||
set(CMAKE_STATIC_LINKER_FLAGS_PROFILE "${CMAKE_STATIC_LINKER_FLAGS_RELEASE} ${_gcc_profile_flags}"
|
||||
CACHE STRING "" FORCE)
|
||||
set(CMAKE_MODULE_LINKER_FLAGS_PROFILE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} ${_gcc_profile_flags}"
|
||||
CACHE STRING "" FORCE)
|
||||
elseif(CMAKE_CXX_COMPILER_IS_Intel)
|
||||
@@ -53,12 +56,19 @@ elseif(CMAKE_BUILD_TYPE STREQUAL Debug)
|
||||
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${_gcc_debug_flags}" CACHE STRING "" FORCE)
|
||||
|
||||
string(REPLACE " ${_gcc_debug_flags}" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${_gcc_debug_flags}" CACHE STRING "" FORCE)
|
||||
if(CMLIB_ENABLE_WARNING_FLAGS)
|
||||
set(CMAKE_CXX_FLAGS_DEBUG
|
||||
"${CMAKE_CXX_FLAGS_DEBUG} ${CMLIB_DETECTED_CXX_FLAGS_DEBUG} ${_gcc_debug_flags}" CACHE STRING ""
|
||||
FORCE)
|
||||
else()
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${_gcc_debug_flags}" CACHE STRING "" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
set(CMAKE_VERBOSE_MAKEFILE ON CACHE BOOL "Enable generation of verbose build scripts." FORCE)
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable generation of compile_commands.json." FORCE)
|
||||
set(DEBUG 1)
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL Release)
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${CMLIB_DETECTED_CXX_FLAGS}" CACHE STRING "" FORCE)
|
||||
set(RELEASE 1)
|
||||
elseif(CMAKE_BUILD_TYPE STREQUAL None)
|
||||
# Режим None используется для статического анализа кода
|
||||
|
@@ -49,9 +49,9 @@ if(CMLIB_CPACK_DEFAULT_SCHEME)
|
||||
|
||||
set(CPACK_DEBIAN_LIBS-DEV_PACKAGE_DEPENDS "lib${CMLIB_PROJECT_NAME_LOWER}-base-dev")
|
||||
|
||||
foreach(_C ${CPACK_COMPONENTS_ALL})
|
||||
string(TOLOWER ${_C} _cl)
|
||||
string(TOUPPER ${_C} _cu)
|
||||
foreach(component ${CPACK_COMPONENTS_ALL})
|
||||
string(TOLOWER ${component} _cl)
|
||||
string(TOUPPER ${component} _cu)
|
||||
# Правила формирования имени пакета и файла для остальных компонентов
|
||||
if(NOT ${_cl} STREQUAL main AND NOT ${_cl} STREQUAL base-dev AND NOT ${_cl} STREQUAL libs-dev)
|
||||
set(CPACK_DEBIAN_${_cu}_PACKAGE_NAME "${CMLIB_PROJECT_NAME_LOWER}-${_cl}")
|
||||
|
@@ -5,15 +5,14 @@ function(add_common_library target)
|
||||
set(multiValueArgs SOURCES)
|
||||
|
||||
cmake_parse_arguments(_LOCAL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
set(SOURCES ${_LOCAL_SOURCES})
|
||||
|
||||
if(_LOCAL_OUTPUT_NAME)
|
||||
set(OUTNAME ${_LOCAL_OUTPUT_NAME})
|
||||
set(output_name ${_LOCAL_OUTPUT_NAME})
|
||||
else()
|
||||
set(OUTNAME ${target})
|
||||
set(output_name ${target})
|
||||
endif()
|
||||
|
||||
add_library(${target} OBJECT ${SOURCES})
|
||||
add_library(${target} OBJECT ${_LOCAL_SOURCES})
|
||||
target_include_directories(
|
||||
${target} PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
|
||||
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include> $<INSTALL_INTERFACE:include/${target}>)
|
||||
@@ -22,7 +21,7 @@ function(add_common_library target)
|
||||
# cmake-format: off
|
||||
if(BUILD_SHARED_LIBS)
|
||||
add_library(${target}_shared SHARED $<TARGET_OBJECTS:${target}>)
|
||||
set_target_properties(${target}_shared PROPERTIES OUTPUT_NAME ${OUTNAME}
|
||||
set_target_properties(${target}_shared PROPERTIES OUTPUT_NAME ${output_name}
|
||||
VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}
|
||||
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
||||
install(TARGETS ${target}_shared LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
@@ -30,7 +29,7 @@ function(add_common_library target)
|
||||
|
||||
if(NOT SKIP_STATIC_LIBS)
|
||||
add_library(${target}_static STATIC $<TARGET_OBJECTS:${target}>)
|
||||
set_target_properties(${target}_static PROPERTIES OUTPUT_NAME ${OUTNAME}
|
||||
set_target_properties(${target}_static PROPERTIES OUTPUT_NAME ${output_name}
|
||||
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/${CMAKE_INSTALL_LIBDIR})
|
||||
install(TARGETS ${target}_static ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
|
||||
endif()
|
||||
|
@@ -10,8 +10,8 @@ function(common_target_properties target)
|
||||
endif()
|
||||
|
||||
get_target_property(__sources ${target} SOURCES)
|
||||
foreach(__src IN LISTS __sources)
|
||||
string(REGEX MATCH ".*/qrc_.*\\.cpp$" __qrc ${__src})
|
||||
foreach(src IN LISTS __sources)
|
||||
string(REGEX MATCH ".*/qrc_.*\\.cpp$" __qrc ${src})
|
||||
if(__qrc)
|
||||
set_property(SOURCE ${__qrc} PROPERTY COTIRE_EXCLUDED ON)
|
||||
endif()
|
||||
|
@@ -1,7 +1,5 @@
|
||||
# based on https://github.com/bluescarni/yacma
|
||||
|
||||
option(CMLIB_WARNING_FLAGS "Enable warning flags" ON)
|
||||
|
||||
include(CheckCXXCompilerFlag)
|
||||
|
||||
macro(CHECK_ENABLE_CXX_FLAG flag)
|
||||
@@ -10,8 +8,8 @@ macro(CHECK_ENABLE_CXX_FLAG flag)
|
||||
unset(CMAKE_REQUIRED_QUIET)
|
||||
|
||||
if(CHECK_CXX_FLAG)
|
||||
message(STATUS "'${flag}': flag is enabled.")
|
||||
add_compile_options("${flag}")
|
||||
message(STATUS "'${flag}': flag is supported.")
|
||||
string(CONCAT _CMLIB_DETECTED_CXX_FLAGS "${_CMLIB_DETECTED_CXX_FLAGS} ${flag}")
|
||||
else()
|
||||
message(STATUS "'${flag}': flag is NOT supported.")
|
||||
endif()
|
||||
@@ -19,6 +17,21 @@ macro(CHECK_ENABLE_CXX_FLAG flag)
|
||||
unset(CHECK_CXX_FLAG CACHE)
|
||||
endmacro()
|
||||
|
||||
macro(CHECK_ENABLE_DEBUG_CXX_FLAG flag)
|
||||
set(CMAKE_REQUIRED_QUIET TRUE)
|
||||
check_cxx_compiler_flag("${flag}" CHECK_CXX_FLAG_DEBUG)
|
||||
unset(CMAKE_REQUIRED_QUIET)
|
||||
|
||||
if(CHECK_CXX_FLAG_DEBUG)
|
||||
message(STATUS "'${flag}': debug flag is supported.")
|
||||
string(CONCAT _CMLIB_DETECTED_CXX_FLAGS_DEBUG "${_CMLIB_DETECTED_CXX_FLAGS_DEBUG} ${flag}")
|
||||
else()
|
||||
message(STATUS "'${flag}': debug flag is NOT supported.")
|
||||
endif()
|
||||
# NOTE: check_cxx_compiler stores variables in the cache.
|
||||
unset(CHECK_CXX_FLAG_DEBUG CACHE)
|
||||
endmacro()
|
||||
|
||||
function(cmlib_set_cxx_standard version)
|
||||
# Выбор стандарта по умолчанию (можно переопределить в проекте)
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED YES PARENT_SCOPE)
|
||||
@@ -61,106 +74,142 @@ function(cmlib_set_cxx_standard version)
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# cmake-format: off
|
||||
if(LSB_DISTRIBUTOR_ID STREQUAL "AstraLinuxSE" AND
|
||||
LSB_CODENAME STREQUAL "smolensk" AND
|
||||
LSB_RELEASE STREQUAL "1.5")
|
||||
# cmake-format: on
|
||||
cmlib_set_cxx_standard(11)
|
||||
if(NOT CMLIB_CXX_FLAGS_AUTODETECTION_DONE)
|
||||
set(_CMLIB_DETECTED_CXX_FLAGS "")
|
||||
set(_CMLIB_DETECTED_CXX_FLAGS_DEBUG "")
|
||||
|
||||
set(_CMAKE_TOOLCHAIN_PREFIX "x86_64-linux-gnu-")
|
||||
set(_CMAKE_TOOLCHAIN_SUFFIX "-4.7")
|
||||
set(_CMAKE_TOOLCHAIN_LOCATION} "/usr/bin")
|
||||
else()
|
||||
cmlib_set_cxx_standard(17)
|
||||
|
||||
# -Wshadow gives a lot of false positives with GCC 4.7.2 in Astra Linux 1.5
|
||||
if(CMAKE_CXX_COMPILER_IS_GCC)
|
||||
check_enable_cxx_flag(-Wshadow)
|
||||
# Configuration bits specific for clang.
|
||||
if(CMAKE_CXX_COMPILER_IS_CLANG)
|
||||
# For now it seems like -Wshadow from clang behaves better than GCC's,
|
||||
# just enable it here for the time being.
|
||||
check_enable_debug_cxx_flag(-Wshadow)
|
||||
# New warnings in clang 8.
|
||||
# NOTE: a few issues with macros here, let's disable for now.
|
||||
# CHECK_ENABLE_DEBUG_CXX_FLAG(-Wextra-semi-stmt)
|
||||
# New warnings in clang 10.
|
||||
check_enable_debug_cxx_flag(-Wtautological-overlap-compare)
|
||||
check_enable_debug_cxx_flag(-Wtautological-compare)
|
||||
check_enable_debug_cxx_flag(-Wtautological-bitwise-compare)
|
||||
check_enable_debug_cxx_flag(-Wbitwise-conditional-parentheses)
|
||||
check_enable_debug_cxx_flag(-Wrange-loop-analysis)
|
||||
check_enable_debug_cxx_flag(-Wmisleading-indentation)
|
||||
check_enable_debug_cxx_flag(-Wc99-designator)
|
||||
check_enable_debug_cxx_flag(-Wreorder-init-list)
|
||||
check_enable_debug_cxx_flag(-Wsizeof-pointer-div)
|
||||
check_enable_debug_cxx_flag(-Wsizeof-array-div)
|
||||
check_enable_debug_cxx_flag(-Wxor-used-as-pow)
|
||||
check_enable_debug_cxx_flag(-Wfinal-dtor-non-final-class)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Common configuration for GCC, clang and Intel.
|
||||
if(CMAKE_CXX_COMPILER_IS_CLANG OR CMAKE_CXX_COMPILER_IS_INTEL OR CMAKE_CXX_COMPILER_IS_GCC)
|
||||
if(CMLIB_WARNING_FLAGS AND CMAKE_BUILD_TYPE STREQUAL "Debug")
|
||||
check_enable_cxx_flag(-Wall)
|
||||
check_enable_cxx_flag(-Wextra)
|
||||
check_enable_cxx_flag(-Wnon-virtual-dtor)
|
||||
check_enable_cxx_flag(-Wnoexcept)
|
||||
check_enable_cxx_flag(-Wlogical-op)
|
||||
check_enable_cxx_flag(-Wconversion)
|
||||
check_enable_cxx_flag(-Wdeprecated)
|
||||
# Common configuration for GCC, clang and Intel.
|
||||
if(CMAKE_CXX_COMPILER_IS_CLANG OR CMAKE_CXX_COMPILER_IS_INTEL OR CMAKE_CXX_COMPILER_IS_GCC)
|
||||
check_enable_debug_cxx_flag(-Wall)
|
||||
check_enable_debug_cxx_flag(-Wextra)
|
||||
check_enable_debug_cxx_flag(-Wnon-virtual-dtor)
|
||||
check_enable_debug_cxx_flag(-Wnoexcept)
|
||||
check_enable_debug_cxx_flag(-Wlogical-op)
|
||||
check_enable_debug_cxx_flag(-Wconversion)
|
||||
check_enable_debug_cxx_flag(-Wdeprecated)
|
||||
# This limit is supposed to be at least 1024 in C++11, but for some reason
|
||||
# clang sets this to 256, and gcc to 900.
|
||||
check_enable_cxx_flag(-ftemplate-depth=1024)
|
||||
check_enable_cxx_flag(-Wold-style-cast)
|
||||
check_enable_cxx_flag(-Wdisabled-optimization)
|
||||
check_enable_debug_cxx_flag(-Wold-style-cast)
|
||||
check_enable_debug_cxx_flag(-Wdisabled-optimization)
|
||||
# This is useful when the compiler decides the template backtrace is too
|
||||
# verbose.
|
||||
check_enable_cxx_flag(-ftemplate-backtrace-limit=0)
|
||||
check_enable_cxx_flag(-fstack-protector-all)
|
||||
check_enable_debug_cxx_flag(-ftemplate-backtrace-limit=0)
|
||||
check_enable_debug_cxx_flag(-fstack-protector-all)
|
||||
# A few suggestion flags.
|
||||
check_enable_cxx_flag(-Wsuggest-attribute=pure)
|
||||
check_enable_cxx_flag(-Wsuggest-attribute=const)
|
||||
check_enable_cxx_flag(-Wsuggest-attribute=noreturn)
|
||||
check_enable_cxx_flag(-Wsuggest-attribute=format)
|
||||
check_enable_debug_cxx_flag(-Wsuggest-attribute=pure)
|
||||
check_enable_debug_cxx_flag(-Wsuggest-attribute=const)
|
||||
check_enable_debug_cxx_flag(-Wsuggest-attribute=noreturn)
|
||||
check_enable_debug_cxx_flag(-Wsuggest-attribute=format)
|
||||
# From GCC 5.
|
||||
check_enable_cxx_flag(-Wodr)
|
||||
check_enable_cxx_flag(-Wsuggest-final-types)
|
||||
check_enable_cxx_flag(-Wsuggest-final-methods)
|
||||
check_enable_cxx_flag(-Wsuggest-override)
|
||||
check_enable_debug_cxx_flag(-Wodr)
|
||||
check_enable_debug_cxx_flag(-Wsuggest-final-types)
|
||||
check_enable_debug_cxx_flag(-Wsuggest-final-methods)
|
||||
check_enable_debug_cxx_flag(-Wsuggest-override)
|
||||
# From GCC 6.
|
||||
check_enable_cxx_flag(-Wshift-negative-value)
|
||||
check_enable_cxx_flag(-Wshift-overflow=2)
|
||||
check_enable_cxx_flag(-Wduplicated-cond)
|
||||
check_enable_cxx_flag(-Wnull-dereference)
|
||||
check_enable_debug_cxx_flag(-Wshift-negative-value)
|
||||
check_enable_debug_cxx_flag(-Wshift-overflow=2)
|
||||
check_enable_debug_cxx_flag(-Wduplicated-cond)
|
||||
check_enable_debug_cxx_flag(-Wnull-dereference)
|
||||
# From GCC 7.
|
||||
check_enable_cxx_flag(-Wrestrict)
|
||||
check_enable_cxx_flag(-Waligned-new)
|
||||
check_enable_debug_cxx_flag(-Wrestrict)
|
||||
check_enable_debug_cxx_flag(-Waligned-new)
|
||||
check_enable_debug_cxx_flag(-fdiagnostics-parseable-fixits)
|
||||
check_enable_debug_cxx_flag(-fdiagnostics-generate-patch)
|
||||
# From GCC 8.
|
||||
check_enable_cxx_flag(-Wcast-align=strict)
|
||||
check_enable_debug_cxx_flag(-Wcast-align=strict)
|
||||
# This is supposed to produce a nice graphical visualization of mismatching
|
||||
# template errors.
|
||||
check_enable_cxx_flag(-fdiagnostics-show-template-tree)
|
||||
check_enable_cxx_flag(-fdiagnostics-show-option)
|
||||
check_enable_debug_cxx_flag(-fdiagnostics-show-option)
|
||||
|
||||
check_enable_cxx_flag(-pedantic)
|
||||
check_enable_cxx_flag(-Wcast-align)
|
||||
check_enable_cxx_flag(-Wcast-qual)
|
||||
check_enable_cxx_flag(-Wctor-dtor-privacy)
|
||||
check_enable_cxx_flag(-Wdisabled-optimization)
|
||||
check_enable_cxx_flag(-Wformat=2)
|
||||
check_enable_cxx_flag(-Winit-self)
|
||||
check_enable_cxx_flag(-Wmissing-include-dirs)
|
||||
check_enable_cxx_flag(-Woverloaded-virtual)
|
||||
check_enable_cxx_flag(-Wredundant-decls)
|
||||
check_enable_cxx_flag(-Wsign-promo)
|
||||
check_enable_cxx_flag(-Wstrict-overflow=5)
|
||||
check_enable_cxx_flag(-Wundef)
|
||||
check_enable_cxx_flag(-Wno-unused)
|
||||
check_enable_cxx_flag(-Wno-variadic-macros)
|
||||
check_enable_cxx_flag(-Wno-parentheses)
|
||||
check_enable_cxx_flag(-Wstrict-null-sentinel)
|
||||
check_enable_cxx_flag(-Wshadow-all)
|
||||
check_enable_debug_cxx_flag(-pedantic)
|
||||
check_enable_debug_cxx_flag(-Wcast-align)
|
||||
check_enable_debug_cxx_flag(-Wcast-qual)
|
||||
check_enable_debug_cxx_flag(-Wctor-dtor-privacy)
|
||||
check_enable_debug_cxx_flag(-Wdisabled-optimization)
|
||||
check_enable_debug_cxx_flag(-Wformat=2)
|
||||
check_enable_debug_cxx_flag(-Winit-self)
|
||||
check_enable_debug_cxx_flag(-Wmissing-include-dirs)
|
||||
check_enable_debug_cxx_flag(-Woverloaded-virtual)
|
||||
check_enable_debug_cxx_flag(-Wredundant-decls)
|
||||
check_enable_debug_cxx_flag(-Wsign-promo)
|
||||
check_enable_debug_cxx_flag(-Wstrict-overflow=5)
|
||||
check_enable_debug_cxx_flag(-Wundef)
|
||||
check_enable_debug_cxx_flag(-Wno-unused)
|
||||
check_enable_debug_cxx_flag(-Wno-variadic-macros)
|
||||
check_enable_debug_cxx_flag(-Wno-parentheses)
|
||||
check_enable_debug_cxx_flag(-Wstrict-null-sentinel)
|
||||
check_enable_debug_cxx_flag(-Wshadow-all)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_CXX_COMPILER_IS_GCC)
|
||||
check_enable_cxx_flag(-fdiagnostics-color=auto)
|
||||
# The -Wmaybe-uninitialized flag is enabled by -Wall,
|
||||
# but it is known to emit a lot of possibly spurious warnings.
|
||||
# Let's just disable it.
|
||||
check_enable_cxx_flag(-Wno-maybe-uninitialized)
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "5.999")
|
||||
# NOTE: GCC >= 6 seems to be wrongly warning about visibility attributes
|
||||
# in some situations:
|
||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80947
|
||||
# Let's just disable the warning for now.
|
||||
check_enable_cxx_flag(-Wno-attributes)
|
||||
if(CMAKE_CXX_COMPILER_IS_GCC)
|
||||
check_enable_cxx_flag(-fdiagnostics-color=auto)
|
||||
# The -Wmaybe-uninitialized flag is enabled by -Wall,
|
||||
# but it is known to emit a lot of possibly spurious warnings.
|
||||
# Let's just disable it.
|
||||
check_enable_debug_cxx_flag(-Wno-maybe-uninitialized)
|
||||
# New in GCC 9.
|
||||
check_enable_debug_cxx_flag(-Waddress-of-packed-member)
|
||||
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "5.999")
|
||||
# NOTE: GCC >= 6 seems to be wrongly warning about visibility attributes
|
||||
# in some situations:
|
||||
# https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80947
|
||||
# Let's just disable the warning for now.
|
||||
check_enable_cxx_flag(-Wno-attributes)
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "e2k")
|
||||
check_enable_cxx_flag(-Wno-invalid-offsetof)
|
||||
list(APPEND CMAKE_LIBRARY_PATH "/usr/lib/e2k-linux-gnu")
|
||||
# cmake-format: off
|
||||
if(LSB_DISTRIBUTOR_ID STREQUAL "AstraLinuxSE" AND
|
||||
LSB_CODENAME STREQUAL "smolensk" AND
|
||||
LSB_RELEASE STREQUAL "1.5")
|
||||
# cmake-format: on
|
||||
cmlib_set_cxx_standard(11)
|
||||
|
||||
set(_CMAKE_TOOLCHAIN_PREFIX "x86_64-linux-gnu-" CACHE INTERNAL "" FORCE)
|
||||
set(_CMAKE_TOOLCHAIN_SUFFIX "-4.7" CACHE INTERNAL "" FORCE)
|
||||
set(_CMAKE_TOOLCHAIN_LOCATION "/usr/bin" CACHE INTERNAL "" FORCE)
|
||||
else()
|
||||
cmlib_set_cxx_standard(17)
|
||||
|
||||
# -Wshadow gives a lot of false positives with GCC 4.7.2 in Astra Linux 1.5
|
||||
if(CMAKE_CXX_COMPILER_IS_GCC)
|
||||
check_enable_debug_cxx_flag(-Wshadow)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(CMAKE_SYSTEM_PROCESSOR STREQUAL "e2k")
|
||||
check_enable_debug_cxx_flag(-Wno-invalid-offsetof)
|
||||
list(APPEND CMAKE_LIBRARY_PATH "/usr/lib/e2k-linux-gnu")
|
||||
endif()
|
||||
|
||||
# Set the cache variables.
|
||||
set(CMLIB_DETECTED_CXX_FLAGS "${_CMLIB_DETECTED_CXX_FLAGS}" CACHE INTERNAL "")
|
||||
set(CMLIB_DETECTED_CXX_FLAGS_DEBUG "${_CMLIB_DETECTED_CXX_FLAGS_DEBUG}" CACHE INTERNAL "")
|
||||
set(CMLIB_CXX_FLAGS_AUTODETECTION_DONE YES CACHE INTERNAL "")
|
||||
endif()
|
||||
|
@@ -14,8 +14,8 @@ endif()
|
||||
|
||||
# Очистка от сгенерированных файлов
|
||||
file(GLOB_RECURSE _cmakelists_files RELATIVE ${_source_realpath} CMakeLists.txt)
|
||||
foreach(_it ${_cmakelists_files})
|
||||
get_filename_component(_file ${_it} REALPATH)
|
||||
foreach(it ${_cmakelists_files})
|
||||
get_filename_component(_file ${it} REALPATH)
|
||||
get_filename_component(_dir ${_file} DIRECTORY)
|
||||
file(
|
||||
REMOVE_RECURSE
|
||||
|
@@ -1,10 +1,10 @@
|
||||
find_program(DISTCC_EXECUTABLE distcc)
|
||||
mark_as_advanced(DISTCC_EXECUTABLE)
|
||||
if(DISTCC_EXECUTABLE)
|
||||
foreach(LANG C CXX)
|
||||
if(NOT DEFINED CMAKE_${LANG}_COMPILER_LAUNCHER AND NOT CMAKE_${LANG}_COMPILER MATCHES ".*/distcc$")
|
||||
message(STATUS "Enabling distcc for ${LANG}")
|
||||
set(CMAKE_${LANG}_COMPILER_LAUNCHER ${DISTCC_EXECUTABLE} CACHE STRING "")
|
||||
foreach(lang C CXX)
|
||||
if(NOT DEFINED CMAKE_${lang}_COMPILER_LAUNCHER AND NOT CMAKE_${lang}_COMPILER MATCHES ".*/distcc$")
|
||||
message(STATUS "Enabling distcc for ${lang}")
|
||||
set(CMAKE_${lang}_COMPILER_LAUNCHER ${DISTCC_EXECUTABLE} CACHE STRING "")
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
@@ -25,15 +25,15 @@ function(add_doxygen target)
|
||||
set(GENERATE_LATEX YES)
|
||||
endif()
|
||||
|
||||
set(WORK_DIR ${CMAKE_BINARY_DIR}/doc/doxygen)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/cmake/doc/Doxyfile.in ${WORK_DIR}/Doxyfile @ONLY)
|
||||
set(work_dir ${CMAKE_BINARY_DIR}/doc/doxygen)
|
||||
configure_file(${CMAKE_SOURCE_DIR}/cmake/doc/Doxyfile.in ${work_dir}/Doxyfile @ONLY)
|
||||
|
||||
add_custom_target(
|
||||
${target}
|
||||
VERBATIM
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove -f "${WORK_DIR}/doxygen_sqlite3.db"
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${WORK_DIR}/Doxyfile
|
||||
WORKING_DIRECTORY ${WORK_DIR}
|
||||
COMMAND "${CMAKE_COMMAND}" -E remove -f "${work_dir}/doxygen_sqlite3.db"
|
||||
COMMAND ${DOXYGEN_EXECUTABLE} ${work_dir}/Doxyfile
|
||||
WORKING_DIRECTORY ${work_dir}
|
||||
COMMENT "Generating API documentation with Doxygen")
|
||||
else()
|
||||
message(STATUS "CMLIB warning:")
|
||||
|
@@ -6,6 +6,7 @@
|
||||
#
|
||||
# Pre: apply_global_cxx_flags_to_all_targets() must be invoked.
|
||||
#
|
||||
# cmake-lint: disable=C0103
|
||||
macro(remove_flag_from_target _target _flag)
|
||||
get_target_property(_target_cxx_flags ${_target} COMPILE_OPTIONS)
|
||||
if(_target_cxx_flags)
|
||||
@@ -22,6 +23,7 @@ endmacro()
|
||||
#
|
||||
# Pre: apply_global_cxx_flags_to_all_targets() must be invoked.
|
||||
#
|
||||
# cmake-lint: disable=C0103
|
||||
macro(remove_flag_from_file _target _file _flag)
|
||||
get_target_property(_target_sources ${_target} SOURCES)
|
||||
# Check if a sync is required, in which case we'll force a rewrite of the cache variables.
|
||||
|
@@ -2,13 +2,13 @@ function(cmlib_generate_private_config_hpp)
|
||||
include(CMLibLargeFiles)
|
||||
cmlib_test_large_files(HAVE_LARGEFILES)
|
||||
|
||||
set(OUTPUT_FILE ${CMAKE_BINARY_DIR}/include/cmlib_private_config.hpp)
|
||||
set(output_file ${CMAKE_BINARY_DIR}/include/cmlib_private_config.hpp)
|
||||
if(CMLIB_GENERATED_HEADERS_PATH)
|
||||
set(OUTPUT_FILE ${CMLIB_GENERATED_HEADERS_PATH}/cmlib_private_config.hpp)
|
||||
set(output_file ${CMLIB_GENERATED_HEADERS_PATH}/cmlib_private_config.hpp)
|
||||
elseif(ARGV0)
|
||||
set(OUTPUT_FILE ${ARGV0})
|
||||
set(output_file ${ARGV0})
|
||||
endif()
|
||||
|
||||
get_property(PROJECT_VERSION_INT GLOBAL PROPERTY PROJECT_VERSION_INT)
|
||||
configure_file(${CMLIB_MODULE_DIR}/hpp/cmlib_private_config.hpp.in ${OUTPUT_FILE})
|
||||
configure_file(${CMLIB_MODULE_DIR}/hpp/cmlib_private_config.hpp.in ${output_file})
|
||||
endfunction()
|
||||
|
@@ -1,14 +1,14 @@
|
||||
function(canonical_string INV OUTV)
|
||||
string(TOUPPER ${INV} _arg_uppercase)
|
||||
function(canonical_string in_string out_string)
|
||||
string(TOUPPER ${in_string} _arg_uppercase)
|
||||
string(REGEX REPLACE "[ -]" "_" _arg_fixed ${_arg_uppercase})
|
||||
set(${OUTV} ${_arg_fixed} PARENT_SCOPE)
|
||||
set(${out_string} ${_arg_fixed} PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Добавление общего префикса ко всем переменным в списке
|
||||
function(list_transform_prepend var prefix)
|
||||
set(temp "")
|
||||
foreach(f ${${var}})
|
||||
list(APPEND temp "${prefix}${f}")
|
||||
foreach(filename ${${var}})
|
||||
list(APPEND temp "${prefix}${filename}")
|
||||
endforeach()
|
||||
set(${var} "${temp}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
@@ -14,19 +14,18 @@ string(TOUPPER ${CMLIB_ORGANIZATION_NAME_CANONICAL} CMLIB_ORGANIZATION_NAME_UPPE
|
||||
string(TOUPPER ${CMLIB_PROJECT_NAME_CANONICAL} CMLIB_PROJECT_NAME_UPPER)
|
||||
string(TOUPPER ${CMLIB_THEME_NAME_CANONICAL} CMLIB_THEME_NAME_UPPER)
|
||||
|
||||
option(CMLIB_USE_DEVELOPMENT_INSTALL_PREFIX "Auto-generated output prefix for development installation" OFF)
|
||||
if(CMLIB_USE_DEVELOPMENT_INSTALL_PREFIX)
|
||||
if(CMLIB_THEME_NAME_LOWER STREQUAL "default")
|
||||
set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/_output" CACHE PATH "" FORCE)
|
||||
else()
|
||||
set(CMAKE_INSTALL_PREFIX "${PROJECT_SOURCE_DIR}/_output/${CMLIB_THEME_NAME_LOWER}" CACHE PATH "" FORCE)
|
||||
option(CMLIB_ADD_THEME_PREFIX "Append theme name to install prefix" OFF)
|
||||
if(CMLIB_ADD_THEME_PREFIX AND NOT CMLIB_THEME_PREFIX_APPENDED)
|
||||
if(NOT CMLIB_THEME_NAME_LOWER STREQUAL "default")
|
||||
set(CMLIB_THEME_PREFIX_APPENDED ON CACHE BOOL "" FORCE)
|
||||
set(CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}/${CMLIB_THEME_NAME}" CACHE PATH "" FORCE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# CMLIB_MODULE_DIR
|
||||
foreach(_m ${CMAKE_MODULE_PATH})
|
||||
if(EXISTS ${_m}/CMLibCommon.cmake)
|
||||
get_filename_component(CMLIB_MODULE_DIR ${_m}/CMLibCommon.cmake DIRECTORY)
|
||||
foreach(module ${CMAKE_MODULE_PATH})
|
||||
if(EXISTS ${module}/CMLibCommon.cmake)
|
||||
get_filename_component(CMLIB_MODULE_DIR ${module}/CMLibCommon.cmake DIRECTORY)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
@@ -16,14 +16,11 @@ if(EXISTS /etc/mcst_version)
|
||||
execute_process(COMMAND cat /etc/mcst_version OUTPUT_VARIABLE LSB_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
else()
|
||||
find_program(_lsb_release_executable lsb_release)
|
||||
# cmake-format: off
|
||||
if(_lsb_release_executable)
|
||||
execute_process(COMMAND ${_lsb_release_executable} -si OUTPUT_VARIABLE LSB_DISTRIBUTOR_ID
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
execute_process(COMMAND ${_lsb_release_executable} -sc OUTPUT_VARIABLE LSB_CODENAME
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
|
||||
execute_process(COMMAND ${_lsb_release_executable} -sr OUTPUT_VARIABLE LSB_RELEASE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(COMMAND ${_lsb_release_executable} -si OUTPUT_VARIABLE LSB_DISTRIBUTOR_ID OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(COMMAND ${_lsb_release_executable} -sc OUTPUT_VARIABLE LSB_CODENAME OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
execute_process(COMMAND ${_lsb_release_executable} -sr OUTPUT_VARIABLE LSB_RELEASE OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||
# cmake-format: on
|
||||
endif()
|
||||
endif()
|
||||
|
@@ -129,6 +129,7 @@ macro(cmlib_test_large_files VARIABLE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# cmake-lint: disable=C0103
|
||||
if(NOT FILE64_OK)
|
||||
# now check for Windows stuff
|
||||
try_compile(FILE64_OK "${CMAKE_BINARY_DIR}" "${CMLIB_MODULE_DIR}/tests/TestWindowsFSeek.c")
|
||||
|
@@ -11,22 +11,22 @@ function(qt5_translation outfiles)
|
||||
set(_output_dir ${_QTTR_OUTPUT_DIR})
|
||||
set(_languages ${_QTTR_LANGUAGES})
|
||||
|
||||
set(L10N_QRC_BODY "")
|
||||
set(_l10n_qrc_body "")
|
||||
make_directory(${_output_dir})
|
||||
|
||||
foreach(_lang ${_languages})
|
||||
set(_ts "${_base_name}_${_lang}.ts")
|
||||
set(_qm "${_base_name}_${_lang}.qm")
|
||||
foreach(lang ${_languages})
|
||||
set(_ts "${_base_name}_${lang}.ts")
|
||||
set(_qm "${_base_name}_${lang}.qm")
|
||||
list(APPEND _ts_list ${_output_dir}/${_ts})
|
||||
list(APPEND _l10n_names_list "${_base_name}_l10n_${_lang}")
|
||||
string(APPEND L10N_QRC_BODY "<file alias=\"${_qm}\">${CMAKE_BINARY_DIR}/${_qm}</file>\n")
|
||||
list(APPEND _l10n_names_list "${_base_name}_l10n_${lang}")
|
||||
string(APPEND _l10n_qrc_body "<file alias=\"${_qm}\">${CMAKE_BINARY_DIR}/${_qm}</file>\n")
|
||||
|
||||
add_custom_target(
|
||||
${_base_name}_l10n_${_lang} COMMAND ${Qt5_LUPDATE_EXECUTABLE} ${_sources} -ts ${_output_dir}/${_ts}
|
||||
-target-language ${_lang} DEPENDS ${_sources})
|
||||
${_base_name}_l10n_${lang} COMMAND ${Qt5_LUPDATE_EXECUTABLE} ${_sources} -ts ${_output_dir}/${_ts}
|
||||
-target-language ${lang} DEPENDS ${_sources})
|
||||
|
||||
if(NOT EXISTS "${_output_dir}/${_ts}")
|
||||
add_custom_target(${_ts} DEPENDS ${_base_name}_l10n_${_lang})
|
||||
add_custom_target(${_ts} DEPENDS ${_base_name}_l10n_${lang})
|
||||
else()
|
||||
add_custom_target(${_ts} COMMAND echo "Skipping lupdate for ${_ts}")
|
||||
endif()
|
||||
|
@@ -1,5 +1,5 @@
|
||||
if(IS_DIRECTORY "${CMLIB_MODULE_DIR}")
|
||||
set(CMLIB_SANITIZERS_DIR "${CMLIB_MODULE_DIR}/thirdparty/sanitizers/cmake")
|
||||
set(CMLIB_SANITIZERS_DIR "${CMLIB_MODULE_DIR}/thirdparty/sanitizers")
|
||||
if(IS_DIRECTORY "${CMLIB_SANITIZERS_DIR}")
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMLIB_SANITIZERS_DIR})
|
||||
find_package(Sanitizers)
|
||||
|
1
thirdparty/sanitizers
vendored
1
thirdparty/sanitizers
vendored
Submodule thirdparty/sanitizers deleted from f1abee3365
248
thirdparty/sanitizers/.cmake-format.py
vendored
Normal file
248
thirdparty/sanitizers/.cmake-format.py
vendored
Normal file
@@ -0,0 +1,248 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
# ----------------------------------
|
||||
# Options affecting listfile parsing
|
||||
# ----------------------------------
|
||||
with section("parse"):
|
||||
|
||||
# Specify structure for custom cmake functions
|
||||
additional_commands = {
|
||||
'add_doxygen': { 'flags' : [],
|
||||
'kwargs': { 'LATEX': 1,
|
||||
'HTML': 1,
|
||||
'COMMENT': 1}},
|
||||
'add_breathe': { 'flags' : [],
|
||||
'kwargs': { 'COMMENT': 1}},
|
||||
'add_common_library': { 'flags' : [],
|
||||
'kwargs': { 'OUTPUT_NAME': 1,
|
||||
'SOURCES': '*',
|
||||
'TARGET': 1}},
|
||||
'qt5_translation': { 'flags' : [],
|
||||
'kwargs': { 'OUTPUT_DIR': 1,
|
||||
'LANGUAGES': '*',
|
||||
'SOURCES': '*',
|
||||
'BASE_NAME': 1}},
|
||||
'pvs_studio_add_target': { 'flags' : [ 'COMPILE_COMMANDS',
|
||||
'OUTPUT',
|
||||
'HIDE_HELP'],
|
||||
'kwargs': { 'ARGS': '*',
|
||||
'CONFIG': '*',
|
||||
'DEPENDS': '*',
|
||||
'FORMAT': '*',
|
||||
'MODE': '*',
|
||||
'TARGET': 1}},
|
||||
'write_compiler_detection_header': { 'flags' : [],
|
||||
'kwargs': { 'COMPILERS': '*',
|
||||
'FEATURES': '*',
|
||||
'FILE': '*',
|
||||
'PREFIX': '*'}}}
|
||||
|
||||
# Specify variable tags.
|
||||
vartags = []
|
||||
|
||||
# Specify property tags.
|
||||
proptags = []
|
||||
|
||||
# -----------------------------
|
||||
# Options affecting formatting.
|
||||
# -----------------------------
|
||||
with section("format"):
|
||||
|
||||
# How wide to allow formatted cmake files
|
||||
line_width = 100
|
||||
|
||||
# How many spaces to tab for indent
|
||||
tab_size = 4
|
||||
|
||||
# If an argument group contains more than this many sub-groups (parg or kwarg
|
||||
# groups) then force it to a vertical layout.
|
||||
max_subgroups_hwrap = 3
|
||||
|
||||
# If a positional argument group contains more than this many arguments, then
|
||||
# force it to a vertical layout.
|
||||
max_pargs_hwrap = 5
|
||||
|
||||
# If a cmdline positional group consumes more than this many lines without
|
||||
# nesting, then invalidate the layout (and nest)
|
||||
max_rows_cmdline = 2
|
||||
|
||||
# If true, separate flow control names from their parentheses with a space
|
||||
separate_ctrl_name_with_space = False
|
||||
|
||||
# If true, separate function names from parentheses with a space
|
||||
separate_fn_name_with_space = False
|
||||
|
||||
# If a statement is wrapped to more than one line, than dangle the closing
|
||||
# parenthesis on its own line.
|
||||
dangle_parens = False
|
||||
|
||||
# If the trailing parenthesis must be 'dangled' on its on line, then align it
|
||||
# to this reference: `prefix`: the start of the statement, `prefix-indent`:
|
||||
# the start of the statement, plus one indentation level, `child`: align to
|
||||
# the column of the arguments
|
||||
dangle_align = 'prefix'
|
||||
|
||||
# If the statement spelling length (including space and parenthesis) is
|
||||
# smaller than this amount, then force reject nested layouts.
|
||||
min_prefix_chars = 4
|
||||
|
||||
# If the statement spelling length (including space and parenthesis) is larger
|
||||
# than the tab width by more than this amount, then force reject un-nested
|
||||
# layouts.
|
||||
max_prefix_chars = 2
|
||||
|
||||
# If a candidate layout is wrapped horizontally but it exceeds this many
|
||||
# lines, then reject the layout.
|
||||
max_lines_hwrap = 2
|
||||
|
||||
# What style line endings to use in the output.
|
||||
line_ending = 'unix'
|
||||
|
||||
# Format command names consistently as 'lower' or 'upper' case
|
||||
command_case = 'canonical'
|
||||
|
||||
# Format keywords consistently as 'lower' or 'upper' case
|
||||
keyword_case = 'upper'
|
||||
|
||||
# A list of command names which should always be wrapped
|
||||
always_wrap = []
|
||||
|
||||
# If true, the argument lists which are known to be sortable will be sorted
|
||||
# lexicographicall
|
||||
enable_sort = True
|
||||
|
||||
# If true, the parsers may infer whether or not an argument list is sortable
|
||||
# (without annotation).
|
||||
autosort = False
|
||||
|
||||
# By default, if cmake-format cannot successfully fit everything into the
|
||||
# desired linewidth it will apply the last, most agressive attempt that it
|
||||
# made. If this flag is True, however, cmake-format will print error, exit
|
||||
# with non-zero status code, and write-out nothing
|
||||
require_valid_layout = False
|
||||
|
||||
# A dictionary mapping layout nodes to a list of wrap decisions. See the
|
||||
# documentation for more information.
|
||||
layout_passes = {}
|
||||
|
||||
# ------------------------------------------------
|
||||
# Options affecting comment reflow and formatting.
|
||||
# ------------------------------------------------
|
||||
with section("markup"):
|
||||
|
||||
# What character to use for bulleted lists
|
||||
bullet_char = '*'
|
||||
|
||||
# What character to use as punctuation after numerals in an enumerated list
|
||||
enum_char = '.'
|
||||
|
||||
# If comment markup is enabled, don't reflow the first comment block in each
|
||||
# listfile. Use this to preserve formatting of your copyright/license
|
||||
# statements.
|
||||
first_comment_is_literal = False
|
||||
|
||||
# If comment markup is enabled, don't reflow any comment block which matches
|
||||
# this (regex) pattern. Default is `None` (disabled).
|
||||
literal_comment_pattern = None
|
||||
|
||||
# Regular expression to match preformat fences in comments default=
|
||||
# ``r'^\s*([`~]{3}[`~]*)(.*)$'``
|
||||
fence_pattern = '^\\s*([`~]{3}[`~]*)(.*)$'
|
||||
|
||||
# Regular expression to match rulers in comments default=
|
||||
# ``r'^\s*[^\w\s]{3}.*[^\w\s]{3}$'``
|
||||
ruler_pattern = '^\\s*[^\\w\\s]{3}.*[^\\w\\s]{3}$'
|
||||
|
||||
# If a comment line matches starts with this pattern then it is explicitly a
|
||||
# trailing comment for the preceeding argument. Default is '#<'
|
||||
explicit_trailing_pattern = '#<'
|
||||
|
||||
# If a comment line starts with at least this many consecutive hash
|
||||
# characters, then don't lstrip() them off. This allows for lazy hash rulers
|
||||
# where the first hash char is not separated by space
|
||||
hashruler_min_length = 10
|
||||
|
||||
# If true, then insert a space between the first hash char and remaining hash
|
||||
# chars in a hash ruler, and normalize its length to fill the column
|
||||
canonicalize_hashrulers = True
|
||||
|
||||
# enable comment markup parsing and reflow
|
||||
enable_markup = False
|
||||
|
||||
# ----------------------------
|
||||
# Options affecting the linter
|
||||
# ----------------------------
|
||||
with section("lint"):
|
||||
|
||||
# a list of lint codes to disable
|
||||
disabled_codes = ['C0113']
|
||||
|
||||
# regular expression pattern describing valid function names
|
||||
function_pattern = '[0-9a-z_]+'
|
||||
|
||||
# regular expression pattern describing valid macro names
|
||||
macro_pattern = '[0-9A-Z_]+'
|
||||
|
||||
# regular expression pattern describing valid names for variables with global
|
||||
# scope
|
||||
global_var_pattern = '[0-9A-Z][0-9A-Z_]+'
|
||||
|
||||
# regular expression pattern describing valid names for variables with global
|
||||
# scope (but internal semantic)
|
||||
internal_var_pattern = '_[0-9A-Z][0-9A-Z_]+'
|
||||
|
||||
# regular expression pattern describing valid names for variables with local
|
||||
# scope
|
||||
local_var_pattern = '[0-9a-z_]+'
|
||||
|
||||
# regular expression pattern describing valid names for privatedirectory
|
||||
# variables
|
||||
private_var_pattern = '_[0-9a-z_]+'
|
||||
|
||||
# regular expression pattern describing valid names for publicdirectory
|
||||
# variables
|
||||
public_var_pattern = '[0-9A-Z][0-9A-Z_]+'
|
||||
|
||||
# regular expression pattern describing valid names for keywords used in
|
||||
# functions or macros
|
||||
keyword_pattern = '[0-9A-Z_]+'
|
||||
|
||||
# In the heuristic for C0201, how many conditionals to match within a loop in
|
||||
# before considering the loop a parser.
|
||||
max_conditionals_custom_parser = 2
|
||||
|
||||
# Require at least this many newlines between statements
|
||||
min_statement_spacing = 1
|
||||
|
||||
# Require no more than this many newlines between statements
|
||||
max_statement_spacing = 2
|
||||
max_returns = 6
|
||||
max_branches = 12
|
||||
max_arguments = 5
|
||||
max_localvars = 15
|
||||
max_statements = 50
|
||||
|
||||
# -------------------------------
|
||||
# Options affecting file encoding
|
||||
# -------------------------------
|
||||
with section("encode"):
|
||||
|
||||
# If true, emit the unicode byte-order mark (BOM) at the start of the file
|
||||
emit_byteorder_mark = False
|
||||
|
||||
# Specify the encoding of the input file. Defaults to utf-8
|
||||
input_encoding = 'utf-8'
|
||||
|
||||
# Specify the encoding of the output file. Defaults to utf-8. Note that cmake
|
||||
# only claims to support utf-8 so be careful when using anything else
|
||||
output_encoding = 'utf-8'
|
||||
|
||||
# -------------------------------------
|
||||
# Miscellaneous configurations options.
|
||||
# -------------------------------------
|
||||
with section("misc"):
|
||||
|
||||
# A dictionary containing any per-command configuration overrides. Currently
|
||||
# only `command_case` is supported.
|
||||
per_command = {}
|
||||
|
45
thirdparty/sanitizers/FindASan.cmake
vendored
Normal file
45
thirdparty/sanitizers/FindASan.cmake
vendored
Normal file
@@ -0,0 +1,45 @@
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c)
|
||||
# 2013 Matthew Arsenault 2015-2016 RWTH Aachen University, Federal Republic of Germany
|
||||
# 2021 Markus Eggenbauer
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
# associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all copies or
|
||||
# substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
||||
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
option(SANITIZE_ADDRESS "Enable AddressSanitizer for sanitized targets." Off)
|
||||
|
||||
set(FLAG_CANDIDATES
|
||||
# Clang 3.2+ use this version. The no-omit-frame-pointer option is optional.
|
||||
"-g -fsanitize=address -fno-omit-frame-pointer" "-g -fsanitize=address"
|
||||
# Older deprecated flag for ASan
|
||||
"-g -faddress-sanitizer")
|
||||
|
||||
include(sanitize-helpers)
|
||||
|
||||
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "AddressSanitizer" "ASan")
|
||||
|
||||
find_program(ASan_WRAPPER "asan-wrapper" PATHS ${CMAKE_MODULE_PATH})
|
||||
mark_as_advanced(ASan_WRAPPER)
|
||||
|
||||
function(add_sanitize_address TARGET)
|
||||
# TODO: check conditions for target:
|
||||
# if (SANITIZE_ADDRESS AND (SANITIZE_THREAD OR SANITIZE_MEMORY))
|
||||
# message(FATAL_ERROR "AddressSanitizer is not compatible with ThreadSanitizer or MemorySanitizer.")
|
||||
# endif ()
|
||||
|
||||
sanitizer_check_target(${TARGET})
|
||||
sanitizer_add_flags(${TARGET} "AddressSanitizer" "ASan")
|
||||
endfunction()
|
44
thirdparty/sanitizers/FindCFI.cmake
vendored
Normal file
44
thirdparty/sanitizers/FindCFI.cmake
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c)
|
||||
# 2013 Matthew Arsenault 2015-2016 RWTH Aachen University, Federal Republic of Germany
|
||||
# 2021 Markus Eggenbauer
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
# associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all copies or
|
||||
# substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
||||
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
option(SANITIZE_CFI "Enable Control Flow Integrity (CFI) for sanitized targets." OFF)
|
||||
|
||||
set(FLAG_CANDIDATES
|
||||
# FIXME: Brief comment on why the additional flags
|
||||
# In this case you need a
|
||||
# linker that does optimization at
|
||||
# linking time such as LLVM lld or GNU gold.
|
||||
"-g -fsanitize=cfi -fvisibility=hidden -flto -fuse-ld=lld")
|
||||
|
||||
# There might be some conflict with the other sanitizer
|
||||
# hence it might need an if statement here.
|
||||
|
||||
# add some handy functions
|
||||
include(sanitize-helpers)
|
||||
|
||||
if(SANITIZE_CFI)
|
||||
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "ControlFlowIntegrity" "CFI")
|
||||
endif()
|
||||
|
||||
function(add_sanitize_cfi TARGET)
|
||||
sanitizer_check_target(${TARGET})
|
||||
sanitizer_add_flags(${TARGET} "ControlFlowIntegrity" "CFI")
|
||||
endfunction()
|
39
thirdparty/sanitizers/FindLeakSan.cmake
vendored
Normal file
39
thirdparty/sanitizers/FindLeakSan.cmake
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c)
|
||||
# 2013 Matthew Arsenault
|
||||
# 2015-2016 RWTH Aachen University, Federal Republic of Germany
|
||||
# 2019 Barcelona Supercomputing Center
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
option(SANITIZE_LEAK "Enable LeakSanitizer for sanitized targets." Off)
|
||||
|
||||
set(FLAG_CANDIDATES "-g -fsanitize=leak")
|
||||
|
||||
include(sanitize-helpers)
|
||||
|
||||
if(SANITIZE_LEAK)
|
||||
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "LeakSanitizer" "LeakSan")
|
||||
endif()
|
||||
|
||||
function(add_sanitize_leak TARGET)
|
||||
sanitizer_check_target(${TARGET})
|
||||
sanitizer_add_flags(${TARGET} "LeakSanitizer" "LeakSan")
|
||||
endfunction()
|
49
thirdparty/sanitizers/FindMSan.cmake
vendored
Normal file
49
thirdparty/sanitizers/FindMSan.cmake
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c)
|
||||
# 2013 Matthew Arsenault
|
||||
# 2015-2016 RWTH Aachen University, Federal Republic of Germany
|
||||
# 2021 Markus Eggenbauer
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
option(SANITIZE_MEMORY "Enable MemorySanitizer for sanitized targets." Off)
|
||||
|
||||
set(FLAG_CANDIDATES "-g -fsanitize=memory")
|
||||
|
||||
include(sanitize-helpers)
|
||||
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
|
||||
message(NOTICE "MemorySanitizer disabled for target ${TARGET} because "
|
||||
"MemorySanitizer is supported for Linux systems only.")
|
||||
elseif(NOT ${CMAKE_SIZEOF_VOID_P} EQUAL 8)
|
||||
message(NOTICE "MemorySanitizer disabled for target ${TARGET} because "
|
||||
"MemorySanitizer is supported for 64bit systems only.")
|
||||
else()
|
||||
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "MemorySanitizer" "MSan")
|
||||
endif()
|
||||
|
||||
function(add_sanitize_memory TARGET)
|
||||
# TODO: check conditions for target:
|
||||
# if (SANITIZE_MEMORY AND (SANITIZE_THREAD OR SANITIZE_ADDRESS))
|
||||
# message(FATAL_ERROR "AddressSanitizer is not compatible with ThreadSanitizer or MemorySanitizer.")
|
||||
# endif ()
|
||||
sanitizer_check_target(${TARGET})
|
||||
sanitizer_add_flags(${TARGET} "MemorySanitizer" "MSan")
|
||||
endfunction()
|
39
thirdparty/sanitizers/FindSS.cmake
vendored
Normal file
39
thirdparty/sanitizers/FindSS.cmake
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c)
|
||||
# 2013 Matthew Arsenault 2015-2016 RWTH Aachen University, Federal Republic of Germany
|
||||
# 2021 Markus Eggenbauer
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy of this software and
|
||||
# associated documentation files (the "Software"), to deal in the Software without restriction,
|
||||
# including without limitation the rights to use, copy, modify, merge, publish, distribute,
|
||||
# sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all copies or
|
||||
# substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT
|
||||
# NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
|
||||
# DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT
|
||||
# OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
option(SANITIZE_SS "Enable SafeStack for sanitized targets." OFF)
|
||||
|
||||
set(FLAG_CANDIDATES "-g -fsanitize=safe-stack")
|
||||
|
||||
# There might be some conflict with the other sanitizer
|
||||
# hence it might need an if statement here.
|
||||
|
||||
# add some handy functions
|
||||
include(sanitize-helpers)
|
||||
|
||||
if(SANITIZE_SS)
|
||||
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "SafeStack" "SS")
|
||||
endif()
|
||||
|
||||
function(add_sanitize_ss TARGET)
|
||||
sanitizer_check_target(${TARGET})
|
||||
sanitizer_add_flags(${TARGET} "SafeStack" "SS")
|
||||
endfunction()
|
109
thirdparty/sanitizers/FindSanitizers.cmake
vendored
Normal file
109
thirdparty/sanitizers/FindSanitizers.cmake
vendored
Normal file
@@ -0,0 +1,109 @@
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c)
|
||||
# 2013 Matthew Arsenault
|
||||
# 2015-2016 RWTH Aachen University, Federal Republic of Germany
|
||||
# 2021 Markus Eggenbauer
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
# If any of the used compiler is a GNU compiler, add a second option to static
|
||||
# link against the sanitizers.
|
||||
option(SANITIZE_LINK_STATIC "Try to link static against sanitizers." Off)
|
||||
|
||||
set(FIND_QUIETLY_FLAG "")
|
||||
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})
|
||||
|
||||
function(sanitizer_add_blacklist_file FILE)
|
||||
if(NOT IS_ABSOLUTE ${FILE})
|
||||
set(FILE "${CMAKE_CURRENT_SOURCE_DIR}/${FILE}")
|
||||
endif()
|
||||
get_filename_component(FILE "${FILE}" REALPATH)
|
||||
|
||||
sanitizer_check_compiler_flags("-fsanitize-blacklist=${FILE}" "SanitizerBlacklist" "SanBlist")
|
||||
endfunction()
|
||||
|
||||
function(add_sanitizers ...)
|
||||
# If no sanitizer is enabled, return immediately.
|
||||
if(NOT
|
||||
(SANITIZE_ADDRESS
|
||||
OR SANITIZE_MEMORY
|
||||
OR SANITIZE_THREAD
|
||||
OR SANITIZE_UNDEFINED
|
||||
OR SANITIZE_LEAK
|
||||
OR SANITIZE_CFI
|
||||
OR SANITIZE_SS))
|
||||
message(STATUS "No sanitizer selected.")
|
||||
return()
|
||||
endif()
|
||||
|
||||
if(SANITIZE_ADDRESS AND SANITIZE_THREAD)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Incompatible Sanitizer combination enabled: AddressSanitizer, ThreadSanitizer")
|
||||
endif()
|
||||
if(SANITIZE_ADDRESS AND SANITIZE_MEMORY)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Incompatible Sanitizer combination enabled: AddressSanitizer, MemorySanitizer")
|
||||
endif()
|
||||
|
||||
if(SANITIZE_MEMORY AND SANITIZE_THREAD)
|
||||
message(
|
||||
FATAL_ERROR
|
||||
"Incompatible Sanitizer combination enabled: MemorySanitizer, ThreadSanitizer")
|
||||
endif()
|
||||
|
||||
foreach(TARGET ${ARGV})
|
||||
sanitizer_check_target(${TARGET})
|
||||
|
||||
# Add sanitizers for target.
|
||||
if(SANITIZE_ADDRESS)
|
||||
add_sanitize_address(${TARGET})
|
||||
endif()
|
||||
if(SANITIZE_THREAD)
|
||||
add_sanitize_thread(${TARGET})
|
||||
endif()
|
||||
if(SANITIZE_MEMORY)
|
||||
add_sanitize_memory(${TARGET})
|
||||
endif()
|
||||
if(SANITIZE_UNDEFINED)
|
||||
add_sanitize_undefined(${TARGET})
|
||||
endif()
|
||||
if(SANITIZE_LEAK)
|
||||
add_sanitize_leak(${TARGET})
|
||||
endif()
|
||||
if(SANITIZE_CFI)
|
||||
add_sanitize_cfi(${TARGET})
|
||||
endif()
|
||||
if(SANITIZE_SS)
|
||||
add_sanitize_ss(${TARGET})
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction(add_sanitizers)
|
53
thirdparty/sanitizers/FindTSan.cmake
vendored
Normal file
53
thirdparty/sanitizers/FindTSan.cmake
vendored
Normal file
@@ -0,0 +1,53 @@
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c)
|
||||
# 2013 Matthew Arsenault
|
||||
# 2015-2016 RWTH Aachen University, Federal Republic of Germany
|
||||
# 2021 Markus Eggenbauer
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
option(SANITIZE_THREAD "Enable ThreadSanitizer for sanitized targets." Off)
|
||||
|
||||
set(FLAG_CANDIDATES "-g -fsanitize=thread")
|
||||
|
||||
include(sanitize-helpers)
|
||||
|
||||
if(NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" AND NOT ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
|
||||
message(NOTICE "ThreadSanitizer disabled for target ${TARGET} because "
|
||||
"ThreadSanitizer is supported for Linux systems and macOS only.")
|
||||
set(SANITIZE_THREAD Off CACHE BOOL "Enable ThreadSanitizer for sanitized targets." FORCE)
|
||||
elseif(NOT ${CMAKE_SIZEOF_VOID_P} EQUAL 8)
|
||||
message(NOTICE "ThreadSanitizer disabled for target ${TARGET} because "
|
||||
"ThreadSanitizer is supported for 64bit systems only.")
|
||||
set(SANITIZE_THREAD Off CACHE BOOL "Enable ThreadSanitizer for sanitized targets." FORCE)
|
||||
else()
|
||||
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "ThreadSanitizer" "TSan")
|
||||
endif()
|
||||
|
||||
function(add_sanitize_thread TARGET)
|
||||
# ThreadSanitizer is not compatible with MemorySanitizer.
|
||||
#
|
||||
# if(SANITIZE_THREAD AND SANITIZE_MEMORY)
|
||||
# message(FATAL_ERROR "ThreadSanitizer is not compatible with " "MemorySanitizer.")
|
||||
# endif()
|
||||
|
||||
sanitizer_check_target(${TARGET})
|
||||
sanitizer_add_flags(${TARGET} "ThreadSanitizer" "TSan")
|
||||
endfunction()
|
37
thirdparty/sanitizers/FindUBSan.cmake
vendored
Normal file
37
thirdparty/sanitizers/FindUBSan.cmake
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c)
|
||||
# 2013 Matthew Arsenault
|
||||
# 2015-2016 RWTH Aachen University, Federal Republic of Germany
|
||||
# 2021 Markus Eggenbauer
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
option(SANITIZE_UNDEFINED "Enable UndefinedBehaviorSanitizer for sanitized targets." Off)
|
||||
|
||||
set(FLAG_CANDIDATES "-g -fsanitize=undefined")
|
||||
|
||||
include(sanitize-helpers)
|
||||
|
||||
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "UndefinedBehaviorSanitizer" "UBSan")
|
||||
|
||||
function(add_sanitize_undefined TARGET)
|
||||
sanitizer_check_target(${TARGET})
|
||||
sanitizer_add_flags(${TARGET} "UndefinedBehaviorSanitizer" "UBSan")
|
||||
endfunction()
|
55
thirdparty/sanitizers/asan-wrapper
vendored
Executable file
55
thirdparty/sanitizers/asan-wrapper
vendored
Executable file
@@ -0,0 +1,55 @@
|
||||
#!/bin/sh
|
||||
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c)
|
||||
# 2013 Matthew Arsenault
|
||||
# 2015-2016 RWTH Aachen University, Federal Republic of Germany
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
# This script is a wrapper for AddressSanitizer. In some special cases you need
|
||||
# to preload AddressSanitizer to avoid error messages - e.g. if you're
|
||||
# preloading another library to your application. At the moment this script will
|
||||
# only do something, if we're running on a Linux platform. OSX might not be
|
||||
# affected.
|
||||
|
||||
|
||||
# Exit immediately, if platform is not Linux.
|
||||
if [ "$(uname)" != "Linux" ]
|
||||
then
|
||||
exec $@
|
||||
fi
|
||||
|
||||
|
||||
# Get the used libasan of the application ($1). If a libasan was found, it will
|
||||
# be prepended to LD_PRELOAD.
|
||||
libasan=$(ldd $1 | grep libasan | sed "s/^[[:space:]]//" | cut -d' ' -f1)
|
||||
if [ -n "$libasan" ]
|
||||
then
|
||||
if [ -n "$LD_PRELOAD" ]
|
||||
then
|
||||
export LD_PRELOAD="$libasan:$LD_PRELOAD"
|
||||
else
|
||||
export LD_PRELOAD="$libasan"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Execute the application.
|
||||
exec $@
|
199
thirdparty/sanitizers/sanitize-helpers.cmake
vendored
Normal file
199
thirdparty/sanitizers/sanitize-helpers.cmake
vendored
Normal file
@@ -0,0 +1,199 @@
|
||||
# The MIT License (MIT)
|
||||
#
|
||||
# Copyright (c)
|
||||
# 2013 Matthew Arsenault
|
||||
# 2015-2016 RWTH Aachen University, Federal Republic of Germany
|
||||
# 2021 Markus Eggenbauer
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included in all
|
||||
# copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
|
||||
# Helper function to get the language of a source file.
|
||||
function(sanitizer_lang_of_source FILE RETURN_VAR)
|
||||
get_filename_component(LONGEST_EXT "${FILE}" EXT)
|
||||
# If extension is empty return. This can happen for extensionless headers
|
||||
if("${LONGEST_EXT}" STREQUAL "")
|
||||
set(${RETURN_VAR} "" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
# Get shortest extension as some files can have dot in their names
|
||||
string(REGEX REPLACE "^.*(\\.[^.]+)$" "\\1" FILE_EXT ${LONGEST_EXT})
|
||||
string(TOLOWER "${FILE_EXT}" FILE_EXT)
|
||||
string(SUBSTRING "${FILE_EXT}" 1 -1 FILE_EXT)
|
||||
|
||||
get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
foreach(LANG ${ENABLED_LANGUAGES})
|
||||
list(FIND CMAKE_${LANG}_SOURCE_FILE_EXTENSIONS "${FILE_EXT}" TEMP)
|
||||
if(NOT ${TEMP} EQUAL -1)
|
||||
set(${RETURN_VAR} "${LANG}" PARENT_SCOPE)
|
||||
return()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(${RETURN_VAR} "" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Helper function to get compilers used by a target.
|
||||
function(sanitizer_target_compilers TARGET RETURN_VAR)
|
||||
# Check if all sources for target use the same compiler. If a target uses
|
||||
# e.g. C and Fortran mixed and uses different compilers (e.g. clang and
|
||||
# gfortran) this can trigger huge problems, because different compilers may
|
||||
# use different implementations for sanitizers.
|
||||
set(BUFFER "")
|
||||
get_target_property(TSOURCES ${TARGET} SOURCES)
|
||||
foreach(FILE ${TSOURCES})
|
||||
# If expression was found, FILE is a generator-expression for an object
|
||||
# library. Object libraries will be ignored.
|
||||
string(REGEX MATCH "TARGET_OBJECTS:([^ >]+)" _file ${FILE})
|
||||
if("${_file}" STREQUAL "")
|
||||
sanitizer_lang_of_source(${FILE} LANG)
|
||||
if(LANG)
|
||||
list(APPEND BUFFER ${CMAKE_${LANG}_COMPILER_ID})
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
list(REMOVE_DUPLICATES BUFFER)
|
||||
set(${RETURN_VAR} "${BUFFER}" PARENT_SCOPE)
|
||||
endfunction()
|
||||
|
||||
# Helper function to check compiler flags for language compiler.
|
||||
function(sanitizer_check_compiler_flag FLAG LANG VARIABLE)
|
||||
if(${LANG} STREQUAL "C")
|
||||
include(CheckCCompilerFlag)
|
||||
check_c_compiler_flag("${FLAG}" ${VARIABLE})
|
||||
|
||||
elseif(${LANG} STREQUAL "CXX")
|
||||
include(CheckCXXCompilerFlag)
|
||||
check_cxx_compiler_flag("${FLAG}" ${VARIABLE})
|
||||
|
||||
elseif(${LANG} STREQUAL "Fortran")
|
||||
# CheckFortranCompilerFlag was introduced in CMake 3.x. To be compatible
|
||||
# with older Cmake versions, we will check if this module is present
|
||||
# before we use it. Otherwise we will define Fortran coverage support as
|
||||
# not available.
|
||||
include(CheckFortranCompilerFlag OPTIONAL RESULT_VARIABLE INCLUDED)
|
||||
if(INCLUDED)
|
||||
CHECK_Fortran_COMPILER_FLAG("${FLAG}" ${VARIABLE})
|
||||
elseif(NOT CMAKE_REQUIRED_QUIET)
|
||||
message(STATUS "Performing Test ${VARIABLE}")
|
||||
message(STATUS "Performing Test ${VARIABLE}" " - Failed (Check not supported)")
|
||||
endif()
|
||||
endif()
|
||||
endfunction()
|
||||
|
||||
# Helper function to test compiler flags.
|
||||
function(sanitizer_check_compiler_flags FLAG_CANDIDATES NAME PREFIX)
|
||||
set(CMAKE_REQUIRED_QUIET ${${PREFIX}_FIND_QUIETLY})
|
||||
|
||||
get_property(ENABLED_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
|
||||
foreach(LANG ${ENABLED_LANGUAGES})
|
||||
# Sanitizer flags are not dependend on language, but the used compiler.
|
||||
# So instead of searching flags foreach language, search flags foreach
|
||||
# compiler used.
|
||||
set(COMPILER ${CMAKE_${LANG}_COMPILER_ID})
|
||||
if(NOT DEFINED ${PREFIX}_${COMPILER}_FLAGS)
|
||||
foreach(FLAG ${FLAG_CANDIDATES})
|
||||
if(NOT CMAKE_REQUIRED_QUIET)
|
||||
message(STATUS "Try ${COMPILER} ${NAME} flag = [${FLAG}]")
|
||||
endif()
|
||||
|
||||
set(CMAKE_REQUIRED_FLAGS "${FLAG}")
|
||||
unset(${PREFIX}_FLAG_DETECTED CACHE)
|
||||
sanitizer_check_compiler_flag("${FLAG}" ${LANG} ${PREFIX}_FLAG_DETECTED)
|
||||
|
||||
if(${PREFIX}_FLAG_DETECTED)
|
||||
# If compiler is a GNU compiler, search for static flag, if
|
||||
# SANITIZE_LINK_STATIC is enabled.
|
||||
if(SANITIZE_LINK_STATIC AND (${COMPILER} STREQUAL "GNU"))
|
||||
string(TOLOWER ${PREFIX} PREFIX_lower)
|
||||
sanitizer_check_compiler_flag("-static-lib${PREFIX_lower}" ${LANG}
|
||||
${PREFIX}_STATIC_FLAG_DETECTED)
|
||||
|
||||
if(${PREFIX}_STATIC_FLAG_DETECTED)
|
||||
set(FLAG "-static-lib${PREFIX_lower} ${FLAG}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
set(${PREFIX}_${COMPILER}_FLAGS "${FLAG}"
|
||||
CACHE STRING "${NAME} flags for ${COMPILER} compiler.")
|
||||
mark_as_advanced(${PREFIX}_${COMPILER}_FLAGS)
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(NOT ${PREFIX}_FLAG_DETECTED)
|
||||
set(${PREFIX}_${COMPILER}_FLAGS "" CACHE STRING
|
||||
"${NAME} flags for ${COMPILER} compiler.")
|
||||
mark_as_advanced(${PREFIX}_${COMPILER}_FLAGS)
|
||||
|
||||
message(
|
||||
NOTICE "${NAME} is not available for ${COMPILER} "
|
||||
"compiler. Targets using this compiler will be " "compiled without ${NAME}.")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endfunction()
|
||||
|
||||
# Helper to assign sanitizer flags for TARGET.
|
||||
function(sanitizer_add_flags TARGET NAME PREFIX)
|
||||
# Get list of compilers used by target and check, if sanitizer is available
|
||||
# for this target. Other compiler checks like check for conflicting
|
||||
# compilers will be done in add_sanitizers function.
|
||||
sanitizer_target_compilers(${TARGET} TARGET_COMPILER)
|
||||
list(LENGTH TARGET_COMPILER NUM_COMPILERS)
|
||||
if("${${PREFIX}_${TARGET_COMPILER}_FLAGS}" STREQUAL "")
|
||||
return()
|
||||
endif()
|
||||
|
||||
# Set compile- and link-flags for target.
|
||||
set_property(TARGET ${TARGET} APPEND_STRING PROPERTY COMPILE_FLAGS
|
||||
" ${${PREFIX}_${TARGET_COMPILER}_FLAGS}")
|
||||
set_property(TARGET ${TARGET} APPEND_STRING PROPERTY COMPILE_FLAGS
|
||||
" ${SanBlist_${TARGET_COMPILER}_FLAGS}")
|
||||
set_property(TARGET ${TARGET} APPEND_STRING PROPERTY LINK_FLAGS
|
||||
" ${${PREFIX}_${TARGET_COMPILER}_FLAGS}")
|
||||
endfunction()
|
||||
|
||||
macro(sanitizer_check_target TARGET)
|
||||
# Check if this target will be compiled by exactly one compiler. Other-
|
||||
# wise sanitizers can't be used and a warning should be printed once.
|
||||
get_target_property(TARGET_TYPE ${TARGET} TYPE)
|
||||
if(TARGET_TYPE STREQUAL "INTERFACE_LIBRARY")
|
||||
message(NOTICE "Can't use any sanitizers for target ${TARGET}, "
|
||||
"because it is an interface library and cannot be " "compiled directly.")
|
||||
return()
|
||||
endif()
|
||||
sanitizer_target_compilers(${TARGET} TARGET_COMPILER)
|
||||
list(LENGTH TARGET_COMPILER NUM_COMPILERS)
|
||||
if(NUM_COMPILERS GREATER 1)
|
||||
message(
|
||||
NOTICE "Can't use any sanitizers for target ${TARGET}, "
|
||||
"because it will be compiled by incompatible compilers. "
|
||||
"Target will be compiled without sanitizers.")
|
||||
return()
|
||||
|
||||
# If the target is compiled by no or no known compiler, give a warning.
|
||||
elseif(NUM_COMPILERS EQUAL 0)
|
||||
message(
|
||||
NOTICE "Sanitizers for target ${TARGET} may not be"
|
||||
" usable, because it uses no or an unknown compiler. "
|
||||
"This is a false warning for targets using only " "object lib(s) as input.")
|
||||
return()
|
||||
endif()
|
||||
endmacro(sanitizer_check_target)
|
Reference in New Issue
Block a user