Repository: mesos Updated Branches: refs/heads/master 34c6400f8 -> f0ee4aa3d
Add CMake logic for building the Stout tests. This project is the first of two commits that will add support for building and running the Stout tests, using CMake. NOTE: This commit will be "wired up" into the Mesos project in the second commit. It is so split because of our strict requirements that the Stout source history remain separated from the rest of the Mesos project history, and it is not allowed to commit both these things at the same time. More particularly, this commit will introduce the core CMake logic for actually building the Stout tests from source, as well as the logic for finding a couple dependencies we expect to be on the system already (particularly SVN and APR). Review: https://reviews.apache.org/r/36689 Project: http://git-wip-us.apache.org/repos/asf/mesos/repo Commit: http://git-wip-us.apache.org/repos/asf/mesos/commit/8017e734 Tree: http://git-wip-us.apache.org/repos/asf/mesos/tree/8017e734 Diff: http://git-wip-us.apache.org/repos/asf/mesos/diff/8017e734 Branch: refs/heads/master Commit: 8017e734bd15411b4b9e09c5ec3f0e6d45186616 Parents: 34c6400 Author: Alex Clemmer <[email protected]> Authored: Thu Jul 23 09:21:05 2015 -0700 Committer: Benjamin Hindman <[email protected]> Committed: Thu Jul 23 09:21:05 2015 -0700 ---------------------------------------------------------------------- .../3rdparty/stout/cmake/FindApr.cmake | 195 +++++++++++++++++++ .../3rdparty/stout/cmake/FindSvn.cmake | 124 ++++++++++++ .../stout/cmake/StoutTestsConfigure.cmake | 93 +++++++++ .../3rdparty/stout/tests/CMakeLists.txt | 86 ++++++++ 4 files changed, 498 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/mesos/blob/8017e734/3rdparty/libprocess/3rdparty/stout/cmake/FindApr.cmake ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/cmake/FindApr.cmake b/3rdparty/libprocess/3rdparty/stout/cmake/FindApr.cmake new file mode 100644 index 0000000..4b28aa1 --- /dev/null +++ b/3rdparty/libprocess/3rdparty/stout/cmake/FindApr.cmake @@ -0,0 +1,195 @@ +# 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. + +############################################################### +# IMPORTANT NOTE: I (hausdorff) have copied a *lot* of stuff in this file from +# code I found at in the Akumuli[1] project. The original version +# of this file was also released under the Apache 2.0 license, and +# licensed to the ASF, making it fully compatible with the Mesos +# project. +# [1] https://github.com/akumuli/Akumuli/blob/master/cmake/FindAPR.cmake + +# This module helps to find the Apache Portable Runtime (APR) and APR-Util +# packages. +# +# USAGE: to use this module, add the following line to your CMake project: +# find_package(Apr) +# +# To make linking to APR simple, this module defines: +# * APR_FOUND and APRUTIL_FOUND (if false, linking build will fail) +# * APR_INCLUDE_DIR and APRUTIL_INCLUDE_DIR (defineswhere to find apr.h, etc.) +# * APR_LIBS and APRUTIL_LIBS (binaries for APR and friends) +# +# Also defined, but not for general use are: +# * APR_LIB and APRUTIL_LIB (where to find the APR library) + +# CONFIGURE THE APR SEARCH. Specify what we're looking for, and which directories +# we're going to look through to find them. +############################################################################# +set(POSSIBLE_APR_INCLUDE_DIRS + ${POSSIBLE_APR_INCLUDE_DIRS} + /opt/homebrew/opt/apr/include/apr-1 + /usr/local/include/apr-1 + /usr/local/include/apr-1.0 + /usr/include/apr-1 + /usr/include/apr-1.0 + /usr/local/apr/include/apr-1 + ) + +set(APR_LIB_NAMES ${APR_LIB_NAMES} apr-1) + +set(POSSIBLE_APR_LIB_DIRS + ${POSSIBLE_APR_LIB_DIRS} + /usr/lib + /usr/local/lib + /usr/local/apr/lib + /opt/homebrew/opt/apr/lib + ) + +# SEARCH FOR APR LIBRARIES. +########################### +find_path(APR_INCLUDE_DIR apr.h ${POSSIBLE_APR_INCLUDE_DIRS}) + +find_library( + APR_LIB + NAMES ${APR_LIB_NAMES} + PATHS ${POSSIBLE_APR_LIB_DIRS} + ) + +# Did we find the include directory? +string( + COMPARE NOTEQUAL + "APR_INCLUDE_DIR-NOTFOUND" + ${APR_INCLUDE_DIR} # Value set to APR_INCLUDE_DIR-NOTFOUND if not found. + APR_INCLUDE_DIR_FOUND + ) + +# Did we find the library? +string( + COMPARE NOTEQUAL + "APR_LIB-NOTFOUND" + ${APR_LIB} # Value set to `APR_LIB-NOTFOUND` if not found. + APR_LIB_FOUND + ) + +# APR is considered "found" if we've both an include directory and an APR binary. +if ("${APR_LIB_FOUND}" AND "${APR_INCLUDE_DIR_FOUND}") + set(APR_LIBS ${APR_LIB}) + set(APR_FOUND 1) +else ("${APR_LIB_FOUND}" AND "${APR_INCLUDE_DIR_FOUND}") + set(APR_FOUND 0) +endif ("${APR_LIB_FOUND}" AND "${APR_INCLUDE_DIR_FOUND}") + +# Results. +if (APR_FOUND) + if (NOT Apr_FIND_QUIETLY) + message(STATUS "Found APR headers: ${APR_INCLUDE_DIR}") + message(STATUS "Found APR library: ${APR_LIBS}") + endif (NOT Apr_FIND_QUIETLY) +else (APR_FOUND) + if (Apr_FIND_REQUIRED) + message(FATAL_ERROR "Could not find APR library") + endif (Apr_FIND_REQUIRED) +endif (APR_FOUND) + +# (Deprecated declarations.) +set(NATIVE_APR_INCLUDE_PATH ${APR_INCLUDE_DIR} ) +get_filename_component(NATIVE_APR_LIB_PATH ${APR_LIB} PATH) + +# Export libraries variables. +mark_as_advanced( + APR_LIB + APR_INCLUDE_DIR + ) + +# CONFIGURE THE APR-UTIL SEARCH. Specify what we're looking for, and which +# directories we're going to look through to find them. +############################################################################# +set(POSSIBLE_APRUTIL_INCLUDE_DIRS + ${POSSIBLE_APRUTIL_INCLUDE_DIRS} + /opt/homebrew/opt/apr-util/include/apr-1 + /usr/local/include/apr-1 + /usr/local/include/apr-1.0 + /usr/include/apr-1 + /usr/include/apr-1.0 + /usr/local/apr/include/apr-1 + ) + +set(APRUTIL_LIB_NAMES ${APRUTIL_LIB_NAMES} aprutil-1) + +set(POSSIBLE_APRURIL_LIB_DIRS + ${POSSIBLE_APRURIL_LIB_DIRS} + /usr/lib + /usr/local/lib + /usr/local/apr/lib + /opt/homebrew/opt/apr-util/lib + ) + +# SEARCH FOR APR-UTIL LIBRARIES. +################################ +find_path(APRUTIL_INCLUDE_DIR apu.h ${POSSIBLE_APRUTIL_INCLUDE_DIRS}) + +find_library( + APRUTIL_LIB + NAMES ${APRUTIL_LIB_NAMES} + PATHS ${POSSIBLE_APRUTIL_LIB_DIRS} + ) + +# Did we find the include directory? +string( + COMPARE NOTEQUAL + "APRUTIL_INCLUDE_DIR-NOTFOUND" + ${APRUTIL_INCLUDE_DIR} # Value set to APR_INCLUDE_DIR-NOTFOUND if not found. + APRUTIL_INCLUDE_DIR_FOUND + ) + +# Did we find the library? +string( + COMPARE NOTEQUAL + "APRUTIL_LIB-NOTFOUND" + ${APRUTIL_LIB} # Value set to `APR_LIB-NOTFOUND` if not found. + APRUTIL_LIB_FOUND + ) + +# APR-UTIL is "found" if we've both an include directory and an APR-UTIL binary. +if ("${APRUTIL_LIB_FOUND}" AND "${APRUTIL_INCLUDE_DIR_FOUND}") + set(APRUTIL_LIBS ${APRUTIL_LIB}) + set(APRUTIL_FOUND 1) +else ("${APRUTIL_LIB_FOUND}" AND "${APRUTIL_INCLUDE_DIR_FOUND}") + set(APRUTIL_FOUND 0) +endif ("${APRUTIL_LIB_FOUND}" AND "${APRUTIL_INCLUDE_DIR_FOUND}") + +# Results. +if (APRUTIL_FOUND) + if (NOT Apr_FIND_QUIETLY) + message(STATUS "Found APRUTIL headers: ${APRUTIL_INCLUDE_DIR}") + message(STATUS "Found APRUTIL library: ${APRUTIL_LIBS}") + endif (NOT Apr_FIND_QUIETLY) +else (APRUTIL_FOUND) + if (Apr_FIND_REQUIRED) + message(FATAL_ERROR "Could not find APRUTIL library") + endif (Apr_FIND_REQUIRED) +endif (APRUTIL_FOUND) + +# (Deprecated declarations.) +set(NATIVE_APRUTIL_INCLUDE_PATH ${APRUTIL_INCLUDE_DIR}) +get_filename_component(NATIVE_APRUTIL_LIB_PATH ${APRUTIL_LIB} PATH) + +# Export libraries variables. +mark_as_advanced( + APRUTIL_LIB + APRUTIL_INCLUDE_DIR + ) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/mesos/blob/8017e734/3rdparty/libprocess/3rdparty/stout/cmake/FindSvn.cmake ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/cmake/FindSvn.cmake b/3rdparty/libprocess/3rdparty/stout/cmake/FindSvn.cmake new file mode 100644 index 0000000..c0c0f34 --- /dev/null +++ b/3rdparty/libprocess/3rdparty/stout/cmake/FindSvn.cmake @@ -0,0 +1,124 @@ +# 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. + +############################################################### +# IMPORTANT NOTE: Much of this file is taken almost-directly from the +# FindApr.cmake file in this project. This file is itself taken +# from an external source; see comments for details. + +# This module helps to find the Subversion packages. +# +# USAGE: to use this module, add the following line to your CMake project: +# find_package(Svn) +# +# To make linking to Subversion simple, this module defines: +# * SVN_FOUND (if false, linking build will fail) +# * SVN_INCLUDE_DIR (defineswhere to find svn_client.h, etc.) +# * SVN_LIBS (binaries for SVN and friends) +# +# Also defined, but not for general use are: +# * SVN_LIB (where to find the APR library) + +# CONFIGURE OUR SEARCH. Specify what we're looking for, and which directories +# we're going to look through to find them. +############################################################################# +set(POSSIBLE_SVN_INCLUDE_DIRECTORIES + ${POSSIBLE_SVN_INCLUDE_DIRECTORIES} + /usr/local/include/subversion-1 + /usr/include/subversion-1 + ) + +set(SVN_LIB_NAMES + ${SVN_LIB_NAMES} + svn_client-1 + svn_delta-1 + svn_diff-1 + svn_fs-1 + svn_fs_base-1 + svn_fs_fs-1 + svn_fs_util-1 + svn_ra-1 + svn_ra_local-1 + svn_ra_serf-1 + svn_ra_svn-1 + svn_repos-1 + svn_subr-1 + svn_wc-1 + ) + +set(POSSIBLE_SVN_LIB_DIRECTORIES + ${POSSIBLE_SVN_LIB_DIRECTORIES} + /usr/lib + /usr/local/lib + ) + +# SEARCH FOR SVN LIBRARIES. +########################### +find_path(SVN_INCLUDE_DIR svn_client.h ${POSSIBLE_SVN_INCLUDE_DIRECTORIES}) + +# Did we find the include directory? +string( + COMPARE NOTEQUAL + "SVN_INCLUDE_DIR-NOTFOUND" + ${SVN_INCLUDE_DIR} # Value set to `SVN_INCLUDE_DIR-NOTFOUND` if not found. + SVN_INCLUDE_DIR_FOUND + ) + +foreach (LIB_NAME ${SVN_LIB_NAMES}) + find_library( + ${LIB_NAME}_PATH + NAMES ${LIB_NAME} + PATHS ${POSSIBLE_SVN_LIB_DIRECTORIES} + ) + + # Did we find the library? + string( + COMPARE NOTEQUAL + "${LIB_NAME}_PATH-NOTFOUND" + ${${LIB_NAME}_PATH} # Value set to ${${LIB_NAME}_PATH}-NOTFOUND if not found. + ${LIB_NAME}_PATH_FOUND + ) + + if ("${${LIB_NAME}_PATH_FOUND}") + message(STATUS "Found SVN lib: ${${LIB_NAME}_PATH}") + list(APPEND SVN_LIBS ${${LIB_NAME}_PATH}) + else ("${${LIB_NAME}_PATH_FOUND}") + message(FATAL_ERROR "Could not find SVN library ${${LIB_NAME}_PATH}") + endif ("${${LIB_NAME}_PATH_FOUND}") +endforeach (LIB_NAME ${SVN_LIB_NAMES}) + +list(LENGTH SVN_LIB_NAMES NUM_REQD_LIBS) +list(LENGTH SVN_LIBS NUM_FOUND_LIBS) + +# Results. +if ((NUM_FOUND_LIBS AND (NUM_REQD_LIBS EQUAL NUM_FOUND_LIBS)) AND + SVN_INCLUDE_DIR_FOUND) + if (NOT Svn_FIND_QUIETLY) + message(STATUS "Found SVN: ${SVN_LIBS}") + endif(NOT Svn_FIND_QUIETLY) +else ((NUM_FOUND_LIBS AND (NUM_REQD_LIBS EQUAL NUM_FOUND_LIBS)) AND + SVN_INCLUDE_DIR_FOUND) + if (Svn_FIND_REQUIRED) + message(FATAL_ERROR "Could not find SVN library") + endif (Svn_FIND_REQUIRED) +endif ((NUM_FOUND_LIBS AND (NUM_REQD_LIBS EQUAL NUM_FOUND_LIBS)) AND + SVN_INCLUDE_DIR_FOUND) + +# Export variables. +mark_as_advanced( + SVN_LIB + SVN_INCLUDE_DIR + ) \ No newline at end of file http://git-wip-us.apache.org/repos/asf/mesos/blob/8017e734/3rdparty/libprocess/3rdparty/stout/cmake/StoutTestsConfigure.cmake ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/cmake/StoutTestsConfigure.cmake b/3rdparty/libprocess/3rdparty/stout/cmake/StoutTestsConfigure.cmake new file mode 100644 index 0000000..e9be4aa --- /dev/null +++ b/3rdparty/libprocess/3rdparty/stout/cmake/StoutTestsConfigure.cmake @@ -0,0 +1,93 @@ +# 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. + +find_package(Apr REQUIRED) +find_package(Svn REQUIRED) + +# DEFINE PROCESS LIBRARY DEPENDENCIES. Tells the process library build targets +# download/configure/build all third-party libraries before attempting to build. +################################################################################ +set(STOUT_TEST_DEPENDENCIES + ${GMOCK_TARGET} + ${GTEST_TARGET} + ${PROTOBUF_TARGET} + ) + +# DEFINE THIRD-PARTY INCLUDE DIRECTORIES. Tells compiler toolchain where to get +# headers for our third party libs (e.g., -I/path/to/glog on Linux).. +############################################################################### +set(STOUT_TEST_INCLUDE_DIRS + ${STOUT_TEST_INCLUDE_DIRS} + ${STOUT}/include + ${BOOST_ROOT} + ${PICOJSON_ROOT} + ${APR_INCLUDE_DIR} + ${SVN_INCLUDE_DIR} + ${GMOCK_ROOT}/include + ${GTEST_SRC}/include + ${PROTOBUF_LIB}/include + src + ) + +if (WIN32) + set(STOUT_TEST_INCLUDE_DIRS + ${STOUT_TEST_INCLUDE_DIRS} + ${GLOG_ROOT}/src/windows + ) +else (WIN32) + set(STOUT_TEST_INCLUDE_DIRS + ${STOUT_TEST_INCLUDE_DIRS} + ${GLOG_LIB}/include + ) +endif (WIN32) + +# 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). +######################################################################## +set(STOUT_TEST_LIB_DIRS + ${STOUT_TEST_LIB_DIRS} + ${GLOG_LIB}/lib + ${APR_LIBS} + ${SVN_LIBS} + ${GMOCK_ROOT}-build/lib/.libs + ${GMOCK_ROOT}-build/gtest/lib/.libs + ${PROTOBUF_LIB}/lib + ) + +# DEFINE THIRD-PARTY LIBS. Used to generate flags that the linker uses to +# include our third-party libs (e.g., -lglog on Linux). +######################################################################### +set(STOUT_TEST_LIBS + ${STOUT_TEST_LIBS} + ${CMAKE_THREAD_LIBS_INIT} + glog + dl + apr-1 + protobuf + gtest + gmock + ${SVN_LIBS} + ) + +if (NOT WIN32) + find_library(LIBRT_LIBRARIES rt REQUIRED) + + set(STOUT_TEST_LIBS + ${STOUT_TEST_LIBS} + ${LIBRT_LIBRARIES} + ) +endif (NOT WIN32) http://git-wip-us.apache.org/repos/asf/mesos/blob/8017e734/3rdparty/libprocess/3rdparty/stout/tests/CMakeLists.txt ---------------------------------------------------------------------- diff --git a/3rdparty/libprocess/3rdparty/stout/tests/CMakeLists.txt b/3rdparty/libprocess/3rdparty/stout/tests/CMakeLists.txt new file mode 100644 index 0000000..b1a5190 --- /dev/null +++ b/3rdparty/libprocess/3rdparty/stout/tests/CMakeLists.txt @@ -0,0 +1,86 @@ +# 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. + +set(STOUT_TESTS_TARGET stout_tests) + +# STOUT TESTS. +############## +set(STOUT_TESTS_SRC + ${STOUT_TESTS_SRC} + base64_tests.cpp + bits_tests.cpp + bytes_tests.cpp + cache_tests.cpp + svn_tests.cpp + duration_tests.cpp + dynamiclibrary_tests.cpp + error_tests.cpp + flags_tests.cpp + gzip_tests.cpp + hashmap_tests.cpp + hashset_tests.cpp + interval_tests.cpp + ip_tests.cpp + json_tests.cpp + linkedhashmap_tests.cpp + mac_tests.cpp + main.cpp + multimap_tests.cpp + none_tests.cpp + option_tests.cpp + os_tests.cpp + path_tests.cpp + protobuf_tests.cpp + protobuf_tests.pb.cc + protobuf_tests.pb.h + protobuf_tests.proto + result_tests.cpp + os/sendfile_tests.cpp + os/signals_tests.cpp + set_tests.cpp + some_tests.cpp + strings_tests.cpp + subcommand_tests.cpp + thread_tests.cpp + uuid_tests.cpp + version_tests.cpp + ) + +# INCLUDE DIRECTIVES FOR STOUT TEST BINARY (generates, e.g., -I/path/to/thing +# on Linux). +############################################################################# +include_directories(${STOUT_TEST_INCLUDE_DIRS}) + +# LINKING LIBRARIES BY DIRECTORY (might generate, e.g., -L/path/to/thing on +# Linux). +########################################################################### +link_directories(${STOUT_TEST_LIB_DIRS}) + +# THE STOUT TEST EXECUTABLE (generates, e.g., stout_tests, etc., on Linux). +########################################################################### +add_executable(${STOUT_TESTS_TARGET} ${STOUT_TESTS_SRC}) + +# ADD LINKER FLAGS (generates, e.g., -lglog on Linux). +###################################################### +target_link_libraries(${STOUT_TESTS_TARGET} ${STOUT_TEST_LIBS}) + +# ADD BINARY DEPENDENCIES (tells CMake what to compile/build first). +#################################################################### +add_dependencies(${STOUT_TESTS_TARGET} ${STOUT_TEST_DEPENDENCIES}) + +# ADD TEST TARGET (runs when you do, e.g., `make check`). +######################################################### +add_test(NAME StoutTests COMMAND ./${STOUT_TESTS_TARGET}) \ No newline at end of file
