Alexey Samsonov | 02dcc63 | 2012-12-19 12:33:39 +0000 | [diff] [blame] | 1 | include(AddLLVM) |
| 2 | include(LLVMParseArguments) |
| 3 | |
| 4 | set(COMPILER_RT_GTEST_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest) |
| 5 | set(COMPILER_RT_GTEST_SOURCE ${COMPILER_RT_GTEST_PATH}/gtest-all.cc) |
| 6 | set(COMPILER_RT_GTEST_INCLUDE_CFLAGS |
| 7 | -DGTEST_NO_LLVM_RAW_OSTREAM=1 |
| 8 | -I${COMPILER_RT_GTEST_PATH}/include |
| 9 | ) |
| 10 | |
| 11 | # Use Clang to link objects into a single executable with just-built |
| 12 | # Clang, using specific link flags. Make executable a part of provided |
| 13 | # test_suite. |
| 14 | # add_compiler_rt_test(<test_suite> <test_name> |
| 15 | # OBJECTS <object files> |
| 16 | # DEPS <deps (e.g. runtime libs)> |
| 17 | # LINK_FLAGS <link flags>) |
| 18 | macro(add_compiler_rt_test test_suite test_name) |
| 19 | parse_arguments(TEST "OBJECTS;DEPS;LINK_FLAGS" "" ${ARGN}) |
| 20 | get_unittest_directory(OUTPUT_DIR) |
Evgeniy Stepanov | 49ca997 | 2012-12-20 14:34:09 +0000 | [diff] [blame^] | 21 | file(MAKE_DIRECTORY ${OUTPUT_DIR}) |
Alexey Samsonov | 02dcc63 | 2012-12-19 12:33:39 +0000 | [diff] [blame] | 22 | set(output_bin "${OUTPUT_DIR}/${test_name}") |
| 23 | add_custom_command( |
| 24 | OUTPUT ${output_bin} |
| 25 | COMMAND clang ${TEST_OBJECTS} -o "${output_bin}" |
| 26 | ${TEST_LINK_FLAGS} |
| 27 | DEPENDS clang ${TEST_DEPS} ${TEST_OBJECTS}) |
| 28 | add_custom_target(${test_name} DEPENDS ${output_bin}) |
| 29 | # Make the test suite depend on the binary. |
| 30 | add_dependencies(${test_suite} ${test_name}) |
| 31 | endmacro() |