summaryrefslogtreecommitdiff
path: root/cmake/Modules/CompilerRTCompile.cmake
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2012-12-19 12:33:39 +0000
committerAlexey Samsonov <samsonov@google.com>2012-12-19 12:33:39 +0000
commit02dcc63dde3106c24999040768a5eb52f99fedda (patch)
treee13d730e565297f827bbe9e4e88dda2c95d16177 /cmake/Modules/CompilerRTCompile.cmake
parent37a14418e494d3dfb27cd6bddcd9855df2c80ff5 (diff)
Significantly change the way we build ASan unittests in CMake
build tree. Now just-built Clang is used to: 1) compile instrumented sources (as before); 2) compile non-instrumented sources; 3) compile our own instrumented version of googletest; 4) link it all together using -fsanitize=address flag (instead of trying to copy linker behavior in CMake build rules). This makes ASan unittests pretty much self-consistent and independent of other LLVM libraries. git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@170541 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake/Modules/CompilerRTCompile.cmake')
-rw-r--r--cmake/Modules/CompilerRTCompile.cmake16
1 files changed, 16 insertions, 0 deletions
diff --git a/cmake/Modules/CompilerRTCompile.cmake b/cmake/Modules/CompilerRTCompile.cmake
new file mode 100644
index 000000000..2794cabe5
--- /dev/null
+++ b/cmake/Modules/CompilerRTCompile.cmake
@@ -0,0 +1,16 @@
+include(LLVMParseArguments)
+
+# Compile a source into an object file with just-built Clang using
+# a provided compile flags and dependenices.
+# clang_compile(<object> <source>
+# CFLAGS <list of compile flags>
+# DEPS <list of dependencies>)
+macro(clang_compile object_file source)
+ parse_arguments(SOURCE "CFLAGS;DEPS" "" ${ARGN})
+ get_filename_component(source_rpath ${source} REALPATH)
+ add_custom_command(
+ OUTPUT ${object_file}
+ COMMAND clang ${SOURCE_CFLAGS} -c -o "${object_file}" ${source_rpath}
+ MAIN_DEPENDENCY ${source}
+ DEPENDS clang ${SOURCE_DEPS})
+endmacro()