From 9239b2d2a5856b363fc8770710fecacde9f05a92 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Fri, 17 Feb 2017 18:19:53 +0100 Subject: [PATCH] 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 --- src/CMakeLists.txt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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() -- 2.25.1