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 2017/09/03 12:51:27 UTC

[05/42] mesos git commit: CMake: Added `stout` interface library.

CMake: Added `stout` interface library.

CMake provides a mechanism for dealing with header only libraries such
as stout: an interface library.  Thus CMake will treat stout as a
"library" and automatically add the necessary compiler and link
information to targets which depend on stout.

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


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

Branch: refs/heads/master
Commit: 3b9658a63aa948487f6a08e7bfdb90918f3648c5
Parents: 85bc581
Author: Andrew Schwartzmeyer <an...@schwartzmeyer.com>
Authored: Mon Aug 7 16:58:50 2017 -0700
Committer: Joseph Wu <jo...@apache.org>
Committed: Sun Sep 3 05:51:05 2017 -0700

----------------------------------------------------------------------
 3rdparty/stout/CMakeLists.txt                  | 36 +++++++++++++++++++
 3rdparty/stout/cmake/StoutConfigure.cmake      |  7 +---
 3rdparty/stout/cmake/StoutTestsConfigure.cmake |  8 -----
 3rdparty/stout/tests/CMakeLists.txt            | 39 +++++++++------------
 4 files changed, 53 insertions(+), 37 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/mesos/blob/3b9658a6/3rdparty/stout/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/3rdparty/stout/CMakeLists.txt b/3rdparty/stout/CMakeLists.txt
new file mode 100644
index 0000000..9fcde58
--- /dev/null
+++ b/3rdparty/stout/CMakeLists.txt
@@ -0,0 +1,36 @@
+# 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.
+
+include(StoutConfigure)
+
+# TODO(andschwa): Remove this when all libraries are fully qualified.
+link_directories(${STOUT_LIB_DIRS})
+
+# THE STOUT LIBRARY INTERFACE
+#############################
+add_library(stout INTERFACE)
+
+# TODO(andschwa): Remove this when all dependencies have top-level targets.
+add_dependencies(stout ${STOUT_DEPENDENCIES})
+
+target_include_directories(stout INTERFACE
+  include/
+  ${STOUT_3RDPARTY_INCLUDE_DIRS})
+
+target_link_libraries(stout INTERFACE
+  ${STOUT_LIBS})
+
+add_subdirectory(tests)

http://git-wip-us.apache.org/repos/asf/mesos/blob/3b9658a6/3rdparty/stout/cmake/StoutConfigure.cmake
----------------------------------------------------------------------
diff --git a/3rdparty/stout/cmake/StoutConfigure.cmake b/3rdparty/stout/cmake/StoutConfigure.cmake
index 69474a8..48b153a 100644
--- a/3rdparty/stout/cmake/StoutConfigure.cmake
+++ b/3rdparty/stout/cmake/StoutConfigure.cmake
@@ -47,7 +47,7 @@ macro(GROUP_STOUT_HEADERS)
     "*.h*")
 endmacro()
 
-# DEFINE PROCESS LIBRARY DEPENDENCIES. Tells the process library build targets
+# DEFINE STOUT LIBRARY DEPENDENCIES. Tells the stout library build targets
 # download/configure/build all third-party libraries before attempting to build.
 ################################################################################
 set(STOUT_DEPENDENCIES
@@ -91,11 +91,6 @@ if (WIN32)
     )
 endif ()
 
-set(STOUT_INCLUDE_DIRS
-  ${STOUT_INCLUDE_DIRS}
-  ${STOUT_INCLUDE_DIR}
-  )
-
 # DEFINE THIRD-PARTY LIB INSTALL DIRECTORIES. Used to tell the compiler
 # toolchain where to find our third party libs (e.g., -L/path/to/glog on
 # Linux).

http://git-wip-us.apache.org/repos/asf/mesos/blob/3b9658a6/3rdparty/stout/cmake/StoutTestsConfigure.cmake
----------------------------------------------------------------------
diff --git a/3rdparty/stout/cmake/StoutTestsConfigure.cmake b/3rdparty/stout/cmake/StoutTestsConfigure.cmake
index 43baaca..b6e9902 100644
--- a/3rdparty/stout/cmake/StoutTestsConfigure.cmake
+++ b/3rdparty/stout/cmake/StoutTestsConfigure.cmake
@@ -31,10 +31,6 @@
 #     for the core dependencies (e.g., where to find the .so/.dll files) without
 #     having to also export the variables for test-only dependencies.
 
-set(
-  STOUT_TESTS_TARGET stout-tests
-  CACHE STRING "Target we use to refer to tests for the stout library")
-
 # COMPILER CONFIGURATION.
 #########################
 EXTERNAL("googletest" ${GOOGLETEST_VERSION} "${MESOS_3RDPARTY_BIN}")
@@ -62,7 +58,6 @@ set(GTEST_LFLAG gtest)
 ################################################################################
 set(STOUT_TEST_DEPENDENCIES
   ${STOUT_TEST_DEPENDENCIES}
-  ${STOUT_DEPENDENCIES}
   ${GOOGLETEST_TARGET}
   )
 
