#20198·opencv

find_package(OpenCV) 2 times

Author: ilya-lavrenovCreated Jun 2, 2021Updated Sep 28, 2026
Labelscategory: build/installRFC

We are finding OpenCV multiple times with different components:

find_package(OpenCV QUIET) # just probe that OpenCV is here

..
find_package(OpenCV QUIET COMPONENTS opencv_core)

The issue that second call returns all OpenCV libraries in OpenCV_LIBRARIES, while I want to have only opencv_core to be in OpenCV_LIBRARIES list.

You can say that I have to find OpenCV only once per project, but what if these projects are independent? And depending on which project is included first, the second project will reuse libraries from first one