diff --git a/CMakeLists.txt b/CMakeLists.txt index 75c419c13..36da01122 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,7 +113,9 @@ if(__BUILTIN_TRAP) set(HAVE_NORETURN_BUILTIN_TRAP 1) endif() -find_package(LibRT) +if(NOT CMAKE_SYSTEM_NAME STREQUAL Android) + find_package(LibRT) +endif() check_function_exists(_pthread_workqueue_init HAVE__PTHREAD_WORKQUEUE_INIT) check_function_exists(getprogname HAVE_GETPROGNAME) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index a27603559..0176a062b 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -88,6 +88,14 @@ function(add_unit_test name) target_compile_options(${name} PRIVATE -fblocks) target_compile_options(${name} PRIVATE -Wall -Wno-deprecated-declarations) endif() + # Without this flag, cross-compiling static test executables for Android armv7 + # fails with the multiple definition errors seen in android/ndk#176, so I + # pulled in this workaround noted there. The tests build and run with this + # flag applied. + if(NOT BUILD_SHARED_LIBS AND CMAKE_SYSTEM_NAME STREQUAL Android AND + CMAKE_SYSTEM_PROCESSOR STREQUAL armv7-a) + target_link_options(${name} PRIVATE "LINKER:--allow-multiple-definition") + endif() target_link_libraries(${name} PRIVATE dispatch