blob: b0bfb8bf16021222a3392ab7e3017471bb888836 [file] [log] [blame]
Patrick Williamsac13d5f2023-11-24 18:59:46 -06001From 77da477840f89da7ced29da315de77571e8f190e Mon Sep 17 00:00:00 2001
2From: Martin Jansa <martin.jansa@gmail.com>
3Date: Fri, 20 Oct 2023 22:57:48 +0200
4Subject: [PATCH] CMakeLists.txt: fix googletest related options
5
6* https://cmake.org/cmake/help/book/mastering-cmake/chapter/Writing%20CMakeLists%20Files.html
7 says that CMake options are case-sensitive and I don't see lower-case version in
8 currently used googletest submodules and gtest is indeed installed with leveldb
9
10* install_gmock option I don't see at all, so I've kept it as is, INSTALL_GTEST, BUILD_GMOCK
11 do exist as upper-case
12
13$ grep -Ri install_.*mock .
14./CMakeLists.txt: set(install_gmock OFF)
15./third_party/googletest/googlemock/CMakeLists.txt:install_project(gmock gmock_main)
16$ grep -Ri build_gmock .
17./CMakeLists.txt: set(BUILD_GMOCK ON)
18./third_party/googletest/googletest/README.md:cmake .. -DBUILD_GMOCK=OFF
19./third_party/googletest/CMakeLists.txt:option(BUILD_GMOCK "Builds the googlemock subproject" ON)
20./third_party/googletest/CMakeLists.txt:if(BUILD_GMOCK)
21$ grep -Ri install_gtest .
22./CMakeLists.txt: set(INSTALL_GTEST OFF)
23./third_party/googletest/googletest/cmake/internal_utils.cmake: if(INSTALL_GTEST)
24./third_party/googletest/googletest/CMakeLists.txt:if (INSTALL_GTEST)
25./third_party/googletest/CMakeLists.txt:option(INSTALL_GTEST "Enable installation of googletest. (Projects embedding googletest may want to turn this OFF.)" ON)
26
27* also use CACHE and FORCE as sugested in:
28 https://cmake.org/cmake/help/latest/command/set.html
29 https://stackoverflow.com/questions/20239334/cmake-set-subdirectory-options
30 for the value to correctly propagate into third_party/googletest subdirectory
31
32Signed-off-by: Martin Jansa <martin.jansa@gmail.com>
33---
34Upstream-Status: Submitted [https://github.com/google/leveldb/pull/1152]
35
36 CMakeLists.txt | 6 +++---
37 1 file changed, 3 insertions(+), 3 deletions(-)
38
39diff --git a/CMakeLists.txt b/CMakeLists.txt
40index fda9e01..f8a2629 100644
41--- a/CMakeLists.txt
42+++ b/CMakeLists.txt
43@@ -295,9 +295,9 @@ if(LEVELDB_BUILD_TESTS)
44
45 # Prevent overriding the parent project's compiler/linker settings on Windows.
46 set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
47- set(install_gtest OFF)
48- set(install_gmock OFF)
49- set(build_gmock ON)
50+ set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
51+ set(install_gmock OFF CACHE BOOL "" FORCE)
52+ set(BUILD_GMOCK ON CACHE BOOL "" FORCE)
53
54 # This project is tested using GoogleTest.
55 add_subdirectory("third_party/googletest")