Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fmt: add lint support for cv_bridge and image_geometry && add auto cmake support #518

Draft
wants to merge 3 commits into
base: rolling
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 41 additions & 43 deletions cv_bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
cmake_minimum_required(VERSION 3.14)
project(cv_bridge)

find_package(ament_cmake_ros REQUIRED)
find_package(ament_cmake_auto REQUIRED)
ament_auto_find_build_dependencies()

# Default to C++17
if(NOT CMAKE_CXX_STANDARD)
Expand Down Expand Up @@ -39,34 +40,47 @@ else()
endif()
endif()

find_package(rclcpp REQUIRED)
find_package(rcpputils REQUIRED)
find_package(sensor_msgs REQUIRED)

find_package(OpenCV 4 QUIET
COMPONENTS
opencv_core
opencv_imgproc
opencv_imgcodecs
CONFIG
)
if(NOT OpenCV_FOUND)
find_package(OpenCV 3 REQUIRED
COMPONENTS
opencv_core
opencv_imgproc
opencv_imgcodecs
CONFIG
)
endif()

if(NOT CV_BRIDGE_DISABLE_PYTHON)
ament_python_install_package(${PROJECT_NAME}
PACKAGE_DIR python/${PROJECT_NAME}
)
endif()

add_subdirectory(src)
ament_auto_add_library(
${PROJECT_NAME} SHARED
src/cv_bridge.cpp
src/cv_mat_sensor_msgs_image_type_adapter.cpp
src/rgb_colors.cpp
)
include(GenerateExportHeader)
generate_export_header(${PROJECT_NAME} EXPORT_FILE_NAME ${PROJECT_NAME}/${PROJECT_NAME}_export.h)
target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")

install(FILES
${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}/${PROJECT_NAME}_export.h
DESTINATION include/${PROJECT_NAME}/${PROJECT_NAME})

if(NOT CV_BRIDGE_DISABLE_PYTHON)
python3_add_library(${PROJECT_NAME}_boost MODULE src/module.cpp src/module_opencv4.cpp)
target_link_libraries(${PROJECT_NAME}_boost PRIVATE
${PROJECT_NAME}
${boost_python_target}
Python3::NumPy)
target_compile_definitions(${PROJECT_NAME}_boost PRIVATE PYTHON3)

if(OpenCV_VERSION_MAJOR VERSION_EQUAL 4)
target_compile_definitions(${PROJECT_NAME}_boost PRIVATE OPENCV_VERSION_4)
endif()

set_target_properties(${PROJECT_NAME}_boost PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/boost/
PREFIX ""
)
install(TARGETS ${PROJECT_NAME}_boost DESTINATION ${PYTHON_INSTALL_DIR}/${PROJECT_NAME}/boost/)
endif()

# cv_bridge_lib_dir is passed as APPEND_LIBRARY_DIRS for each ament_add_gtest call so
# the project library that they link against is on the library path.
Expand All @@ -75,26 +89,10 @@ add_subdirectory(src)
set(cv_bridge_lib_dir "$<TARGET_FILE_DIR:${PROJECT_NAME}>")

if(BUILD_TESTING)
# Add all the unit tests for cv_bridge
find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
add_subdirectory(test)
endif()

ament_export_dependencies(
OpenCV
sensor_msgs
rclcpp
)

ament_export_targets(export_${PROJECT_NAME})

# install the include folder
install(DIRECTORY include/ DESTINATION include/${PROJECT_NAME})

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

ament_package(
CONFIG_EXTRAS "cmake/cv_bridge-extras.cmake.in"
)
ament_auto_package()
10 changes: 0 additions & 10 deletions cv_bridge/cmake/cv_bridge-extras.cmake.in

This file was deleted.

15 changes: 15 additions & 0 deletions cv_bridge/doc/conf.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# Copyright 2023 Open Source Robotics Foundation, Inc.
# Copyright 2023 Homalozoa, Direct Drive Technology, Inc.
#
# 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.
#
# -*- coding: utf-8 -*-
#
# cv_bridge documentation build configuration file, created by
Expand Down
Loading