From b59ac43b9d1122da3d00882efa7c5d6833c06ea7 Mon Sep 17 00:00:00 2001 From: Alex Stewart Date: Wed, 27 Feb 2013 09:10:19 +0000 Subject: [PATCH] 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 --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c66feca7b..6d33b1e52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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})