From: Jo-Philipp Wich Date: Fri, 17 Feb 2017 17:19:53 +0000 (+0100) Subject: build: do not unconditionally link libpthread X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=9239b2d2a5856b363fc8770710fecacde9f05a92;p=oweals%2Fopkg-lede.git build: do not unconditionally link libpthread 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 --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5e1deca..c419866 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 2.6) 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) @@ -11,7 +13,10 @@ ELSE() 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()