diff options
author | Abseil Team <absl-team@google.com> | 2020-10-21 00:01:29 -0700 |
---|---|---|
committer | Gennadiy Rozental <rogeeff@google.com> | 2020-10-22 02:21:05 -0400 |
commit | eb317a701b83bf9a4f2a035d75747a3d76a48324 (patch) | |
tree | b208a95534ae461724c9f170d500915a18fa6381 /CMake | |
parent | 4b915e70929ca2d6152240facc83d3d38c5d5f28 (diff) |
Export of internal Abseil changes
--
d09230db053c544c2dc7fd7d95d1ebe4302071e9 by Abseil Team <absl-team@google.com>:
Move testonly_uses_linear_node_search to BtreeNodePeer
PiperOrigin-RevId: 338210523
--
7b11c945dbba7a354103c194877eba240f7f0cbc by Derek Mauro <dmauro@google.com>:
Allow pinning to a GoogleTest commit to make the build reproducible
Allow using a cached copy of the commit to avoid depending on GitHub
PiperOrigin-RevId: 338115715
--
8414f496c570a6398744da8324e158b39a2e3d92 by Andy Getzendanner <durandal@google.com>:
Generate a pkg-config file per absl_cc_library.
PiperOrigin-RevId: 337986219
GitOrigin-RevId: d09230db053c544c2dc7fd7d95d1ebe4302071e9
Change-Id: Iae398ab8ad5c0c6833abd01aa5198315f5b6fa99
Diffstat (limited to 'CMake')
-rw-r--r-- | CMake/AbseilHelpers.cmake | 39 | ||||
-rw-r--r-- | CMake/Googletest/CMakeLists.txt.in | 30 | ||||
-rwxr-xr-x | CMake/install_test_project/test.sh | 18 |
3 files changed, 66 insertions, 21 deletions
diff --git a/CMake/AbseilHelpers.cmake b/CMake/AbseilHelpers.cmake index 8b2925c5..e63db3a8 100644 --- a/CMake/AbseilHelpers.cmake +++ b/CMake/AbseilHelpers.cmake @@ -137,6 +137,45 @@ function(absl_cc_library) set(_build_type "static") endif() + # Generate a pkg-config file for every library: + if(${_build_type} STREQUAL "static" OR ${_build_type} STREQUAL "shared") + if(NOT ABSL_CC_LIB_TESTONLY) + if(absl_VERSION) + set(PC_VERSION "${absl_VERSION}") + else() + set(PC_VERSION "head") + endif() + foreach(dep ${ABSL_CC_LIB_DEPS}) + if(${dep} MATCHES "^absl::(.*)") + set(PC_DEPS "${PC_DEPS} absl_${CMAKE_MATCH_1} = ${PC_VERSION}") + endif() + endforeach() + foreach(cflag ${ABSL_CC_LIB_COPTS}) + if(${cflag} MATCHES "^(-Wno|/wd)") + # These flags are needed to suppress warnings that might fire in our headers. + set(PC_CFLAGS "${PC_CFLAGS} ${cflag}") + elseif(${cflag} MATCHES "^(-W|/w[1234eo])") + # Don't impose our warnings on others. + else() + set(PC_CFLAGS "${PC_CFLAGS} ${cflag}") + endif() + endforeach() + FILE(GENERATE OUTPUT "${CMAKE_INSTALL_PREFIX}/lib/pkgconfig/absl_${_NAME}.pc" CONTENT "\ +prefix=${CMAKE_INSTALL_PREFIX}\n\ +exec_prefix=\${prefix}\n\ +libdir=\${prefix}/lib\n\ +includedir=\${prefix}/include\n\ +\n\ +Name: absl_${_NAME}\n\ +Description: Abseil ${_NAME} library\n\ +URL: https://abseil.io/\n\ +Version: ${PC_VERSION}\n\ +Requires.private:${PC_DEPS}\n\ +Libs: -L\${libdir} $<JOIN:${ABSL_CC_LIB_LINKOPTS}, > $<$<NOT:$<BOOL:${ABSL_CC_LIB_IS_INTERFACE}>>:-labsl_${_NAME}>\n\ +Cflags: -I\${includedir}${PC_CFLAGS}\n") + endif() + endif() + if(NOT ABSL_CC_LIB_IS_INTERFACE) if(${_build_type} STREQUAL "dll_dep") # This target depends on the DLL. When adding dependencies to this target, diff --git a/CMake/Googletest/CMakeLists.txt.in b/CMake/Googletest/CMakeLists.txt.in index 994dac0b..5769e3a9 100644 --- a/CMake/Googletest/CMakeLists.txt.in +++ b/CMake/Googletest/CMakeLists.txt.in @@ -3,24 +3,12 @@ cmake_minimum_required(VERSION 2.8.2) project(googletest-external NONE) include(ExternalProject) -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 +ExternalProject_Add(googletest + URL "${absl_gtest_download_url}" # May be empty + SOURCE_DIR "${absl_gtest_src_dir}" + BINARY_DIR "${absl_gtest_build_dir}" + CONFIGURE_COMMAND "" + BUILD_COMMAND "" + INSTALL_COMMAND "" + TEST_COMMAND "" +) diff --git a/CMake/install_test_project/test.sh b/CMake/install_test_project/test.sh index 99989b03..ddc7726b 100755 --- a/CMake/install_test_project/test.sh +++ b/CMake/install_test_project/test.sh @@ -118,6 +118,24 @@ if ! grep absl::strings "${libdir}/cmake/${absl_subdir}/abslTargets.cmake"; then exit 1 fi +pushd "${HOME}" +cat > hello-abseil.cc << EOF +#include <cstdlib> + +#include "absl/strings/str_format.h" + +int main(int argc, char **argv) { + absl::PrintF("Hello Abseil!\n"); + return EXIT_SUCCESS; +} +EOF +export PKG_CONFIG_PATH="${install_dir}/${libdir}/pkgconfig" +pc_args=($(pkg-config --cflags --libs --static absl_str_format)) +g++ -static -o hello-abseil hello-abseil.cc "${pc_args[@]}" +hello="$(./hello-abseil)" +[[ "${hello}" == "Hello Abseil!" ]] +popd + uninstall_absl popd |