CMake: Avoid Google Test error when re-configuring with latest Abseil

Abseil insists on having a Google Test directory, even if we're not going to
run (or even build) the tests.

This changes forces all test settings to `OFF` just for Abseil, allowing
SAPI builds to complete normally. Embedding projects should not be affected,
if they already included Abseil.

PiperOrigin-RevId: 309035680
Change-Id: Ie46297d8b502d92d0c10ef04360e992bcee4964b
This commit is contained in:
Christian Blichmann 2020-04-29 09:16:56 -07:00 committed by Copybara-Service
parent 7ec20bd5d5
commit fea5e8c485

View File

@ -33,13 +33,20 @@ if(error)
endif()
set(_sapi_saved_CMAKE_CXX_STANDARD ${CMAKE_CXX_STANDARD})
set(_sapi_saved_BUILD_TESTING ${BUILD_TESTING})
set(CMAKE_CXX_STANDARD ${SAPI_CXX_STANDARD})
set(ABSL_USE_GOOGLETEST_HEAD OFF CACHE BOOL "" FORCE)
set(ABSL_RUN_TESTS OFF CACHE BOOL "" FORCE)
set(BUILD_TESTING OFF) # Avoid errors when re-configuring SAPI
set(ABSL_CXX_STANDARD ${SAPI_CXX_STANDARD} CACHE STRING "" FORCE)
add_subdirectory("${CMAKE_BINARY_DIR}/absl-src"
"${CMAKE_BINARY_DIR}/absl-build" EXCLUDE_FROM_ALL)
if(_sapi_saved_BUILD_TESTING)
set(BUILD_TESTING "${_sapi_saved_BUILD_TESTING}")
endif()
if(_sapi_saved_CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD "${_sapi_saved_CMAKE_CXX_STANDARD}")
endif()