Skip to content

Commit 86d9f22

Browse files
committed
Revert "Revert "Use Boost::pythonXY target (ros-perception#421)""
This reverts commit 7a9b580.
1 parent deb39d4 commit 86d9f22

File tree

2 files changed

+17
-24
lines changed

2 files changed

+17
-24
lines changed

cv_bridge/CMakeLists.txt

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,23 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
1212
add_compile_options(-Wall -Wextra)
1313
endif()
1414

15-
if(NOT ANDROID)
16-
find_package(PythonLibs)
17-
if(PYTHONLIBS_VERSION_STRING VERSION_LESS 3)
18-
find_package(Boost REQUIRED python)
19-
else()
20-
find_package(Boost QUIET)
21-
if(Boost_VERSION LESS 106500)
22-
find_package(Boost REQUIRED python)
23-
else()
24-
# This is a bit of a hack to suppress a warning
25-
# No header defined for python3; skipping header check
26-
# Which should only affect Boost versions < 1.67
27-
# Resolution for newer versions:
28-
# https://gitlab.kitware.com/cmake/cmake/issues/16391
29-
if (Boost_VERSION LESS 106700)
30-
set(_Boost_PYTHON3_HEADERS "boost/python.hpp")
31-
endif()
32-
find_package(Boost COMPONENTS python3 REQUIRED)
33-
endif()
34-
endif()
15+
if(ANDROID)
16+
find_package(Boost REQUIRED)
17+
set(boost_python_target "")
3518
else()
36-
find_package(Boost REQUIRED COMPONENTS python)
19+
find_package(Python3 REQUIRED COMPONENTS Development NumPy)
20+
find_package(Boost QUIET)
21+
if(Boost_VERSION_STRING VERSION_LESS "1.67")
22+
# This is a bit of a hack to suppress a warning
23+
# No header defined for python3; skipping header check
24+
# Which should only affect Boost versions < 1.67
25+
# Resolution for newer versions:
26+
# https://gitlab.kitware.com/cmake/cmake/issues/16391
27+
set(_Boost_PYTHON3_HEADERS "boost/python.hpp")
28+
endif()
29+
find_package(Python3 REQUIRED COMPONENTS Development NumPy)
30+
find_package(Boost REQUIRED COMPONENTS python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
31+
set(boost_python_target "Boost::python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}")
3732
endif()
3833

3934
find_package(rcpputils REQUIRED)

cv_bridge/src/CMakeLists.txt

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,10 @@ install(FILES
2626
DESTINATION include/${PROJECT_NAME}/${PROJECT_NAME})
2727

2828
if(NOT ANDROID)
29-
find_package(Python3 REQUIRED COMPONENTS Development NumPy)
30-
3129
Python3_add_library(${PROJECT_NAME}_boost MODULE module.cpp module_opencv3.cpp)
3230
target_link_libraries(${PROJECT_NAME}_boost PRIVATE
3331
${PROJECT_NAME}
34-
Boost::python
32+
${boost_python_target}
3533
Python3::NumPy)
3634
target_compile_definitions(${PROJECT_NAME}_boost PRIVATE PYTHON3)
3735

0 commit comments

Comments
 (0)