diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..b5207e9 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "thirdparty/sanitizers"] + path = thirdparty/sanitizers + url = git@git.246060.ru:/f1x1t/cmake-sanitizers diff --git a/CMLibSanitizers.cmake b/CMLibSanitizers.cmake index 028d1d6..6c1d38a 100644 --- a/CMLibSanitizers.cmake +++ b/CMLibSanitizers.cmake @@ -1,27 +1,11 @@ -if(CMAKE_CXX_COMPILER_IS_CLANG OR CMAKE_CXX_COMPILER_IS_GCC) - - option(SANITIZE_THREAD "Enable thread sanitizer" OFF) - option(SANITIZE_ADDRESS "Enable address sanitizer" OFF) - if(SANITIZE_THREAD AND SANITIZE_ADDRESS) - message(FATAL_ERROR "AddressSanitizer is not compatible with ThreadSanitizer.") - endif() - - if(SANITIZE_ADDRESS) - message(STATUS "AddressSanitizer enabled") - set(SANITIZER_FLAGS "-fsanitize=address,undefined") - check_enable_cxx_flag(-fno-sanitize=signed-integer-overflow) - endif() - - if(SANITIZE_THREAD) - message(STATUS "ThreadSanitizer enabled") - set(SANITIZER_FLAGS "-fsanitize=thread") - endif() - - if(SANITIZE_THREAD OR SANITIZE_ADDRESS) - check_enable_cxx_flag(${SANITIZER_FLAGS}) - check_enable_cxx_flag("-fno-sanitize-recover=all") - check_enable_cxx_flag("-fno-omit-frame-pointer") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${SANITIZER_FLAGS} -fuse-ld=gold") +if(DIRECTORY CMLIB_MODULE_DIR) + set(CMLIB_SANITIZERS_DIR "${CMLIB_MODULE_DIR}/thirdparty/sanitizers/cmake") + if(DIRECTORY CMLIB_SANITIZERS_DIR) + list(APPEND CMAKE_MODULE_PATH ${CMLIB_SANITIZERS_DIR}) + else() + message(WARNING "Sanitizers submodule not found.") endif() +else() + message(FATAL_ERROR "CMLib directory not found.") endif() diff --git a/thirdparty/sanitizers b/thirdparty/sanitizers new file mode 160000 index 0000000..9b4aec0 --- /dev/null +++ b/thirdparty/sanitizers @@ -0,0 +1 @@ +Subproject commit 9b4aec096e3c05124bb46c9d9dc18468b3646e95