[CMake] Differentiate between static and shared libc++abi

This addresses the issue introduced in r354212 which broke the case when
static libc++abi is merged into static libc++, but shared libc++ is
linked against shared libc++. There are 4 different possible
combinations which is difficult to capture using a single variable. This
change splits LIBCXX_CXX_ABI_LIBRARY into two:
LIBCXX_CXX_SHARED_ABI_LIBRARY and LIBCXX_CXX_STATIC_ABI_LIBRARY to
handle the shared and static cases. This in turn allows simplification
of some of the logic around merging of static archives.

Differential Revision: https://reviews.llvm.org/D60114

llvm-svn: 357556
diff --git a/libcxx/lib/CMakeLists.txt b/libcxx/lib/CMakeLists.txt
index 50b7e28..d7791c2 100644
--- a/libcxx/lib/CMakeLists.txt
+++ b/libcxx/lib/CMakeLists.txt
@@ -59,16 +59,16 @@
 
 if (LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY)
   if (APPLE)
-    add_library_flags("-Wl,-force_load" "${LIBCXX_CXX_ABI_LIBRARY}")
+    add_library_flags("-Wl,-force_load" "${LIBCXX_CXX_STATIC_ABI_LIBRARY}")
   else()
     add_library_flags("-Wl,--whole-archive" "-Wl,-Bstatic")
-    add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
+    add_library_flags("${LIBCXX_CXX_STATIC_ABI_LIBRARY}")
     add_library_flags("-Wl,-Bdynamic" "-Wl,--no-whole-archive")
   endif()
 elseif (LIBCXX_OSX_REEXPORT_LIBCXXABI_SYMBOLS)
-  add_library_flags("${LIBCXX_CXX_ABI_LIBRARY}")
+  add_library_flags("${LIBCXX_CXX_SHARED_ABI_LIBRARY}")
 else ()
- add_interface_library("${LIBCXX_CXX_ABI_LIBRARY}")
+  add_interface_library("${LIBCXX_CXX_SHARED_ABI_LIBRARY}")
 endif()
 
 if (APPLE AND LLVM_USE_SANITIZER)
@@ -253,12 +253,11 @@
     if (LIBCXX_CXX_ABI_LIBRARY_PATH)
       set(MERGE_ARCHIVES_SEARCH_PATHS "-L${LIBCXX_CXX_ABI_LIBRARY_PATH}")
     endif()
-    if ((TARGET ${LIBCXX_CXX_ABI_LIBRARY}) OR
-        (${LIBCXX_CXX_ABI_LIBRARY} MATCHES "cxxabi(_static|_shared)?" AND HAVE_LIBCXXABI))
-      set(MERGE_ARCHIVES_ABI_TARGET "$<TARGET_LINKER_FILE:cxxabi_static>")
+    if (TARGET "${LIBCXX_CXX_STATIC_ABI_LIBRARY}" OR HAVE_LIBCXXABI)
+      set(MERGE_ARCHIVES_ABI_TARGET "$<TARGET_LINKER_FILE:${LIBCXX_CXX_STATIC_ABI_LIBRARY}>")
     else()
       set(MERGE_ARCHIVES_ABI_TARGET
-          "${CMAKE_STATIC_LIBRARY_PREFIX}${LIBCXX_CXX_ABI_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX}")
+        "${CMAKE_STATIC_LIBRARY_PREFIX}${LIBCXX_CXX_STATIC_ABI_LIBRARY}${CMAKE_STATIC_LIBRARY_SUFFIX}")
     endif()
     add_custom_command(TARGET cxx_static POST_BUILD
     COMMAND