Skip to content

Commit

Permalink
Revert "Use Boost::pythonXY target (#421)"
Browse files Browse the repository at this point in the history
This reverts commit e1df7ee.

Signed-off-by: Kenji Brameld <kenjibrameld@gmail.com>
(cherry picked from commit 7a9b580)
  • Loading branch information
ijnek authored and mergify[bot] committed Sep 17, 2022
1 parent 55fa7f3 commit 8eb2ec8
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
37 changes: 21 additions & 16 deletions cv_bridge/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,28 @@ if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra)
endif()

if(ANDROID)
find_package(Boost REQUIRED)
set(boost_python_target "")
else()
find_package(Python3 REQUIRED COMPONENTS Development NumPy)
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")
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()
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}")
else()
find_package(Boost REQUIRED COMPONENTS python)
endif()

find_package(rcpputils REQUIRED)
Expand Down
4 changes: 3 additions & 1 deletion cv_bridge/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,12 @@ 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_target}
Boost::python
Python3::NumPy)
target_compile_definitions(${PROJECT_NAME}_boost PRIVATE PYTHON3)

Expand Down

0 comments on commit 8eb2ec8

Please sign in to comment.