blob: 298518781e9b7a16f8f3e4f90676a2017b531a4a [file] [log] [blame]
Ryan Prichardd173ce4a2023-10-19 20:58:301# Build libc++abi and libc++ closely resembling what is shipped in the Android
2# NDK.
3
4# The NDK names the libraries libc++_shared.so and libc++_static.a. Using the
5# libc++_shared.so soname ensures that the library doesn't interact with the
6# libc++.so in /system/lib[64].
7set(LIBCXX_SHARED_OUTPUT_NAME c++_shared CACHE STRING "")
8set(LIBCXX_STATIC_OUTPUT_NAME c++_static CACHE STRING "")
9
10# The NDK libc++ uses a special namespace to help isolate its symbols from those
11# in the platform's STL (e.g. /system/lib[64]/libc++.so, but possibly stlport on
12# older versions of Android).
13set(LIBCXX_ABI_VERSION 1 CACHE STRING "")
14set(LIBCXX_ABI_NAMESPACE __ndk1 CACHE STRING "")
15
16# CMake doesn't add a version suffix to an Android shared object filename,
17# (because CMAKE_PLATFORM_NO_VERSIONED_SONAME is set), so it writes both a
18# libc++_shared.so ELF file and a libc++_shared.so linker script to the same
19# output path (the script clobbers the binary). Turn off the linker script.
20set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
21
22set(LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY ON CACHE BOOL "")
23set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
24
Louis Dionne8f90e692024-01-11 15:13:2125# Android uses its own unwinder library
26set(LIBCXXABI_USE_LLVM_UNWINDER OFF CACHE BOOL "")
27
Ryan Prichardd173ce4a2023-10-19 20:58:3028# Clang links libc++ by default, but it doesn't exist yet. The libc++ CMake
29# files specify -nostdlib++ to avoid this problem, but CMake's default "compiler
30# works" testing doesn't pass that flag, so force those tests to pass.
31set(CMAKE_C_COMPILER_WORKS ON CACHE BOOL "")
32set(CMAKE_CXX_COMPILER_WORKS ON CACHE BOOL "")
33
34# Use adb to push tests to a locally-connected device (e.g. emulator) and run
35# them.
36set(LIBCXX_TEST_CONFIG "llvm-libc++-android-ndk.cfg.in" CACHE STRING "")
37set(LIBCXXABI_TEST_CONFIG "llvm-libc++abi-android-ndk.cfg.in" CACHE STRING "")