From a50ae369a30f99f79d7559002aba3413dac1bd48 Mon Sep 17 00:00:00 2001 From: Abseil Team Date: Mon, 22 Feb 2021 13:18:10 -0800 Subject: Export of internal Abseil changes -- 4ceae78ecef025a331985958bba12ce12d4d0a68 by Derek Mauro : Internal change PiperOrigin-RevId: 358888936 -- 48f69b0b46e2041bb321e8af7374d7e0b45efc25 by Derek Mauro : Use the standard CTest mechanism BUILD_TESTING for enabling/disabling tests in CMake Fixes #901 PiperOrigin-RevId: 358822190 GitOrigin-RevId: 4ceae78ecef025a331985958bba12ce12d4d0a68 Change-Id: Ib1ca69a42355f2a4cd4c7f5a47184c4fd8441f35 --- CMakeLists.txt | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index d8c3b58..8843ee7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -41,7 +41,12 @@ if (POLICY CMP0077) cmake_policy(SET CMP0077 NEW) endif (POLICY CMP0077) +# Set BUILD_TESTING to OFF by default. +# This must come before the project() and include(CTest) lines. +OPTION(BUILD_TESTING "Build tests" OFF) + project(absl CXX) +include(CTest) # Output directory is correct by default for most build setups. However, when # building Abseil as a DLL, it is important to have the DLL in the same @@ -104,13 +109,7 @@ set(ABSL_LOCAL_GOOGLETEST_DIR "/usr/src/googletest" CACHE PATH "If ABSL_USE_GOOGLETEST_HEAD is OFF and ABSL_GOOGLETEST_URL is not set, specifies the directory of a local GoogleTest checkout." ) -option(ABSL_RUN_TESTS "If ON, Abseil tests will be run." OFF) - -if(${ABSL_RUN_TESTS}) - # enable CTest. This will set BUILD_TESTING to ON unless otherwise specified - # on the command line - include(CTest) - +if(BUILD_TESTING) ## check targets if (NOT ABSL_USE_EXTERNAL_GOOGLETEST) set(absl_gtest_build_dir ${CMAKE_BINARY_DIR}/googletest-build) -- cgit v1.2.3