From: Alexander GQ Gerasiov <gq@cs.msu.su>
Date: Sun, 6 Jan 2019 01:59:33 +0300
Subject: Fix link with pthread when std::thread is used.

According to docs, you should add -lpthread when use std::thread in your code.
This doesn't matter if you build static binaries but fails the build when
one anable SPLIT_SHARED_LIBRARIES.

Signed-off-by: Alexander GQ Gerasiov <gq@cs.msu.su>
---
 dbms/src/Common/Config/CMakeLists.txt          | 2 +-
 dbms/src/Common/ZooKeeper/tests/CMakeLists.txt | 2 +-
 dbms/src/Common/tests/CMakeLists.txt           | 8 ++++----
 dbms/src/DataStreams/tests/CMakeLists.txt      | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/dbms/src/Common/Config/CMakeLists.txt b/dbms/src/Common/Config/CMakeLists.txt
index a1bb279..0af2585 100644
--- a/dbms/src/Common/Config/CMakeLists.txt
+++ b/dbms/src/Common/Config/CMakeLists.txt
@@ -4,5 +4,5 @@ add_headers_and_sources(clickhouse_common_config .)
 
 add_library(clickhouse_common_config ${LINK_MODE} ${clickhouse_common_config_headers} ${clickhouse_common_config_sources})
 
-target_link_libraries(clickhouse_common_config PUBLIC common PRIVATE clickhouse_common_zookeeper string_utils PUBLIC ${Poco_XML_LIBRARY} ${Poco_Util_LIBRARY})
+target_link_libraries(clickhouse_common_config PUBLIC common PRIVATE clickhouse_common_zookeeper string_utils PUBLIC ${Poco_XML_LIBRARY} ${Poco_Util_LIBRARY} pthread)
 target_include_directories(clickhouse_common_config PUBLIC ${DBMS_INCLUDE_DIR})
diff --git a/dbms/src/Common/ZooKeeper/tests/CMakeLists.txt b/dbms/src/Common/ZooKeeper/tests/CMakeLists.txt
index 06716e4..282c4c6 100644
--- a/dbms/src/Common/ZooKeeper/tests/CMakeLists.txt
+++ b/dbms/src/Common/ZooKeeper/tests/CMakeLists.txt
@@ -11,7 +11,7 @@ add_executable(zkutil_expiration_test zkutil_expiration_test.cpp)
 target_link_libraries(zkutil_expiration_test PRIVATE clickhouse_common_zookeeper)
 
 add_executable(zkutil_test_async zkutil_test_async.cpp)
-target_link_libraries(zkutil_test_async PRIVATE clickhouse_common_zookeeper)
+target_link_libraries(zkutil_test_async PRIVATE clickhouse_common_zookeeper pthread)
 
 add_executable(zkutil_zookeeper_holder zkutil_zookeeper_holder.cpp)
 target_link_libraries(zkutil_zookeeper_holder PRIVATE clickhouse_common_zookeeper)
diff --git a/dbms/src/Common/tests/CMakeLists.txt b/dbms/src/Common/tests/CMakeLists.txt
index 05984c9..4f8e5c5 100644
--- a/dbms/src/Common/tests/CMakeLists.txt
+++ b/dbms/src/Common/tests/CMakeLists.txt
@@ -11,7 +11,7 @@ add_executable (auto_array auto_array.cpp)
 target_link_libraries (auto_array PRIVATE clickhouse_common_io)
 
 add_executable (lru_cache lru_cache.cpp)
-target_link_libraries (lru_cache PRIVATE clickhouse_common_io)
+target_link_libraries (lru_cache PRIVATE clickhouse_common_io pthread)
 
 add_executable (hash_table hash_table.cpp)
 target_link_libraries (hash_table PRIVATE clickhouse_common_io)
@@ -48,13 +48,13 @@ add_executable (pod_array pod_array.cpp)
 target_link_libraries (pod_array PRIVATE clickhouse_common_io)
 
 add_executable (thread_creation_latency thread_creation_latency.cpp)
-target_link_libraries (thread_creation_latency PRIVATE clickhouse_common_io)
+target_link_libraries (thread_creation_latency PRIVATE clickhouse_common_io pthread)
 
 add_executable (thread_pool thread_pool.cpp)
 target_link_libraries (thread_pool PRIVATE clickhouse_common_io)
 
 add_executable (array_cache array_cache.cpp)
-target_link_libraries (array_cache PRIVATE clickhouse_common_io)
+target_link_libraries (array_cache PRIVATE clickhouse_common_io pthread)
 
 add_executable (space_saving space_saving.cpp)
 target_link_libraries (space_saving PRIVATE clickhouse_common_io)
@@ -70,4 +70,4 @@ add_executable (cow_columns cow_columns.cpp)
 target_link_libraries (cow_columns PRIVATE clickhouse_common_io)
 
 add_executable (stopwatch stopwatch.cpp)
-target_link_libraries (stopwatch PRIVATE clickhouse_common_io)
+target_link_libraries (stopwatch PRIVATE clickhouse_common_io pthread)
diff --git a/dbms/src/DataStreams/tests/CMakeLists.txt b/dbms/src/DataStreams/tests/CMakeLists.txt
index 3f6e154..310e7bc 100644
--- a/dbms/src/DataStreams/tests/CMakeLists.txt
+++ b/dbms/src/DataStreams/tests/CMakeLists.txt
@@ -7,7 +7,7 @@ add_executable (filter_stream filter_stream.cpp ${SRCS})
 target_link_libraries (filter_stream PRIVATE dbms clickhouse_storages_system clickhouse_parsers clickhouse_common_io)
 
 add_executable (union_stream2 union_stream2.cpp ${SRCS})
-target_link_libraries (union_stream2 PRIVATE dbms)
+target_link_libraries (union_stream2 PRIVATE dbms pthread)
 
 add_executable (collapsing_sorted_stream collapsing_sorted_stream.cpp ${SRCS})
 target_link_libraries (collapsing_sorted_stream PRIVATE dbms)
