Make GoogleTest version compatible with C++11 / resolve errors running C++11 test on Ubuntu 24.04 - #1260
Open
garcia556 wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem Statement
While running test suites of generated C++11 code on recent OS versions of Ubuntu 24 or MacOS they fail with error like "googletest library requires at least C++14 standard".
I could not find any relevant issue so decided to go staright with the PR to fix that.
Root Cause
It does not fail in CI because Ubuntu 22.04 runners are used:
.github/workflows/test.ymlline 12GoogleTest library is installed as libgtest-dev APT package:
.github/workflows/test.ymlline 31Its Ubuntu 22.04 version is 1.11.0 and it supports C++11 standard.
Latest GoogleTest version to support C++11 is 1.12.1.
However running the same on Ubuntu 24.04 installs GoogleTest version 1.14.0 which explicitly requires C++14.
Same is happening on MacOS, brew googletest version is 1.18.0.
Solution Design
C++ standard change seems too radical to me so I would suggest to decouple GoogleTest version from environment and download its sources (v1.12.1) during test suites runs.
This solution also works for MacOS (causing other issues with ARM compability but that's another topic).
The change also opens path to update CI runners to Ubuntu 24.04 (or even 26.04) as eventually 22.04 will reach EOL.
Testing
Tested on clean Ubuntu 24.04 VM without libgtest-dev installed:
sudo apt install --yes build-essential git clone https://github.com/ArduPilot/mavlink.git ln -sf ./mavlink/message_definitions message_definitions git clone https://github.com/garcia556/pymavlink.git cd pymavlink git switch make-gtest-portable-to-support-cpp11 git pull ./test_generator.sh