CMake: Pulled third-party configuration logic into its own .cmake file. Review: https://reviews.apache.org/r/38751
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/685df82d Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/685df82d Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/685df82d Branch: refs/heads/master Commit: 685df82d54814a1a004e695802d0c3d6fefbdd77 Parents: 868e787 Author: Alex Clemmer <[email protected]> Authored: Sun Sep 27 15:41:30 2015 -0700 Committer: Joris Van Remoortere <[email protected]> Committed: Sun Sep 27 16:17:39 2015 -0700 ---------------------------------------------------------------------- 3rdparty/libprocess/3rdparty/CMakeLists.txt | 2 +- .../cmake/Process3rdpartyConfigure.cmake | 103 +++++++++++++++++++ .../libprocess/cmake/ProcessConfigure.cmake | 77 +++----------- .../cmake/ProcessTestsConfigure.cmake | 35 +++++-- 4 files changed, 144 insertions(+), 73 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/685df82d/3rdparty/libprocess/3rdparty/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/CMakeLists.txt b/3rdparty/libprocess/3rdparty/CMakeLists.txt index d77f357..c85586b 100644 --- a/3rdparty/libprocess/3rdparty/CMakeLists.txt +++ b/3rdparty/libprocess/3rdparty/CMakeLists.txt @@ -90,7 +90,7 @@ endif (WIN32) # build directory into `configure` as a prefix; so if we're going to move the # libraries, we might as well move them to a library folder.) if (NOT WIN32) - set(GLOG_CONFIG_CMD ${GLOG_ROOT}/src/../configure --prefix=${GLOG_LIB}) + set(GLOG_CONFIG_CMD ${GLOG_ROOT}/src/../configure --prefix=${GLOG_LIB_ROOT}) set(GLOG_BUILD_CMD make) set(GLOG_INSTALL_CMD make install) # Patch glog to deal with a problem that appears when compiling on clang http://git-wip-us.apache.org/repos/asf/mesos/blob/685df82d/3rdparty/libprocess/cmake/Process3rdpartyConfigure.cmake ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/cmake/Process3rdpartyConfigure.cmake b/3rdparty/libprocess/cmake/Process3rdpartyConfigure.cmake new file mode 100644 index 0000000..9c369e2 --- /dev/null +++ b/3rdparty/libprocess/cmake/Process3rdpartyConfigure.cmake @@ -0,0 +1,103 @@ +# 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. + +# DEFINE DIRECTORY STRUCTURE FOR THIRD-PARTY LIBS. +################################################## +set(PROCESS_3RD_SRC ${CMAKE_SOURCE_DIR}/3rdparty/libprocess/3rdparty) +set(PROCESS_3RD_BIN ${CMAKE_BINARY_DIR}/3rdparty/libprocess/3rdparty) + +set(STOUT ${PROCESS_3RD_SRC}/stout) + +EXTERNAL("boost" ${BOOST_VERSION} "${PROCESS_3RD_BIN}") +EXTERNAL("picojson" ${PICOJSON_VERSION} "${PROCESS_3RD_BIN}") +EXTERNAL("http_parser" ${HTTP_PARSER_VERSION} "${PROCESS_3RD_BIN}") +EXTERNAL("libev" ${LIBEV_VERSION} "${PROCESS_3RD_BIN}") +EXTERNAL("libevent" ${LIBEVENT_VERSION} "${PROCESS_3RD_BIN}") +EXTERNAL("libapr" ${LIBAPR_VERSION} "${PROCESS_3RD_BIN}") +EXTERNAL("protobuf" ${PROTOBUF_VERSION} "${PROCESS_3RD_BIN}") + +if (NOT WIN32) + EXTERNAL("glog" ${GLOG_VERSION} "${PROCESS_3RD_BIN}") +elseif (WIN32) + # Glog 0.3.3 does not compile out of the box on Windows. Therefore, we + # require 0.3.4. + EXTERNAL("glog" "0.3.4" "${PROCESS_3RD_BIN}") + + # NOTE: We expect cURL exists on Unix (usually pulled in with a package + # manager), but Windows has no package manager, so we have to go get it. + EXTERNAL("curl" ${CURL_VERSION} "${PROCESS_3RD_BIN}") +endif (NOT WIN32) + +# Intermediate convenience variables for oddly-structured directories. +set(GLOG_LIB_ROOT ${GLOG_ROOT}-lib/lib) +set(PROTOBUF_LIB ${PROTOBUF_ROOT}-lib/lib) + +# Convenience variables for include directories of third-party dependencies. +set(PROCESS_INCLUDE_DIR ${PROCESS_3RD_SRC}/../include) +set(STOUT_INCLUDE_DIR ${STOUT}/include) + +set(BOOST_INCLUDE_DIR ${BOOST_ROOT}) +set(GPERFTOOLS_INCLUDE_DIR ${GPERFTOOLS}/src) +set(HTTP_PARSER_INCLUDE_DIR ${HTTP_PARSER_ROOT}) +set(LIBEV_INCLUDE_DIR ${LIBEV_ROOT}) +set(PICOJSON_INCLUDE_DIR ${PICOJSON_ROOT}) +set(PROTOBUF_INCLUDE_DIR ${PROTOBUF_LIB}/include) + +if (WIN32) + set(CURL_INCLUDE_DIR ${CURL_ROOT}/include) + set(GLOG_INCLUDE_DIR ${GLOG_ROOT}/src/windows) +else (WIN32) + set(GLOG_INCLUDE_DIR ${GLOG_LIB_ROOT}/include) +endif (WIN32) + +# Convenience variables for `lib` directories of built third-party dependencies. +set(HTTP_PARSER_LIB_DIR ${HTTP_PARSER_ROOT}-build) +set(LIBEV_LIB_DIR ${LIBEV_ROOT}-build/.libs) + +if (WIN32) + set(CURL_LIB_DIR ${CURL_ROOT}/lib) + set(GLOG_LIB_DIR ${GLOG_ROOT}/Debug) + set(PROTOBUF_LIB_DIR ${PROTOBUF_ROOT}/vsprojects/Debug) +else (WIN32) + set(GLOG_LIB_DIR ${GLOG_LIB_ROOT}/lib) + set(PROTOBUF_LIB_DIR ${PROTOBUF_LIB}/lib) +endif (WIN32) + +# Convenience variables for "lflags", the symbols we pass to CMake to generate +# things like `-L/path/to/glog` or `-lglog`. +set(HTTP_PARSER_LFLAG http_parser) +set(LIBEV_LFLAG ev) + +if (WIN32) + # Necessary because the lib names for (e.g.) glog are generated incorrectly + # on Windows. That is, on *nix, the glog binary should be (e.g.) libglog.so, + # and on Windows it should be glog.lib. But on Windows, it's actually + # libglog.lib. Hence, we have to special case it here because CMake assumes + # the library names are generated correctly. + set(CURL_LFLAG libcurl_a) + set(GLOG_LFLAG libglog) + set(PROTOBUF_LFLAG libprotobuf) +else (WIN32) + set(GLOG_LFLAG glog) + set(PROTOBUF_LFLAG protobuf) +endif (WIN32) + +# Convenience variable for `protoc`, the Protobuf compiler. +set(PROTOC ${PROTOBUF_LIB}/bin/protoc) + +# Configure the process library, the last of our third-party libraries. +####################################################################### +include(ProcessConfigure) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/mesos/blob/685df82d/3rdparty/libprocess/cmake/ProcessConfigure.cmake ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/cmake/ProcessConfigure.cmake b/3rdparty/libprocess/cmake/ProcessConfigure.cmake index a5dea3a..076c883 100755 --- a/3rdparty/libprocess/cmake/ProcessConfigure.cmake +++ b/3rdparty/libprocess/cmake/ProcessConfigure.cmake @@ -44,36 +44,6 @@ set(PROCESS_PACKAGE_VERSION 0.0.1) set(PROCESS_PACKAGE_SOVERSION 0) set(PROCESS_TARGET process-${PROCESS_PACKAGE_VERSION}) -# DEFINE DIRECTORY STRUCTURE FOR THIRD-PARTY LIBS. -################################################## -set(PROCESS_3RD_SRC ${CMAKE_SOURCE_DIR}/3rdparty/libprocess/3rdparty) -set(PROCESS_3RD_BIN ${CMAKE_BINARY_DIR}/3rdparty/libprocess/3rdparty) - -set(STOUT ${PROCESS_3RD_SRC}/stout) - -EXTERNAL("boost" ${BOOST_VERSION} "${PROCESS_3RD_BIN}") -EXTERNAL("picojson" ${PICOJSON_VERSION} "${PROCESS_3RD_BIN}") -EXTERNAL("http_parser" ${HTTP_PARSER_VERSION} "${PROCESS_3RD_BIN}") -EXTERNAL("libev" ${LIBEV_VERSION} "${PROCESS_3RD_BIN}") -EXTERNAL("libevent" ${LIBEVENT_VERSION} "${PROCESS_3RD_BIN}") -EXTERNAL("libapr" ${LIBAPR_VERSION} "${PROCESS_3RD_BIN}") - -if (NOT WIN32) - EXTERNAL("glog" ${GLOG_VERSION} "${PROCESS_3RD_BIN}") -elseif (WIN32) - # Glog 0.3.3 does not compile out of the box on Windows. Therefore, we - # require 0.3.4. - EXTERNAL("glog" "0.3.4" "${PROCESS_3RD_BIN}") -endif (NOT WIN32) - -set(GLOG_LIB ${GLOG_ROOT}-lib/lib) - -# Directory structure for windows-only third-party libs. -######################################################## -if (WIN32) - EXTERNAL("curl" ${CURL_VERSION} "${PROCESS_3RD_BIN}") -endif (WIN32) - # Define process library dependencies. Tells the process library build targets # download/configure/build all third-party libraries before attempting to build. ################################################################################ @@ -84,6 +54,7 @@ set(PROCESS_DEPENDENCIES ${PICOJSON_TARGET} ${HTTP_PARSER_TARGET} ${LIBEV_TARGET} + ${PROTOBUF_TARGET} ) # Define third-party include directories. Tells compiler toolchain where to get @@ -91,35 +62,17 @@ set(PROCESS_DEPENDENCIES ############################################################################### set(PROCESS_INCLUDE_DIRS ${PROCESS_INCLUDE_DIRS} - ${PROCESS_3RD_SRC}/../include - ${STOUT}/include - ${BOOST_ROOT} - ${LIBEV_ROOT} - ${PICOJSON_ROOT} - ) - -if (WIN32) - set(PROCESS_INCLUDE_DIRS - ${PROCESS_INCLUDE_DIRS} - ${GLOG_ROOT}/src/windows - ) -else (WIN32) - set(PROCESS_INCLUDE_DIRS - ${PROCESS_INCLUDE_DIRS} - ${GLOG_LIB}/include - ) -endif (WIN32) - -set(PROCESS_INCLUDE_DIRS - ${PROCESS_INCLUDE_DIRS} - ${HTTP_PARSER_ROOT} + ${PROCESS_INCLUDE_DIR} + ${STOUT_INCLUDE_DIR} + ${BOOST_INCLUDE_DIR} + ${LIBEV_INCLUDE_DIR} + ${PICOJSON_INCLUDE_DIR} + ${GLOG_INCLUDE_DIR} + ${HTTP_PARSER_INCLUDE_DIR} ) if (HAS_GPERFTOOLS) - set(PROCESS_INCLUDE_DIRS - ${PROCESS_INCLUDE_DIRS} - ${GPERFTOOLS}/src - ) + set(PROCESS_INCLUDE_DIRS ${PROCESS_INCLUDE_DIRS} ${GPERFTOOLS_INCLUDE_DIR}) endif (HAS_GPERFTOOLS) # Define third-party lib install directories. Used to tell the compiler @@ -128,9 +81,9 @@ endif (HAS_GPERFTOOLS) ######################################################################## set(PROCESS_LIB_DIRS ${PROCESS_LIB_DIRS} - ${GLOG_LIB}/lib - ${LIBEV_ROOT}-build/.libs - ${HTTP_PARSER_ROOT}-build + ${GLOG_LIB_DIR} + ${LIBEV_LIB_DIR} + ${HTTP_PARSER_LIB_DIR} ) # Define third-party libs. Used to generate flags that the linker uses to @@ -141,9 +94,9 @@ find_package(Threads REQUIRED) set(PROCESS_LIBS ${PROCESS_LIBS} ${PROCESS_TARGET} - glog - ev - http_parser + ${GLOG_LFLAG} + ${LIBEV_LFLAG} + ${HTTP_PARSER_LFLAG} ${CMAKE_THREAD_LIBS_INIT} ) http://git-wip-us.apache.org/repos/asf/mesos/blob/685df82d/3rdparty/libprocess/cmake/ProcessTestsConfigure.cmake ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/cmake/ProcessTestsConfigure.cmake b/3rdparty/libprocess/cmake/ProcessTestsConfigure.cmake index e105bd8..99496f2 100644 --- a/3rdparty/libprocess/cmake/ProcessTestsConfigure.cmake +++ b/3rdparty/libprocess/cmake/ProcessTestsConfigure.cmake @@ -33,13 +33,29 @@ # DIRECTORY STRUCTURE FOR THIRD-PARTY LIBS REQUIRED FOR TEST INFRASTRUCTURE. ############################################################################ -EXTERNAL("gmock" ${GMOCK_VERSION} "${PROCESS_3RD_BIN}") -EXTERNAL("protobuf" ${PROTOBUF_VERSION} "${PROCESS_3RD_BIN}") +EXTERNAL("gmock" ${GMOCK_VERSION} "${PROCESS_3RD_BIN}") set(GTEST_SRC ${GMOCK_ROOT}/gtest) set(GPERFTOOLS_VERSION 2.0) set(GPERFTOOLS ${PROCESS_3RD_BIN}/gperftools-${GPERFTOOLS_VERSION}) -set(PROTOBUF_LIB ${PROTOBUF_ROOT}-lib/lib) + +# Convenience variables for include directories of third-party dependencies. +set(GMOCK_INCLUDE_DIR ${GMOCK_ROOT}/include) +set(GTEST_INCLUDE_DIR ${GTEST_SRC}/include) + +# Convenience variables for `lib` directories of built third-party dependencies. +set(GTEST_LIB_DIR ${GMOCK_ROOT}-build/gtest/lib/.libs) + +if (WIN32) + set(GMOCK_LIB_DIR ${GMOCK_ROOT}/msvc/2010/Debug) +else (WIN32) + set(GMOCK_LIB_DIR ${GMOCK_ROOT}-build/lib/.libs) +endif (WIN32) + +# Convenience variables for "lflags", the symbols we pass to CMake to generate +# things like `-L/path/to/glog` or `-lglog`. +set(GMOCK_LFLAG gmock) +set(GTEST_LFLAG gtest) # COMPILER CONFIGURATION. ######################### @@ -55,7 +71,6 @@ endif (APPLE) set(PROCESS_TEST_DEPENDENCIES ${PROCESS_TEST_DEPENDENCIES} ${PROCESS_DEPENDENCIES} - ${PROTOBUF_TARGET} ${GMOCK_TARGET} ) @@ -66,8 +81,8 @@ set(PROCESS_TEST_INCLUDE_DIRS ${PROCESS_TEST_INCLUDE_DIRS} ../ # includes, e.g., decoder.hpp ${PROCESS_INCLUDE_DIRS} - ${GMOCK_ROOT}/include - ${GTEST_SRC}/include + ${GMOCK_INCLUDE_DIR} + ${GTEST_INCLUDE_DIR} src ) @@ -78,8 +93,8 @@ set(PROCESS_TEST_INCLUDE_DIRS set(PROCESS_TEST_LIB_DIRS ${PROCESS_TEST_LIB_DIRS} ${PROCESS_LIB_DIRS} - ${GMOCK_ROOT}-build/lib/.libs - ${GMOCK_ROOT}-build/gtest/lib/.libs + ${GMOCK_LIB_DIR} + ${GTEST_LIB_DIR} ) # DEFINE THIRD-PARTY LIBS. Used to generate flags that the linker uses to @@ -88,6 +103,6 @@ set(PROCESS_TEST_LIB_DIRS set(PROCESS_TEST_LIBS ${PROCESS_TEST_LIBS} ${PROCESS_LIBS} - gmock - gtest + ${GMOCK_LFLAG} + ${GTEST_LFLAG} )
