Check for rt and pthread libraries before linking

This fixes building on Android which does not have separate librt
or libpthread libraries.

Signed-off-by: Fredrik Fornwall <fredrik@fornwall.net>
pull/413/head
Fredrik Fornwall 9 years ago committed by Roger A. Light
parent 9b05b12039
commit 532273250c

@ -7,7 +7,12 @@ if (${WITH_THREADING} STREQUAL ON)
set (PTHREAD_LIBRARIES C:\\pthreads\\Pre-built.2\\lib\\x86\\pthreadVC2.lib)
set (PTHREAD_INCLUDE_DIR C:\\pthreads\\Pre-built.2\\include)
else (WIN32)
find_library(LIBPTHREAD pthread)
if (LIBPTHREAD)
set (PTHREAD_LIBRARIES pthread)
else (LIBPTHREAD)
set (PTHREAD_LIBRARIES "")
endif()
set (PTHREAD_INCLUDE_DIR "")
endif (WIN32)
else (${WITH_THREADING} STREQUAL ON)
@ -44,7 +49,10 @@ add_library(libmosquitto SHARED
set (LIBRARIES ${OPENSSL_LIBRARIES} ${PTHREAD_LIBRARIES})
if (UNIX AND NOT APPLE)
find_library(LIBRT rt)
if (LIBRT)
set (LIBRARIES ${LIBRARIES} rt)
endif (LIBRT)
endif (UNIX AND NOT APPLE)
if (WIN32)

@ -86,7 +86,11 @@ if (UNIX)
if (APPLE)
set (MOSQ_LIBS ${MOSQ_LIBS} dl m)
else (APPLE)
set (MOSQ_LIBS ${MOSQ_LIBS} rt dl m)
set (MOSQ_LIBS ${MOSQ_LIBS} dl m)
find_library(LIBRT rt)
if (LIBRT)
set (MOSQ_LIBS ${MOSQ_LIBS} rt)
endif (LIBRT)
endif (APPLE)
endif (UNIX)

Loading…
Cancel
Save