diff --git a/cv_bridge/CMakeLists.txt b/cv_bridge/CMakeLists.txt index 83f550e30..00e7c225b 100644 --- a/cv_bridge/CMakeLists.txt +++ b/cv_bridge/CMakeLists.txt @@ -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) diff --git a/cv_bridge/src/CMakeLists.txt b/cv_bridge/src/CMakeLists.txt index a28fec325..7eea3ee38 100644 --- a/cv_bridge/src/CMakeLists.txt +++ b/cv_bridge/src/CMakeLists.txt @@ -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)