Some environments, e.g. musl libc based ones, do not have a dedicated
libpthread, so only link it if it exists.
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
PROJECT(opkg-cl C)
+INCLUDE(CheckLibraryExists)
+
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libopkg)
LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../libopkg ${CMAKE_CURRENT_SOURCE_DIR}/../libbb)
FIND_LIBRARY(ubox NAMES ubox)
ENDIF()
-FIND_LIBRARY(pthread NAMES pthread)
-
ADD_EXECUTABLE(opkg-cl opkg-cl.c)
-TARGET_LINK_LIBRARIES(opkg-cl opkg bb ${ubox} ${pthread})
+TARGET_LINK_LIBRARIES(opkg-cl opkg bb ${ubox})
+
+CHECK_LIBRARY_EXISTS(pthread pthread_create "" NEED_PTHREAD)
+IF(NEED_PTHREAD)
+ TARGET_LINK_LIBRARIES(opkg-cl pthread)
+ENDIF()