Skip to content

Commit

Permalink
Revert "More alot (#419)"
Browse files Browse the repository at this point in the history
This reverts commit 9ea8908.

Signed-off-by: Kenji Brameld <kenjibrameld@gmail.com>
(cherry picked from commit 1a78fcb)
  • Loading branch information
ijnek authored and mergify[bot] committed Sep 17, 2022
1 parent 8eb2ec8 commit a09a5e5
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 60 deletions.
12 changes: 8 additions & 4 deletions cv_bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.14)
cmake_minimum_required(VERSION 3.5)
project(cv_bridge)

find_package(ament_cmake_ros REQUIRED)
Expand Down Expand Up @@ -33,7 +33,7 @@ if(NOT ANDROID)
endif()
endif()
else()
find_package(Boost REQUIRED COMPONENTS python)
find_package(Boost REQUIRED)
endif()

find_package(rcpputils REQUIRED)
Expand Down Expand Up @@ -79,10 +79,14 @@ ament_export_dependencies(
sensor_msgs
)

ament_export_targets(export_${PROJECT_NAME})
ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME})

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

install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
Expand Down
84 changes: 56 additions & 28 deletions cv_bridge/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,46 +2,74 @@
add_library(${PROJECT_NAME} cv_bridge.cpp 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}>")
target_link_libraries(${PROJECT_NAME} PUBLIC
${sensor_msgs_TARGETS}
opencv_core
opencv_imgproc
opencv_imgcodecs)
target_link_libraries(${PROJECT_NAME} PRIVATE
Boost::headers
rcpputils::rcpputils)

install(TARGETS ${PROJECT_NAME} EXPORT export_${PROJECT_NAME}
target_include_directories(${PROJECT_NAME}
PUBLIC "$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}>"
${PROJECT_SOURCE_DIR}/include
${Boost_INCLUDE_DIRS})
ament_target_dependencies(${PROJECT_NAME}
"OpenCV"
"sensor_msgs"
)
target_link_libraries(${PROJECT_NAME} ${PYTHON_LIBRARIES} ${Boost_LIBRARIES} ${OpenCV_LIBRARIES} rcpputils::rcpputils)

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

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

if(NOT ANDROID)
find_package(Python3 REQUIRED COMPONENTS Development NumPy)
# add a Boost Python library
find_package(PythonInterp REQUIRED)
find_package(PythonLibs "${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}")

Python3_add_library(${PROJECT_NAME}_boost MODULE module.cpp module_opencv3.cpp)
target_link_libraries(${PROJECT_NAME}_boost PRIVATE
${PROJECT_NAME}
Boost::python
Python3::NumPy)
target_compile_definitions(${PROJECT_NAME}_boost PRIVATE PYTHON3)
# Get the numpy include directory from its python module
if(NOT PYTHON_NUMPY_INCLUDE_DIR)
execute_process(COMMAND ${PYTHON_EXECUTABLE} -c "import numpy; print(numpy.get_include())"
RESULT_VARIABLE PYTHON_NUMPY_PROCESS
OUTPUT_VARIABLE PYTHON_NUMPY_INCLUDE_DIR
OUTPUT_STRIP_TRAILING_WHITESPACE)

if(OpenCV_VERSION_MAJOR VERSION_EQUAL 4)
target_compile_definitions(${PROJECT_NAME}_boost PRIVATE OPENCV_VERSION_4)
if(PYTHON_NUMPY_PROCESS EQUAL 0)
file(TO_CMAKE_PATH "${PYTHON_NUMPY_INCLUDE_DIR}" PYTHON_NUMPY_INCLUDE_CMAKE_PATH)
set(PYTHON_NUMPY_INCLUDE_DIR ${PYTHON_NUMPY_INCLUDE_CMAKE_PATH} CACHE PATH "Numpy include directory")
else()
message(SEND_ERROR "Could not determine the NumPy include directory, verify that NumPy was installed correctly.")
endif()
endif()

include_directories(${PYTHON_INCLUDE_PATH} ${PYTHON_NUMPY_INCLUDE_DIR})

if(PYTHON_VERSION_MAJOR VERSION_EQUAL 3)
add_definitions(-DPYTHON3)
endif()

if(OpenCV_VERSION_MAJOR VERSION_EQUAL 4)
add_definitions(-DOPENCV_VERSION_4)
endif()

if(OpenCV_VERSION_MAJOR VERSION_LESS 3)
add_library(${PROJECT_NAME}_boost module.cpp module_opencv2.cpp)
else()
add_library(${PROJECT_NAME}_boost module.cpp module_opencv3.cpp)
endif()
target_link_libraries(${PROJECT_NAME}_boost
${PYTHON_LIBRARIES}
${PROJECT_NAME}
)

set_target_properties(${PROJECT_NAME}_boost PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/boost/
PREFIX ""
)
if(APPLE)
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/)
SUFFIX ".so")
endif()

