You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by jo...@apache.org on 2017/09/03 12:51:40 UTC
[18/42] mesos git commit: CMake: Cleaned up 3rdparty/CMakelists.txt.
CMake: Cleaned up 3rdparty/CMakelists.txt.
This move some macros away from the global scope, as they are only used
in one file; and cleans up some comments and whitespace.
Review: https://reviews.apache.org/r/61360/
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/b44557f1
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/b44557f1
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/b44557f1
Branch: refs/heads/master
Commit: b44557f110f01721cf7ccf0b4af903db70474551
Parents: c23cc03
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Sat Sep 2 17:37:33 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Sun Sep 3 05:51:07 2017 -0700
----------------------------------------------------------------------
3rdparty/CMakeLists.txt | 127 ++++++++++++++++++++-----------------------
CMakeLists.txt | 6 --
cmake/Common.cmake | 25 ---------
3 files changed, 59 insertions(+), 99 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/b44557f1/3rdparty/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt
index eb258b3..8655f3d 100755
--- a/3rdparty/CMakeLists.txt
+++ b/3rdparty/CMakeLists.txt
@@ -14,39 +14,27 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-include(ExternalProject)
-
-if (BUILD_SHARED_LIBS)
- set(LIBRARY_LINKAGE SHARED)
- set(LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
-else ()
- set(LIBRARY_LINKAGE STATIC)
- set(LIBRARY_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX})
-endif ()
-
-
-# Define sources of third-party dependencies.
-#############################################
+# URLs for each downloaded or bundled third-party dependency.
+#############################################################
if (REBUNDLED)
set(FETCH_URL ${CMAKE_CURRENT_SOURCE_DIR})
else ()
set(FETCH_URL ${3RDPARTY_DEPENDENCIES})
endif ()
-
-# DEPENDENCIES FOR THE PROCESS LIBRARY AND STOUT.
-#
-# Downloads, configures, and compiles the third-party libraries for the process
-# library (located in `3rdparty/`, i.e. not the `mesos-3rdparty` repository).
-###############################################################################
+# TODO(andschwa): Move each URL to the dependency itself.
set(BOOST_URL ${FETCH_URL}/boost-${BOOST_VERSION}.tar.gz)
set(CONCURRENTQUEUE_URL ${FETCH_URL}/concurrentqueue-${CONCURRENTQUEUE_VERSION}.tar.gz)
set(ELFIO_URL ${FETCH_URL}/elfio-${ELFIO_VERSION}.tar.gz)
set(GLOG_URL ${FETCH_URL}/glog-${GLOG_VERSION}.tar.gz)
+set(GOOGLETEST_URL ${FETCH_URL}/googletest-release-${GOOGLETEST_VERSION}.tar.gz)
set(HTTP_PARSER_URL ${FETCH_URL}/http-parser-${HTTP_PARSER_VERSION}.tar.gz)
set(PICOJSON_URL ${FETCH_URL}/picojson-${PICOJSON_VERSION}.tar.gz)
-set(NVML_URL ${FETCH_URL}/nvml-${NVML_VERSION}.tar.gz)
+set(PROTOBUF_URL ${FETCH_URL}/protobuf-${PROTOBUF_VERSION}.tar.gz)
+set(LEVELDB_URL ${FETCH_URL}/leveldb-${LEVELDB_VERSION}.tar.gz)
set(LIBEV_URL ${FETCH_URL}/libev-${LIBEV_VERSION}.tar.gz)
+set(NVML_URL ${FETCH_URL}/nvml-${NVML_VERSION}.tar.gz)
+set(ZOOKEEPER_URL ${FETCH_URL}/zookeeper-${ZOOKEEPER_VERSION}.tar.gz)
# NOTE: libevent doesn't come rebundled, so this URL is always the same. But,
# it's only downloaded if `ENABLE_LIBEVENT` is set.
@@ -65,6 +53,42 @@ if (WIN32)
set(GLOG_URL ${3RDPARTY_DEPENDENCIES}/glog-${GLOG_VERSION}.tar.gz)
endif ()
+
+# Helper utilities for dealing with third-party dependencies.
+#############################################################
+# ExternalProject: Create custom targets to build projects in external trees.
+# https://cmake.org/cmake/help/latest/module/ExternalProject.html
+include(ExternalProject)
+
+# This adds our FindApr and FindSvn packages.
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/stout/cmake)
+
+# This adds our `external()` and `patch_command()` functions.
+list(APPEND CMAKE_MODULE_PATH
+ ${CMAKE_CURRENT_SOURCE_DIR}/libprocess/cmake/macros)
+
+include(External)
+include(PatchCommand)
+
+# Variables for current specified linkage.
+# NOTE: Not all third-party dependencies will respect this.
+if (BUILD_SHARED_LIBS)
+ set(LIBRARY_LINKAGE SHARED)
+ set(LIBRARY_SUFFIX ${CMAKE_SHARED_LIBRARY_SUFFIX})
+else ()
+ set(LIBRARY_LINKAGE STATIC)
+ set(LIBRARY_SUFFIX ${CMAKE_STATIC_LIBRARY_SUFFIX})
+endif ()
+
+# Sets a variable CMAKE_NOOP as noop operation.
+#
+# NOTE: This is especially important when building third-party libraries on
+# Windows; the default behavior of `ExternalProject` is to try to assume that
+# third-party libraries can be configured/built/installed with CMake, so in
+# cases where this isn't true, we have to "trick" CMake into skipping those
+# steps by giving it a noop command to run instead.
+set(CMAKE_NOOP ${CMAKE_COMMAND} -E echo)
+
# This `CMAKE_FORWARD_ARGS` variable is sent as the `CMAKE_ARGS` argument to
# the `ExternalProject_Add` macro (along with any per-project arguments), and
# is used when the external project is configured as a CMake project.
@@ -78,9 +102,7 @@ list(APPEND CMAKE_FORWARD_ARGS
# TODO(andschwa): Set the CMAKE_GENERATOR explicitly as an argmuent to
# `ExternalProject_Add`.
-G${CMAKE_GENERATOR}
-
- -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS}
- )
+ -DBUILD_SHARED_LIBS=${BUILD_SHARED_LIBS})
# This only matters for single-configuration generators.
# E.g. Makefile, but not Visual Studio.
@@ -90,21 +112,14 @@ endif ()
foreach (lang C CXX)
list(APPEND CMAKE_FORWARD_ARGS
- -DCMAKE_${lang}_FLAGS=${CMAKE_${lang}_FLAGS}
- )
+ -DCMAKE_${lang}_FLAGS=${CMAKE_${lang}_FLAGS})
foreach (config DEBUG RELEASE RELWITHDEBINFO MINSIZEREL)
list(APPEND CMAKE_FORWARD_ARGS
- -DCMAKE_${lang}_FLAGS_${config}=${CMAKE_${lang}_FLAGS_${config}}
- )
+ -DCMAKE_${lang}_FLAGS_${config}=${CMAKE_${lang}_FLAGS_${config}})
endforeach ()
endforeach ()
-
-# Third-party libraries. Tell the build system how to pull in and build third-
-# party libraries at compile time, using the ExternalProject_Add macro.
-##############################################################################
-
# This function works around a CMake issue with setting include directories of
# imported libraries built with `ExternalProject_Add`.
# https://gitlab.kitware.com/cmake/cmake/issues/15052
@@ -113,6 +128,12 @@ function(MAKE_INCLUDE_DIR TARGET)
file(MAKE_DIRECTORY ${DIR})
endfunction()
+
+# Third-party libraries. Adds CMake imported or interface targets for each
+# dependency. Bundled dependencies are built with `ExternalProject_Add`,
+# otherwise `find_package()` is used.
+##########################################################################
+
# Boost: C++ Libraries.
# http://www.boost.org
#######################
@@ -537,16 +558,6 @@ set_target_properties(
INTERFACE_COMPILE_DEFINITIONS HAVE_LIBZ)
-# DEPENDENCIES FOR THE PROCESS LIBRARY TESTS AND STOUT TESTS.
-#
-# Downloads, configures, and compiles the third-party libraries for the process
-# library tests (located in `3rdparty/`).
-###############################################################################
-list(
- APPEND CMAKE_MODULE_PATH
- ${CMAKE_SOURCE_DIR}/3rdparty/stout/cmake)
-
-
# Google Test: Google's C++ test framework (GoogleTest and GoogleMock).
# https://github.com/google/googletest
#######################################################################
@@ -589,8 +600,6 @@ endif ()
MAKE_INCLUDE_DIR(gmock)
MAKE_INCLUDE_DIR(gtest)
-set(GOOGLETEST_URL ${FETCH_URL}/googletest-release-${GOOGLETEST_VERSION}.tar.gz)
-
ExternalProject_Add(
${GOOGLETEST_TARGET}
PREFIX ${GOOGLETEST_CMAKE_ROOT}
@@ -645,8 +654,6 @@ endif ()
MAKE_INCLUDE_DIR(protobuf)
-set(PROTOBUF_URL ${FETCH_URL}/protobuf-${PROTOBUF_VERSION}.tar.gz)
-
ExternalProject_Add(
${PROTOBUF_TARGET}
PREFIX ${PROTOBUF_CMAKE_ROOT}
@@ -657,28 +664,6 @@ ExternalProject_Add(
URL_HASH ${PROTOBUF_HASH})
-# BUILDING THE STOUT LIBRARY AND ITS TESTS.
-#
-# Builds, configures, and compiles the stout library and assorted tests.
-########################################################################
-add_subdirectory(stout)
-
-
-# BUILDING THE PROCESS LIBRARY AND ITS TESTS.
-#
-# Builds, configures, and compiles the process library and assorted tests.
-##########################################################################
-add_subdirectory(libprocess)
-
-
-# BUILDING THE MESOS DEPENDENCIES.
-#
-# Downloads, configures, and compiles the third-party libraries for the mesos.
-###################################################
-set(LEVELDB_URL ${FETCH_URL}/leveldb-${LEVELDB_VERSION}.tar.gz)
-set(ZOOKEEPER_URL ${FETCH_URL}/zookeeper-${ZOOKEEPER_VERSION}.tar.gz)
-
-
# Apache ZooKeeper: C Client Library to ZooKeeper.
# https://zookeeper.apache.org/
##################################################
@@ -765,3 +750,9 @@ if (NOT WIN32)
URL ${LEVELDB_URL}
URL_HASH ${LEVELDB_HASH})
endif ()
+
+
+# In-tree dependencies.
+#######################
+add_subdirectory(stout)
+add_subdirectory(libprocess)
http://git-wip-us.apache.org/repos/asf/mesos/blob/b44557f1/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/CMakeLists.txt b/CMakeLists.txt
index c1126a7..8e18c2c 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -40,9 +40,6 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/3rdparty/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/3rdparty/libprocess/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/3rdparty/stout/cmake)
-list(
- APPEND
- CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/3rdparty/libprocess/cmake/macros)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/src/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/src/examples/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/src/master/cmake)
@@ -50,9 +47,6 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/src/slave/cmake)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/src/tests/cmake)
# Macros.
-include(Common)
-include(External)
-include(PatchCommand)
include(Versions)
include(cotire)
http://git-wip-us.apache.org/repos/asf/mesos/blob/b44557f1/cmake/Common.cmake
----------------------------------------------------------------------
diff --git a/cmake/Common.cmake b/cmake/Common.cmake
deleted file mode 100644
index 76b2a67..0000000
--- a/cmake/Common.cmake
+++ /dev/null
@@ -1,25 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-###############################################################
-# Exports a variable CMAKE_NOOP as noop operation.
-#
-# NOTE: This is especially important when building third-party libraries on
-# Windows; the default behavior of `ExternalProject` is to try to assume that
-# third-party libraries can be configured/built/installed with CMake, so in
-# cases where this isn't true, we have to "trick" CMake into skipping those
-# steps by giving it a noop command to run instead.
-set(CMAKE_NOOP ${CMAKE_COMMAND} -E echo)