Issue 83 fix: use correct pthread linker flags with clang.

1. -lpthreads was previously added to the CMAKE_CXX_FLAGS which are
not passed to the linker thus linking would fail.
2. Clang would emit a warning about -lpthreads being added to a
build instruction with -c (compile only).

This patch fixes both of these issues by adding -lpthreads to the
linker flags (and removes them from the CXX flags).

Change-Id: I5e54de3ab7eced177aa31f311926893598af5b56
This commit is contained in:
Alex Stewart
2013-02-27 09:10:19 +00:00
parent 6fb1024ed5
commit b59ac43b9d
+2 -1
View File
@@ -473,7 +473,8 @@ IF ("${UNIX}" AND NOT ${BUILD_ANDROID})
# At least on Linux, we need pthreads to be enabled for mutex to compile.
# This may not work on windows or android.
FIND_PACKAGE(Threads REQUIRED)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
SET(STATIC_LIBRARY_FLAGS "${STATIC_LIBRARY_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CMAKE_THREAD_LIBS_INIT}")
ADD_DEFINITIONS(-DCERES_HAVE_PTHREAD)
ADD_DEFINITIONS(-DCERES_HAVE_RWLOCK)
ENDIF ("${UNIX}" AND NOT ${BUILD_ANDROID})