Skip to content

Commit

Permalink
Update to use modern CMake idioms
Browse files Browse the repository at this point in the history
Signed-off-by: Alberto Tudela <[email protected]>
  • Loading branch information
ajtudela committed Jul 31, 2024
1 parent 8c4f09d commit 7013c16
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 35 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@
Changelog for package slg_msgs
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

3.9.1 (31-07-2024)
------------------
* Update to use modern CMake idioms.

3.9.0 (29-02-2024)
------------------
* Improve formatting.
Expand Down
37 changes: 17 additions & 20 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,33 +66,26 @@ rosidl_generate_interfaces(${PROJECT_NAME}
DEPENDENCIES std_msgs geometry_msgs
)

add_library(${PROJECT_NAME}_includes INTERFACE)
target_include_directories(${PROJECT_NAME}_includes INTERFACE
set(library_name slg_core)

add_library(${library_name} INTERFACE)
target_include_directories(${library_name} INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)

# ##########
# # Build ##
# ##########
# # Specify additional locations of header files
# # Your package locations should be listed before other locations
include_directories(
include
)

# ############
# # Install ##
# ############
install(DIRECTORY include/${PROJECT_NAME}/
install(DIRECTORY include/
DESTINATION include/${PROJECT_NAME}
FILES_MATCHING PATTERN "*.hpp"

# PATTERN ".svn" EXCLUDE
)

install(TARGETS ${PROJECT_NAME}_includes
EXPORT export_${PROJECT_NAME}
install(TARGETS ${library_name}
EXPORT ${library_name}
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
)

# ############
Expand All @@ -110,7 +103,11 @@ endif()
# ##################################
# # ament specific configuration ##
# ##################################
ament_export_include_directories(include)
ament_export_targets(export_${PROJECT_NAME})
ament_export_dependencies(rosidl_default_runtime)
ament_export_include_directories(include/${PROJECT_NAME})
ament_export_dependencies(
geometry_msgs
std_msgs
rosidl_default_runtime
)
ament_export_targets(${library_name})
ament_package()
2 changes: 1 addition & 1 deletion package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<?xml-model href="http://download.ros.org/schema/package_format3.xsd" schematypens="http://www.w3.org/2001/XMLSchema"?>
<package format="3">
<name>slg_msgs</name>
<version>3.8.0</version>
<version>3.9.1</version>
<description>This package provides classes and messages to interact with laser related geometry.</description>
<maintainer email="[email protected]">Alberto Tudela</maintainer>
<license>Apache-2.0</license>
Expand Down
26 changes: 15 additions & 11 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,28 @@
ament_add_gtest(test_point2d
test_point2d.cpp
)
ament_target_dependencies(test_point2d
geometry_msgs
target_link_libraries(test_point2d
${geometry_msgs_TARGETS}
${library_name}
)

ament_add_gtest(test_polygon
test_polygon.cpp
test_polygon.cpp
)
ament_target_dependencies(test_polygon
geometry_msgs
target_link_libraries(test_polygon
${geometry_msgs_TARGETS}
${library_name}
)

ament_add_gtest(test_segment2d
test_segment2d.cpp
test_segment2d.cpp
)
rosidl_get_typesupport_target(cpp_typesupport_target
${PROJECT_NAME} rosidl_typesupport_cpp)

ament_target_dependencies(test_segment2d
geometry_msgs
${PROJECT_NAME} rosidl_typesupport_cpp
)
target_link_libraries(test_segment2d "${cpp_typesupport_target}")

target_link_libraries(test_segment2d
${geometry_msgs_TARGETS}
${library_name}
"${cpp_typesupport_target}"
)
1 change: 1 addition & 0 deletions test/test_point2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

#include "gtest/gtest.h"
#include "geometry_msgs/msg/point.hpp"
#include "slg_msgs/point2D.hpp"

// Default constructor, constructor with values and copy constructor
Expand Down
2 changes: 2 additions & 0 deletions test/test_polygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// limitations under the License.

#include "gtest/gtest.h"
#include "geometry_msgs/msg/polygon.hpp"
#include "geometry_msgs/msg/point32.hpp"
#include "slg_msgs/polygon.hpp"

slg::Polygon square()
Expand Down
6 changes: 3 additions & 3 deletions test/test_segment2d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ TEST(Segment2DTest, constructors) {
EXPECT_DOUBLE_EQ(segment1.get_last_centroid().x, 0.0);
EXPECT_DOUBLE_EQ(segment1.get_last_centroid().y, 0.0);
// Constructor with values
slg::Segment2D segment2(1, slg::Point2D(1.0, 2.0, slg::PERSON), slg::Point2D(
3.0, 4.0,
slg::PERSON),
slg::Segment2D segment2(1,
slg::Point2D(1.0, 2.0, slg::PERSON),
slg::Point2D(3.0, 4.0, slg::PERSON),
slg::Point2D(5.0, 6.0, slg::PERSON));
EXPECT_EQ(segment2.get_id(), 1);
EXPECT_EQ(segment2.get_label(), slg::BACKGROUND);
Expand Down

0 comments on commit 7013c16

Please sign in to comment.