2012-12-19 12:33:39 +00:00
|
|
|
include(AddLLVM)
|
|
|
|
include(LLVMParseArguments)
|
2013-01-18 16:05:21 +00:00
|
|
|
include(CompilerRTUtils)
|
2012-12-19 12:33:39 +00:00
|
|
|
|
2013-01-18 16:05:21 +00:00
|
|
|
# Tries to add "object library" target for a given architecture
|
|
|
|
# with name "<name>.<arch>" if architecture can be targeted.
|
|
|
|
# add_compiler_rt_object_library(<name> <arch>
|
|
|
|
# SOURCES <source files>
|
|
|
|
# CFLAGS <compile flags>)
|
|
|
|
macro(add_compiler_rt_object_library name arch)
|
|
|
|
if(CAN_TARGET_${arch})
|
|
|
|
parse_arguments(LIB "SOURCES;CFLAGS" "" ${ARGN})
|
|
|
|
add_library(${name}.${arch} OBJECT ${LIB_SOURCES})
|
|
|
|
set_target_compile_flags(${name}.${arch}
|
|
|
|
${TARGET_${arch}_CFLAGS} ${LIB_CFLAGS})
|
|
|
|
else()
|
|
|
|
message(FATAL_ERROR "Archtecture ${arch} can't be targeted")
|
|
|
|
endif()
|
|
|
|
endmacro()
|
|
|
|
|
|
|
|
# Unittests support.
|
2012-12-19 12:33:39 +00:00
|
|
|
set(COMPILER_RT_GTEST_PATH ${LLVM_MAIN_SRC_DIR}/utils/unittest/googletest)
|
|
|
|
set(COMPILER_RT_GTEST_SOURCE ${COMPILER_RT_GTEST_PATH}/gtest-all.cc)
|
|
|
|
set(COMPILER_RT_GTEST_INCLUDE_CFLAGS
|
|
|
|
-DGTEST_NO_LLVM_RAW_OSTREAM=1
|
|
|
|
-I${COMPILER_RT_GTEST_PATH}/include
|
|
|
|
)
|
|
|
|
|
|
|
|
# Use Clang to link objects into a single executable with just-built
|
|
|
|
# Clang, using specific link flags. Make executable a part of provided
|
|
|
|
# test_suite.
|
|
|
|
# add_compiler_rt_test(<test_suite> <test_name>
|
|
|
|
# OBJECTS <object files>
|
|
|
|
# DEPS <deps (e.g. runtime libs)>
|
|
|
|
# LINK_FLAGS <link flags>)
|
|
|
|
macro(add_compiler_rt_test test_suite test_name)
|
|
|
|
parse_arguments(TEST "OBJECTS;DEPS;LINK_FLAGS" "" ${ARGN})
|
|
|
|
get_unittest_directory(OUTPUT_DIR)
|
2012-12-20 14:34:09 +00:00
|
|
|
file(MAKE_DIRECTORY ${OUTPUT_DIR})
|
2012-12-19 12:33:39 +00:00
|
|
|
set(output_bin "${OUTPUT_DIR}/${test_name}")
|
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${output_bin}
|
|
|
|
COMMAND clang ${TEST_OBJECTS} -o "${output_bin}"
|
|
|
|
${TEST_LINK_FLAGS}
|
2012-12-21 08:56:14 +00:00
|
|
|
DEPENDS clang ${TEST_DEPS})
|
2012-12-19 12:33:39 +00:00
|
|
|
add_custom_target(${test_name} DEPENDS ${output_bin})
|
|
|
|
# Make the test suite depend on the binary.
|
|
|
|
add_dependencies(${test_suite} ${test_name})
|
|
|
|
endmacro()
|