OK, it seems that OpenCVConfig.cmake distorts the OpenCVConfig.cmake variable when it is turned on several times with successive calls to FIND_PACKAGE() .
A quick fix is ββto add FORCE to lines 91-94 in OpenCVConfig.cmake :
# Provide the libs directories to the caller set(OpenCV_LIB_DIR_OPT "C:/opencv/build2/lib" CACHE PATH "Path where release OpenCV libraries are located" FORCE) set(OpenCV_LIB_DIR_DBG "C:/opencv/build2/lib" CACHE PATH "Path where debug OpenCV libraries are located" FORCE) set(OpenCV_3RDPARTY_LIB_DIR_OPT "C:/opencv/build2/3rdparty/lib" CACHE PATH "Path where release 3rdpaty OpenCV dependencies are located" FORCE) set(OpenCV_3RDPARTY_LIB_DIR_DBG "C:/opencv/build2/3rdparty/lib" CACHE PATH "Path where debug 3rdpaty OpenCV dependencies are located" FORCE)
The file to change is C:\opencv\cmake\templates\OpenCVConfig.cmake.in .
Then rebuild / recompile / reinstall OpenCV and then your own project.
source share