@@ -26,6 +26,8 @@ option(UMF_BUILD_BENCHMARKS "Build UMF benchmarks" OFF)
26
26
option (UMF_ENABLE_POOL_TRACKING "Build UMF with pool tracking" ON )
27
27
option (UMF_DEVELOPER_MODE "Enable developer checks, treats warnings as errors" OFF )
28
28
option (UMF_FORMAT_CODE_STYLE "Format UMF code with clang-format" OFF )
29
+ option (USE_ASAN "Enable AddressSanitizer checks" OFF )
30
+ option (USE_UBSAN "Enable UndefinedBehaviorSanitizer checks" OFF )
29
31
30
32
if (${CMAKE_SYSTEM_NAME} MATCHES "Linux" )
31
33
set (LINUX TRUE )
@@ -57,6 +59,14 @@ if(MSVC)
57
59
set (CUSTOM_COMMAND_BINARY_DIR ${CUSTOM_COMMAND_BINARY_DIR} /$<CONFIG> )
58
60
endif ()
59
61
62
+ # Sanitizer flags
63
+ if (USE_ASAN )
64
+ add_sanitizer_flag (address )
65
+ endif ()
66
+ if (USE_UBSAN )
67
+ add_sanitizer_flag (undefined )
68
+ endif ()
69
+
60
70
# A header only library to specify include directories in transitive
61
71
# dependencies.
62
72
add_library (umf_headers INTERFACE )
@@ -94,7 +104,7 @@ endif()
94
104
if (UMF_FORMAT_CODE_STYLE )
95
105
find_program (CLANG_FORMAT NAMES clang-format-15 clang-format-15.0 clang-format )
96
106
97
- if (CLANG_FORMAT )
107
+ if (CLANG_FORMAT )
98
108
get_program_version_major_minor (${CLANG_FORMAT} CLANG_FORMAT_VERSION )
99
109
message (STATUS "Found clang-format: ${CLANG_FORMAT} (version: ${CLANG_FORMAT_VERSION} )" )
100
110
@@ -105,7 +115,7 @@ if(UMF_FORMAT_CODE_STYLE)
105
115
else ()
106
116
message (FATAL_ERROR "UMF_FORMAT_CODE_STYLE=ON, but clang-format not found (required version: ${CLANG_FORMAT_REQUIRED} )" )
107
117
endif ()
108
-
118
+
109
119
# Obtain files for clang-format check
110
120
set (format_glob )
111
121
foreach (DIR IN ITEMS include src test benchmark )
@@ -123,11 +133,11 @@ if(UMF_FORMAT_CODE_STYLE)
123
133
file (GLOB_RECURSE format_list ${format_glob} )
124
134
125
135
message (STATUS "Adding clang-format-check and clang-format-apply make targets" )
126
-
136
+
127
137
add_custom_target (clang-format-check
128
138
COMMAND ${CLANG_FORMAT}
129
- --style=file
130
- --dry-run
139
+ --style=file
140
+ --dry-run
131
141
-Werror
132
142
${format_list}
133
143
COMMENT "Check files formatting using clang-format" )
@@ -137,7 +147,7 @@ if(UMF_FORMAT_CODE_STYLE)
137
147
--style=file
138
148
--i
139
149
${format_list}
140
- COMMENT "Format files using clang-format" )
150
+ COMMENT "Format files using clang-format" )
141
151
endif ()
142
152
143
153
# Add license to the installation path
0 commit comments