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.
main
Niels Grewe 10 years ago
parent 57856fb507
commit 8b5e85a95c

@ -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})

Loading…
Cancel
Save