File: 0001-Use-googletest-lib-built-from-source.patch

package info (click to toggle)
librime 1.14.0%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 7,900 kB
  • sloc: cpp: 34,985; ansic: 2,519; javascript: 443; sh: 231; makefile: 125
file content (39 lines) | stat: -rw-r--r-- 1,255 bytes parent folder | download | duplicates (2)
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
From: Boyuan Yang <byang@debian.org>
Date: Thu, 21 Sep 2023 20:27:45 -0400
Subject: Use googletest lib built from source

Forwarded: not-needed
---
 CMakeLists.txt | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3ec4398..2f55f95 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -98,10 +98,24 @@ if(NOT ENABLE_THREADING)
 endif()
 
 if(BUILD_TEST)
-  find_package(GTest REQUIRED)
+  find_package(GTest)
   if(GTEST_FOUND)
     enable_testing()
     include_directories(${GTEST_INCLUDE_DIRS})
+  else()
+    # Debian-specific: build gtest as library from source code
+    set(GTEST_SRC_DIR /usr/src/googletest/googletest CACHE STRING "Location of gest sources")
+    if(EXISTS ${GTEST_SRC_DIR}/src/gtest-all.cc)
+      message(STATUS "building gtest from sources in ${GTEST_SRC_DIR}")
+      set(gtest_sources ${GTEST_SRC_DIR}/src/gtest-all.cc)
+      add_library(gtest STATIC ${gtest_sources})
+      include_directories(${GTEST_SRC_DIR})
+      include_directories(${GTEST_SRC_DIR}/include)
+      set(GTEST_LIBRARIES gtest)
+      enable_testing()
+    else()
+      message(FATAL_ERROR "BUILD_TEST is set but unable to find gtest library")
+    endif()
   endif()
 endif()