Skip to content

Add posibility to build with sanitizers enabled #247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 4, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ option(CUKE_ENABLE_GTEST "Enable Google Test framework" ON)
option(CUKE_ENABLE_QT "Enable Qt framework" ON)
option(CUKE_TESTS_E2E "Enable end-to-end tests" ON)
option(CUKE_TESTS_UNIT "Enable unit tests" ON)
set(CUKE_ENABLE_SANITIZER "OFF" CACHE STRING "Sanitizer to use for checking")
set_property(CACHE CUKE_ENABLE_SANITIZER PROPERTY STRINGS OFF "address" "thread" "undefined")
option(CUKE_TESTS_VALGRIND "Enable tests within Valgrind" OFF)
set(GMOCK_SRC_DIR "" CACHE STRING "Google Mock framework sources path (otherwise downloaded)")
set(GMOCK_VER "1.7.0" CACHE STRING "Google Mock framework version to be used")
Expand Down Expand Up @@ -244,6 +246,25 @@ if(CUKE_ENABLE_QT)
endif()
endif()


#
# Sanitizers
#

if(CUKE_ENABLE_SANITIZER AND NOT ${CUKE_ENABLE_SANITIZER} EQUAL "OFF")
message("Disabling valgrind when a sanitizer is enabled")
set(CUKE_TESTS_VALGRIND OFF)

if (WIN32)
message(WARNING "The use of the sanatizers on Windows is not tested")
endif()

add_compile_options("-fsanitize=${CUKE_ENABLE_SANITIZER}")
add_link_options("-fsanitize=${CUKE_ENABLE_SANITIZER}")
endif()



#
# Valgrind
#
Expand Down