[20328] Add support for building tests within an ament context #200
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.
This PR adds support for building Fast CDR within an ament context (as is the ROS 2 CI).
Since Fast CDR v2.0.0, the CMake option to build the tests is the CMake standard
-DBUILD_TESTING=ON
. When trying to introduce Fast CDR v2 in ROS 2, ROS 2 CI was failing because that CI builds all packages with-DBUILD_TESTING=ON
, and in that context Fast CDR could not find GTest because is not installed in the system.In the ROS 2 ecosystem, there are vendor packages within ament for GTest, which are the ones the CI is using. However, Fast CDR's CMakeLists.txt was doing a plain
find_package(GTest REQUIRED)
, and thus failing. In order to find GTest in that context, ament's infrastructure needs to be used. This PR:find_or_add_gtest
to correctly include GTest both in and outside an ament context.Thanks to @clalancette and @mjcarroll for their help on this