install(TARGETS ${PROJECT_NAME}_boost DESTINATION ${PYTHON_INSTALL_DIR}/${PROJECT_NAME}/boost/)
endif()
6 changes: 2 additions & 4 deletions cv_bridge/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@ ament_add_gtest(${PROJECT_NAME}-utest
APPEND_LIBRARY_DIRS "${cv_bridge_lib_dir}")
target_link_libraries(${PROJECT_NAME}-utest
${PROJECT_NAME}
Boost::headers
opencv_core
opencv_imgcodecs
${sensor_msgs_TARGETS})
${OpenCV_LIBRARIES}
)

# enable cv_bridge python tests
find_package(ament_cmake_pytest REQUIRED)
Expand Down
47 changes: 27 additions & 20 deletions image_geometry/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,40 +18,47 @@ endif()
find_package(OpenCV REQUIRED COMPONENTS calib3d core highgui imgproc)
find_package(sensor_msgs REQUIRED)

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include
${OpenCV_INCLUDE_DIRS}
)

# add a library
add_library(${PROJECT_NAME}
src/pinhole_camera_model.cpp
src/stereo_camera_model.cpp
src/pinhole_camera_model.cpp src/stereo_camera_model.cpp
)
target_link_libraries(${PROJECT_NAME} ${OpenCV_LIBRARIES})
ament_target_dependencies(
${PROJECT_NAME}
OpenCV
sensor_msgs
)

install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION include/${PROJECT_NAME}
)
target_include_directories(${PROJECT_NAME} PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include/${PROJECT_NAME}>")
target_link_libraries(${PROJECT_NAME} PUBLIC
opencv_calib3d
opencv_core
opencv_highgui
opencv_imgproc
${sensor_msgs_TARGETS})

install(DIRECTORY include/ DESTINATION include/${PROJECT_NAME})

# Causes the visibility macros to use dllexport rather than dllimport,
# which is appropriate when building the dll but not consuming it.
target_compile_definitions(${PROJECT_NAME} PRIVATE "IMAGE_GEOMETRY_BUILDING_DLL")

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

# image_geometry_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.
# This is especially important on Windows.
# This is overwritten each loop, but which one it points to doesn't really matter.
set(image_geometry_lib_dir "$<TARGET_FILE_DIR:${PROJECT_NAME}>")

# add tests
if(BUILD_TESTING)
find_package(ament_cmake_gtest REQUIRED)
ament_add_gtest(${PROJECT_NAME}-utest test/utest.cpp)
target_link_libraries(${PROJECT_NAME}-utest ${PROJECT_NAME})
add_subdirectory(test)
endif()

ament_export_targets(export_${PROJECT_NAME})
ament_export_libraries(${PROJECT_NAME})
ament_export_dependencies(OpenCV)
ament_export_dependencies(sensor_msgs)

ament_export_include_directories(include)
ament_package()
8 changes: 4 additions & 4 deletions image_geometry/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ find_package(ament_cmake_gtest REQUIRED)

# ament_add_pytest_test(directed.py "directed.py")

ament_add_gtest(${PROJECT_NAME}-utest utest.cpp)
target_link_libraries(${PROJECT_NAME}-utest ${PROJECT_NAME})
ament_add_gtest(${PROJECT_NAME}-utest utest.cpp APPEND_LIBRARY_DIRS "${image_geometry_lib_dir}")
target_link_libraries(${PROJECT_NAME}-utest ${PROJECT_NAME} ${OpenCV_LIBS})

ament_add_gtest(${PROJECT_NAME}-utest-equi utest_equi.cpp)
target_link_libraries(${PROJECT_NAME}-utest-equi ${PROJECT_NAME})
ament_add_gtest(${PROJECT_NAME}-utest-equi utest_equi.cpp APPEND_LIBRARY_DIRS "${image_geometry_lib_dir}")
target_link_libraries(${PROJECT_NAME}-utest-equi ${PROJECT_NAME} ${OpenCV_LIBS})

0 comments on commit a09a5e5

Please sign in to comment.