summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt16
-rw-r--r--cmake/AddCompilerFlag.cmake1
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
192option(ASAN "Enable address-sanitizer to detect invalid memory accesses" OFF) 192option(ASAN "Enable address-sanitizer to detect invalid memory accesses" OFF)
193if(ASAN) 193if(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")
196endif()
197
198if(LINUX)
199 add_dllflag("-Wl,-z,defs")
198else() 200else()
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()
206endif() 202endif()
207 203
208option(USE_IPV6 "Use IPv6 in tests" ON) 204option(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()
41endfunction() 42endfunction()
42 43