From 29102187c5483b510ed829c7801a450427f06fd0 Mon Sep 17 00:00:00 2001 From: Andrew Minh Nguyen Date: Mon, 30 Sep 2024 13:56:19 -0500 Subject: [PATCH] cmake : adapt native lib linking for Android --- ggml/src/CMakeLists.txt | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/ggml/src/CMakeLists.txt b/ggml/src/CMakeLists.txt index cbc349500728b..93d9b95124bbd 100644 --- a/ggml/src/CMakeLists.txt +++ b/ggml/src/CMakeLists.txt @@ -1127,7 +1127,7 @@ if (CMAKE_OSX_ARCHITECTURES STREQUAL "arm64" OR endif() endif() if (${CMAKE_SYSTEM_PROCESSOR} MATCHES "armv8") - # Android arm64-v8a + # Android arm64-v8a <- NOT REACHED; arm64-v8a and armv8 differ # Raspberry Pi 3, 4, Zero 2 (32-bit) list(APPEND ARCH_FLAGS -mno-unaligned-access) endif() @@ -1341,11 +1341,15 @@ list(APPEND GGML_EXTRA_LIBS_PRIVATE Threads::Threads) find_library(MATH_LIBRARY m) if (MATH_LIBRARY) - if (NOT WIN32 OR NOT GGML_SYCL) + if (NOT WIN32 OR NOT GGML_SYCL OR NOT CMAKE_SYSTEM_NAME MATCHES "Android") list(APPEND GGML_EXTRA_LIBS_PRIVATE m) endif() endif() +if (CMAKE_SYSTEM_NAME MATCHES "Android") + list(APPEND GGML_EXTRA_LIBS_PRIVATE dl) # Must be linked explicitly +endif() + list(REMOVE_DUPLICATES GGML_EXTRA_LIBS_PRIVATE) list(REMOVE_DUPLICATES GGML_EXTRA_LIBS_PUBLIC) target_link_libraries(ggml PRIVATE ${GGML_EXTRA_LIBS_PRIVATE} PUBLIC ${GGML_EXTRA_LIBS_PUBLIC})