diff options
author | Daniel Richard G <skunk@iSKUNK.ORG> | 2023-10-17 08:31:26 -0700 |
---|---|---|
committer | Copybara-Service <copybara-worker@google.com> | 2023-10-17 08:32:18 -0700 |
commit | b87875aa079571a3aa8829d61538672d88657566 (patch) | |
tree | cfc6215cfdd5c7e253c9bc7e2702f570c424bd46 | |
parent | 2a18ba753bca64e79f6d9857a9f64e638b32c371 (diff) |
PR #1546: CMake: Enable CMP0074 so that GTest_ROOT can be specified
Imported from GitHub PR https://github.com/abseil/abseil-cpp/pull/1546
I am building Abseil with tests enabled and an external GTest build, i.e.
```
-DABSL_BUILD_TESTING=ON
-DABSL_USE_EXTERNAL_GOOGLETEST=ON
-DABSL_FIND_GOOGLETEST=ON
-DGTest_ROOT=/path/to/googletest/1.14.0
```
However, CMake (3.20.2) configuration yielded this result:
```
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
CMake Warning (dev) at CMakeLists.txt:150 (find_package):
Policy CMP0074 is not set: find_package uses <PackageName>_ROOT variables.
Run "cmake --help-policy CMP0074" for policy details. Use the cmake_policy
command to set the policy and suppress this warning.
CMake variable GTest_ROOT is set to:
/path/to/googletest/1.14.0
For compatibility, CMake is ignoring the variable.
This warning is for project developers. Use -Wno-dev to suppress it.
CMake Error at /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find GTest (missing: GTEST_LIBRARY GTEST_INCLUDE_DIR
GTEST_MAIN_LIBRARY)
Call Stack (most recent call first):
/usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
/usr/share/cmake/Modules/FindGTest.cmake:255 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:150 (find_package)
-- Configuring incomplete, errors occurred!
See also "/tmp/abseil-build/CMakeFiles/CMakeOutput.log".
See also "/tmp/abseil-build/CMakeFiles/CMakeError.log".
```
This PR sets `CMP0074=NEW` so that the GTest install location can be specified via `GTest_ROOT`.
Merge 4e4f035affd9b8af739634afdf9c2e80d14c2391 into 2a18ba753bca64e79f6d9857a9f64e638b32c371
Merging this change closes #1546
COPYBARA_INTEGRATE_REVIEW=https://github.com/abseil/abseil-cpp/pull/1546 from iskunk:feature/fix-gtest-root 4e4f035affd9b8af739634afdf9c2e80d14c2391
PiperOrigin-RevId: 574159856
Change-Id: Ifc796500c3a6403d28a027375116437bc743205a
-rw-r--r-- | CMakeLists.txt | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 16915a14..ca74b80d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,11 @@ if (POLICY CMP0048) cmake_policy(SET CMP0048 NEW) endif (POLICY CMP0048) +# Honor the GTest_ROOT variable if specified +if (POLICY CMP0074) + cmake_policy(SET CMP0074 NEW) +endif (POLICY CMP0074) + # option() honor variables if (POLICY CMP0077) cmake_policy(SET CMP0077 NEW) |