You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mesos.apache.org by an...@apache.org on 2018/03/19 20:20:46 UTC

[8/9] mesos git commit: Windows: Set 3rdparty libraries to link to CRT dynamically.

Windows: Set 3rdparty libraries to link to CRT dynamically.

This also fixes a bug where the `libevent` build on Windows would add
`''` to the compiler flags, which is an unrecognized flag, and sets
the names of our `CMAKE_FORWARD_ARGS` variables consistently (some
were missing the `FORWARD` part).

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


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

Branch: refs/heads/master
Commit: 5915f8f19a70b895742288f852afc45fc178e9aa
Parents: b9abc38
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Fri Mar 9 11:57:21 2018 -0800
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Mon Mar 19 12:34:57 2018 -0700

----------------------------------------------------------------------
 3rdparty/CMakeLists.txt | 28 +++++++++++++++++++---------
 1 file changed, 19 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/5915f8f1/3rdparty/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt
index 0436c59..06f8aa0 100644
--- a/3rdparty/CMakeLists.txt
+++ b/3rdparty/CMakeLists.txt
@@ -504,18 +504,21 @@ if (ENABLE_LIBEVENT)
       IMPORTED_LOCATION ${LIBEVENT_ROOT}-build/lib/libevent${LIBRARY_SUFFIX})
   endif ()
 
-  set(LIBEVENT_CMAKE_ARGS
+  set(LIBEVENT_CMAKE_FORWARD_ARGS
     ${CMAKE_FORWARD_ARGS}
     ${CMAKE_SSL_FORWARD_ARGS}
     # NOTE: Libevent does not respect the BUILD_SHARED_LIBS global flag.
     -DEVENT__BUILD_SHARED_LIBRARIES=${BUILD_SHARED_LIBS}
     -DEVENT__DISABLE_OPENSSL=$<NOT:$<BOOL:${ENABLE_SSL}>>
-    -DCMAKE_C_FLAGS=$<IF:$<PLATFORM_ID:Windows>,"",-fPIC>
     -DEVENT__DISABLE_BENCHMARK=ON
     -DEVENT__DISABLE_REGRESS=ON
     -DEVENT__DISABLE_SAMPLES=ON
     -DEVENT__DISABLE_TESTS=ON)
 
+  if (CMAKE_C_COMPILER_ID MATCHES GNU OR CMAKE_C_COMPILER_ID MATCHES Clang)
+    list(APPEND LIBEVENT_CMAKE_FORWARD_ARGS -DCMAKE_C_FLAGS=-fPIC)
+  endif ()
+
   MAKE_INCLUDE_DIR(libevent)
   GET_BYPRODUCTS(libevent)
 
@@ -523,7 +526,7 @@ if (ENABLE_LIBEVENT)
     ${LIBEVENT_TARGET}
     PREFIX            ${LIBEVENT_CMAKE_ROOT}
     BUILD_BYPRODUCTS  ${LIBEVENT_BYPRODUCTS}
-    CMAKE_ARGS        ${LIBEVENT_CMAKE_ARGS}
+    CMAKE_ARGS        ${LIBEVENT_CMAKE_FORWARD_ARGS}
     INSTALL_COMMAND   ${CMAKE_NOOP}
     URL               ${LIBEVENT_URL}
     URL_HASH          ${LIBEVENT_HASH})
@@ -643,7 +646,7 @@ if (WIN32)
   # `add_dependencies` creates a cycle.
   add_executable(curl IMPORTED GLOBAL)
 
-  set(CURL_CMAKE_ARGS
+  set(CURL_CMAKE_FORWARD_ARGS
     ${CMAKE_FORWARD_ARGS}
     -DCMAKE_USE_WINSSL=ON
     -DCURL_DISABLE_LDAP=ON
@@ -652,7 +655,7 @@ if (WIN32)
   # NOTE: cURL does not respect BUILD_SHARED_LIBS.
   if (NOT BUILD_SHARED_LIBS)
     # This is both a CMake argument and a pre-processor definition.
-    list(APPEND CURL_CMAKE_ARGS -DCURL_STATICLIB=ON)
+    list(APPEND CURL_CMAKE_FORWARD_ARGS -DCURL_STATICLIB=ON)
 
     set_target_properties(
       libcurl PROPERTIES
@@ -698,7 +701,7 @@ if (WIN32)
     PREFIX            ${CURL_CMAKE_ROOT}
     BUILD_BYPRODUCTS  ${LIBCURL_BYPRODUCTS};${CURL_BYPRODUCTS}
     PATCH_COMMAND     ${CMAKE_NOOP}
-    CMAKE_ARGS        ${CURL_CMAKE_ARGS}
+    CMAKE_ARGS        ${CURL_CMAKE_FORWARD_ARGS}
     INSTALL_COMMAND   ${CMAKE_NOOP}
     URL               ${CURL_URL}
     URL_HASH          ${CURL_HASH})
@@ -855,9 +858,9 @@ GET_BYPRODUCTS(gtest)
 # Unconditionally build static libraries.
 list(APPEND GOOGLETEST_CMAKE_FORWARD_ARGS -DBUILD_SHARED_LIBS=OFF)
 
-# Link to the correct CRT based on other libraries' linkage.
+# But also link to the CRT dynamically.
 list(APPEND GOOGLETEST_CMAKE_FORWARD_ARGS
-  -Dgtest_force_shared_crt=${BUILD_SHARED_LIBS})
+  -Dgtest_force_shared_crt=ON)
 
 ExternalProject_Add(
   ${GOOGLETEST_TARGET}
@@ -885,9 +888,16 @@ set_target_properties(
   protobuf PROPERTIES
   INTERFACE_INCLUDE_DIRECTORIES ${PROTOBUF_ROOT}/src)
 
+set(PROTOBUF_CMAKE_FORWARD_ARGS ${CMAKE_FORWARD_ARGS}
+  -Dprotobuf_BUILD_TESTS=OFF)
+
 if (WIN32)
   PATCH_CMD(PROTOBUF_PATCH_CMD protobuf-${PROTOBUF_VERSION}.patch)
 
+  # Link to the CRT dynamically.
+  list(APPEND PROTOBUF_CMAKE_FORWARD_ARGS
+    -Dprotobuf_MSVC_STATIC_RUNTIME=OFF)
+
   if (CMAKE_GENERATOR MATCHES "Visual Studio")
     set_target_properties(
       protobuf PROPERTIES
@@ -932,7 +942,7 @@ ExternalProject_Add(
   PATCH_COMMAND     ${PROTOBUF_PATCH_CMD}
   BUILD_BYPRODUCTS  ${PROTOBUF_BYPRODUCTS}
   SOURCE_SUBDIR     cmake
-  CMAKE_ARGS        ${CMAKE_FORWARD_ARGS};-Dprotobuf_BUILD_TESTS=OFF
+  CMAKE_ARGS        ${PROTOBUF_CMAKE_FORWARD_ARGS}
   INSTALL_COMMAND   ${CMAKE_NOOP}
   URL               ${PROTOBUF_URL}
   URL_HASH          ${PROTOBUF_HASH})