summaryrefslogtreecommitdiff
path: root/cmake/Modules
diff options
context:
space:
mode:
authorGeorge Karpenkov <ekarpenkov@apple.com>2017-08-15 18:38:14 +0000
committerGeorge Karpenkov <ekarpenkov@apple.com>2017-08-15 18:38:14 +0000
commit7de198abb3557fb8b6c5bca2beaeb7910d687d89 (patch)
tree13613d695878bb319ce49cb983e12b9f509d3f7f /cmake/Modules
parent0ea082ef441a219374b785aa0a1a3e290015d852 (diff)
[CMake compiler-rt] NFC: Minor CMake refactoring.
Detect ObjC files in `clang_compile` and pass an appropriate flag to a compiler, also change `clang_compile` to a function. Differential Revision: https://reviews.llvm.org/D36727 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@310945 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'cmake/Modules')
-rw-r--r--cmake/Modules/CompilerRTCompile.cmake8
1 files changed, 6 insertions, 2 deletions
diff --git a/cmake/Modules/CompilerRTCompile.cmake b/cmake/Modules/CompilerRTCompile.cmake
index 8727f5bb3..4c6568167 100644
--- a/cmake/Modules/CompilerRTCompile.cmake
+++ b/cmake/Modules/CompilerRTCompile.cmake
@@ -61,7 +61,7 @@ endfunction()
# clang_compile(<object> <source>
# CFLAGS <list of compile flags>
# DEPS <list of dependencies>)
-macro(clang_compile object_file source)
+function(clang_compile object_file source)
cmake_parse_arguments(SOURCE "" "" "CFLAGS;DEPS" ${ARGN})
get_filename_component(source_rpath ${source} REALPATH)
if(NOT COMPILER_RT_STANDALONE_BUILD)
@@ -71,6 +71,7 @@ macro(clang_compile object_file source)
list(APPEND SOURCE_DEPS CompilerRTUnitTestCheckCxx)
endif()
string(REGEX MATCH "[.](cc|cpp)$" is_cxx ${source_rpath})
+ string(REGEX MATCH "[.](m|mm)$" is_objc ${source_rpath})
if(is_cxx)
string(REPLACE " " ";" global_flags "${CMAKE_CXX_FLAGS}")
else()
@@ -84,6 +85,9 @@ macro(clang_compile object_file source)
if (APPLE)
set(global_flags ${OSX_SYSROOT_FLAG} ${global_flags})
endif()
+ if (is_objc)
+ list(APPEND global_flags -ObjC)
+ endif()
# Ignore unknown warnings. CMAKE_CXX_FLAGS may contain GCC-specific options
# which are not supported by Clang.
@@ -96,7 +100,7 @@ macro(clang_compile object_file source)
${source_rpath}
MAIN_DEPENDENCY ${source}
DEPENDS ${SOURCE_DEPS})
-endmacro()
+endfunction()
# On Darwin, there are no system-wide C++ headers and the just-built clang is
# therefore not able to compile C++ files unless they are copied/symlinked into