Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 97B7D200CF5 for ; Sun, 13 Aug 2017 07:21:32 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 9622F16488F; Sun, 13 Aug 2017 05:21:32 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id DBEBB164889 for ; Sun, 13 Aug 2017 07:21:31 +0200 (CEST) Received: (qmail 48971 invoked by uid 500); 13 Aug 2017 05:21:30 -0000 Mailing-List: contact commits-help@zookeeper.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zookeeper.apache.org Delivered-To: mailing list commits@zookeeper.apache.org Received: (qmail 48960 invoked by uid 99); 13 Aug 2017 05:21:30 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 13 Aug 2017 05:21:30 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9EB92E964E; Sun, 13 Aug 2017 05:21:29 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: hanm@apache.org To: commits@zookeeper.apache.org Message-Id: <3b1bd723d4f0445c9828431651d6b011@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: zookeeper git commit: ZOOKEEPER-2859: Fix CMake build on OS X. Date: Sun, 13 Aug 2017 05:21:29 +0000 (UTC) archived-at: Sun, 13 Aug 2017 05:21:32 -0000 Repository: zookeeper Updated Branches: refs/heads/master 0c5b32006 -> 5bcffe9bc ZOOKEEPER-2859: Fix CMake build on OS X. The libraries `libm` and `librt` (providing `math.h` and `clock_gettime` respectively) cannot be linked on OS X. Instead, this functionality is "free" with `libSystem`. Note that the `hashtable` library has the dependency on `libm`, not the `zookeeper` library. This was an error carried over from the Autotools build. Also finishes a TODO for `pthread` by importing it using the `FindThreads` CMake package. Author: Andrew Schwartzmeyer Reviewers: Michael Han Closes #319 from andschwa/macos Project: http://git-wip-us.apache.org/repos/asf/zookeeper/repo Commit: http://git-wip-us.apache.org/repos/asf/zookeeper/commit/5bcffe9b Tree: http://git-wip-us.apache.org/repos/asf/zookeeper/tree/5bcffe9b Diff: http://git-wip-us.apache.org/repos/asf/zookeeper/diff/5bcffe9b Branch: refs/heads/master Commit: 5bcffe9bc242d825ad97ff4f9d2dea6476983a9a Parents: 0c5b320 Author: Andrew Schwartzmeyer Authored: Sat Aug 12 22:21:25 2017 -0700 Committer: Michael Han Committed: Sat Aug 12 22:21:25 2017 -0700 ---------------------------------------------------------------------- src/c/CMakeLists.txt | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zookeeper/blob/5bcffe9b/src/c/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/c/CMakeLists.txt b/src/c/CMakeLists.txt index 4bdb5e0..ef95a76 100644 --- a/src/c/CMakeLists.txt +++ b/src/c/CMakeLists.txt @@ -45,10 +45,11 @@ if(WANT_SYNCAPI) endif() # CppUnit option -if(WIN32) - # The tests do not yet compile on Windows, so we set this to off by default. +if(WIN32 OR APPLE) + # The tests do not yet compile on Windows or macOS, + # so we set this to off by default. # - # Note that CMake can does not have expressions except in conditionals, + # Note that CMake does not have expressions except in conditionals, # so we're left with this if/else/endif pattern. set(DEFAULT_WANT_CPPUNIT OFF) else() @@ -147,6 +148,7 @@ configure_file(cmake_config.h.in ${CMAKE_SOURCE_DIR}/include/config.h) # hashtable library set(hashtable_sources src/hashtable/hashtable_itr.c src/hashtable/hashtable.c) add_library(hashtable STATIC ${hashtable_sources}) +target_link_libraries(hashtable PUBLIC $<$:m>) # zookeeper library set(zookeeper_sources @@ -168,17 +170,14 @@ if(WIN32) endif() add_library(zookeeper STATIC ${zookeeper_sources}) -target_link_libraries(zookeeper PUBLIC hashtable) -if(UNIX) - target_link_libraries(zookeeper PUBLIC m rt) -elseif(WIN32) - # Link to Winsock 2.0 - target_link_libraries(zookeeper PUBLIC ws2_32) -endif() +target_link_libraries(zookeeper PUBLIC + hashtable + $<$:rt> # clock_gettime + $<$:ws2_32>) # Winsock 2.0 if(WANT_SYNCAPI AND NOT WIN32) - # TODO: Use `find_library()` or `FindThreads()` for `pthread`. - target_link_libraries(zookeeper PUBLIC pthread) + find_package(Threads REQUIRED) + target_link_libraries(zookeeper PUBLIC Threads::Threads) endif() # cli executable