diff options
Diffstat (limited to 'debian/patches/use_local_gtest.diff')
-rw-r--r-- | debian/patches/use_local_gtest.diff | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/debian/patches/use_local_gtest.diff b/debian/patches/use_local_gtest.diff new file mode 100644 index 00000000..9ccd2316 --- /dev/null +++ b/debian/patches/use_local_gtest.diff @@ -0,0 +1,130 @@ +From: Benjamin Barenblat <bbaren@google.com> +Subject: Support testing with a local googletest checkout +Forwarded: yes +Applied-Upstream: https://github.com/abseil/abseil-cpp/commit/bcefbdcdf6ad85046ccacee0aeffba5404d3e528 + +Debian likes doing dependency management manually, so add support for +testing against a local googletest checkout rather than one downloaded +from GitHub. Add an ABSL_LOCAL_GOOGLETEST_DIR variable that can be used +in conjunction with -DABSL_RUN_TESTS=ON -DABSL_USE_GOOGLETEST_HEAD=OFF +to specify the googletest location manually, and do a bit of related +cleanup. + +This patch was originally submitted as +https://github.com/abseil/abseil-cpp/pull/628. Since the author works at +Google, upstream requested that he submit it internally. It was applied +as Piper revision 297677173 and exported to GitHub; the Applied-Upstream +URL above points to the exported commit. + +--- a/CMake/Googletest/CMakeLists.txt.in ++++ b/CMake/Googletest/CMakeLists.txt.in +@@ -1,15 +1,26 @@ + cmake_minimum_required(VERSION 2.8.2) + +-project(googletest-download NONE) ++project(googletest-external NONE) + + include(ExternalProject) +-ExternalProject_Add(googletest +- GIT_REPOSITORY https://github.com/google/googletest.git +- GIT_TAG master +- SOURCE_DIR "${CMAKE_BINARY_DIR}/googletest-src" +- BINARY_DIR "${CMAKE_BINARY_DIR}/googletest-build" +- CONFIGURE_COMMAND "" +- BUILD_COMMAND "" +- INSTALL_COMMAND "" +- TEST_COMMAND "" +-) +\ No newline at end of file ++if(${ABSL_USE_GOOGLETEST_HEAD}) ++ ExternalProject_Add(googletest ++ GIT_REPOSITORY https://github.com/google/googletest.git ++ GIT_TAG master ++ SOURCE_DIR "${absl_gtest_src_dir}" ++ BINARY_DIR "${absl_gtest_build_dir}" ++ CONFIGURE_COMMAND "" ++ BUILD_COMMAND "" ++ INSTALL_COMMAND "" ++ TEST_COMMAND "" ++ ) ++else() ++ ExternalProject_Add(googletest ++ SOURCE_DIR "${absl_gtest_src_dir}" ++ BINARY_DIR "${absl_gtest_build_dir}" ++ CONFIGURE_COMMAND "" ++ BUILD_COMMAND "" ++ INSTALL_COMMAND "" ++ TEST_COMMAND "" ++ ) ++endif() +\ No newline at end of file +--- a/CMake/Googletest/DownloadGTest.cmake ++++ b/CMake/Googletest/DownloadGTest.cmake +@@ -1,10 +1,11 @@ +-# Downloads and unpacks googletest at configure time. Based on the instructions +-# at https://github.com/google/googletest/tree/master/googletest#incorporating-into-an-existing-cmake-project ++# Integrates googletest at configure time. Based on the instructions at ++# https://github.com/google/googletest/tree/master/googletest#incorporating-into-an-existing-cmake-project + +-# Download the latest googletest from Github master ++# Set up the external googletest project, downloading the latest from Github ++# master if requested. + configure_file( + ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt.in +- ${CMAKE_BINARY_DIR}/googletest-download/CMakeLists.txt ++ ${CMAKE_BINARY_DIR}/googletest-external/CMakeLists.txt + ) + + set(ABSL_SAVE_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) +@@ -14,17 +15,17 @@ if (BUILD_SHARED_LIBS) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DGTEST_CREATE_SHARED_LIBRARY=1") + endif() + +-# Configure and build the downloaded googletest source ++# Configure and build the googletest source. + execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . + RESULT_VARIABLE result +- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download ) ++ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-external ) + if(result) + message(FATAL_ERROR "CMake step for googletest failed: ${result}") + endif() + + execute_process(COMMAND ${CMAKE_COMMAND} --build . + RESULT_VARIABLE result +- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download) ++ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-external) + if(result) + message(FATAL_ERROR "Build step for googletest failed: ${result}") + endif() +diff --git a/CMakeLists.txt b/CMakeLists.txt +index fdfb2cf..74b5cd9 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -84,6 +84,10 @@ + option(ABSL_USE_GOOGLETEST_HEAD + "If ON, abseil will download HEAD from googletest at config time." OFF) + ++set(ABSL_LOCAL_GOOGLETEST_DIR "/usr/src/googletest" CACHE PATH ++ "If ABSL_USE_GOOGLETEST_HEAD is OFF, specifies the directory of a local googletest checkout." ++ ) ++ + option(ABSL_RUN_TESTS "If ON, Abseil tests will be run." OFF) + + if(${ABSL_RUN_TESTS}) +@@ -96,11 +100,13 @@ + ## check targets + if(BUILD_TESTING) + ++ set(absl_gtest_build_dir ${CMAKE_BINARY_DIR}/googletest-build) + if(${ABSL_USE_GOOGLETEST_HEAD}) +- include(CMake/Googletest/DownloadGTest.cmake) + set(absl_gtest_src_dir ${CMAKE_BINARY_DIR}/googletest-src) +- set(absl_gtest_build_dir ${CMAKE_BINARY_DIR}/googletest-build) ++ else() ++ set(absl_gtest_src_dir ${ABSL_LOCAL_GOOGLETEST_DIR}) + endif() ++ include(CMake/Googletest/DownloadGTest.cmake) + + check_target(gtest) + check_target(gtest_main) |