[libc++abi] Make sure we link in CrashReporterClient.a when it's present

When building the system libc++abi for Apple, we use CrashReporterClient
to provide better crash logs when calling abort(). This is exemplified by
the fact that we test for the presence of <CrashReporterClient.h> in
abort_message.cpp.

However, we must link against CrashReporterClient.a in order to get that
functionality, otherwise we get a linking error.

GitOrigin-RevId: 6f6c8a2d96f580c79e00c43d0ec368346c7bff49
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 7b837a4..d5251ac 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -135,6 +135,17 @@
       add_link_flags("-Wl,-rpath,${LIBDIR}")
     endif()
   endif()
+
+  # Make sure we link in CrashReporterClient if we find it -- it's used by
+  # abort() on Apple platforms when building the system dylib.
+  find_library(CrashReporterClient NAMES libCrashReporterClient.a
+                                   PATHS "${CMAKE_OSX_SYSROOT}/usr/local/lib")
+  if (CrashReporterClient)
+    message(STATUS "Linking with CrashReporterClient at ${CrashReporterClient}")
+    add_library_flags("${CrashReporterClient}")
+  else()
+    message(STATUS "Could not find CrashReporterClient, not linking against it")
+  endif()
 endif()
 
 split_list(LIBCXXABI_COMPILE_FLAGS)