Skip to content

Commit 4c0a91f

Browse files
committed
build: add a workaround for Android builds
The android build requires linking to libunwind to prevent underlinking. This library is squirreled away into the compiler resource directory and since we do not use the NDK compiler we do not pick it up. Explicitly add the directory to our linker search path to pick up the necessary library. This library should really be provided by the NDK as we cannot ascertain if the unwinder has been modified or contains extensions.
1 parent ab54b5e commit 4c0a91f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

CMakeLists.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,26 @@ target_include_directories(firebase INTERFACE
3333
if(ANDROID)
3434
target_link_directories(firebase INTERFACE
3535
third_party/firebase-development/usr/libs/android/${CMAKE_ANDROID_ARCH_ABI})
36+
37+
# Add the compiler resource directory as a library search path explicitly as
38+
# we do not use `clang` from the NDK but do require `libunwind.a` which is not
39+
# in the sysroot (platform SDK) but rather placed into the resource directory
40+
# on the Android platform.
41+
if(CMAKE_ANDROID_ARCH STREQUAL arm64)
42+
target_link_directories(firebase INTERFACE
43+
$ENV{ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/windows-x86_64/lib/clang/17/lib/linux/aarch64)
44+
elseif(CMAKE_ANDROID_ARCH STREQUAL arm)
45+
target_link_directories(firebase INTERFACE
46+
$ENV{ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/windows-x86_64/lib/clang/17/lib/linux/arm)
47+
elseif(CMAKE_ANDROID_ARCH STREQUAL x86)
48+
target_link_directories(firebase INTERFACE
49+
$ENV{ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/windows-x86_64/lib/clang/17/lib/linux/i386)
50+
elseif(CMAKE_ANDROID_ARCH STREQUAL x86_64)
51+
target_link_directories(firebase INTERFACE
52+
$ENV{ANDROID_NDK_ROOT}/toolchains/llvm/prebuilt/windows-x86_64/lib/clang/17/lib/linux/x86_64)
53+
else()
54+
message(SEND_ERROR "unsupported architecture for Android")
55+
endif()
3656
elseif(WIN32)
3757
target_link_directories(firebase INTERFACE
3858
third_party/firebase-development/usr/libs/windows

0 commit comments

Comments
 (0)