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 2015/09/28 01:27:45 UTC

[06/20] mesos git commit: Added CMake macro VsBuildCommand in libprocess.

Added CMake macro VsBuildCommand in libprocess.

Original review: https://reviews.apache.org/r/37273

Review: https://reviews.apache.org/r/38539


Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/46612006
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/46612006
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/46612006

Branch: refs/heads/master
Commit: 466120068e029cec97198a9967aa78deef70d2e2
Parents: fa481e4
Author: haosdent huang <ha...@gmail.com>
Authored: Sun Sep 27 15:41:19 2015 -0700
Committer: Joris Van Remoortere <jo...@gmail.com>
Committed: Sun Sep 27 16:07:46 2015 -0700

----------------------------------------------------------------------
 3rdparty/libprocess/3rdparty/CMakeLists.txt     | 134 ++++++++++---------
 .../libprocess/cmake/macros/VsBuildCommand.bat  |  67 ++++++++++
 .../cmake/macros/VsBuildCommand.cmake           |  40 ++++++
 3 files changed, 178 insertions(+), 63 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/46612006/3rdparty/libprocess/3rdparty/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/3rdparty/CMakeLists.txt b/3rdparty/libprocess/3rdparty/CMakeLists.txt
index cb2b55e..4f439fa 100644
--- a/3rdparty/libprocess/3rdparty/CMakeLists.txt
+++ b/3rdparty/libprocess/3rdparty/CMakeLists.txt
@@ -103,62 +103,44 @@ if (NOT WIN32)
   set(LIBEV_INSTALL_CMD mkdir -p ${LIBEV_ROOT}-lib/lib && cp -r ${LIBEV_ROOT}-build/.libs/. ${LIBEV_ROOT}-lib/lib)
   # Patch libev to keep it from reaping child processes.
   PATCH_CMD(${PROCESS_3RD_SRC}/libev-4.15.patch LIBEV_PATCH_CMD)
+elseif (WIN32)
+  set(GLOG_PATCH_CMD   ${CMAKE_NOOP})
+  set(GLOG_CONFIG_CMD  ${CMAKE_NOOP})
+  set(GLOG_INSTALL_CMD ${CMAKE_NOOP})
+  VS_BUILD_CMD(
+      GLOG
+      ${GLOG_ROOT}/google-glog.sln
+      ${CMAKE_BUILD_TYPE}
+      "libglog")
+
+  set(RY_BUILD_CMD   ${CMAKE_NOOP})
+  set(RY_INSTALL_CMD ${CMAKE_NOOP})
+
+  set(LIBEV_PATCH_CMD    ${CMAKE_NOOP})
+  set(LIBEV_CONFIG_CMD   ${CMAKE_NOOP})
+  set(LIBEV_BUILD_CMD    ${CMAKE_NOOP})
+  set(LIBEV_INSTALL_CMD  ${CMAKE_NOOP})
 endif (NOT WIN32)
 
 # 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}
-  CONFIGURE_COMMAND ""
-  BUILD_COMMAND     ""
-  INSTALL_COMMAND   ""
+  CONFIGURE_COMMAND ${CMAKE_NOOP}
+  BUILD_COMMAND     ${CMAKE_NOOP}
+  INSTALL_COMMAND   ${CMAKE_NOOP}
   URL               ${BOOST_URL}
   )
 
 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
   )
@@ -166,28 +148,28 @@ ExternalProject_Add(
 ExternalProject_Add(
   ${PICOJSON_TARGET}
   PREFIX            ${PICOJSON_CMAKE_ROOT}
-  CONFIGURE_COMMAND ""
-  BUILD_COMMAND     ""
-  INSTALL_COMMAND   ""
+  CONFIGURE_COMMAND ${CMAKE_NOOP}
+  BUILD_COMMAND     ${CMAKE_NOOP}
+  INSTALL_COMMAND   ${CMAKE_NOOP}
   URL               ${PICOJSON_URL}
   )
 
 ExternalProject_Add(
   ${HTTP_PARSER_TARGET}
   PREFIX            ${HTTP_PARSER_CMAKE_ROOT}
-  CONFIGURE_COMMAND ""
-  BUILD_COMMAND     "${RY_BUILD_CMD}"
-  INSTALL_COMMAND   "${RY_INSTALL_CMD}"
+  CONFIGURE_COMMAND ${CMAKE_NOOP}
+  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}"
-  INSTALL_COMMAND   "${LIBEV_INSTALL_CMD}"
+  PATCH_COMMAND     ${LIBEV_PATCH_CMD}
+  CONFIGURE_COMMAND ${LIBEV_CONFIG_CMD}
+  BUILD_COMMAND     ${LIBEV_BUILD_CMD}
+  INSTALL_COMMAND   ${LIBEV_INSTALL_CMD}
   URL               ${LIBEV_URL}
   )
 
