diff options
-rw-r--r-- | CMakeLists.txt | 16 | ||||
-rw-r--r-- | cmake/AddCompilerFlag.cmake | 1 |
2 files changed, 7 insertions, 10 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 411d75d6..a12631c9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
@@ -191,18 +191,14 @@ endif() | |||
191 | 191 | ||
192 | option(ASAN "Enable address-sanitizer to detect invalid memory accesses" OFF) | 192 | option(ASAN "Enable address-sanitizer to detect invalid memory accesses" OFF) |
193 | if(ASAN) | 193 | if(ASAN) |
194 | set(SAFE_CMAKE_REQUIRED_LIBRARIES "${CMAKE_REQUIRED_LIBRARIES}") | ||
195 | set(CMAKE_REQUIRED_LIBRARIES "-fsanitize=address") | ||
196 | add_cflag("-fsanitize=address") | 194 | add_cflag("-fsanitize=address") |
197 | set(CMAKE_REQUIRED_LIBRARIES "${SAFE_CMAKE_REQUIRED_LIBRARIES}") | 195 | add_dllflag("-fsanitize=address") |
196 | endif() | ||
197 | |||
198 | if(LINUX) | ||
199 | add_dllflag("-Wl,-z,defs") | ||
198 | else() | 200 | else() |
199 | # Forbid undefined symbols in shared libraries. This is incompatible with | 201 | add_dllflag("-undefined error") |
200 | # asan, so it's in the else branch here. | ||
201 | if(LINUX) | ||
202 | add_dllflag("-Wl,-z,defs") | ||
203 | else() | ||
204 | add_dllflag("-undefined error") | ||
205 | endif() | ||
206 | endif() | 202 | endif() |
207 | 203 | ||
208 | option(USE_IPV6 "Use IPv6 in tests" ON) | 204 | option(USE_IPV6 "Use IPv6 in tests" ON) |
diff --git a/cmake/AddCompilerFlag.cmake b/cmake/AddCompilerFlag.cmake index 78102dcc..6a4a3f56 100644 --- a/cmake/AddCompilerFlag.cmake +++ b/cmake/AddCompilerFlag.cmake | |||
@@ -37,6 +37,7 @@ function(add_dllflag flag) | |||
37 | check_c_compiler_flag("${flag}" HAVE_LD${var} QUIET) | 37 | check_c_compiler_flag("${flag}" HAVE_LD${var} QUIET) |
38 | if(HAVE_LD${var}) | 38 | if(HAVE_LD${var}) |
39 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${flag}" PARENT_SCOPE) | 39 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${flag}" PARENT_SCOPE) |
40 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${flag}" PARENT_SCOPE) | ||
40 | endif() | 41 | endif() |
41 | endfunction() | 42 | endfunction() |
42 | 43 | ||