Compare commits

...

4 Commits

6 changed files with 12 additions and 13 deletions

View File

@@ -1,6 +1,7 @@
cmake_policy(SET CMP0057 NEW)
option(CMLIB_ENABLE_WARNING_FLAGS "Enable autodetected warning flags" ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON CACHE BOOL "Enable generation of compile_commands.json." FORCE)
# Добавление конфигурации для профилирования
if(CMAKE_CONFIGURATION_TYPES)
@@ -47,7 +48,6 @@ if(CMAKE_BUILD_TYPE STREQUAL Profile)
message("Set options for profiling with Visual Studio C++")
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(PROFILE 1)
elseif(CMAKE_BUILD_TYPE STREQUAL Debug)
# В режиме отладки подробный вывод сообщений компилятора
@@ -65,7 +65,6 @@ elseif(CMAKE_BUILD_TYPE STREQUAL Debug)
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)
@@ -73,7 +72,6 @@ elseif(CMAKE_BUILD_TYPE STREQUAL Release)
elseif(CMAKE_BUILD_TYPE STREQUAL None)
# Режим None используется для статического анализа кода
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(ANALYSIS 1)
endif()

View File

@@ -38,3 +38,10 @@ if(IS_DIRECTORY "${CMLIB_MODULE_DIR}")
else()
message(FATAL_ERROR "CMLib directory not found.")
endif()
if(NOT DEFINED CMLIB_CMAKE_DIR)
get_filename_component(CMLIB_CMAKE_DIR ${CMLIB_MODULE_DIR} DIRECTORY)
if(IS_DIRECTORY "${CMLIB_CMAKE_DIR}/find")
list(APPEND CMAKE_MODULE_PATH "${CMLIB_CMAKE_DIR}/find")
endif()
endif()

View File

@@ -34,9 +34,7 @@ set(FLAG_CANDIDATES
# add some handy functions
include(sanitize-helpers)
if(SANITIZE_CFI)
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "ControlFlowIntegrity" "CFI")
endif()
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "ControlFlowIntegrity" "CFI")
function(add_sanitize_cfi TARGET)
sanitizer_check_target(${TARGET})

View File

@@ -29,9 +29,7 @@ set(FLAG_CANDIDATES "-g -fsanitize=leak")
include(sanitize-helpers)
if(SANITIZE_LEAK)
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "LeakSanitizer" "LeakSan")
endif()
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "LeakSanitizer" "LeakSan")
function(add_sanitize_leak TARGET)
sanitizer_check_target(${TARGET})

View File

@@ -29,9 +29,7 @@ set(FLAG_CANDIDATES "-g -fsanitize=safe-stack")
# add some handy functions
include(sanitize-helpers)
if(SANITIZE_SS)
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "SafeStack" "SS")
endif()
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "SafeStack" "SS")
function(add_sanitize_ss TARGET)
sanitizer_check_target(${TARGET})

View File

@@ -120,7 +120,7 @@ function(sanitizer_check_compiler_flags FLAG_CANDIDATES NAME PREFIX)
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"))
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)