-
Notifications
You must be signed in to change notification settings - Fork 103
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for building tests within an ament context (#200)
* Refs #20328: Add package.xml and colcon.pkg compatible with ROS 2 CI Signed-off-by: EduPonz <[email protected]> * Refs #20328: Add macro to find gtest both in and outside ament context Signed-off-by: EduPonz <[email protected]> * Refs #20328: Use new macro to find gtest Signed-off-by: EduPonz <[email protected]> * Refs #20328: Apply suggestions Signed-off-by: EduPonz <[email protected]> * Refs #20328: Fix typo Signed-off-by: EduPonz <[email protected]> --------- Signed-off-by: EduPonz <[email protected]>
- Loading branch information
Showing
4 changed files
with
83 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
# Copyright 2024 Proyectos y Sistemas de Mantenimiento SL (eProsima). | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
macro(find_or_add_gtest) | ||
# Check if building on an ament context, i.e. ROS 2 | ||
# Thanks to https://github.com/facontidavide/PlotJuggler/blob/main/CMakeLists.txt#L66 | ||
find_package(ament_cmake QUIET) | ||
|
||
# This is a ROS 2 build | ||
if(ament_cmake_FOUND) | ||
# Find all GTest vendor required packages | ||
find_package(ament_cmake REQUIRED) | ||
find_package(gtest_vendor REQUIRED) | ||
find_package(ament_cmake_gtest REQUIRED) | ||
|
||
# Find GTest | ||
ament_find_gtest() | ||
|
||
# Add aliases for GTest libraries so we can use them as targets independently of the context | ||
add_library(GTest::gtest ALIAS gtest) | ||
add_library(GTest::gtest_main ALIAS gtest_main) | ||
target_link_libraries(gtest_main gtest) | ||
|
||
# This is a non-ROS 2 build | ||
else() | ||
# Find GTest normally | ||
find_package(GTest CONFIG REQUIRED) | ||
endif() | ||
endmacro() |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
{ | ||
"name": "fastcdr", | ||
"type": "cmake", | ||
"dependencies" : ["googletest-distribution"] | ||
} | ||
name: fastcdr | ||
type: cmake | ||
dependencies: | ||
# Needed for test compilation in ROS 2 CI | ||
- ament_cmake_gtest | ||
- ament_cmake | ||
# Needed for test compilation in eProsima CI | ||
- googletest-distribution |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?xml version="1.0"?> | ||
<?xml-model href="http://download.ros.org/schema/package_format2.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?> | ||
<package format="2"> | ||
<name>fastcdr</name> | ||
<version>2.1.3</version> | ||
<description> | ||
*eProsima Fast CDR* is a C++ serialization library implementing the Common Data Representation (CDR) mechanism defined by the Object Management Group (OMG) consortium. CDR is the serialization mechanism used in DDS for the DDS Interoperability Wire Protocol (DDSI-RTPS). | ||
</description> | ||
<maintainer email="[email protected]">Miguel Company</maintainer> | ||
<maintainer email="[email protected]">Eduardo Ponz</maintainer> | ||
<license file="LICENSE">Apache 2.0</license> | ||
|
||
<url type="website">https://www.eprosima.com/</url> | ||
<url type="bugtracker">https://github.com/eProsima/Fast-CDR/issues</url> | ||
<url type="repository">https://github.com/eProsima/Fast-CDR</url> | ||
|
||
<buildtool_depend>cmake</buildtool_depend> | ||
<doc_depend>doxygen</doc_depend> | ||
|
||
<test_depend>ament_cmake_gtest</test_depend> | ||
<test_depend>ament_cmake</test_depend> | ||
|
||
<export> | ||
<build_type>cmake</build_type> | ||
</export> | ||
</package> |
This file contains 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