summaryrefslogtreecommitdiff
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorJonas Hahnfeld <hahnjo@hahnjo.de>2019-02-15 14:30:18 +0000
committerJonas Hahnfeld <hahnjo@hahnjo.de>2019-02-15 14:30:18 +0000
commit3a8f865f1a8407e11e305fae69cc833227f64ef8 (patch)
treef2f947cf14e5898e1f8e6f6e235b7f86e7054621 /CMakeLists.txt
parent3bca84ff3f580ed8f9724218fc9bff83c442f7a1 (diff)
downloadcompiler-rt-3a8f865f1a8407e11e305fae69cc833227f64ef8.tar.gz
[compiler-rt] Cleanup usage of C++ ABI library
Add missed value "libcxxabi" and introduce SANITIZER_TEST_CXX for linking unit tests. This needs to be a full C++ library and cannot be libcxxabi. Differential Revision: https://reviews.llvm.org/D58012 git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@354132 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt72
1 files changed, 47 insertions, 25 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3b2b5145f..7a8face86 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -197,26 +197,38 @@ if (cxxabi_supported AND SANITIZER_ALLOW_CXXABI)
endif()
pythonize_bool(SANITIZER_CAN_USE_CXXABI)
+macro(handle_default_cxx_lib var)
+ if (${var} STREQUAL "default")
+ if (APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ set(${var}_LIBNAME "libc++")
+ set(${var}_SYSTEM 1)
+ elseif (FUCHSIA)
+ set(${var}_LIBNAME "libc++")
+ set(${var}_INTREE 1)
+ else()
+ set(${var}_LIBNAME "libstdc++")
+ set(${var}_SYSTEM 1)
+ endif()
+ else()
+ set(${var}_LIBNAME "${${var}}")
+ set(${var}_SYSTEM 1)
+ endif()
+endmacro()
+
+# This is either directly the C++ ABI library or the full C++ library
+# which pulls in the ABI transitively.
set(SANITIZER_CXX_ABI "default" CACHE STRING
"Specify C++ ABI library to use.")
-set(CXXABIS none default libstdc++ libc++)
+set(CXXABIS none default libstdc++ libc++ libcxxabi)
set_property(CACHE SANITIZER_CXX_ABI PROPERTY STRINGS ;${CXXABIS})
+handle_default_cxx_lib(SANITIZER_CXX_ABI)
-if (SANITIZER_CXX_ABI STREQUAL "default")
- if (APPLE OR CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
- set(SANITIZER_CXX_ABI_LIBNAME "libc++")
- set(SANITIZER_CXX_ABI_SYSTEM 1)
- elseif (FUCHSIA)
- set(SANITIZER_CXX_ABI_LIBNAME "libc++")
- set(SANITIZER_CXX_ABI_INTREE 1)
- else()
- set(SANITIZER_CXX_ABI_LIBNAME "libstdc++")
- set(SANITIZER_CXX_ABI_SYSTEM 1)
- endif()
-else()
- set(SANITIZER_CXX_ABI_LIBNAME "${SANITIZER_CXX_ABI}")
- set(SANITIZER_CXX_ABI_SYSTEM 1)
-endif()
+# This needs to be a full C++ library for linking gtest and unit tests.
+set(SANITIZER_TEST_CXX "default" CACHE STRING
+ "Specify C++ library to use for tests.")
+set(CXXLIBS none default libstdc++ libc++)
+set_property(CACHE SANITIZER_TEST_CXX PROPERTY STRINGS ;${CXXLIBS})
+handle_default_cxx_lib(SANITIZER_TEST_CXX)
set(DEFAULT_SANITIZER_USE_STATIC_LLVM_UNWINDER OFF)
if (FUCHSIA)
@@ -412,26 +424,36 @@ if("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia")
list(APPEND SANITIZER_COMMON_LINK_LIBS zircon)
endif()
-if (SANITIZER_CXX_ABI_LIBNAME STREQUAL "libc++")
- if (SANITIZER_CXX_ABI_INTREE)
+macro(append_libcxx_libs var)
+ if (${var}_INTREE)
if (SANITIZER_USE_STATIC_LLVM_UNWINDER AND (TARGET unwind_static OR HAVE_LIBUNWIND))
- list(APPEND SANITIZER_CXX_ABI_LIBRARY unwind_static)
+ list(APPEND ${var}_LIBRARIES unwind_static)
elseif (TARGET unwind_shared OR HAVE_LIBUNWIND)
- list(APPEND SANITIZER_CXX_ABI_LIBRARY unwind_shared)
+ list(APPEND ${var}_LIBRARIES unwind_shared)
endif()
if (SANITIZER_USE_STATIC_CXX_ABI AND (TARGET cxxabi_static OR HAVE_LIBCXXABI))
- list(APPEND SANITIZER_CXX_ABI_LIBRARY cxxabi_static)
+ list(APPEND ${var}_LIBRARIES cxxabi_static)
elseif (TARGET cxxabi_shared OR HAVE_LIBCXXABI)
- list(APPEND SANITIZER_CXX_ABI_LIBRARY cxxabi_shared)
+ list(APPEND ${var}_LIBRARIES cxxabi_shared)
endif()
else()
- append_list_if(COMPILER_RT_HAS_LIBCXX c++ SANITIZER_CXX_ABI_LIBRARY)
+ append_list_if(COMPILER_RT_HAS_LIBCXX c++ ${var}_LIBRARIES)
endif()
+endmacro()
+
+if (SANITIZER_CXX_ABI_LIBNAME STREQUAL "libc++")
+ append_libcxx_libs(SANITIZER_CXX_ABI)
elseif (SANITIZER_CXX_ABI_LIBNAME STREQUAL "libcxxabi")
- list(APPEND SANITIZER_CXX_ABI_LIBRARY "c++abi")
+ list(APPEND SANITIZER_CXX_ABI_LIBRARIES "c++abi")
elseif (SANITIZER_CXX_ABI_LIBNAME STREQUAL "libstdc++")
- append_list_if(COMPILER_RT_HAS_LIBSTDCXX stdc++ SANITIZER_CXX_ABI_LIBRARY)
+ append_list_if(COMPILER_RT_HAS_LIBSTDCXX stdc++ SANITIZER_CXX_ABI_LIBRARIES)
+endif()
+
+if (SANITIZER_TEST_CXX_LIBNAME STREQUAL "libc++")
+ append_libcxx_libs(SANITIZER_TEST_CXX)
+elseif (SANITIZER_TEST_CXX_LIBNAME STREQUAL "libstdc++")
+ append_list_if(COMPILER_RT_HAS_LIBSTDCXX stdc++ SANITIZER_TEST_CXX_LIBRARIES)
endif()
# Warnings to turn off for all libraries, not just sanitizers.