CV Import location problem with Linux

Hello, A new dev here. Recently changed the development environment to Ubuntu 22.04, having issues with cmake (3.22) building the project. While building the project, make showing “IMPORTED_LOCATION not set for imported target ‘opencv_calib3d’,‘opencv_core’,‘opencv_dnn’,‘opencvfeatures2d’…”, but the target link library was set in the cmake file, and with message printing out all the libraries included in the Libs.
CMakeLists.txt:
find_package(OpenCV REQUIRED)
add_library(OpenCV SHARED IMPORTED)
message(“${OpenCV_LIBS}”) — this printed exactly all the ‘not set’ libraries.

set_target_properties(OpenCV PROPERTIES
IMPORTED_LOCARTION ${OpenCV_LIBS}
)
What might be the root cause of this issue?

that’s a typo, no ?

i’ve never used IMPORTED or similar (it might not be nessecary),
can you take a look at the (tried & tested !) example here , please ?

Thanks, and yes that’s a typo.

After transferring to 22.04, I tried to rebuild without setting the properties nor using the IMPORTED on OpenCV libraries, and the problem issue start to reveal. The same error showed the import location was not set, hence using the IMPORTED and set properties.

I don’t have access to the same environment at the moment, but I’ll post the result later for. My original CMakeLists (before adding the IMPORT and SETs) were pretty much the same as in the example, just less the MESSAGE portion.

Hi berak, jsut tried the example and the output from cmake command appears:

-- OpenCV library status:
--     config: /usr/local/lib/cmake/opencv4
--     version: 4.7.0
--     libraries: opencv_calib3d;opencv_core;opencv_dnn;opencv_features2d;opencv_flann;opencv_gapi;opencv_highgui;opencv_imgcodecs;opencv_imgproc;opencv_ml;opencv_objdetect;opencv_photo;opencv_stitching;opencv_video;opencv_videoio
--     include path: /usr/local/include/opencv4
-- Configuring done
CMake Error in CMakeLists.txt:
  IMPORTED_LOCATION not set for imported target "opencv_calib3d".

CMake Error in CMakeLists.txt:
  IMPORTED_LOCATION not set for imported target "opencv_core".

CMake Error in CMakeLists.txt:
  IMPORTED_LOCATION not set for imported target "opencv_dnn".

CMake Error in CMakeLists.txt:
  IMPORTED_LOCATION not set for imported target "opencv_features2d".

CMake Error in CMakeLists.txt:
  IMPORTED_LOCATION not set for imported target "opencv_flann".

CMake Error in CMakeLists.txt:
  IMPORTED_LOCATION not set for imported target "opencv_gapi".

CMake Error in CMakeLists.txt:
  IMPORTED_LOCATION not set for imported target "opencv_highgui".

CMake Error in CMakeLists.txt:
  IMPORTED_LOCATION not set for imported target "opencv_imgcodecs".

CMake Error in CMakeLists.txt:
  IMPORTED_LOCATION not set for imported target "opencv_imgproc".

CMake Error in CMakeLists.txt:
  IMPORTED_LOCATION not set for imported target "opencv_ml".

CMake Error in CMakeLists.txt:
  IMPORTED_LOCATION not set for imported target "opencv_objdetect".

CMake Error in CMakeLists.txt:
  IMPORTED_LOCATION not set for imported target "opencv_photo".

CMake Error in CMakeLists.txt:
  IMPORTED_LOCATION not set for imported target "opencv_stitching".

CMake Error in CMakeLists.txt:
  IMPORTED_LOCATION not set for imported target "opencv_video".

CMake Error in CMakeLists.txt:
  IMPORTED_LOCATION not set for imported target "opencv_videoio".

-- Generating done
CMake Generate step failed.  Build files cannot be regenerated correctly.