Don't use -Wl,-z,defs with Clang's sanitizers

Fix "undefined reference" linker errors with -DSANITIZE=address
-DBUILD_SHARED_LIBS=ON when using Clang.

Bug: aomedia:3438
Change-Id: I8caded92679601b2e8b1ab11326c90985762cae5
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6fb7362..f4c0571 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -833,7 +833,15 @@
 endif()
 
 if(BUILD_SHARED_LIBS)
-  if(NOT WIN32 AND NOT APPLE)
+  # Don't use -Wl,-z,defs with Clang's sanitizers.
+  #
+  # Clang's AddressSanitizer documentation says "When linking shared libraries,
+  # the AddressSanitizer run-time is not linked, so -Wl,-z,defs may cause link
+  # errors (don't use it with AddressSanitizer)." See
+  # https://clang.llvm.org/docs/AddressSanitizer.html#usage.
+  if(NOT WIN32
+     AND NOT APPLE
+     AND NOT (CMAKE_C_COMPILER_ID MATCHES "Clang" AND SANITIZE))
     # The -z defs linker option reports unresolved symbol references from object
     # files when building a shared library.
     if("${CMAKE_VERSION}" VERSION_LESS "3.13")