[CMake] Add optional asan & safestack dependencies to DEBUGINFO_TEST_DEPS

GitOrigin-RevId: e477a5f6c88de0ef7745694ec5f00bd69da23177
diff --git a/CMakeLists.txt b/CMakeLists.txt
index dcd80bd..429e7e3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,6 +22,15 @@
   not
   )
 
+# llgdb-tests/asan.c and other asan* files.
+if(TARGET asan)
+  list(APPEND DEBUGINFO_TEST_DEPS asan)
+endif()
+# llgdb-tests/safestack.c
+if(TARGET safestack)
+  list(APPEND DEBUGINFO_TEST_DEPS safestack)
+endif()
+
 # The Windows builder scripts pass -fuse-ld=lld.
 if (WIN32)
   set(DEBUGINFO_TEST_DEPS ${DEBUGINFO_TEST_DEPS} lld)