From 9c937cf8dfe226004f611e0f160df650d62452d1 Mon Sep 17 00:00:00 2001 From: Alexey Samsonov Date: Mon, 24 Mar 2014 09:42:12 +0000 Subject: [CMake] Respect CMAKE_CXX_FLAGS in custom clang_compile commands git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@204593 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/Modules/CompilerRTCompile.cmake | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'cmake/Modules/CompilerRTCompile.cmake') diff --git a/cmake/Modules/CompilerRTCompile.cmake b/cmake/Modules/CompilerRTCompile.cmake index bb2d08018..b3482e9ce 100644 --- a/cmake/Modules/CompilerRTCompile.cmake +++ b/cmake/Modules/CompilerRTCompile.cmake @@ -11,9 +11,19 @@ macro(clang_compile object_file source) if(NOT COMPILER_RT_STANDALONE_BUILD) list(APPEND SOURCE_DEPS clang) endif() + string(REGEX MATCH "[.](cc|cpp)$" is_cxx ${source_rpath}) + if(is_cxx) + string(REPLACE " " ";" global_flags "${CMAKE_CXX_FLAGS}") + else() + string(REPLACE " " ";" global_flags "${CMAKE_C_FLAGS}") + endif() + # Ignore unknown warnings. CMAKE_CXX_FLAGS may contain GCC-specific options + # which are not supported by Clang. + list(APPEND global_flags -Wno-unknown-warning-option) + set(compile_flags ${global_flags} ${SOURCE_CFLAGS}) add_custom_command( OUTPUT ${object_file} - COMMAND ${COMPILER_RT_TEST_COMPILER} ${SOURCE_CFLAGS} -c -o "${object_file}" + COMMAND ${COMPILER_RT_TEST_COMPILER} ${compile_flags} -c -o "${object_file}" ${source_rpath} MAIN_DEPENDENCY ${source} DEPENDS ${SOURCE_DEPS}) -- cgit v1.2.3