diff options
| author | Alexey Samsonov <samsonov@google.com> | 2013-01-18 16:05:21 +0000 |
|---|---|---|
| committer | Alexey Samsonov <samsonov@google.com> | 2013-01-18 16:05:21 +0000 |
| commit | 163ab9d0a5119325fafcb79e240894fa8c8cc63f (patch) | |
| tree | 05a4652087dd38502eed7977b91bb4154cf9b869 | |
| parent | c8cde8d736593150b09b782b7e179c05502babd4 (diff) | |
| download | bcm5719-llvm-163ab9d0a5119325fafcb79e240894fa8c8cc63f.tar.gz bcm5719-llvm-163ab9d0a5119325fafcb79e240894fa8c8cc63f.zip | |
CMake: create AddCompilerRT module and implement convenience add_compiler_rt_object_library function
llvm-svn: 172826
| -rw-r--r-- | compiler-rt/CMakeLists.txt | 18 | ||||
| -rw-r--r-- | compiler-rt/cmake/Modules/AddCompilerRT.cmake (renamed from compiler-rt/cmake/Modules/CompilerRTUnittests.cmake) | 18 | ||||
| -rw-r--r-- | compiler-rt/cmake/Modules/CompilerRTUtils.cmake | 17 | ||||
| -rw-r--r-- | compiler-rt/lib/asan/tests/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | compiler-rt/lib/interception/CMakeLists.txt | 21 | ||||
| -rw-r--r-- | compiler-rt/lib/msan/tests/CMakeLists.txt | 1 | ||||
| -rw-r--r-- | compiler-rt/lib/sanitizer_common/CMakeLists.txt | 21 | ||||
| -rw-r--r-- | compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt | 1 |
8 files changed, 54 insertions, 44 deletions
diff --git a/compiler-rt/CMakeLists.txt b/compiler-rt/CMakeLists.txt index 9ab40891636..4b71d6acb84 100644 --- a/compiler-rt/CMakeLists.txt +++ b/compiler-rt/CMakeLists.txt @@ -20,6 +20,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules" ) +include(AddCompilerRT) set(COMPILER_RT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) @@ -123,23 +124,6 @@ if(APPLE) list(APPEND SANITIZER_COMMON_CFLAGS -mmacosx-version-min=10.5) endif() -# Because compiler-rt spends a lot of time setting up custom compile flags, -# define a handy helper function for it. The compile flags setting in CMake -# has serious issues that make its syntax challenging at best. -function(set_target_compile_flags target) - foreach(arg ${ARGN}) - set(argstring "${argstring} ${arg}") - endforeach() - set_property(TARGET ${target} PROPERTY COMPILE_FLAGS "${argstring}") -endfunction() - -function(set_target_link_flags target) - foreach(arg ${ARGN}) - set(argstring "${argstring} ${arg}") - endforeach() - set_property(TARGET ${target} PROPERTY LINK_FLAGS "${argstring}") -endfunction() - # Compute the Clang version from the LLVM version. # FIXME: We should be able to reuse CLANG_VERSION variable calculated # in Clang cmake files, instead of copying the rules here. diff --git a/compiler-rt/cmake/Modules/CompilerRTUnittests.cmake b/compiler-rt/cmake/Modules/AddCompilerRT.cmake index dbf14804be0..e90253fdfa1 100644 --- a/compiler-rt/cmake/Modules/CompilerRTUnittests.cmake +++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake @@ -1,6 +1,24 @@ include(AddLLVM) include(LLVMParseArguments) +include(CompilerRTUtils) +# 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. 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 diff --git a/compiler-rt/cmake/Modules/CompilerRTUtils.cmake b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake new file mode 100644 index 00000000000..50f068091e6 --- /dev/null +++ b/compiler-rt/cmake/Modules/CompilerRTUtils.cmake @@ -0,0 +1,17 @@ +# Because compiler-rt spends a lot of time setting up custom compile flags, +# define a handy helper function for it. The compile flags setting in CMake +# has serious issues that make its syntax challenging at best. +function(set_target_compile_flags target) + foreach(arg ${ARGN}) + set(argstring "${argstring} ${arg}") + endforeach() + set_property(TARGET ${target} PROPERTY COMPILE_FLAGS "${argstring}") +endfunction() + +function(set_target_link_flags target) + foreach(arg ${ARGN}) + set(argstring "${argstring} ${arg}") + endforeach() + set_property(TARGET ${target} PROPERTY LINK_FLAGS "${argstring}") +endfunction() + diff --git a/compiler-rt/lib/asan/tests/CMakeLists.txt b/compiler-rt/lib/asan/tests/CMakeLists.txt index c0324902ac3..272950bc545 100644 --- a/compiler-rt/lib/asan/tests/CMakeLists.txt +++ b/compiler-rt/lib/asan/tests/CMakeLists.txt @@ -11,7 +11,6 @@ include(CheckCXXCompilerFlag) include(CompilerRTCompile) -include(CompilerRTUnittests) include_directories(..) include_directories(../..) diff --git a/compiler-rt/lib/interception/CMakeLists.txt b/compiler-rt/lib/interception/CMakeLists.txt index 1e25214a995..7640409166d 100644 --- a/compiler-rt/lib/interception/CMakeLists.txt +++ b/compiler-rt/lib/interception/CMakeLists.txt @@ -27,21 +27,18 @@ if(APPLE) filter_available_targets(INTERCEPTION_TARGETS x86_64 i386) set_target_properties(RTInterception.osx PROPERTIES OSX_ARCHITECTURES "${INTERCEPTION_TARGETS}") +elseif(ANDROID) + add_library(RTInterception.arm.android OBJECT ${INTERCEPTION_SOURCES}) + set_target_compile_flags(RTInterception.arm.android + ${INTERCEPTION_CFLAGS}) else() # Otherwise, build separate libraries for each target. if(CAN_TARGET_x86_64) - add_library(RTInterception.x86_64 OBJECT ${INTERCEPTION_SOURCES}) - set_target_compile_flags(RTInterception.x86_64 - ${INTERCEPTION_CFLAGS} ${TARGET_x86_64_CFLAGS}) + add_compiler_rt_object_library(RTInterception x86_64 + SOURCES ${INTERCEPTION_SOURCES} CFLAGS ${INTERCEPTION_CFLAGS}) endif() - if(CAN_TARGET_i386) - add_library(RTInterception.i386 OBJECT ${INTERCEPTION_SOURCES}) - set_target_compile_flags(RTInterception.i386 - ${INTERCEPTION_CFLAGS} ${TARGET_i386_CFLAGS}) - endif() - if(ANDROID) - add_library(RTInterception.arm.android OBJECT ${INTERCEPTION_SOURCES}) - set_target_compile_flags(RTInterception.arm.android - ${INTERCEPTION_CFLAGS}) + if (CAN_TARGET_i386) + add_compiler_rt_object_library(RTInterception i386 + SOURCES ${INTERCEPTION_SOURCES} CFLAGS ${INTERCEPTION_CFLAGS}) endif() endif() diff --git a/compiler-rt/lib/msan/tests/CMakeLists.txt b/compiler-rt/lib/msan/tests/CMakeLists.txt index d5fb8aed70a..d2a28b2cba5 100644 --- a/compiler-rt/lib/msan/tests/CMakeLists.txt +++ b/compiler-rt/lib/msan/tests/CMakeLists.txt @@ -1,7 +1,6 @@ include(CheckCXXCompilerFlag) include(CompilerRTCompile) include(CompilerRTLink) -include(CompilerRTUnittests) include_directories(..) include_directories(../..) diff --git a/compiler-rt/lib/sanitizer_common/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/CMakeLists.txt index bd1d19ef9bf..001ea0844d5 100644 --- a/compiler-rt/lib/sanitizer_common/CMakeLists.txt +++ b/compiler-rt/lib/sanitizer_common/CMakeLists.txt @@ -58,26 +58,23 @@ if(APPLE) set_target_properties(RTSanitizerCommon.osx PROPERTIES OSX_ARCHITECTURES "${SANITIZER_TARGETS}") list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.osx) +elseif(ANDROID) + add_library(RTSanitizerCommon.arm.android OBJECT ${SANITIZER_SOURCES}) + set_target_compile_flags(RTSanitizerCommon.arm.android + ${SANITIZER_CFLAGS}) + list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.arm.android) else() # Otherwise, build separate libraries for each target. if(CAN_TARGET_x86_64) - add_library(RTSanitizerCommon.x86_64 OBJECT ${SANITIZER_SOURCES}) - set_target_compile_flags(RTSanitizerCommon.x86_64 - ${SANITIZER_CFLAGS} ${TARGET_x86_64_CFLAGS}) + add_compiler_rt_object_library(RTSanitizerCommon x86_64 + SOURCES ${SANITIZER_SOURCES} CFLAGS ${SANITIZER_CFLAGS}) list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.x86_64) endif() if(CAN_TARGET_i386) - add_library(RTSanitizerCommon.i386 OBJECT ${SANITIZER_SOURCES}) - set_target_compile_flags(RTSanitizerCommon.i386 - ${SANITIZER_CFLAGS} ${TARGET_i386_CFLAGS}) + add_compiler_rt_object_library(RTSanitizerCommon i386 + SOURCES ${SANITIZER_SOURCES} CFLAGS ${SANITIZER_CFLAGS}) list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.i386) endif() - if(ANDROID) - add_library(RTSanitizerCommon.arm.android OBJECT ${SANITIZER_SOURCES}) - set_target_compile_flags(RTSanitizerCommon.arm.android - ${SANITIZER_CFLAGS}) - list(APPEND SANITIZER_RUNTIME_LIBRARIES RTSanitizerCommon.arm.android) - endif() endif() # Unit tests for common sanitizer runtime. diff --git a/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt b/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt index e0a27611232..f83a89cbe37 100644 --- a/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt +++ b/compiler-rt/lib/sanitizer_common/tests/CMakeLists.txt @@ -1,5 +1,4 @@ include(CompilerRTCompile) -include(CompilerRTUnittests) set(SANITIZER_UNITTESTS sanitizer_allocator_test.cc |

