Skip to content

Commit 5df1929

Browse files
committed
allow to enable sanitizer for any build type
- there is no real reason to allow this for debug only - just having it disabled for release builds by default is important, but it is disabled always now by default anyway
1 parent b9c84a6 commit 5df1929

File tree

6 files changed

+12
-12
lines changed

6 files changed

+12
-12
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ option(NOBLKBUFMEM "should block and buffer memory be disabled" OFF)
8686
option(NOBLKMEM "should block memory be disabled" OFF)
8787
option(NOBUFMEM "should buffer memory be disabled" OFF)
8888
option(DEBUGSOL "should the debug solution mechanism be enabled" OFF)
89-
option(SANITIZE "should sanitizers be enabled in debug mode if available" OFF)
89+
option(SANITIZE "should sanitizers be enabled if available" OFF)
9090
option(COVERAGE "enable coverage support" OFF)
9191
SET(COVERAGE_CTEST_ARGS "" CACHE STRING "additional ctest arguments for coverage")
9292
option(MT "use static runtime libraries for Visual Studio compiler" OFF)

INSTALL.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ e.g., `cmake </path/to/SCIP> -DSOPLEX_DIR=<path/to/SoPlex/build/or/install>`.
199199
| `NOBLKBUFMEM` | `on`, `off` | `NOBLKBUFMEM=[true,false]` | |
200200
| `MT` | `on`, `off` | | use static runtime libraries for Visual Studio compiler on Windows |
201201
| `THREADSAFE` | `on`, `off` | `THREADSAFE=[true,false]` | thread safe compilation |
202-
| `SANITIZE` | `on`, `off`, `thread`, `address`, `memory` | `SANITIZE=...` | sanitizers to enable if available and debug mode; if not `off`, then enables undefined-behavior sanitizer, `thread` enables thread sanitizer, `address` enables address sanitizer, `memory` enables memory sanitizer |
202+
| `SANITIZE` | `on`, `off`, `thread`, `address`, `memory` | `SANITIZE=...` | sanitizers to enable; if not `off` (default), then enables undefined-behavior sanitizer, `thread` enables also thread sanitizer, `address` enables also address sanitizer, `memory` enables also memory sanitizer |
203203
| `TPI` | `tny`, `omp`, `none` | `TPI=[tny,omp,none]` | enable task processing interface required for concurrent solver |
204204

205205
Parameters can be set all at once or in subsequent calls to `cmake` - extending or modifying the existing configuration.

cmake/Modules/FindMSan.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,13 @@ if(${SANITIZE} STREQUAL "memory")
3333
message(WARNING "MemorySanitizer disabled for target ${TARGET} because "
3434
"MemorySanitizer is supported for Linux systems only.")
3535
set(SANITIZE Off CACHE BOOL
36-
"should sanitizers be enabled in debug mode if available" FORCE)
36+
"should sanitizers be enabled if available" FORCE)
3737
set(${FLAG_CANDIDATES} "")
3838
elseif (NOT ${CMAKE_SIZEOF_VOID_P} EQUAL 8)
3939
message(WARNING "MemorySanitizer disabled for target ${TARGET} because "
4040
"MemorySanitizer is supported for 64bit systems only.")
4141
set(SANITIZE Off CACHE BOOL
42-
"should sanitizers be enabled in debug mode if available" FORCE)
42+
"should sanitizers be enabled if available" FORCE)
4343
set(${FLAG_CANDIDATES} "")
4444
else ()
4545
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "MemorySanitizer"

cmake/Modules/FindTSan.cmake

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,12 @@ if(${SANITIZE} STREQUAL "thread")
3434
message(WARNING "ThreadSanitizer disabled for target ${TARGET} because "
3535
"ThreadSanitizer is supported for Linux and macOS systems only.")
3636
set(SANITIZE Off CACHE BOOL
37-
"should sanitizers be enabled in debug mode if available" FORCE)
37+
"should sanitizers be enabled if available" FORCE)
3838
elseif (NOT ${CMAKE_SIZEOF_VOID_P} EQUAL 8)
3939
message(WARNING "ThreadSanitizer disabled for target ${TARGET} because "
4040
"ThreadSanitizer is supported for 64bit systems only.")
4141
set(SANITIZE Off CACHE BOOL
42-
"should sanitizers be enabled in debug mode if available" FORCE)
42+
"should sanitizers be enabled if available" FORCE)
4343
else ()
4444
sanitizer_check_compiler_flags("${FLAG_CANDIDATES}" "ThreadSanitizer"
4545
"TSan")

src/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,12 +1118,12 @@ include(GenerateExportHeader)
11181118
generate_export_header(libscip BASE_NAME scip EXPORT_FILE_NAME ${PROJECT_BINARY_DIR}/scip/scip_export.h)
11191119
target_compile_definitions(scip PRIVATE SCIP_STATIC_DEFINE)
11201120

1121-
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND SANITIZE)
1121+
if(SANITIZE)
11221122
find_package(Sanitizers)
11231123
add_sanitizers(libscip)
11241124
add_sanitizers(scip)
11251125
get_target_property(CONF_SANITIZE_FLAGS libscip SANITIZE_FLAGS)
1126-
endif()
1126+
endif(SANITIZE)
11271127

11281128
target_link_libraries(scip
11291129
PUBLIC

tests/CMakeLists.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,9 @@ if( CRITERION_FOUND )
6464
#
6565
include_directories(${CRITERION_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/../src)
6666

67-
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND SANITIZE)
67+
if(SANITIZE)
6868
find_package(Sanitizers)
69-
endif()
69+
endif(SANITIZE)
7070

7171
#
7272
# Prepare unit test executable for every source file
@@ -101,9 +101,9 @@ if( CRITERION_FOUND )
101101
#
102102
target_link_libraries(${testName} ${CRITERION_LIBRARIES} libscip m)
103103

104-
if(CMAKE_BUILD_TYPE STREQUAL "Debug" AND SANITIZE)
104+
if(SANITIZE)
105105
add_sanitizers(${testName})
106-
endif()
106+
endif(SANITIZE)
107107

108108
#
109109
# use the directory name (relative to src/) to build the executable

0 commit comments

Comments
 (0)