From 08a862685dc81ddfb5c77dcf36b0e219d98ca4b8 Mon Sep 17 00:00:00 2001 From: Francis Ricci Date: Thu, 25 Aug 2016 16:15:45 +0000 Subject: [builtins] Make sure builtin compile tests respect CMAKE_C_COMPILER_TARGET Summary: Since we generate the compiler invocation on our own, we need to manually add -target if CMAKE_C_COMPILER_TARGET has been specified. Reviewers: compnerd, beanz Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D23823 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@279747 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/Modules/BuiltinTests.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/Modules/BuiltinTests.cmake b/cmake/Modules/BuiltinTests.cmake index 6bbf44951..5f3cc7e58 100644 --- a/cmake/Modules/BuiltinTests.cmake +++ b/cmake/Modules/BuiltinTests.cmake @@ -11,7 +11,13 @@ function(try_compile_only output) file(WRITE ${SIMPLE_C} "${ARG_SOURCE}\n") string(REGEX MATCHALL "<[A-Za-z0-9_]*>" substitutions ${CMAKE_C_COMPILE_OBJECT}) - string(REPLACE ";" " " extra_flags "${ARG_FLAGS}") + + set(TRY_COMPILE_FLAGS "${ARG_FLAGS}") + if(CMAKE_C_COMPILER_ID MATCHES Clang AND CMAKE_C_COMPILER_TARGET) + list(APPEND TRY_COMPILE_FLAGS "-target ${CMAKE_C_COMPILER_TARGET}") + endif() + + string(REPLACE ";" " " extra_flags "${TRY_COMPILE_FLAGS}") set(test_compile_command "${CMAKE_C_COMPILE_OBJECT}") foreach(substitution ${substitutions}) -- cgit v1.2.1