From 6bad847991e663f2e2cc0fac1e72765763ab616b Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Tue, 18 Oct 2022 21:39:44 -0700 Subject: CMake: Add GTEST_HAS_ABSL build option for using Absl PiperOrigin-RevId: 482101793 Change-Id: I1bd140fd6a325f573c8a0c464e4dccd4acd0d0a3 --- CMakeLists.txt | 1 + googletest/CMakeLists.txt | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 725d670..4210622 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ include(GNUInstallDirs) #Note that googlemock target already builds googletest option(BUILD_GMOCK "Builds the googlemock subproject" ON) option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON) +option(GTEST_HAS_ABSL "Use Abseil and RE2. Requires Abseil and RE2 to be separately added to the build." OFF) if(BUILD_GMOCK) add_subdirectory( googlemock ) diff --git a/googletest/CMakeLists.txt b/googletest/CMakeLists.txt index aa00a5f..95bfa44 100644 --- a/googletest/CMakeLists.txt +++ b/googletest/CMakeLists.txt @@ -125,6 +125,22 @@ include_directories(${gtest_build_include_dirs}) # aggressive about warnings. cxx_library(gtest "${cxx_strict}" src/gtest-all.cc) set_target_properties(gtest PROPERTIES VERSION ${GOOGLETEST_VERSION}) +if(GTEST_HAS_ABSL) + target_compile_definitions(gtest PUBLIC GTEST_HAS_ABSL=1) + target_link_libraries(gtest PUBLIC + absl::failure_signal_handler + absl::stacktrace + absl::symbolize + absl::flags_parse + absl::flags_reflection + absl::flags_usage + absl::strings + absl::any + absl::optional + absl::variant + re2::re2 + ) +endif() cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc) set_target_properties(gtest_main PROPERTIES VERSION ${GOOGLETEST_VERSION}) # If the CMake version supports it, attach header directory information -- cgit v0.12