@@ -71,7 +66,6 @@ set(STOUT_TEST_DEPENDENCIES
 ###############################################################################
 set(STOUT_TEST_3RDPARTY_INCLUDE_DIRS
   ${STOUT_TEST_3RDPARTY_INCLUDE_DIRS}
-  ${STOUT_3RDPARTY_INCLUDE_DIRS}
   ${GMOCK_INCLUDE_DIR}
   ${GTEST_INCLUDE_DIR}
   )
@@ -82,7 +76,6 @@ set(STOUT_TEST_3RDPARTY_INCLUDE_DIRS
 ########################################################################
 set(STOUT_TEST_LIB_DIRS
   ${STOUT_TEST_LIB_DIRS}
-  ${STOUT_LIB_DIRS}
   ${GMOCK_LIB_DIR}
   ${GTEST_LIB_DIR}
   )
@@ -92,7 +85,6 @@ set(STOUT_TEST_LIB_DIRS
 #########################################################################
 set(STOUT_TEST_LIBS
   ${STOUT_TEST_LIBS}
-  ${STOUT_LIBS}
   ${GMOCK_LFLAG}
   )
 

http://git-wip-us.apache.org/repos/asf/mesos/blob/3b9658a6/3rdparty/stout/tests/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/3rdparty/stout/tests/CMakeLists.txt b/3rdparty/stout/tests/CMakeLists.txt
index 953be64..74b8758 100644
--- a/3rdparty/stout/tests/CMakeLists.txt
+++ b/3rdparty/stout/tests/CMakeLists.txt
@@ -14,6 +14,9 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+# TODO(andschwa): Remove this when gmock and gtest can be included.
+include(StoutTestsConfigure)
+
 # STOUT TESTS.
 ##############
 set(STOUT_ROOT_TESTS_SRC
@@ -95,18 +98,6 @@ set(STOUT_TESTS_SRC
   ${STOUT_OS_TESTS_SRC}
   )
 
-# INCLUDE DIRECTIVES FOR STOUT TEST BINARY (generates, e.g., -I/path/to/thing
-# on Linux).
-#############################################################################
-include_directories(SYSTEM ${STOUT_TEST_3RDPARTY_INCLUDE_DIRS})
-include_directories(${STOUT_INCLUDE_DIRS})
-include_directories(${CMAKE_CURRENT_BINARY_DIR})
-
-# LINKING LIBRARIES BY DIRECTORY (might generate, e.g., -L/path/to/thing on
-# Linux).
-###########################################################################
-link_directories(${STOUT_TEST_LIB_DIRS})
-
 # THE C++ PROTOCOL BUFFER CODE (protobuf_tests.pb.h and protobuf_tests.pb.cc).
 ##############################################################################
 add_custom_command(
@@ -117,10 +108,6 @@ add_custom_command(
     ${CMAKE_SOURCE_DIR}/3rdparty/stout/tests/protobuf_tests.proto
   DEPENDS ${CMAKE_SOURCE_DIR}/3rdparty/stout/tests/protobuf_tests.proto)
 
-# THE STOUT TEST EXECUTABLE (generates, e.g., stout-tests, etc., on Linux).
-###########################################################################
-add_executable(${STOUT_TESTS_TARGET} EXCLUDE_FROM_ALL ${STOUT_TESTS_SRC})
-
 GROUP_STOUT_HEADERS()
 
 GROUP_SOURCE(
@@ -129,14 +116,20 @@ GROUP_SOURCE(
   "${CMAKE_CURRENT_SOURCE_DIR}"
   "*.[ch]*")
 
-# ADD LINKER FLAGS (generates, e.g., -lglog on Linux).
-######################################################
-target_link_libraries(${STOUT_TESTS_TARGET} ${STOUT_TEST_LIBS})
+# TODO(andschwa): Remove when gmock and gtest are top-level targets.
+link_directories(${STOUT_TEST_LIB_DIRS})
+
+add_executable(stout-tests EXCLUDE_FROM_ALL ${STOUT_TESTS_SRC})
+
+# TODO(andschwa): Remove when gmock and gtest are top-level targets.
+add_dependencies(stout-tests ${STOUT_TEST_DEPENDENCIES})
+target_include_directories(stout-tests PRIVATE
+  ${CMAKE_CURRENT_BINARY_DIR}
+  ${STOUT_TEST_3RDPARTY_INCLUDE_DIRS})
 
-# ADD BINARY DEPENDENCIES (tells CMake what to compile/build first).
-####################################################################
-add_dependencies(${STOUT_TESTS_TARGET} ${STOUT_TEST_DEPENDENCIES})
+# TODO(andschwa): Link to gmock and gtest explicitly.
+target_link_libraries(stout-tests stout ${STOUT_TEST_LIBS})
 
 # ADD TEST TARGET (runs when you do, e.g., `make check`).
 #########################################################
-add_test(NAME StoutTests COMMAND ${STOUT_TESTS_TARGET})
+add_test(NAME StoutTests COMMAND stout-tests)