Skip to content

Commit 8ea1cac

Browse files
committed
[android] Put in fixes for librt and armv7-a
Android doesn't have a separate librt, it's just part of libc. Also, the static build wasn't working for armv7-a, because the test executables wouldn't link with the multiple definition errors listed in android/ndk#176, so use the workaround given there.
1 parent f13ea5d commit 8ea1cac

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ if(__BUILTIN_TRAP)
113113
set(HAVE_NORETURN_BUILTIN_TRAP 1)
114114
endif()
115115

116-
find_package(LibRT)
116+
if(NOT CMAKE_SYSTEM_NAME STREQUAL Android)
117+
find_package(LibRT)
118+
endif()
117119

118120
check_function_exists(_pthread_workqueue_init HAVE__PTHREAD_WORKQUEUE_INIT)
119121
check_function_exists(getprogname HAVE_GETPROGNAME)

tests/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@ function(add_unit_test name)
8888
target_compile_options(${name} PRIVATE -fblocks)
8989
target_compile_options(${name} PRIVATE -Wall -Wno-deprecated-declarations)
9090
endif()
91+
if(NOT BUILD_SHARED_LIBS AND CMAKE_SYSTEM_NAME STREQUAL Android AND
92+
CMAKE_SYSTEM_PROCESSOR STREQUAL armv7-a)
93+
target_link_options(${name} PRIVATE "LINKER:--allow-multiple-definition")
94+
endif()
9195
target_link_libraries(${name}
9296
PRIVATE
9397
dispatch

0 commit comments

Comments
 (0)