Skip to content

Commit

Permalink
Generalize gz vendor use and modernize CMake (#232)
Browse files Browse the repository at this point in the history
* Generalize gz vendor use and modernize CMake

Signed-off-by: Jose Luis Rivero <[email protected]>

* Do not use component targets in ament_target_dependencies

* Fix indentation

---------

Signed-off-by: Jose Luis Rivero <[email protected]>
  • Loading branch information
j-rivero authored Sep 19, 2024
1 parent 71cda80 commit 63e1c4c
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
34 changes: 19 additions & 15 deletions irobot_create_common/irobot_create_toolbox/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,42 +11,46 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
endif()

find_package(ament_cmake REQUIRED)
find_package(gz-math7 REQUIRED)
find_package(gz_math_vendor REQUIRED)
find_package(gz-math REQUIRED)
find_package(rclcpp REQUIRED)

#### Libraries

set(dependencies
gz-math7
rclcpp
)

add_library(irobot_create_toolbox SHARED)
target_sources(
irobot_create_toolbox
PRIVATE
src/polar_coordinates.cpp
)
target_include_directories(irobot_create_toolbox PUBLIC include)
ament_target_dependencies(irobot_create_toolbox
${dependencies}
target_include_directories(irobot_create_toolbox PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")

target_link_libraries(irobot_create_toolbox
PUBLIC
gz-math::gz-math
${rclcpp_TARGETS}
)

#### Install

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

install(DIRECTORY include/
DESTINATION include
DESTINATION include/${PROJECT_NAME}
)
ament_export_targets(export_${PROJECT_NAME})
ament_export_dependencies(
gz_math_vendor
gz-math
rclcpp
)

ament_export_include_directories(include)
ament_export_libraries(irobot_create_toolbox)
ament_export_dependencies(${dependencies})

if(BUILD_TESTING)
find_package(ament_lint_auto REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion irobot_create_gz/irobot_create_gz_plugins/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ find_package(ament_cmake REQUIRED)
set(OpenGL_GL_PREFERENCE LEGACY)

# Find the Ignition gui library
find_package(gz-gui8 REQUIRED)
find_package(gz_gui_vendor REQUIRED)
add_subdirectory(Create3Hmi)

if(BUILD_TESTING)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ endif()

set(CMAKE_AUTOMOC ON)

# Find Qt5
find_package(gz_gui_vendor REQUIRED)
find_package(gz-gui REQUIRED)
find_package(Qt5
COMPONENTS
Core
Expand All @@ -15,8 +16,6 @@ find_package(Qt5
REQUIRED
)

find_package(gz-gui8 REQUIRED)

qt5_add_resources(resources_rcc Create3Hmi.qrc)

add_library(
Expand All @@ -32,16 +31,17 @@ include_directories(
${Qt5Quick_INCLUDE_DIRS}
${Qt5QuickControls2_INCLUDE_DIRS}
)
target_link_libraries(
Create3Hmi
target_link_libraries(Create3Hmi
PUBLIC
gz-gui::gz-gui
${Qt5Core_LIBRARIES}
${Qt5Qml_LIBRARIES}
${Qt5Quick_LIBRARIES}
${Qt5QuickControls2_LIBRARIES}
)
ament_target_dependencies(
Create3Hmi
gz-gui8
ament_target_dependencies(Create3Hmi
gz_gui_vendor
gz-gui
)

install(
Expand Down

0 comments on commit 63e1c4c

Please sign in to comment.