|
1 | 1 | #===============================================================================
|
2 |
| -# Copyright 2017 Intel Corporation |
| 2 | +# Copyright (C) 2017 Intel Corporation |
3 | 3 | #
|
4 |
| -# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +# Licensed under the Apache License, Version 2.0 (the 'License'); |
5 | 5 | # you may not use this file except in compliance with the License.
|
6 | 6 | # You may obtain a copy of the License at
|
7 |
| -# |
8 |
| -# http://www.apache.org/licenses/LICENSE-2.0 |
9 |
| -# |
10 |
| -# Unless required by applicable law or agreed to in writing, software |
11 |
| -# distributed under the License is distributed on an "AS IS" BASIS, |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, |
| 11 | +# software distributed under the License is distributed on an 'AS IS' BASIS, |
12 | 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
13 |
| -# See the License for the specific language governing permissions and |
14 |
| -# limitations under the License. |
| 13 | +# See the License for the specific language governing permissions |
| 14 | +# and limitations under the License. |
| 15 | +# |
15 | 16 | #===============================================================================
|
16 | 17 |
|
17 | 18 | #
|
@@ -182,6 +183,38 @@ else()
|
182 | 183 | message (STATUS "BUILD_EXAMPLES ........................ off")
|
183 | 184 | endif()
|
184 | 185 |
|
| 186 | +# Build with sanitizers |
| 187 | +set(SANITIZERS OFF) |
| 188 | +if(BUILD_WITH_SANITIZERS AND UNIX AND ${CMAKE_CXX_COMPILER_ID} STREQUAL "Clang" AND ${CMAKE_CXX_COMPILER_VERSION} VERSION_GREATER_EQUAL "12.0.0") |
| 189 | + set(ASAN OFF) |
| 190 | + set(UBSAN OFF) |
| 191 | + set(MSAN OFF) |
| 192 | + if("${BUILD_WITH_SANITIZERS}" MATCHES "address") |
| 193 | + set(ASAN ON) |
| 194 | + list(APPEND PRINT_TYPES_OF_SANITIZERS_LIST "address") |
| 195 | + endif() |
| 196 | + if("${BUILD_WITH_SANITIZERS}" MATCHES "undefined") |
| 197 | + set(UBSAN ON) |
| 198 | + list(APPEND PRINT_TYPES_OF_SANITIZERS_LIST "undefined") |
| 199 | + endif() |
| 200 | + if("${BUILD_WITH_SANITIZERS}" MATCHES "memory") |
| 201 | + set(MSAN ON) |
| 202 | + list(APPEND PRINT_TYPES_OF_SANITIZERS_LIST "memory") |
| 203 | + endif() |
| 204 | + if((ASAN OR UBSAN) AND MSAN) |
| 205 | + message (FATAL_ERROR "Can not use address | undefined sanitizers with memory sanitizer") |
| 206 | + endif() |
| 207 | + if(ASAN OR UBSAN OR MSAN) |
| 208 | + set(SANITIZERS ON) |
| 209 | + endif() |
| 210 | +endif() |
| 211 | +if(SANITIZERS) |
| 212 | + list(JOIN PRINT_TYPES_OF_SANITIZERS_LIST "," PRINT_TYPES_OF_SANITIZERS_STRING) |
| 213 | + message (STATUS "BUILD_WITH_SANITIZERS ................. on (${PRINT_TYPES_OF_SANITIZERS_STRING})") |
| 214 | +else() |
| 215 | + message (STATUS "BUILD_WITH_SANITIZERS ................. off - use -DBUILD_WITH_SANITIZERS=[memory,address,undefined] with CLANG compiler to enable this option") |
| 216 | +endif(SANITIZERS) |
| 217 | + |
185 | 218 | if((UNIX) AND (NOT APPLE))
|
186 | 219 | set(LINUX ON)
|
187 | 220 | else()
|
|
0 commit comments