[ASan] Add CMake configs for libclang_rt.asan_iossim_dynamic.dylib 

CMake changes to build the ASan runtime for the iOS simulator. This is a universal library targeting the same architectures as the OSX ASan runtime does, thus the iossim version can't live in the same universal libclang_rt.asan_osx_dynamic.dylib

The difference between the OSX and iossim builds is in the -mios-simulator-version-min and -ios_simulator_version_min flags that tell Clang to compile and link iossim code.

The iossim runtime can only be built on a machine with both Xcode and the iOS Simulator SDK installed. If xcodebuild -version -sdk iphonesimulator Path returns a nonempty path, it is used when compiling and linking the iossim runtime.


git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@194199 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake
index def0c07..eee23ea 100644
--- a/cmake/Modules/AddCompilerRT.cmake
+++ b/cmake/Modules/AddCompilerRT.cmake
@@ -21,17 +21,17 @@
   endif()
 endmacro()
 
-# Same as above, but adds universal osx library with name "<name>.osx"
-# targeting multiple architectures.
-# add_compiler_rt_osx_object_library(<name> ARCH <architectures>
-#                                           SOURCES <source files>
-#                                           CFLAGS <compile flags>)
-#                                           DEFS <compile definitions>)
-macro(add_compiler_rt_osx_object_library name)
+# Same as above, but adds universal osx library for either OSX or iOS simulator
+# with name "<name>.<os>" targeting multiple architectures.
+# add_compiler_rt_darwin_object_library(<name> <os> ARCH <architectures>
+#                                                   SOURCES <source files>
+#                                                   CFLAGS <compile flags>
+#                                                   DEFS <compile definitions>)
+macro(add_compiler_rt_darwin_object_library name os)
   parse_arguments(LIB "ARCH;SOURCES;CFLAGS;DEFS" "" ${ARGN})
-  set(libname "${name}.osx")
+  set(libname "${name}.${os}")
   add_library(${libname} OBJECT ${LIB_SOURCES})
-  set_target_compile_flags(${libname} ${LIB_CFLAGS})
+  set_target_compile_flags(${libname} ${LIB_CFLAGS} ${DARWIN_${os}_CFLAGS})
   set_target_properties(${libname} PROPERTIES OSX_ARCHITECTURES "${LIB_ARCH}")
   set_property(TARGET ${libname} APPEND PROPERTY
     COMPILE_DEFINITIONS ${LIB_DEFS})
@@ -84,17 +84,19 @@
   add_dependencies(compiler-rt ${name})
 endmacro()
 
-# Adds dynamic runtime library on osx, which supports multiple architectures.
-# add_compiler_rt_osx_dynamic_runtime(<name> ARCH <architectures>
-#                                     SOURCES <source files>
-#                                     CFLAGS <compile flags>
-#                                     DEFS <compile definitions>
-#                                     LINKFLAGS <link flags>)
-macro(add_compiler_rt_osx_dynamic_runtime name)
+# Adds dynamic runtime library on osx/iossim, which supports multiple
+# architectures.
+# add_compiler_rt_darwin_dynamic_runtime(<name> <os>
+#                                        ARCH <architectures>
+#                                        SOURCES <source files>
+#                                        CFLAGS <compile flags>
+#                                        DEFS <compile definitions>
+#                                        LINKFLAGS <link flags>)
+macro(add_compiler_rt_darwin_dynamic_runtime name os)
   parse_arguments(LIB "ARCH;SOURCES;CFLAGS;DEFS;LINKFLAGS" "" ${ARGN})
   add_library(${name} SHARED ${LIB_SOURCES})
-  set_target_compile_flags(${name} ${LIB_CFLAGS})
-  set_target_link_flags(${name} ${LIB_LINKFLAGS})
+  set_target_compile_flags(${name} ${LIB_CFLAGS} ${DARWIN_${os}_CFLAGS})
+  set_target_link_flags(${name} ${LIB_LINKFLAGS} ${DARWIN_${os}_LINKFLAGS})
   set_property(TARGET ${name} APPEND PROPERTY
     COMPILE_DEFINITIONS ${LIB_DEFS})
   set_target_properties(${name} PROPERTIES