From 84b41a69694251bc93259b519d44dad7fa3af89f Mon Sep 17 00:00:00 2001 From: blackyblack Date: Fri, 7 Feb 2020 17:06:43 -0800 Subject: [PATCH] Only add gtest target when building with tests (#6377) Summary: External CMAKE projects cannot add own gtest target due to CMP0002 policy. We should not add gtest target unless we build with tests. Pull Request resolved: https://github.com/facebook/rocksdb/pull/6377 Differential Revision: D19801708 fbshipit-source-id: 662484683e8737e10397ddb0d17705da5243c4f9 --- CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 139866229..e546bb489 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -906,15 +906,15 @@ if(NOT WIN32 OR ROCKSDB_INSTALL_ON_WINDOWS) ) endif() -add_subdirectory(third-party/gtest-1.8.1/fused-src/gtest) -add_library(testharness STATIC - test_util/testharness.cc) -target_link_libraries(testharness gtest) - # Tests are excluded from Release builds CMAKE_DEPENDENT_OPTION(WITH_TESTS "build with tests" ON "CMAKE_BUILD_TYPE STREQUAL Debug" OFF) if(WITH_TESTS) + add_subdirectory(third-party/gtest-1.8.1/fused-src/gtest) + add_library(testharness STATIC + test_util/testharness.cc) + target_link_libraries(testharness gtest) + set(TESTS cache/cache_test.cc cache/lru_cache_test.cc