blob: bb2d08018dfe591266d8895eb62c6316517503ee [file] [log] [blame]
Alexey Samsonovca7fcf22012-12-19 12:33:39 +00001include(LLVMParseArguments)
2
Alexey Samsonov150d62a2014-02-19 13:01:03 +00003# Compile a source into an object file with COMPILER_RT_TEST_COMPILER using
Alexey Samsonovca7fcf22012-12-19 12:33:39 +00004# a provided compile flags and dependenices.
5# clang_compile(<object> <source>
6# CFLAGS <list of compile flags>
7# DEPS <list of dependencies>)
8macro(clang_compile object_file source)
9 parse_arguments(SOURCE "CFLAGS;DEPS" "" ${ARGN})
10 get_filename_component(source_rpath ${source} REALPATH)
Alexey Samsonov150d62a2014-02-19 13:01:03 +000011 if(NOT COMPILER_RT_STANDALONE_BUILD)
12 list(APPEND SOURCE_DEPS clang)
13 endif()
Alexey Samsonovca7fcf22012-12-19 12:33:39 +000014 add_custom_command(
15 OUTPUT ${object_file}
Alexey Samsonov150d62a2014-02-19 13:01:03 +000016 COMMAND ${COMPILER_RT_TEST_COMPILER} ${SOURCE_CFLAGS} -c -o "${object_file}"
17 ${source_rpath}
Alexey Samsonovca7fcf22012-12-19 12:33:39 +000018 MAIN_DEPENDENCY ${source}
Alexey Samsonov150d62a2014-02-19 13:01:03 +000019 DEPENDS ${SOURCE_DEPS})
Alexey Samsonovca7fcf22012-12-19 12:33:39 +000020endmacro()