[CMake] Adding support for generating libclang_rt.eprintf.a

This library provides eprintf for i386 on OS X versions later than 10.4.

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@249913 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/cmake/Modules/CompilerRTDarwinUtils.cmake b/cmake/Modules/CompilerRTDarwinUtils.cmake
index 1e8ebda..c52ba09 100644
--- a/cmake/Modules/CompilerRTDarwinUtils.cmake
+++ b/cmake/Modules/CompilerRTDarwinUtils.cmake
@@ -229,6 +229,23 @@
   set(${output_var} ${intermediate} PARENT_SCOPE)
 endfunction()
 
+function(darwin_add_eprintf_library)
+  add_library(clang_rt.eprintf STATIC eprintf.c)
+  set_target_compile_flags(clang_rt.eprintf
+    -isysroot ${DARWIN_osx_SYSROOT}
+    ${DARWIN_osx_BUILTIN_MIN_VER_FLAG}
+    -arch i386)
+  set_target_properties(clang_rt.eprintf PROPERTIES
+      OUTPUT_NAME clang_rt.eprintf${COMPILER_RT_OS_SUFFIX})
+  set_target_properties(clang_rt.eprintf PROPERTIES
+    OSX_ARCHITECTURES i386)
+  add_dependencies(builtins clang_rt.eprintf)
+  set_target_properties(clang_rt.eprintf PROPERTIES
+        ARCHIVE_OUTPUT_DIRECTORY ${COMPILER_RT_LIBRARY_OUTPUT_DIR})
+  install(TARGETS clang_rt.eprintf
+      ARCHIVE DESTINATION ${COMPILER_RT_LIBRARY_INSTALL_DIR})
+endfunction()
+
 # Generates builtin libraries for all operating systems specified in ARGN. Each
 # OS library is constructed by lipo-ing together single-architecture libraries.
 macro(darwin_add_builtin_libraries)
@@ -306,6 +323,8 @@
     endif()
   endforeach()
 
+  darwin_add_eprintf_library()
+
   # We put the x86 sim slices into the archives for their base OS
   foreach (os ${ARGN})
     if(NOT ${os} MATCHES ".*sim$")