From 17cf7c5c67e5a791cc98c8a2d937338b7a3f9207 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Wed, 19 Feb 2014 13:01:03 +0000 Subject: [CMake] Use host compiler to build unittests in standalone mode git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@201672 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/Modules/AddCompilerRT.cmake | 12 ++++++++---- cmake/Modules/CompilerRTCompile.cmake | 10 +++++++--- cmake/Modules/CompilerRTLink.cmake | 10 +++++++--- 3 files changed, 22 insertions(+), 10 deletions(-) (limited to 'cmake') diff --git a/cmake/Modules/AddCompilerRT.cmake b/cmake/Modules/AddCompilerRT.cmake index bb350e972..357e0a5e5 100644 --- a/cmake/Modules/AddCompilerRT.cmake +++ b/cmake/Modules/AddCompilerRT.cmake @@ -113,8 +113,8 @@ set(COMPILER_RT_GTEST_INCLUDE_CFLAGS -I${COMPILER_RT_GTEST_PATH} ) -# Use Clang to link objects into a single executable with just-built -# Clang, using specific link flags. Make executable a part of provided +# Link objects into a single executable with COMPILER_RT_TEST_COMPILER, +# using specified link flags. Make executable a part of provided # test_suite. # add_compiler_rt_test( # OBJECTS @@ -123,10 +123,14 @@ set(COMPILER_RT_GTEST_INCLUDE_CFLAGS macro(add_compiler_rt_test test_suite test_name) parse_arguments(TEST "OBJECTS;DEPS;LINK_FLAGS" "" ${ARGN}) set(output_bin "${CMAKE_CURRENT_BINARY_DIR}/${test_name}") + # Use host compiler in a standalone build, and just-built Clang otherwise. + if(NOT COMPILER_RT_STANDALONE_BUILD) + list(APPEND TEST_DEPS clang) + endif() add_custom_target(${test_name} - COMMAND clang ${TEST_OBJECTS} -o "${output_bin}" + COMMAND ${COMPILER_RT_TEST_COMPILER} ${TEST_OBJECTS} -o "${output_bin}" ${TEST_LINK_FLAGS} - DEPENDS clang ${TEST_DEPS}) + DEPENDS ${TEST_DEPS}) # Make the test suite depend on the binary. add_dependencies(${test_suite} ${test_name}) endmacro() diff --git a/cmake/Modules/CompilerRTCompile.cmake b/cmake/Modules/CompilerRTCompile.cmake index 2794cabe5..bb2d08018 100644 --- a/cmake/Modules/CompilerRTCompile.cmake +++ b/cmake/Modules/CompilerRTCompile.cmake @@ -1,6 +1,6 @@ include(LLVMParseArguments) -# Compile a source into an object file with just-built Clang using +# Compile a source into an object file with COMPILER_RT_TEST_COMPILER using # a provided compile flags and dependenices. # clang_compile( # CFLAGS @@ -8,9 +8,13 @@ include(LLVMParseArguments) macro(clang_compile object_file source) parse_arguments(SOURCE "CFLAGS;DEPS" "" ${ARGN}) get_filename_component(source_rpath ${source} REALPATH) + if(NOT COMPILER_RT_STANDALONE_BUILD) + list(APPEND SOURCE_DEPS clang) + endif() add_custom_command( OUTPUT ${object_file} - COMMAND clang ${SOURCE_CFLAGS} -c -o "${object_file}" ${source_rpath} + COMMAND ${COMPILER_RT_TEST_COMPILER} ${SOURCE_CFLAGS} -c -o "${object_file}" + ${source_rpath} MAIN_DEPENDENCY ${source} - DEPENDS clang ${SOURCE_DEPS}) + DEPENDS ${SOURCE_DEPS}) endmacro() diff --git a/cmake/Modules/CompilerRTLink.cmake b/cmake/Modules/CompilerRTLink.cmake index 85030a725..0f0e53a3b 100644 --- a/cmake/Modules/CompilerRTLink.cmake +++ b/cmake/Modules/CompilerRTLink.cmake @@ -1,14 +1,18 @@ include(LLVMParseArguments) -# Link a shared library with just-built Clang. +# Link a shared library with COMPILER_RT_TEST_COMPILER. # clang_link_shared( # OBJECTS # LINKFLAGS # DEPS ) macro(clang_link_shared so_file) parse_arguments(SOURCE "OBJECTS;LINKFLAGS;DEPS" "" ${ARGN}) + if(NOT COMPILER_RT_STANDALONE_BUILD) + list(APPEND SOURCE_DEPS clang) + endif() add_custom_command( OUTPUT ${so_file} - COMMAND clang -o "${so_file}" -shared ${SOURCE_LINKFLAGS} ${SOURCE_OBJECTS} - DEPENDS clang ${SOURCE_DEPS}) + COMMAND ${COMPILER_RT_TEST_COMPILER} -o "${so_file}" -shared + ${SOURCE_LINKFLAGS} ${SOURCE_OBJECTS} + DEPENDS ${SOURCE_DEPS}) endmacro() -- cgit v1.2.1