Skip to content
Merged
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
36 changes: 15 additions & 21 deletions cv_bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,22 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra)
endif()

if(NOT ANDROID)
find_package(PythonLibs)
if(PYTHONLIBS_VERSION_STRING VERSION_LESS 3)
find_package(Boost REQUIRED python)
else()
find_package(Boost QUIET)
if(Boost_VERSION LESS 106500)
find_package(Boost REQUIRED python)
else()
# This is a bit of a hack to suppress a warning
# No header defined for python3; skipping header check
# Which should only affect Boost versions < 1.67
# Resolution for newer versions:
# https://gitlab.kitware.com/cmake/cmake/issues/16391
if (Boost_VERSION LESS 106700)
set(_Boost_PYTHON3_HEADERS "boost/python.hpp")
endif()
find_package(Boost COMPONENTS python3 REQUIRED)
endif()
endif()
if(ANDROID)
find_package(Boost REQUIRED)
set(boost_python_target "")
else()
find_package(Boost REQUIRED COMPONENTS python)
find_package(Boost QUIET)
if(Boost_VERSION_STRING VERSION_LESS "1.67")
# This is a bit of a hack to suppress a warning
# No header defined for python3; skipping header check
# Which should only affect Boost versions < 1.67
# Resolution for newer versions:
# https://gitlab.kitware.com/cmake/cmake/issues/16391
set(_Boost_PYTHON3_HEADERS "boost/python.hpp")
endif()
find_package(Python3 REQUIRED COMPONENTS Development NumPy)
find_package(Boost REQUIRED COMPONENTS python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
set(boost_python_target "Boost::python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
endif()

find_package(sensor_msgs REQUIRED)
Expand Down
4 changes: 1 addition & 3 deletions cv_bridge/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ install(FILES
DESTINATION include/${PROJECT_NAME}/${PROJECT_NAME})

if(NOT ANDROID)
find_package(Python3 REQUIRED COMPONENTS Development NumPy)

Python3_add_library(${PROJECT_NAME}_boost MODULE module.cpp module_opencv3.cpp)
target_link_libraries(${PROJECT_NAME}_boost PRIVATE
${PROJECT_NAME}
Boost::python
${boost_python_target}
Python3::NumPy)
target_compile_definitions(${PROJECT_NAME}_boost PRIVATE PYTHON3)

Expand Down