#13117·opencv

Suggestion: use opencv:: namespace for cmake imported targets

Author: huangqinjinCreated Nov 12, 2018Updated Sep 28, 2026
Labelspriority: lowcategory: build/installfuture

While the syntax :: seems to be more modern and conventional in cmake, it has a obvious benefit.

The following won't get any error until the linking time with a undefined reference error to cv::imshow.

cmake
find_package(OpenCV 3.3 REQUIRED COMPONENTS core)
target_link_libraries(myExe opencv_core opencv_highgui)

But if using opencv::highgui, we get a configuration error from cmake:

cmake
Target "myExe" links to target "opencv::highgui" but the target was not
  found.  Perhaps a find_package() call is missing for an IMPORTED target, or
  an ALIAS target is missing?