You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
CMake: add option to use Google Test already installed on system (abseil#969)
As of this change, you can use `-DABSL_USE_EXTERNAL_GOOGLETEST=ON -DABSL_FIND_GOOGLETEST=ON` to have Abseil use the standard CMake find_package(GTest) mechanism.
Then you need to configure and build Abseil. Make sure you enable `ABSL_USE_EXTERNAL_GOOGLETEST` and `ABSL_FIND_GOOGLETEST`. You also need to enable `ABSL_ENABLE_INSTALL` so that you can install Abseil itself.
(`CMAKE_PREFIX_PATH` is where you already have Google Test installed; `CMAKE_INSTALL_PREFIX` is where you want to have Abseil installed; they can be different.)
Copy file name to clipboardexpand all lines: CMakeLists.txt
+32-7
Original file line number
Diff line number
Diff line change
@@ -102,9 +102,18 @@ endif()
102
102
## pthread
103
103
find_package(Threads REQUIRED)
104
104
105
+
include(CMakeDependentOption)
106
+
105
107
option(ABSL_USE_EXTERNAL_GOOGLETEST
106
108
"If ON, Abseil will assume that the targets for GoogleTest are already provided by the including project. This makes sense when Abseil is used with add_subproject."OFF)
107
109
110
+
cmake_dependent_option(ABSL_FIND_GOOGLETEST
111
+
"If ON, Abseil will use find_package(GTest) rather than assuming that GoogleTest is already provided by the including project."
112
+
ON
113
+
"ABSL_USE_EXTERNAL_GOOGLETEST"
114
+
OFF)
115
+
116
+
108
117
option(ABSL_USE_GOOGLETEST_HEAD
109
118
"If ON, abseil will download HEAD from GoogleTest at config time."OFF)
message(FATAL_ERROR "ABSL_USE_EXTERNAL_GOOGLETEST is ON and ABSL_FIND_GOOGLETEST is OFF, which means that the top-level project must build the Google Test project. However, the target gtest was not found.")
0 commit comments