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 2017/12/06 01:33:40 UTC
[2/4] mesos git commit: Set `BUILD_FLAGS` flag in CMake.
Set `BUILD_FLAGS` flag in CMake.
This resolves MESOS-5455, and consolidates the `BUILD` variables into
one location.
Review: https://reviews.apache.org/r/63341
Project: http://git-wip-us.apache.org/repos/asf/mesos/repo
Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/57d58621
Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/57d58621
Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/57d58621
Branch: refs/heads/master
Commit: 57d5862164ebc2c69aa9deba9283d723d49656bf
Parents: a994331
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Thu Oct 26 12:26:11 2017 -0700
Committer: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Committed: Tue Dec 5 17:32:18 2017 -0800
----------------------------------------------------------------------
cmake/CompilationConfigure.cmake | 18 ++++++++++++++++--
src/CMakeLists.txt | 15 +++------------
src/common/build.cpp | 5 +++++
src/common/build_config.hpp.in | 5 +++++
4 files changed, 29 insertions(+), 14 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/mesos/blob/57d58621/cmake/CompilationConfigure.cmake
----------------------------------------------------------------------
diff --git a/cmake/CompilationConfigure.cmake b/cmake/CompilationConfigure.cmake
index deb5742..854e3c9 100644
--- a/cmake/CompilationConfigure.cmake
+++ b/cmake/CompilationConfigure.cmake
@@ -363,11 +363,25 @@ endif ()
string(TIMESTAMP BUILD_DATE "%Y-%m-%d %H:%M:%S UTC" UTC)
string(TIMESTAMP BUILD_TIME "%s" UTC)
if (WIN32)
- set(BUILD_USER "$ENV{USERNAME}")
+ set(BUILD_USER $ENV{USERNAME})
else ()
- set(BUILD_USER "$ENV{USER}")
+ set(BUILD_USER $ENV{USER})
endif ()
+# NOTE: This is not quite the same as the Autotools build, as most definitions,
+# include directories, etc. are embedded as target properties within the CMake
+# graph. However, this is simply a "helper" variable anyway, so providing the
+# "global" compile definitions (at least, those of this directory), is close
+# enough to the intent.
+#
+# This code sets the variable `BUILD_FLAGS_RAW` to the content of the
+# directory's `COMPILE_DEFINITIONS` property. The backslashes are then escaped
+# and the final string is saved into the `BUILD_FLAGS` variable.
+get_directory_property(BUILD_FLAGS_RAW COMPILE_DEFINITIONS)
+string(REPLACE "\"" "\\\"" BUILD_FLAGS "${BUILD_FLAGS_RAW}")
+
+set(BUILD_JAVA_JVM_LIBRARY ${JAVA_JVM_LIBRARY})
+
# When building from source, from a git clone, emit some extra build info.
if (IS_DIRECTORY "${CMAKE_SOURCE_DIR}/.git")
execute_process(
http://git-wip-us.apache.org/repos/asf/mesos/blob/57d58621/src/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 8da64e8..35a602d 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -470,8 +470,8 @@ if (WIN32)
endif ()
-# THE MESOS LIBRARY (generates, e.g., libmesos.so on Linux).
-############################################################
+# THE MESOS LIBRARY
+###################
add_library(mesos ${MESOS_SRC})
set_target_properties(
@@ -479,16 +479,7 @@ set_target_properties(
VERSION ${MESOS_PACKAGE_VERSION}
SOVERSION ${MESOS_PACKAGE_SOVERSION})
-# NOTE: The quotes in these definitions are necessary. Without them, the
-# preprocessor will interpret the symbols as (e.g.) int literals and unquoted
-# identifiers, rather than the string values our code expects.
-target_compile_definitions(
- mesos PUBLIC
- USE_CMAKE_BUILD_CONFIG
- BUILD_JAVA_JVM_LIBRARY="${JAVA_JVM_LIBRARY}"
-
- # TODO(andschwa): (MESOS-5455) `BUILD_FLAGS` is currently a placeholder value.
- BUILD_FLAGS="")
+target_compile_definitions(mesos PUBLIC USE_CMAKE_BUILD_CONFIG)
target_include_directories(
mesos PUBLIC
http://git-wip-us.apache.org/repos/asf/mesos/blob/57d58621/src/common/build.cpp
----------------------------------------------------------------------
diff --git a/src/common/build.cpp b/src/common/build.cpp
index 4192b89..f5271d8 100644
--- a/src/common/build.cpp
+++ b/src/common/build.cpp
@@ -48,7 +48,12 @@ const string USER = "";
#endif
const string FLAGS = BUILD_FLAGS;
+
+#ifdef BUILD_JAVA_JVM_LIBRARY
const string JAVA_JVM_LIBRARY = BUILD_JAVA_JVM_LIBRARY;
+#else
+const string JAVA_JVM_LIBRARY = "";
+#endif
#ifdef BUILD_GIT_SHA
const Option<string> GIT_SHA = string(BUILD_GIT_SHA);
http://git-wip-us.apache.org/repos/asf/mesos/blob/57d58621/src/common/build_config.hpp.in
----------------------------------------------------------------------
diff --git a/src/common/build_config.hpp.in b/src/common/build_config.hpp.in
index ac7059a..4cce240 100644
--- a/src/common/build_config.hpp.in
+++ b/src/common/build_config.hpp.in
@@ -17,9 +17,14 @@
#ifndef __COMMON_BUILD_CONFIG_HPP__
#define __COMMON_BUILD_CONFIG_HPP__
+// NOTE: The quotes in these definitions are necessary. Without them, the
+// preprocessor will interpret the symbols as (e.g.) int literals and unquoted
+// identifiers, rather than the string values our code expects.
#cmakedefine BUILD_DATE "@BUILD_DATE@"
#cmakedefine BUILD_TIME "@BUILD_TIME@"
#cmakedefine BUILD_USER "@BUILD_USER@"
+#cmakedefine BUILD_FLAGS "@BUILD_FLAGS@"
+#cmakedefine BUILD_JAVA_JVM_LIBRARY "@BUILD_JAVA_JVM_LIBRARY@"
#cmakedefine BUILD_GIT_SHA "@BUILD_GIT_SHA@"
#cmakedefine BUILD_GIT_BRANCH "@BUILD_GIT_BRANCH@"