Skip to content
Closed
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
25 changes: 22 additions & 3 deletions cv_bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,29 @@ find_package(catkin REQUIRED COMPONENTS rosconsole sensor_msgs)

if(NOT ANDROID)
find_package(PythonLibs)
if(PYTHONLIBS_VERSION_STRING VERSION_LESS 3)
find_package(Boost REQUIRED python)
if(PYTHONLIBS_VERSION_STRING MATCHES "^([0-9]+)\\.([0-9]+)\\.([0-9]+)")
set(Python_VERSION_MAJOR "${CMAKE_MATCH_1}")
set(Python_VERSION_MINOR "${CMAKE_MATCH_2}")
set(Python_VERSION_PATCH "${CMAKE_MATCH_3}")
find_package(Boost QUIET)
if(Boost_VERSION LESS 106700)
if(Python_VERSION_MAJOR LESS 3)
find_package(Boost REQUIRED COMPONENTS python)
else()
find_package(Boost REQUIRED COMPONENTS python3)
endif()
else()
# The boost_python library has been renamed in Boost 1.67 and the FindBoost.cmake
# module requires a Python version suffix:
#
# References:
# - https://www.boost.org/docs/libs/1_67_0/libs/python/doc/html/rn.html
# - https://cmake.org/cmake/help/v3.12/module/FindBoost.html
#
find_package(Boost REQUIRED COMPONENTS python${Python_VERSION_MAJOR}${Python_VERSION_MINOR})
endif()
else()
find_package(Boost REQUIRED python3)
message(FATAL_ERROR "Could not detect the Python version from string '${PYTHONLIBS_VERSION_STRING}' required to find the respective boost_python module.")
endif()
else()
find_package(Boost REQUIRED)
Expand Down