PacktPublishing / Cpp-High-Performance-Second-Edition

C++ High Performance Second Edition, published by Packt
MIT License
211 stars 98 forks source link

Google Test build failure Ubuntu 20.04 CMake 3.16.3 g++ 13.1 #12

Open daggilli opened 2 months ago

daggilli commented 2 months ago

As cloned from branch master, the cmake step for Ubuntu/gcc fails while building Google Test. The error is a possibly uninitialised variable "dummy".

In file included from XXX/.hunter/_Base/0a8ede4/792e364/69c73d8/Build/GTest/Source/googletest/src/gtest-all.cc:42:
XXX/.hunter/_Base/0a8ede4/792e364/69c73d8/Build/GTest/Source/googletest/src/gtest-death-test.cc: In function
‘bool testing::internal::StackGrowsDown()’:
XXX/.hunter/_Base/0a8ede4/792e364/69c73d8/Build/GTest/Source/googletest/src/gtest-death-test.cc:1301:24: 
error: ‘dummy’ may be used uninitialized [-Werror=maybe-uninitialized]
 1301 |   StackLowerThanAddress(&dummy, &result);
      |   ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
XXX/.hunter/_Base/0a8ede4/792e364/69c73d8/Build/GTest/Source/googletest/src/gtest-death-test.cc:1290:13: note:
by argument 1 of type ‘const void*’ to ‘void testing::internal::StackLowerThanAddress(const void*, bool*)’ declared here
 1290 | static void StackLowerThanAddress(const void* ptr, bool* result) {
      |             ^~~~~~~~~~~~~~~~~~~~~
XXX/.hunter/_Base/0a8ede4/792e364/69c73d8/Build/GTest/Source/googletest/src/gtest-death-test.cc:1299:7: note:
‘dummy’ declared here
 1299 |   int dummy;

This appears to be the result of CMake trying to use an obsolete version of hunter. It is resolved by setting the huntergate URL in line 6 of CMakeLists.txt to the latest version, found at https://github.com/cpp-pm/hunter/releases (0.25.6 at time of writing).

utsusemioxo commented 1 month ago

It works for me ! Thank you!