aau-cns / mars_lib

MaRS: A Modular and Robust Sensor-Fusion Framework
Other
258 stars 34 forks source link

Googletest, warning treated as error in debug build with GCC11 #8

Closed Chris-Bee closed 1 year ago

Chris-Bee commented 1 year ago

The previous Googletest version produces errors during the debug build with a newer GCC version (GCC 11) used by Ubuntu 22.04 currently used as runs-on: ubuntu-latest for Github workflows.

In file included from /home/runner/work/mars_lib/mars_lib/source/tests/googletest/googletest/src/gtest-all.cc:43:
/home/runner/work/mars_lib/mars_lib/source/tests/googletest/googletest/src/gtest-death-test.cc: In function ‘bool testing::internal::StackGrowsDown()’:
/home/runner/work/mars_lib/mars_lib/source/tests/googletest/googletest/src/gtest-death-test.cc:1008:24: error: ‘dummy’ may be used uninitialized [-Werror=maybe-uninitialized]
 1008 |   StackLowerThanAddress(&dummy, &result);
      |   ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~
/home/runner/work/mars_lib/mars_lib/source/tests/googletest/googletest/src/gtest-death-test.cc:998:6: note: by argument 1 of type ‘const void*’ to ‘void testing::internal::StackLowerThanAddress(const void*, bool*)’ declared here
  998 | void StackLowerThanAddress(const void* ptr, bool* result) {
      |      ^~~~~~~~~~~~~~~~~~~~~
/home/runner/work/mars_lib/mars_lib/source/tests/googletest/googletest/src/gtest-death-test.cc:1006:7: note: ‘dummy’ declared here
 1006 |   int dummy;
      |       ^~~~~
cc1plus: all warnings being treated as errors
gmake[2]: *** [source/tests/googletest/googlemock/CMakeFiles/gmock.dir/build.make:76: source/tests/googletest/googlemock/CMakeFiles/gmock.dir/__/googletest/src/gtest-all.cc.o] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:551: source/tests/googletest/googlemock/CMakeFiles/gmock.dir/all] Error 2
gmake: *** [Makefile:146: all] Error 2
Chris-Bee commented 1 year ago

Updated Googletest to version 1.13.0 to solve this issue in 2123ad41394dfbd8ec8ea47d36eba045a762905e

Additional steps, unrelated to the initial issue, needed to be taken to build the new Googletest version successfully. Modification of the Googletest CMakeLists according to Googletest Build Issue was required to address the following error:

CMake Warning at CMakeLists.txt:51 (project):
VERSION keyword not followed by a value or was followed by a value that
expanded to nothing.

CMake Error at CMakeLists.txt:127 (set_target_properties):
set_target_properties called with incorrect number of arguments.

CMake Error at CMakeLists.txt:129 (set_target_properties):
set_target_properties called with incorrect number of arguments.