From 39c65fb3ea6ddbec92b32efa1a7fbd0fb299ce63 Mon Sep 17 00:00:00 2001 From: Pavel Labath Date: Wed, 14 Mar 2018 10:08:21 +0000 Subject: [PATCH] [cmake] Fix standalone+LLVM_LINK_LLVM_DYLIB builds (pr36687) Summary: To make this build work, I needed to add detection code for the pthread library. This is necessary, because we have direct calls to these libraries (instead of going through llvm) and in the standalone build we cannot rely on llvm to detect these for us. In a standalone non-dylib build this was accidentaly working because these libraries were pulled in as an interface dependency of the .a files, but in a dylib build these are no longer part of the link interface, and so we need to add them explicitly. Reviewers: krytarowski, zturner Subscribers: lldb-commits, mgorny Differential Revision: https://reviews.llvm.org/D44379 git-svn-id: https://llvm.org/svn/llvm-project/lldb/trunk@327490 91177308-0d34-0410-b5e6-96231b3b80d8 --- cmake/modules/LLDBConfig.cmake | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cmake/modules/LLDBConfig.cmake b/cmake/modules/LLDBConfig.cmake index 24878b5913..32effe7737 100644 --- a/cmake/modules/LLDBConfig.cmake +++ b/cmake/modules/LLDBConfig.cmake @@ -346,14 +346,18 @@ else() endif() -if (HAVE_LIBPTHREAD) - list(APPEND system_libs pthread) -endif(HAVE_LIBPTHREAD) +if( WIN32 AND NOT CYGWIN ) + set(PURE_WINDOWS 1) +endif() -if (HAVE_LIBDL) - list(APPEND system_libs ${CMAKE_DL_LIBS}) +if(NOT PURE_WINDOWS) + set(CMAKE_THREAD_PREFER_PTHREAD TRUE) + find_package(Threads REQUIRED) + list(APPEND system_libs ${CMAKE_THREAD_LIBS_INIT}) endif() +list(APPEND system_libs ${CMAKE_DL_LIBS}) + # Figure out if lldb could use lldb-server. If so, then we'll # ensure we build lldb-server when an lldb target is being built. if (CMAKE_SYSTEM_NAME MATCHES "Android|Darwin|FreeBSD|Linux|NetBSD")