diff options
author | David Kalnischkies <david@kalnischkies.de> | 2023-11-18 13:40:40 +0000 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2023-11-18 13:40:40 +0000 |
commit | 1f5ecf5d211a073892e05047becd4e55f3e055c9 (patch) | |
tree | 44514094230b9758ca6125e08c2890dc46309497 | |
parent | dc7a8b3050a2a43f49515a03ae19713dfced75dc (diff) |
Use different variable name in GTest source path detection
We used GTEST_ROOT, which becomes an issue with 3.27 as that variable
would influence find_package behaviour by providing PREFIXES –
introduced with potentially mixed-cased name in 3.12.
CMake Warning (dev) at test/libapt/CMakeLists.txt:8 (find_package):
Policy CMP0144 is not set: find_package uses upper-case <PACKAGENAME>_ROOT
variables. Run "cmake --help-policy CMP0144" for policy details. Use the
cmake_policy command to set the policy and suppress this warning.
CMake variable GTEST_ROOT is set to:
/usr/src/googletest/googletest
For compatibility, find_package is ignoring the variable, but code in a
.cmake module might still use it.
As using this new feature isn't what we wanted at all, we just use a
different variable name to avoid the warning and potential future
problems if we would keep using this name.
-rw-r--r-- | test/libapt/CMakeLists.txt | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/test/libapt/CMakeLists.txt b/test/libapt/CMakeLists.txt index 11d4d22c7..6bbe409b7 100644 --- a/test/libapt/CMakeLists.txt +++ b/test/libapt/CMakeLists.txt @@ -1,6 +1,6 @@ if (WITH_TESTS) set(PROJECT_TEST_LIBRARIES apt-private) - find_path(GTEST_ROOT src/gtest.cc + find_path(GTEST_SRCPATH src/gtest.cc /usr/src/googletest/googletest /usr/src/googletest /usr/src/gtest @@ -8,10 +8,10 @@ if (WITH_TESTS) find_package(GTest) set(GTEST_DEPENDENCIES) - if(NOT GTEST_FOUND AND EXISTS ${GTEST_ROOT}) + if(NOT GTEST_FOUND AND EXISTS ${GTEST_SRCPATH}) include(ExternalProject) ExternalProject_Add(gtest PREFIX ./gtest - SOURCE_DIR ${GTEST_ROOT} + SOURCE_DIR ${GTEST_SRCPATH} INSTALL_COMMAND true) link_directories(${CMAKE_CURRENT_BINARY_DIR}/gtest/src/gtest-build) @@ -20,9 +20,9 @@ if (WITH_TESTS) set(GTEST_LIBRARIES "-lgtest") set(GTEST_DEPENDENCIES "gtest") set(GTEST_FOUND TRUE) - find_path(GTEST_INCLUDE_DIRS NAMES gtest/gtest.h PATHS ${GTEST_ROOT}/include) + find_path(GTEST_INCLUDE_DIRS NAMES gtest/gtest.h PATHS ${GTEST_SRCPATH}/include) - message(STATUS "Found GTest at ${GTEST_ROOT}, headers at ${GTEST_INCLUDE_DIRS}") + message(STATUS "Found GTest at ${GTEST_SRCPATH}, headers at ${GTEST_INCLUDE_DIRS}") endif() if (NOT GTEST_FOUND) |