Repository: mesos Updated Branches: refs/heads/master 3b7a6b840 -> cc0b6ea87
Changed build commands for 3rdparty libs to be no-ops in Windows. Largely a reverse of a previous commit. We previously removed the quotes from around some interpolated variables, to instead make them regular variable expansions, but in their context (they expand to build commands for third-party libraries) we now know that this doesn't work on all platforms for all versions of CMake. A longer explanation of the technical issue is in the code comments. Review: https://reviews.apache.org/r/37019 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/3446c25c Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/3446c25c Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/3446c25c Branch: refs/heads/master Commit: 3446c25ca9450807c2547d829412162282e38038 Parents: 3b7a6b8 Author: Alex Clemmer <[email protected]> Authored: Thu Sep 10 12:05:59 2015 -0700 Committer: Joris Van Remoortere <[email protected]> Committed: Thu Sep 10 17:14:28 2015 -0700 ---------------------------------------------------------------------- 3rdparty/libprocess/3rdparty/CMakeLists.txt | 116 ++++++++++++++--------- 1 file changed, 73 insertions(+), 43 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/3446c25c/3rdparty/libprocess/3rdparty/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/CMakeLists.txt b/3rdparty/libprocess/3rdparty/CMakeLists.txt index 997cc0d..683a003 100644 --- a/3rdparty/libprocess/3rdparty/CMakeLists.txt +++ b/3rdparty/libprocess/3rdparty/CMakeLists.txt @@ -16,10 +16,10 @@ include(ExternalProject) -# Downloads, configures, and compiles the third party libraries for the process +# Downloads, configures, and compiles the third-party libraries for the process # library (i.e., 3rdparty/libprocess/3rdparty). -# DEFINE SOURCES OF THIRD_PARTY DEPENDENCIES. +# Define sources of third-party dependencies. ############################################# set(REBUNDLED_DIR ${CMAKE_CURRENT_SOURCE_DIR}) if (REBUNDLED) @@ -29,25 +29,29 @@ if (REBUNDLED) set(HTTP_PARSER_URL ${REBUNDLED_DIR}/ry-http-parser-${HTTP_PARSER_VERSION}.tar.gz) set(LIBEV_URL ${REBUNDLED_DIR}/libev-${LIBEV_VERSION}.tar.gz) else (REBUNDLED) - # TODO(hausdorff): depends on the github mirror, should remove when possible. + # TODO(hausdorff): (MESOS-3395) depends on the github mirror, should remove + # when possible. set(BOOST_URL https://github.com/apache/mesos/raw/master/3rdparty/libprocess/3rdparty/boost-${BOOST_VERSION}.tar.gz) set(GLOG_URL https://google-glog.googlecode.com/files/glog-${GLOG_VERSION}.tar.gz) # NOTE: This url can't be versioned like the others, because it depends on # specific commit, and isn't in our upstream. set(PICOJSON_URL https://github.com/kazuho/picojson/tarball/4f93734ade33ea0f5e5b4de35fc6b2c324a8dca6) - # TODO(hausdorff): depends on the github mirror, should remove when possible. + # TODO(hausdorff): (MESOS-3395) depends on the github mirror, should remove + # when possible. set(HTTP_PARSER_URL https://github.com/apache/mesos/raw/master/3rdparty/libprocess/3rdparty/ry-http-parser-${HTTP_PARSER_VERSION}.tar.gz) - # TODO(hausdorff): depends on the github mirror, should remove when possible. + # TODO(hausdorff): (MESOS-3395) depends on the github mirror, should remove + # when possible. set(LIBEV_URL https://github.com/apache/mesos/raw/master/3rdparty/libprocess/3rdparty/libev-${LIBEV_VERSION}.tar.gz) endif (REBUNDLED) if (WIN32) - # TODO(hausdorff): points at a random tarball in my (hausdorff's) repository. - # We need a more permanent solution for this eventually. + # TODO(hausdorff): (MESOS-3394) points at a random tarball in my + # (hausdorff's) repository. We need a more permanent solution for this + # eventually. set(CURL_URL https://github.com/hausdorff/3rdparty/raw/master/curl-static-${CURL_VERSION}.tar.gz) endif (WIN32) -# DEFINE BUILD/PATCH/CONFIGURE COMMANDS FOR THIRD-PARTY LIBS. +# Define build/patch/configure commands for third-party libs. ############################################################# if (NOT WIN32) set(GLOG_CONFIG_CMD ${GLOG_ROOT}/src/../configure --prefix=${GLOG_LIB}) @@ -64,27 +68,46 @@ if (NOT WIN32) set(LIBEV_BUILD_CMD make) # Patch libev to keep it from reaping child processes. PATCH_CMD(${PROCESS_3RD_SRC}/libev-4.15.patch LIBEV_PATCH_CMD) -else (NOT WIN32) - # Quotes are important in the following commands. Building glog on WIN32 - # must be done in Visual Studio, and in that case, these commands must be - # nops. But if you take out the quote marks, CMake will treat this as an - # empty build command, and will attempt to build glog as a CMake project. - set(GLOG_CONFIG_CMD "") - set(GLOG_BUILD_CMD "") - set(GLOG_INSTALL_CMD "") - set(GLOG_PATCH_CMD "") - - set(RY_BUILD_CMD "") - set(RY_INSTALL_CMD "") - - set(LIBEV_CONFIG_CMD "") - set(LIBEV_BUILD_CMD "") - set(LIBEV_PATCH_CMD "") endif (NOT WIN32) -# THIRD-PARTY LIBRARIES. Tell the build system how to pull in and build third- +# Third-party libraries. Tell the build system how to pull in and build third- # party libraries at compile time, using the ExternalProject_Add macro. ############################################################################## +# NOTE: On ExternalProject_Add calls in the next section, we pass some +# quoted values into `ExternalProject_Add`. We do this because some of these +# projects can't (or shouldn't) be built from the command line (for various +# reasons), and we need to get creative about what values we pass in to make +# sure these operations are no-ops. +# +# There are two flavors of work-around here. The first we use to avoid building +# third-party projects (like Boost) that never need to be built for Mesos. This +# looks like this: +# +# BUILD_COMMAND "" +# +# In most of the major releases of CMake, if we don't set parameters like +# `BUILD_COMMAND`, we will trigger the default behavior of that parameter; +# usually, CMake attempts to configure/build/install/etc. the third-party +# project as if it were a CMake (or perhaps make) project. Since these projects +# are not CMake projects, they will error out. This work-around lets us avoid +# that fate altogether. +# +# The second work-around allows us to build a project except on Windows. It +# looks like this: +# +# BUILD_COMMAND "${GLOG_BUILD_CMD}" +# +# The problem is that there is currently no way to build glog on Windows from +# the command line. But, if GLOG_BUILD_CMD is not set (or if it's an empty +# list), then we run into the same problem as last time; CMake sees that +# `BUILD_COMMAND` is unset, and will default to the "normal" behavior of trying +# to configure/build/install the project as if it was a CMake project. (Since +# it is not, it will of course error out on Windows.) +# +# The work-around is to add quotes to the outside of the variable. In this case, +# ${GLOG_BUILD_CMD} will expand to unset, which will cause us to pass the empty +# string as a parameter to the function. This of course is different from not +# setting the parameter value at all, and hence the work-around works. ExternalProject_Add( ${BOOST_TARGET} PREFIX ${BOOST_CMAKE_ROOT} @@ -97,11 +120,12 @@ ExternalProject_Add( ExternalProject_Add( ${GLOG_TARGET} PREFIX ${GLOG_CMAKE_ROOT} - PATCH_COMMAND ${GLOG_PATCH_CMD} - CONFIGURE_COMMAND ${GLOG_CONFIG_CMD} - BUILD_COMMAND ${GLOG_BUILD_CMD} - INSTALL_COMMAND ${GLOG_INSTALL_CMD} + PATCH_COMMAND "${GLOG_PATCH_CMD}" + CONFIGURE_COMMAND "${GLOG_CONFIG_CMD}" + BUILD_COMMAND "${GLOG_BUILD_CMD}" + INSTALL_COMMAND "${GLOG_INSTALL_CMD}" URL ${GLOG_URL} + DOWNLOAD_NAME glog-${GLOG_VERSION}.tar.gz ) ExternalProject_Add( @@ -118,17 +142,17 @@ ExternalProject_Add( ${HTTP_PARSER_TARGET} PREFIX ${HTTP_PARSER_CMAKE_ROOT} CONFIGURE_COMMAND "" - BUILD_COMMAND ${RY_BUILD_CMD} - INSTALL_COMMAND ${RY_INSTALL_CMD} + BUILD_COMMAND "${RY_BUILD_CMD}" + INSTALL_COMMAND "${RY_INSTALL_CMD}" URL ${HTTP_PARSER_URL} ) ExternalProject_Add( ${LIBEV_TARGET} PREFIX ${LIBEV_CMAKE_ROOT} - PATCH_COMMAND ${LIBEV_PATCH_CMD} - CONFIGURE_COMMAND ${LIBEV_CONFIG_CMD} - BUILD_COMMAND ${LIBEV_BUILD_CMD} + PATCH_COMMAND "${LIBEV_PATCH_CMD}" + CONFIGURE_COMMAND "${LIBEV_CONFIG_CMD}" + BUILD_COMMAND "${LIBEV_BUILD_CMD}" INSTALL_COMMAND "" URL ${LIBEV_URL} ) @@ -140,7 +164,7 @@ if (WIN32) # TODO(hausdorff): maybe try to incorporate this into findpackage for Windows ExternalProject_Add( ${CURL_TARGET} - PREFIX "${CURL_CMAKE_ROOT}" + PREFIX ${CURL_CMAKE_ROOT} PATCH_COMMAND "" CONFIGURE_COMMAND "" BUILD_COMMAND "" @@ -155,9 +179,11 @@ if (REBUNDLED) set(GMOCK_URL ${REBUNDLED_DIR}/gmock-${GMOCK_VERSION}.tar.gz) set(PROTOBUF_URL ${REBUNDLED_DIR}/protobuf-${PROTOBUF_VERSION}.tar.gz) else (REBUNDLED) - # TODO(hausdorff): depends on the github mirror, should remove when possible. + # TODO(hausdorff): (MESOS-3395) depends on the github mirror, should remove + # when possible. set(GMOCK_URL https://github.com/apache/mesos/raw/master/3rdparty/libprocess/3rdparty/gmock-${GMOCK_VERSION}.tar.gz) - # TODO(hausdorff): depends on the github mirror, should remove when possible. + # TODO(hausdorff): (MESOS-3395) depends on the github mirror, should remove + # when possible. set(PROTOBUF_URL https://github.com/hausdorff/mesos/raw/test_cmake/3rdparty/libprocess/3rdparty/protobuf-${PROTOBUF_VERSION}.tar.gz) endif (REBUNDLED) @@ -177,21 +203,25 @@ if (NOT WIN32) endif (NOT WIN32) ExternalProject_Add( + # See note about third-party libraries above to understand quirky actual + # parameters passed in here. ${GMOCK_TARGET} PREFIX ${GMOCK_CMAKE_ROOT} - CONFIGURE_COMMAND ${GMOCK_CONFIG_CMD} - BUILD_COMMAND ${GMOCK_BUILD_CMD} + CONFIGURE_COMMAND "${GMOCK_CONFIG_CMD}" + BUILD_COMMAND "${GMOCK_BUILD_CMD}" INSTALL_COMMAND "" URL ${GMOCK_URL} ) ExternalProject_Add( + # See note about third-party libraries above to understand quirky actual + # parameters passed in here. ${PROTOBUF_TARGET} PREFIX ${PROTOBUF_CMAKE_ROOT} - PATCH_COMMAND ${PROTOBUF_PATCH_CMD} - CONFIGURE_COMMAND ${PROTOBUF_CONFIG_CMD} - BUILD_COMMAND ${PROTOBUF_BUILD_CMD} - INSTALL_COMMAND ${PROTOBUF_INSTALL_CMD} + PATCH_COMMAND "${PROTOBUF_PATCH_CMD}" + CONFIGURE_COMMAND "${PROTOBUF_CONFIG_CMD}" + BUILD_COMMAND "${PROTOBUF_BUILD_CMD}" + INSTALL_COMMAND "${PROTOBUF_INSTALL_CMD}" URL ${PROTOBUF_URL} )
