Skip to content

Commit 0f8ab3e

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 0f8ab3e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CMakeLists.txt

+3-1
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

+8
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,14 @@ 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+
# Without this flag, cross-compiling static test executables for Android armv7
92+
# fails with the multiple definition errors seen in android/ndk#176, so I
93+
# pulled in this workaround noted there. The tests build and run with this
94+
# flag applied.
95+
if(NOT BUILD_SHARED_LIBS AND CMAKE_SYSTEM_NAME STREQUAL Android AND
96+
CMAKE_SYSTEM_PROCESSOR STREQUAL armv7-a)
97+
target_link_options(${name} PRIVATE "LINKER:--allow-multiple-definition")
98+
endif()
9199
target_link_libraries(${name}
92100
PRIVATE
93101
dispatch

0 commit comments

Comments
 (0)