Skip to content

Commit

Permalink
cmake cleanups
Browse files Browse the repository at this point in the history
  • Loading branch information
facontidavide committed Dec 14, 2023
1 parent 3f6bce7 commit 10409ab
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 41 deletions.
8 changes: 5 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,11 @@ cmake_minimum_required(VERSION 3.5)

PROJECT(plotjuggler_ros)

find_package(ament_cmake QUIET)
find_package(catkin QUIET)

# http://answers.ros.org/question/230877/optionally-build-a-package-with-catkin/
if( CATKIN_DEVEL_PREFIX OR catkin_FOUND OR CATKIN_BUILD_BINARY_PACKAGE)
if( catkin_FOUND OR CATKIN_DEVEL_PREFIX OR CATKIN_BUILD_BINARY_PACKAGE)
set(COMPILING_WITH_CATKIN 1)

message(STATUS "---------------------------------------------------------------------")
Expand All @@ -23,14 +26,13 @@ if( CATKIN_DEVEL_PREFIX OR catkin_FOUND OR CATKIN_BUILD_BINARY_PACKAGE)
catkin_package(
CATKIN_DEPENDS ${ROS_DEPENDENCIES} )

elseif( DEFINED ENV{AMENT_PREFIX_PATH})
elseif( ament_cmake_FOUND )
set(COMPILING_WITH_AMENT 1)

message(STATUS "---------------------------------------------------------------------")
message(STATUS "PlotJuggler is being built using AMENT. ROS2 plugins will be compiled")
message(STATUS "---------------------------------------------------------------------")

find_package(ament_cmake REQUIRED)
find_package(rclcpp REQUIRED)
find_package(rcpputils REQUIRED)
find_package(rosbag2 REQUIRED)
Expand Down
59 changes: 21 additions & 38 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
# Qt related stuff
set(CMAKE_AUTOMOC ON)
SET(CMAKE_AUTOUIC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

add_definitions(${QT_DEFINITIONS})
add_definitions(-DQT_PLUGIN)
add_definitions(-DQT_SHARED)
Expand All @@ -12,38 +7,37 @@ QT5_WRAP_UI ( COMMON_UI_SRC
rule_editing.ui
dialog_select_ros_topics.ui
dialog_with_itemlist.ui
publisher_select_dialog.ui
)
publisher_select_dialog.ui )

SET( COMMON_SRC
dialog_select_ros_topics.h
dialog_select_ros_topics.cpp
dialog_with_itemlist.h
publisher_select_dialog.h
parser_configuration.cpp
parser_configuration.h
)
parser_configuration.h )

#############

if(COMPILING_WITH_CATKIN)
include_directories(
${catkin_INCLUDE_DIRS}
${plotjuggler_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR} )

include_directories(
${catkin_INCLUDE_DIRS}
${plotjuggler_INCLUDE_DIRS}
)
if(COMPILING_WITH_CATKIN)

list(APPEND COMMON_SRC
add_library( commonROS STATIC
${COMMON_SRC}
${COMMON_UI_SRC}
qnodedialog.cpp
rule_editing.cpp)
rule_editing.cpp )

add_library( commonROS STATIC ${COMMON_SRC} ${COMMON_UI_SRC} )
target_compile_definitions(commonROS PUBLIC DISABLE_RULE_EDITING)
target_link_libraries( commonROS PRIVATE
target_link_libraries( commonROS
${Qt5Widgets_LIBRARIES}
${Qt5Xml_LIBRARIES}
${plotjuggler_LIBRARIES}
${catkin_LIBRARIES})
${catkin_LIBRARIES}
${plotjuggler_LIBRARIES})

#########
add_library( DataLoadROS SHARED
Expand All @@ -69,28 +63,25 @@ if(COMPILING_WITH_CATKIN)
#######################################################################
elseif(COMPILING_WITH_AMENT)

include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )

list( APPEND COMMON_SRC ros_parsers/ros2_parser.cpp )

set(AMENT_DEPENDENCIES
rclcpp
rosbag2
rcpputils
rosbag2_transport
tf2_msgs
tf2_ros
plotjuggler
)
plotjuggler )

add_library( commonROS STATIC ${COMMON_SRC} ${COMMON_UI_SRC})
add_library( commonROS STATIC
${COMMON_SRC}
${COMMON_UI_SRC}
ros_parsers/ros2_parser.cpp )

target_compile_definitions(commonROS PUBLIC DISABLE_RULE_EDITING)
target_link_libraries( commonROS
${Qt5Widgets_LIBRARIES}
${Qt5Xml_LIBRARIES}
${plotjuggler_LIBRARIES})

ament_target_dependencies( commonROS ${AMENT_DEPENDENCIES})

#############
Expand All @@ -113,15 +104,9 @@ elseif(COMPILING_WITH_AMENT)
message(STATUS "Detected Humble")
target_compile_definitions(TopicPublisherROS2 PUBLIC ROS_HUMBLE)
endif()

add_executable(test_ros2_parser
ros_parsers/test_ros2_parser.cpp
ros_parsers/ros2_parser.cpp)
target_link_libraries( test_ros2_parser commonROS)
ament_target_dependencies( test_ros2_parser ${AMENT_DEPENDENCIES})

endif()


#######################################################################

if(COMPILING_WITH_CATKIN)
Expand All @@ -130,11 +115,9 @@ if(COMPILING_WITH_CATKIN)
DataStreamROS
RosTopicPublisher
RosoutPublisher
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}/
)
DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}/ )
elseif(COMPILING_WITH_AMENT)
install(TARGETS
test_ros2_parser
DataLoadROS2
DataStreamROS2
TopicPublisherROS2
Expand Down

0 comments on commit 10409ab

Please sign in to comment.