llvm-project/libcxx/cmake/caches/AndroidNDK.cmake
tynasello-google 13fe07d670
[libc++] Expand Android libc++ test config files (#142846)
Parameterize (and rename) existing libc++/libc++abi test configuration
files for the Android NDK to work for both the NDK and platform.

Android LLVM downstream seeks to test libc++ for both the NDK and
platform build (currently only testing the NDK), which will use almost
identical test configuration files. The only difference is the name of
the libc++ shared object used. Because of this we parameterize the
current test files (for both libc++ and libc++abi) with the existing
LIBCXX_SHARED_OUTPUT_NAME cmake variable, and rename the file
accordingly.
2025-06-12 11:39:28 -04:00

38 lines
1.8 KiB
CMake

# Build libc++abi and libc++ closely resembling what is shipped in the Android
# NDK.
# The NDK names the libraries libc++_shared.so and libc++_static.a. Using the
# libc++_shared.so soname ensures that the library doesn't interact with the
# libc++.so in /system/lib[64].
set(LIBCXX_SHARED_OUTPUT_NAME c++_shared CACHE STRING "")
set(LIBCXX_STATIC_OUTPUT_NAME c++_static CACHE STRING "")
# The NDK libc++ uses a special namespace to help isolate its symbols from those
# in the platform's STL (e.g. /system/lib[64]/libc++.so, but possibly stlport on
# older versions of Android).
set(LIBCXX_ABI_VERSION 1 CACHE STRING "")
set(LIBCXX_ABI_NAMESPACE __ndk1 CACHE STRING "")
# CMake doesn't add a version suffix to an Android shared object filename,
# (because CMAKE_PLATFORM_NO_VERSIONED_SONAME is set), so it writes both a
# libc++_shared.so ELF file and a libc++_shared.so linker script to the same
# output path (the script clobbers the binary). Turn off the linker script.
set(LIBCXX_ENABLE_ABI_LINKER_SCRIPT OFF CACHE BOOL "")
set(LIBCXX_STATICALLY_LINK_ABI_IN_SHARED_LIBRARY ON CACHE BOOL "")
set(LIBCXXABI_ENABLE_SHARED OFF CACHE BOOL "")
# Android uses its own unwinder library
set(LIBCXXABI_USE_LLVM_UNWINDER OFF CACHE BOOL "")
# Clang links libc++ by default, but it doesn't exist yet. The libc++ CMake
# files specify -nostdlib++ to avoid this problem, but CMake's default "compiler
# works" testing doesn't pass that flag, so force those tests to pass.
set(CMAKE_C_COMPILER_WORKS ON CACHE BOOL "")
set(CMAKE_CXX_COMPILER_WORKS ON CACHE BOOL "")
# Use adb to push tests to a locally-connected device (e.g. emulator) and run
# them.
set(LIBCXX_TEST_CONFIG "llvm-libc++-android.cfg.in" CACHE STRING "")
set(LIBCXXABI_TEST_CONFIG "llvm-libc++abi-android.cfg.in" CACHE STRING "")