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
diff --git a/CMakeLists.txt b/CMakeLists.txt index c66feca..6d33b1e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt
@@ -473,7 +473,8 @@ # 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})