diff --git a/CMakeLists.txt b/CMakeLists.txt index 6a284c9c..d0ed8bbb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,60 +1,43 @@ cmake_minimum_required(VERSION 3.5) project(usb_cam) -## Find catkin macros and libraries -## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz) -## is used, also find other catkin packages - -# find_package(camera_info_manager REQUIRED) -# find_package(image_transport REQUIRED) -find_package(builtin_interfaces REQUIRED) -find_package(rclcpp REQUIRED) -find_package(std_msgs REQUIRED) -find_package(std_srvs REQUIRED) -find_package(sensor_msgs REQUIRED) +# Default to C++14 +if(NOT CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 14) +endif() + +if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") + add_compile_options(-Wall -Wextra -Wpedantic) +endif() + +find_package(ament_cmake_auto REQUIRED) +ament_auto_find_build_dependencies() ## pkg-config libraries find_package(PkgConfig REQUIRED) pkg_check_modules(avcodec libavcodec REQUIRED) pkg_check_modules(swscale libswscale REQUIRED) -# idl stuff -# msg/Format.msg - include_directories(include ${avcodec_INCLUDE_DIRS} ${swscale_INCLUDE_DIRS} ) ## Build the USB camera library -add_library(${PROJECT_NAME} src/usb_cam.cpp) -target_link_libraries(${PROJECT_NAME} - ${avcodec_LIBRARIES} - ${swscale_LIBRARIES} +ament_auto_add_library(${PROJECT_NAME} SHARED + src/usb_cam.cpp ) ## Declare a cpp executable -add_executable(${PROJECT_NAME}_node nodes/usb_cam_node.cpp) +ament_auto_add_executable(${PROJECT_NAME}_node src/usb_cam_node.cpp) target_link_libraries(${PROJECT_NAME}_node ${PROJECT_NAME} ${avcodec_LIBRARIES} ${swscale_LIBRARIES} # TODO(lucasw) should this have been in libavcodec? - avutil -) - -ament_target_dependencies(${PROJECT_NAME} - "builtin_interfaces" - "rclcpp" - "sensor_msgs" - "std_msgs" - "std_srvs" + #avutil ) -install(TARGETS ${PROJECT_NAME} ${PROJECT_NAME}_node DESTINATION lib/${PROJECT_NAME}) install(PROGRAMS scripts/show_image.py DESTINATION lib/${PROJECT_NAME}) -install(DIRECTORY config DESTINATION share/${PROJECT_NAME}) -install(DIRECTORY launch DESTINATION share/${PROJECT_NAME}) - -ament_package() +ament_auto_package() diff --git a/package.xml b/package.xml index a0703991..e8de5b07 100644 --- a/package.xml +++ b/package.xml @@ -17,6 +17,15 @@ ament_cmake + rclcpp + std_msgs + std_srvs + sensor_msgs + camera_info_manager + builtin_interfaces + image_transport + v4l-utils + ffmpeg libboost-dev libboost-lexical-cast-dev @@ -24,22 +33,6 @@ ament_lint_auto ament_lint_common - rosidl_default_generators rosidl_default_runtime diff --git a/nodes/usb_cam_node.cpp b/src/usb_cam_node.cpp similarity index 100% rename from nodes/usb_cam_node.cpp rename to src/usb_cam_node.cpp