Add support for building the ASan instrumentation unit tests with the
just-built Clang binary, and linking them against the just-built ASan
runtime.

This is *very* brittle. I expect it will require tweaking, and I've
pro-actively disabled it on non-Unix builds and on cross-builds.

It is also currently missing dependency edges on GoogleTest header files
and a few other corner cases, but those can be fixed. This is the major
milestone of a mini-bootstrap-like build of the unittest.

git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@159255 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1e6a2ac..97835a1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -48,6 +48,16 @@
             COMPILE_DEFINITIONS "${TARGET_I386_CFLAGS}"
             CMAKE_FLAGS "-DCMAKE_EXE_LINKER_FLAGS:STRING=${TARGET_I386_CFLAGS}")
 
+# Because compiler-rt spends a lot of time setting up custom compile flags,
+# define a handy helper function for it. The compile flags setting in CMake
+# has serious issues that make its syntax challenging at best.
+function(set_target_compile_flags target)
+  foreach(arg ${ARGN})
+    set(argstring "${argstring} ${arg}")
+  endforeach()
+  set_property(TARGET ${target} PROPERTY COMPILE_FLAGS "${argstring}")
+endfunction()
+
 add_subdirectory(lib)
 
 if(LLVM_INCLUDE_TESTS)