summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Benjamin Barenblat <bbaren@google.com>2020-05-19 11:55:11 -0400
committerGravatar Benjamin Barenblat <bbaren@google.com>2020-05-19 11:55:11 -0400
commitacf588f5a22eafd7d21de55b954e8641d4b06568 (patch)
treeee689a9ef34982825e511f997f7b5b9ccb3d2b08
parentf9adb234861d1321e0b8774db9aed57ebc6161f0 (diff)
Enable CMake support
Install Abseil’s CMake support files. Some of these files are autogenerated, and the generator produces files with a googletest dependency if Abseil is built with unit tests enabled; to prevent this, turn off unit tests.
-rw-r--r--debian/control3
-rw-r--r--debian/libabsl-dev.install1
-rw-r--r--debian/patches/series2
-rw-r--r--debian/patches/use_local_gtest.diff130
-rw-r--r--debian/patches/use_local_gtest2.diff21
-rwxr-xr-xdebian/rules2
-rwxr-xr-x[-rw-r--r--]debian/tests/cmake (renamed from debian/not-installed)34
-rw-r--r--debian/tests/control3
8 files changed, 37 insertions, 159 deletions
diff --git a/debian/control b/debian/control
index f43bd41a..202de055 100644
--- a/debian/control
+++ b/debian/control
@@ -18,7 +18,6 @@ Maintainer: Benjamin Barenblat <bbaren@debian.org>
Build-Depends:
cmake (>= 3.5),
debhelper-compat (= 12),
- googletest,
Standards-Version: 4.5.0
Section: libs
Homepage: https://abseil.io/
@@ -90,7 +89,7 @@ Depends:
libabsl-time20200225 (= ${binary:Version}),
libabsl-time-zone20200225 (= ${binary:Version}),
${misc:Depends},
-Recommends: g++ (>= 4.7), libgmock-dev, libgtest-dev
+Recommends: cmake (>= 2.6), g++ (>= 4.7)
Description: ${source:Synopsis} (development files)
${source:Extended-Description}
.
diff --git a/debian/libabsl-dev.install b/debian/libabsl-dev.install
index 43f80c3b..6a5120e6 100644
--- a/debian/libabsl-dev.install
+++ b/debian/libabsl-dev.install
@@ -14,3 +14,4 @@
usr/include/absl
usr/lib/*/*.so
+usr/lib/*/cmake
diff --git a/debian/patches/series b/debian/patches/series
index 0d0ecdd4..f99c8e0c 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -1,4 +1,2 @@
license.diff
-use_local_gtest.diff
-use_local_gtest2.diff
configure.diff
diff --git a/debian/patches/use_local_gtest.diff b/debian/patches/use_local_gtest.diff
deleted file mode 100644
index 9ccd2316..00000000
--- a/debian/patches/use_local_gtest.diff
+++ /dev/null
@@ -1,130 +0,0 @@
-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)
diff --git a/debian/patches/use_local_gtest2.diff b/debian/patches/use_local_gtest2.diff
deleted file mode 100644
index 37f3e7d0..00000000
--- a/debian/patches/use_local_gtest2.diff
+++ /dev/null
@@ -1,21 +0,0 @@
-From: Benjamin Barenblat <bbaren@google.com>
-Subject: Support testing with a local googletest checkout, part 2
-Forwarded: yes
-Applied-Upstream: https://github.com/abseil/abseil-cpp/commit/79e0dc11514df035a8d07a356f9ee1800fb2160c
-
-use_local_gtest.diff missed a necessary line; add it.
-
-The author works at Google. Upstream applied this patch as Piper revision
-302947488 and exported it to GitHub; the Applied-Upstream URL above points to
-the exported commit.
-
---- a/CMake/Googletest/DownloadGTest.cmake
-+++ b/CMake/Googletest/DownloadGTest.cmake
-@@ -38,6 +38,4 @@
-
- # Add googletest directly to our build. This defines the gtest and gtest_main
- # targets.
--add_subdirectory(${CMAKE_BINARY_DIR}/googletest-src
-- ${CMAKE_BINARY_DIR}/googletest-build
-- EXCLUDE_FROM_ALL)
-+add_subdirectory(${absl_gtest_src_dir} ${absl_gtest_build_dir} EXCLUDE_FROM_ALL)
diff --git a/debian/rules b/debian/rules
index 79964920..4c276263 100755
--- a/debian/rules
+++ b/debian/rules
@@ -19,7 +19,7 @@ export DEB_BUILD_MAINT_OPTIONS = hardening=+bindnow
dh $@
override_dh_auto_configure:
- dh_auto_configure -- -DCMAKE_CXX_STANDARD=14 -DABSL_RUN_TESTS=ON -DABSL_USE_GOOGLETEST_HEAD=OFF -DBUILD_SHARED_LIBS=ON
+ dh_auto_configure -- -DCMAKE_CXX_STANDARD=14 -DBUILD_SHARED_LIBS=ON
override_dh_auto_install:
dh_auto_install
diff --git a/debian/not-installed b/debian/tests/cmake
index 01e24a96..1eb04de9 100644..100755
--- a/debian/not-installed
+++ b/debian/tests/cmake
@@ -1,3 +1,4 @@
+#!/bin/sh -eu
# Copyright 2020 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may not
@@ -12,6 +13,33 @@
# License for the specific language governing permissions and limitations under
# the License.
-usr/lib/x86_64-linux-gnu/cmake/absl/abslConfig.cmake
-usr/lib/x86_64-linux-gnu/cmake/absl/abslTargets-none.cmake
-usr/lib/x86_64-linux-gnu/cmake/absl/abslTargets.cmake
+readonly TMP="$(mktemp -d)"
+trap "rm -rf \"$TMP\"" EXIT
+cd "$TMP"
+
+cat >test.cc <<EOF
+#include <absl/strings/numbers.h>
+
+int main(int argc, char* argv[]) {
+ int n;
+ if (!absl::SimpleAtoi(argv[1], &n)) {
+ return 1;
+ }
+ return n;
+}
+EOF
+
+cat >CMakeLists.txt <<EOF
+cmake_minimum_required(VERSION 3.5)
+project(test CXX)
+set(CMAKE_CXX_STANDARD 14)
+add_executable(test test.cc)
+find_package(absl REQUIRED)
+target_link_libraries(test absl::strings)
+EOF
+
+mkdir build
+cd build
+cmake ..
+make
+./test 0
diff --git a/debian/tests/control b/debian/tests/control
index fbbf5129..43dc87cb 100644
--- a/debian/tests/control
+++ b/debian/tests/control
@@ -14,3 +14,6 @@
Tests: smoke
Depends: @, g++, libgtest-dev
+
+Tests: cmake
+Depends: @, cmake (>= 3.5), g++, make