From 8b5e85a95c9395dee8af807aed4efc8ba9fed2d2 Mon Sep 17 00:00:00 2001 From: Niels Grewe Date: Fri, 9 Oct 2015 09:47:55 +0000 Subject: [PATCH] Set the -pthread compiler flag when pthreads is used. Apparently, setting -lpthread is not enough to convince gcc to actually link a thread library, so if we are using pthreads, set the -pthread flag as well. It fixes the gcc situation and doesn't have any adverse effects for clang either. --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b4f37a..26d82a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -240,7 +240,9 @@ endif (ENABLE_OBJCXX) set(CMAKE_THREAD_PREFER_PTHREAD) include(FindThreads) set(objc_LINK_FLAGS "${objc_LINK_FLAGS} ${CMAKE_THREAD_LIBS_INIT}") - +if(CMAKE_USE_PTHREADS_INIT) + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") +endif() add_library(objc SHARED ${libobjc_C_SRCS} ${libobjc_ASM_SRCS} ${libobjc_OBJC_SRCS} ${libobjc_CXX_SRCS})