0005-Use-system-installed-googletest.patch 1.67 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
From: Alexander GQ Gerasiov <gq@cs.msu.su>
Date: Wed, 26 Dec 2018 23:22:09 +0300
Subject: Use system installed googletest.

Since googletest 3.5 or 3.6 in Debian it is installed as source into
/usr/src/googletest to allow build with user's compiler.

So we just need to build it from the directory the same way we build
bundled one.
---
 cmake/find_gtest.cmake | 8 +-------
 contrib/CMakeLists.txt | 3 +++
 2 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/cmake/find_gtest.cmake b/cmake/find_gtest.cmake
index ce0a3d3..514f558 100644
--- a/cmake/find_gtest.cmake
+++ b/cmake/find_gtest.cmake
@@ -9,12 +9,6 @@ if (NOT EXISTS "${ClickHouse_SOURCE_DIR}/contrib/googletest/googletest/CMakeList
 endif ()
 
 if (NOT USE_INTERNAL_GTEST_LIBRARY)
-    find_package (GTest)
-endif ()
-
-if (NOT GTEST_INCLUDE_DIRS AND NOT MISSING_INTERNAL_GTEST_LIBRARY)
-    set (USE_INTERNAL_GTEST_LIBRARY 1)
+    set (GTEST_SRC_DIR "/usr/src/googletest")
     set (GTEST_MAIN_LIBRARIES gtest_main)
 endif ()
-
-message (STATUS "Using gtest: ${GTEST_INCLUDE_DIRS} : ${GTEST_MAIN_LIBRARIES}")
diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt
index ac496a1..ab453b9 100644
--- a/contrib/CMakeLists.txt
+++ b/contrib/CMakeLists.txt
@@ -166,6 +166,9 @@ if (USE_INTERNAL_GTEST_LIBRARY)
     # avoid problems with <regexp.h>
     target_compile_definitions (gtest INTERFACE GTEST_HAS_POSIX_RE=0)
     target_include_directories (gtest SYSTEM INTERFACE ${ClickHouse_SOURCE_DIR}/contrib/googletest/include)
+else ()
+    add_subdirectory(${GTEST_SRC_DIR}/googletest ${CMAKE_CURRENT_BINARY_DIR}/googletest)
+    target_compile_definitions (gtest INTERFACE GTEST_HAS_POSIX_RE=0)
 endif ()
 
 if (USE_INTERNAL_LLVM_LIBRARY)