[libc++] [CMake] Link with /nodefaultlibs on Windows

Summary:
This patch attempts to fix the libc++ build/link so that it doesn't use an default C++ libraries on Windows.  This is needed to prevent linking to MSVC's STL library.

Additionally this patch changes libc++ so that it is always linked with the non-debug DLL's (e.g. `/MD`). This is needed so that the test suite can correctly link the same libraries without needing to know which configuration `c++.dll` was linked with.


Reviewers: compnerd, rnk, majnemer, kimgr, awson, halyavin, smeenai

Subscribers: cfe-commits, mgorny

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

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292001 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index cc3ed16..f83051f 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -104,6 +104,17 @@
 endif()
 add_link_flags_if_supported(-nodefaultlibs)
 
+if (LIBCXX_TARGETING_MSVC)
+  add_compile_flags(/Zl)
+  add_link_flags(/nodefaultlib)
+  add_library_flags(ucrt) # Universal C runtime
+  add_library_flags(vcruntime) # C++ runtime
+  add_library_flags(msvcrt) # C runtime startup files
+  # Required for standards-complaint wide character formatting functions
+  # (e.g. `printfw`/`scanfw`)
+  add_library_flags(iso_stdio_wide_specifiers)
+endif()
+
 if (LIBCXX_OSX_REEXPORT_SYSTEM_ABI_LIBRARY)
   if (NOT DEFINED LIBCXX_LIBCPPABI_VERSION)
     set(LIBCXX_LIBCPPABI_VERSION "2") # Default value