From commits-return-6182-archive-asf-public=cust-asf.ponee.io@zookeeper.apache.org Mon Apr 16 06:30:01 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 1F88E180608 for ; Mon, 16 Apr 2018 06:30:00 +0200 (CEST) Received: (qmail 54034 invoked by uid 500); 16 Apr 2018 04:30:00 -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 54018 invoked by uid 99); 16 Apr 2018 04:30:00 -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; Mon, 16 Apr 2018 04:30:00 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D1A74F320C; Mon, 16 Apr 2018 04:29:59 +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: <6a062f7512fa4fa797825cd17ef4c6a9@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: zookeeper git commit: ZOOKEEPER-2999: CMake build should use target-level commands Date: Mon, 16 Apr 2018 04:29:59 +0000 (UTC) Repository: zookeeper Updated Branches: refs/heads/branch-3.5 cb45603ac -> d9605359c ZOOKEEPER-2999: CMake build should use target-level commands CMake is using `include_directories`, which has global side effects, instead of the more explicit `target_include_directories`, to include directories per target (and with private or public scoping). Furthermore, CMake should also use `CMAKE_CURRENT_SOURCE_DIR` over `CMAKE_SOURCE_DIR` in order to allow inclusion in other projects via `add_subdirectory()`, and we can reduce the minimally required CMake version to 3.5 from 3.6. Author: proller Reviewers: Michael Han Closes #486 from andschwa/ZOOKEEPER-2999 (cherry picked from commit 9ba4aeb4f92c1fc3167ff8e2b56e02f3e344d3ba) Signed-off-by: Michael Han Project: http://git-wip-us.apache.org/repos/asf/zookeeper/repo Commit: http://git-wip-us.apache.org/repos/asf/zookeeper/commit/d9605359 Tree: http://git-wip-us.apache.org/repos/asf/zookeeper/tree/d9605359 Diff: http://git-wip-us.apache.org/repos/asf/zookeeper/diff/d9605359 Branch: refs/heads/branch-3.5 Commit: d9605359c3b82eae37999abc377efc54fd22f34f Parents: cb45603 Author: proller Authored: Sun Apr 15 21:29:43 2018 -0700 Committer: Michael Han Committed: Sun Apr 15 21:29:53 2018 -0700 ---------------------------------------------------------------------- src/c/CMakeLists.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/zookeeper/blob/d9605359/src/c/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/src/c/CMakeLists.txt b/src/c/CMakeLists.txt index 8d78d70..2884ca7 100644 --- a/src/c/CMakeLists.txt +++ b/src/c/CMakeLists.txt @@ -14,14 +14,13 @@ # See the License for the specific language governing permissions and # limitations under the License. -cmake_minimum_required(VERSION 3.6) +cmake_minimum_required(VERSION 3.5) project(zookeeper VERSION 3.5.3) set(email user@zookeeper.apache.org) set(description "zookeeper C client") # general options -include_directories(include tests generated ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) if(UNIX) add_compile_options(-Wall -fPIC) elseif(WIN32) @@ -77,7 +76,7 @@ endfunction() # include file checks foreach(f generated/zookeeper.jute.h generated/zookeeper.jute.c) - if(EXISTS "${CMAKE_SOURCE_DIR}/${f}") + if(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/${f}") to_have(${f} name) set(${name} 1) else() @@ -149,7 +148,7 @@ include(CheckStructHasMember) check_struct_has_member("struct sockaddr_in6" sin6_addr "netinet/in.h" ZOO_IPV6_ENABLED) # configure -configure_file(cmake_config.h.in ${CMAKE_SOURCE_DIR}/include/config.h) +configure_file(cmake_config.h.in ${CMAKE_CURRENT_BINARY_DIR}/include/config.h) # hashtable library set(hashtable_sources src/hashtable/hashtable_itr.c src/hashtable/hashtable.c) @@ -176,6 +175,7 @@ if(WIN32) endif() add_library(zookeeper STATIC ${zookeeper_sources}) +target_include_directories(zookeeper PUBLIC include ${CMAKE_CURRENT_BINARY_DIR}/include generated) target_link_libraries(zookeeper PUBLIC hashtable $<$:rt> # clock_gettime @@ -223,8 +223,10 @@ endif() if(WANT_CPPUNIT) add_executable(zktest ${test_sources}) + target_include_directories(zktest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + target_compile_definitions(zktest - PRIVATE -DZKSERVER_CMD="${CMAKE_SOURCE_DIR}/tests/zkServer.sh") + PRIVATE -DZKSERVER_CMD="${CMAKE_CURRENT_SOURCE_DIR}/tests/zkServer.sh") # TODO: Use `find_library()` for `cppunit`. target_link_libraries(zktest zookeeper cppunit dl) @@ -241,6 +243,6 @@ if(WANT_CPPUNIT) enable_testing() add_test(NAME zktest_runner COMMAND zktest) set_property(TEST zktest_runner PROPERTY ENVIRONMENT - "ZKROOT=${CMAKE_SOURCE_DIR}/../.." + "ZKROOT=${CMAKE_CURRENT_SOURCE_DIR}/../.." "CLASSPATH=$CLASSPATH:$CLOVER_HOME/lib/clover.jar") endif()