Skip to content

Commit

Permalink
cmake : adapt native lib linking for Android
Browse files Browse the repository at this point in the history
  • Loading branch information
amqdn committed Oct 1, 2024
1 parent fc2b435 commit 2910218
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions ggml/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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})
Expand Down

0 comments on commit 2910218

Please sign in to comment.