I have a ROS2 package and I create .deb
packets from it. It worked perfectly until now: locally and in docker container in GitLab pipeline.
Now, after upgrading OpenCV to 4.6.0, I am trying to convert it into debian packet but bloom-generate rosdebian
cannot find package in CMakeLists.txt in docker in GitLab. On local computer everything works as it did before.
#Problem description in detail:
Before:
The ROS2 package used OpenCV 4.5.4
and cv_bridge
. The opencv was installed from source and cv_bridge was installed with pip install. The ROS2 package could be build and the .deb packages could be created.
Now:
I have upgraded Opencv to 4.6.0
and I am installing cv_bridge
also from source now and not pip install. I can build and test the ROS2 package, but when I generate the .deb packages, it fails saying that it cannot find the OpenCVConfig.cmake
and cv_bridgeConfig.cmake
file. This failure to find packages happens only in GitLab docker, but not on local computer.
Everything worked fine until I upgraded the opencv from 4.5.4 to 4.6.0.*
I can build and test the ROS2 package but cannot create .deb
packet because 'bloom-generate` cannot find packages in CMakeLists.txt file.
I see this error.
CMake Error at CMakeLists.txt:56 (find_package):
Could not find a package configuration file provided by "OpenCV" (requested
version 4.6.0) with any of the following names:
OpenCVConfig.cmake
opencv-config.cmake
Add the installation prefix of "OpenCV" to CMAKE_PREFIX_PATH or set
"OpenCV_DIR" to a directory containing one of the above files. If "OpenCV"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
The CMakeLists.txt file could not find the packages. I read the ROS2 and CMake documentations and tried all the following ways mentioned below but none works.
source the build directory, OpenCVConfig.cmake file, setup.bash file of the OpenCV and cv_bridge installation.
I have also tried installing the Opencv and cv_bridge at different locations.
I also tried creating a separate ROS2 workspace containing only OpenCV and cv_bridge and sourcing/adding the WS in the ROS2 packages.
find_package(OpenCV 4.6.0 REQUIRED)
find_package(cv_bridge REQUIRED)
set(CMAKE_PREFIX_PATH "/opt/build" ${CMAKE_PREFIX_PATH})
set(opencv_pkg "/opt/ros/humble/src/opencv_pkg")
include(/opt/build/OpenCVConfig.cmake)
set(cv_bridge_DIR /opt/vision_opencv)
set(OpenCV_DIR /usr/local/lib/cmake/opencv4)
set(OpenCV_CONFIG "${OpenCV_DIR}/OpenCVConfig.cmake")
include(${OpenCV_CONFIG})
include(/home/root/vision_opencv/build/cv_bridge/ament_cmake_core/cv_bridgeConfig.cmake)
include(/usr/local/lib/cmake/opencv4/OpenCVConfig.cmake)
set(CMAKE_PREFIX_PATH "/usr/local/lib/cmake/opencv4;/home/root/vision_opencv/build/cv_bridge")
set(CMAKE_PREFIX_PATH /home/root/vision_opencv/build/cv_bridge ${CMAKE_PREFIX_PATH})
set(CMAKE_MODULE_PATH /usr/local/lib/cmake/opencv4 ${CMAKE_MODULE_PATH})
include_directories(${cv_bridge_INCLUDE_DIRS})
include_directories( include )
find_package(opencv_pkg REQUIRED PATHS "/opt/ros/humble/src/opencv_pkg" NO_DEFAULT_PATH)
find_package(OpenCV 4.6.0 CONFIG REQUIRED PATHS /usr/local/lib/cmake/opencv4)
find_package(OpenCV 4.6.0 QUIET)
find_package(OpenCV 4.6.0 REQUIRED PATHS /usr/local/lib/cmake/opencv4 NO_DEFAULT_PATH)
find_package(OpenCV 4.6.0 REQUIRED COMPONENTS opencv_core opencv_imgproc opencv_imgcodecs CONFIG )
target_link_libraries(libpsaf ${OpenCV_LIBS})
target_include_directories