summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlexey Samsonov <samsonov@google.com>2014-02-18 07:26:58 +0000
committerAlexey Samsonov <samsonov@google.com>2014-02-18 07:26:58 +0000
commitc42a206a2c94db6cf68d2ee0df3f745f90bd8017 (patch)
tree89a6b9dacc9281f4b8e3bdd58c93d1a313121647 /lib
parentb3dd6edc18de2e0fc6fa1e706f811e15f1bab8a7 (diff)
[CMake] Simplify code for detecting/setting compiler flags
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@201543 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CMakeLists.txt2
-rw-r--r--lib/asan/tests/CMakeLists.txt4
-rw-r--r--lib/sanitizer_common/CMakeLists.txt8
-rw-r--r--lib/tsan/CMakeLists.txt8
4 files changed, 7 insertions, 15 deletions
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index 4b37b254d..14fda1fe4 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -1,6 +1,8 @@
# First, add the subdirectories which contain feature-based runtime libraries
# and several convenience helper libraries.
+include(AddCompilerRT)
+include(SanitizerUtils)
# Don't build sanitizers in the bootstrap build.
if(LLVM_USE_SANITIZER STREQUAL "")
# AddressSanitizer is supported on Linux and Mac OS X.
diff --git a/lib/asan/tests/CMakeLists.txt b/lib/asan/tests/CMakeLists.txt
index 8c6a0af64..d9fd44efa 100644
--- a/lib/asan/tests/CMakeLists.txt
+++ b/lib/asan/tests/CMakeLists.txt
@@ -32,9 +32,7 @@ set(ASAN_UNITTEST_COMMON_CFLAGS
-Werror=sign-compare
-g
-O2)
-if(SUPPORTS_NO_VARIADIC_MACROS_FLAG)
- list(APPEND ASAN_UNITTEST_COMMON_CFLAGS -Wno-variadic-macros)
-endif()
+append_if(ASAN_UNITTEST_COMMON_CFLAGS COMPILER_RT_HAS_WNO_VARIADIC_MACROS_FLAG -Wno-variadic-macros)
# Use -D instead of definitions to please custom compile command.
list(APPEND ASAN_UNITTEST_COMMON_CFLAGS
diff --git a/lib/sanitizer_common/CMakeLists.txt b/lib/sanitizer_common/CMakeLists.txt
index 83464d91e..e3a493373 100644
--- a/lib/sanitizer_common/CMakeLists.txt
+++ b/lib/sanitizer_common/CMakeLists.txt
@@ -98,12 +98,8 @@ else()
/GR-)
endif()
-if(SUPPORTS_FRAME_LARGER_THAN_FLAG)
- list(APPEND SANITIZER_CFLAGS -Wframe-larger-than=512)
-endif()
-if(SUPPORTS_GLOBAL_CONSTRUCTORS_FLAG)
- list(APPEND SANITIZER_CFLAGS -Wglobal-constructors)
-endif()
+append_if(SANITIZER_CFLAGS COMPILER_RT_HAS_WFRAME_LARGER_THAN_FLAG -Wframe-larger-than=512)
+append_if(SANITIZER_CFLAGS COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors)
set(SANITIZER_RUNTIME_LIBRARIES)
if(APPLE)
diff --git a/lib/tsan/CMakeLists.txt b/lib/tsan/CMakeLists.txt
index bb7d97581..502145c38 100644
--- a/lib/tsan/CMakeLists.txt
+++ b/lib/tsan/CMakeLists.txt
@@ -10,12 +10,8 @@ set(TSAN_CFLAGS
-fno-rtti)
set(TSAN_RTL_CFLAGS ${TSAN_CFLAGS})
-if(SUPPORTS_FRAME_LARGER_THAN_FLAG)
- list(APPEND TSAN_RTL_CFLAGS -Wframe-larger-than=512)
-endif()
-if(SUPPORTS_GLOBAL_CONSTRUCTORS_FLAG)
- list(APPEND TSAN_RTL_CFLAGS -Wglobal-constructors)
-endif()
+append_if(TSAN_RTL_CFLAGS COMPILER_RT_HAS_WFRAME_LARGER_THAN_FLAG -Wframe-larger-than=512)
+append_if(TSAN_RTL_CFLAGS COMPILER_RT_HAS_WGLOBAL_CONSTRUCTORS_FLAG -Wglobal-constructors)
# FIXME: Add support for --sysroot=. compile flag:
if("${CMAKE_BUILD_TYPE}" EQUAL "Release")