@@ -199,10 +181,10 @@ if (WIN32)
   ExternalProject_Add(
     ${CURL_TARGET}
     PREFIX            ${CURL_CMAKE_ROOT}
-    PATCH_COMMAND     ""
-    CONFIGURE_COMMAND ""
-    BUILD_COMMAND     ""
-    INSTALL_COMMAND   ""
+    PATCH_COMMAND     ${CMAKE_NOOP}
+    CONFIGURE_COMMAND ${CMAKE_NOOP}
+    BUILD_COMMAND     ${CMAKE_NOOP}
+    INSTALL_COMMAND   ${CMAKE_NOOP}
     URL               ${CURL_URL}
   )
 endif (WIN32)
@@ -217,6 +199,14 @@ else (REBUNDLED)
   set(PROTOBUF_URL ${UPSTREAM_URL}/protobuf-${PROTOBUF_VERSION}.tar.gz)
 endif (REBUNDLED)
 
+if (WIN32)
+  # TODO(hausdorff): (MESOS-3453) this is a patched version of the protobuf
+  # library that compiles on Windows. We need to either send this as a PR back
+  # to the protobuf project, or we need to apply these changes to our existing
+  # protobuf tarball in the patch step.
+  set(PROTOBUF_URL https://github.com/haosdent/3rdparty-packages/raw/master/protobuf-${PROTOBUF_VERSION}.tar.gz)
+endif (WIN32)
+
 # NOTE: `gmock` is "installed" into a lib directory, see "NOTE: (fix for
 # MESOS-3250)" comment above for explanation.
 if (APPLE)
@@ -228,12 +218,30 @@ elseif (NOT WIN32)
   set(GMOCK_CONFIG_CMD  ${GMOCK_ROOT}/configure --prefix=${GMOCK_ROOT}-lib)
   set(GMOCK_BUILD_CMD   make)
   set(GMOCK_INSTALL_CMD mkdir -p ${GMOCK_ROOT}-lib/lib && cp -r ${GMOCK_ROOT}-build/lib/.libs/. ${GMOCK_ROOT}-lib/lib && cp -r ${GMOCK_ROOT}-build/gtest/lib/.libs/. ${GMOCK_ROOT}-lib/lib)
+elseif (WIN32)
+  set(GMOCK_CONFIG_CMD ${CMAKE_NOOP})
+  VS_BUILD_CMD(
+      GMOCK
+      ${GMOCK_ROOT}/msvc/2010/gmock.sln
+      ${CMAKE_BUILD_TYPE}
+      "gmock gmock_main")
+  set(GMOCK_INSTALL_CMD ${CMAKE_NOOP})
 endif (APPLE)
 
 if (NOT WIN32)
+  set(PROTOBUF_PATCH_CMD   ${CMAKE_NOOP})
   set(PROTOBUF_CONFIG_CMD  ${PROTOBUF_ROOT}/src/../configure --prefix=${PROTOBUF_LIB})
   set(PROTOBUF_BUILD_CMD   make)
   set(PROTOBUF_INSTALL_CMD make install)
+elseif (WIN32)
+  set(PROTOBUF_PATCH_CMD   ${CMAKE_NOOP})
+  set(PROTOBUF_CONFIG_CMD  ${CMAKE_NOOP})
+  set(PROTOBUF_INSTALL_CMD ${CMAKE_NOOP})
+  VS_BUILD_CMD(
+      PROTOBUF
+      ${PROTOBUF_ROOT}/vsprojects/protobuf.sln
+      ${CMAKE_BUILD_TYPE}
+      "libprotobuf libprotoc protoc")
 endif (NOT WIN32)
 
 ExternalProject_Add(
@@ -241,9 +249,9 @@ ExternalProject_Add(
   # parameters passed in here.
   ${GMOCK_TARGET}
   PREFIX            ${GMOCK_CMAKE_ROOT}
-  CONFIGURE_COMMAND "${GMOCK_CONFIG_CMD}"
-  BUILD_COMMAND     "${GMOCK_BUILD_CMD}"
-  INSTALL_COMMAND   "${GMOCK_INSTALL_CMD}"
+  CONFIGURE_COMMAND ${GMOCK_CONFIG_CMD}
+  BUILD_COMMAND     ${GMOCK_BUILD_CMD}
+  INSTALL_COMMAND   ${GMOCK_INSTALL_CMD}
   URL               ${GMOCK_URL}
   )
 
@@ -252,10 +260,10 @@ ExternalProject_Add(
   # 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}
   )
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/46612006/3rdparty/libprocess/cmake/macros/VsBuildCommand.bat
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/cmake/macros/VsBuildCommand.bat b/3rdparty/libprocess/cmake/macros/VsBuildCommand.bat
new file mode 100644
index 0000000..8da05bc
--- /dev/null
+++ b/3rdparty/libprocess/cmake/macros/VsBuildCommand.bat
@@ -0,0 +1,67 @@
+:: 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.
+
+@echo off
+
+:: Parse command line params.
+for /f "tokens=1-2*" %%A in ("%*") do (
+  set SOLUTION_FILE=%%A
+  set CONFIGURATION=%%B
+  set PROJECTS=%%C
+)
+
+set PLATFORM=Win32
+setlocal EnableDelayedExpansion
+setlocal EnableExtensions
+
+:: Get Visual Studio 2015 install directory.
+set VS2015_KEY=HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\VisualStudio\14.0
+set VS2015_INSTALLDIR_VALUE=InstallDir
+
+for /F "skip=2 tokens=1,2*" %%A ^
+in ('REG QUERY %VS2015_KEY% /v %VS2015_INSTALLDIR_VALUE% 2^>nul') do (
+  set VS2015_DIR=%%C..\..
+)
+
+:: Check if Visual Studio 2015 is installed.
+if defined VS2015_DIR (
+  set SOLUTION_VER=12.00
+  :: Prepare Visual Studio 2015 command line environment.
+  call "%VS2015_DIR%\VC\vcvarsall.bat" x86
+) else (
+  echo "No compiler : Microsoft Visual Studio (2015) is not installed."
+  exit /b 1
+)
+
+FINDSTR ^
+    /C:"Microsoft Visual Studio Solution File, Format Version %SOLUTION_VER%" ^
+    %SOLUTION_FILE:/=\%
+if %errorlevel% neq 0 (
+  :: Upgrade solution file if its version does not match current %SOLUTION_VER%.
+  echo "Upgrading Visual Studio Solution File: %SOLUTION_FILE% ."
+  devenv /upgrade %SOLUTION_FILE%
+)
+
+if not "%PROJECTS%" == "" (
+  set PROJECTS_TARGET=/t:%PROJECTS: =;%
+)
+
+msbuild ^
+    %SOLUTION_FILE% %PROJECTS_TARGET% ^
+    /p:Configuration=%CONFIGURATION%;Platform=%PLATFORM%
+
+:end
+exit /b
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/mesos/blob/46612006/3rdparty/libprocess/cmake/macros/VsBuildCommand.cmake
----------------------------------------------------------------------
diff --git a/3rdparty/libprocess/cmake/macros/VsBuildCommand.cmake b/3rdparty/libprocess/cmake/macros/VsBuildCommand.cmake
new file mode 100644
index 0000000..632696e
--- /dev/null
+++ b/3rdparty/libprocess/cmake/macros/VsBuildCommand.cmake
@@ -0,0 +1,40 @@
+# 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.
+
+##############################################################
+# VS_BUILD_CMD generates a build command for project which have Visual Studio
+# Solution File(.sln). For example, when we want to build GLOG through Visual
+# Studio in command line, we would run this command. It would define
+# ${LIB_NAME_UPPER}_BUILD_CMD with build command finally.
+function(VS_BUILD_CMD LIB_NAME SOLUTION_FILE BUILD_CONFIGURATION PROJECTS)
+
+  string(TOUPPER ${LIB_NAME} LIB_NAME_UPPER)
+
+  set(VS_BUILD_SCRIPT
+    ${CMAKE_SOURCE_DIR}/3rdparty/libprocess/cmake/macros/VsBuildCommand.bat)
+  set(BUILD_CMD_VAR ${LIB_NAME_UPPER}_BUILD_CMD)
+
+  # Generate the build command with ${VS_BUILD_SCRIPT}.
+  ## 1. Convert the path to Windows style.
+  file(
+    TO_NATIVE_PATH
+    "${VS_BUILD_SCRIPT} ${SOLUTION_FILE} ${BUILD_CONFIGURATION} ${PROJECTS}"
+    BUILD_CMD_STRING)
+  ## 2. Convert the command to list so that CMake could handle it correctly.
+  string(REPLACE " " ";" BUILD_CMD ${BUILD_CMD_STRING})
+
+  set(${BUILD_CMD_VAR} ${BUILD_CMD} PARENT_SCOPE)
+endfunction()
\ No newline at end of file