Ask Your Question

Revision history [back]

How to link with OpenCV as cmake subdirectory

I have a project in which I manage most dependencies by tracking them with git submodules and then, where possible, adding them to a CMake build with add_subdirectory. I am having trouble getting this to work with opencv because the include headers seem to be in the wrong spot until OpenCV is actually installed. The targets (e.g. opencv_core, opencv_imgproc) are available to link, but these targets seem not to export the expected build-time include directories.

I get the sense that my approach with git submodules and cmake subdirectories is not the way OpenCV expects this to go. Is there a best practice for linking/installing a custom OpenCV build in the context of a larger project via CMake?