fixed build on android there's no need in libmd and libpthread on android when statically linking libbsd (for arc4random family of functions). FossilOrigin-Name: d8166f4ed14ce7e28ee6093c135cc3e3851273ebc494973b992f980091bb1881
la-ninpre leobrekalini@gmail.com
Fri, 10 Sep 2021 14:54:42 +0000
1 files changed,
27 insertions(+),
18 deletions(-)
jump to
M
CMakeLists.txt
→
CMakeLists.txt
@@ -52,28 +52,37 @@ set(CMAKE_REQUIRED_LINK_OPTIONS "-static")
check_c_source_compiles( "#include<bsd/string.h>\nint main(void){return 0;}" HAVE_LIBBSD_STATIC) - # libpthread and libmd are needed when linking statically on linux. - # these test aren't really checking particular functions, but - # they are here to make sure that program could be linked statically - unset(CMAKE_REQUIRED_LIBRARIES) - set(CMAKE_REQUIRED_LIBRARIES "pthread") - check_c_source_compiles( - "#include<pthread.h>\nint main(void){return 0;}" - HAVE_LIBPTHREAD_STATIC) + + if(NOT ANDROID) + # libpthread and libmd are needed when linking statically on linux. + # these test aren't really checking particular functions, but + # they are here to make sure that program could be linked statically + unset(CMAKE_REQUIRED_LIBRARIES) + set(CMAKE_REQUIRED_LIBRARIES "pthread") + check_c_source_compiles( + "#include<pthread.h>\nint main(void){return 0;}" + HAVE_LIBPTHREAD_STATIC) + + unset(CMAKE_REQUIRED_LIBRARIES) + set(CMAKE_REQUIRED_LIBRARIES "md") + check_c_source_compiles( + "#include<sha2.h>\nint main(void){return 0;}" + HAVE_LIBMD_STATIC) - unset(CMAKE_REQUIRED_LIBRARIES) - set(CMAKE_REQUIRED_LIBRARIES "md") - check_c_source_compiles( - "#include<sha2.h>\nint main(void){return 0;}" - HAVE_LIBMD_STATIC) + if(NOT (HAVE_LIBBSD_STATIC + AND HAVE_LIBPTHREAD_STATIC + AND HAVE_LIBMD_STATIC)) + message(WARNING ${WARNING_STATIC_BUILD}) + list(APPEND EXTRA_LIBS bsd pthread md) + endif() - if(NOT (HAVE_LIBBSD_STATIC - AND HAVE_LIBPTHREAD_STATIC - AND HAVE_LIBMD_STATIC)) - message(WARNING ${WARNING_STATIC_BUILD}) + else() + if(NOT (HAVE_LIBBSD_STATIC)) + message(WARNING ${WARNING_STATIC_BUILD}) + endif() + list(APPEND EXTRA_LIBS bsd) endif() - list(APPEND EXTRA_LIBS bsd pthread md) unset(CMAKE_REQUIRED_LIBRARIES) unset(CMAKE_REQUIRED_LINK_OPTIONS) endif()