#1061533 cmake: CMake doesn't find googletest

Package:
cmake
Source:
cmake
Description:
cross-platform, open-source make system
Submitter:
Jonathan Neuschäfer
Date:
2024-02-27 15:36:03 UTC
Severity:
normal
#1061533#5
Date:
2024-01-26 00:20:03 UTC
From:
To:
Hello, I have installed cmake 3.28.1-1 and googletest 1.14.0-1 from
Debian testing, and I'm trying to use GTest with CMake as follows:

```
# CMakeLists.txt
cmake_minimum_required(VERSION 3.14)
project(foo)

enable_testing()
find_package(GTest REQUIRED)

add_executable(foo foo.cc)
target_link_libraries(foo GTest::gtest GTest::gtest_main)

add_test(AllTestsInFoo foo)
```


```
// foo.cc
TEST(Foo, foo) {
	EXPECT_EQ(1 + 2, 3);
}
```

This is very close to the example provided in /usr/share/cmake-3.28/Modules/FindGTest.cmake,
but it fails:

```
$ cmake .
-- The C compiler identification is GNU 13.2.0
-- The CXX compiler identification is GNU 13.2.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/lib/ccache/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/lib/ccache/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at /usr/share/cmake-3.28/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-3.28/Modules/FindPackageHandleStandardArgs.cmake:600 (_FPHSA_FAILURE_MESSAGE)
  /usr/share/cmake-3.28/Modules/FindGTest.cmake:270 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
  CMakeLists.txt:5 (find_package)

#1061533#10
Date:
2024-01-26 00:39:17 UTC
From:
To:
Sorry for the noise, I found the problem:

For this to work, I need to install libgtest-dev.

Perhaps the googletest package could include a hint to that effect in
the description.

#1061533#15
Date:
2024-01-26 00:39:17 UTC
From:
To:
Sorry for the noise, I found the problem:

For this to work, I need to install libgtest-dev.

Perhaps the googletest package could include a hint to that effect in
the description.