title: DLLs for OpenCV Contrib Modules with CMake
body: <p>I'm building OpenCV and the corresponding contrib modules of OpenCV from source using CMake both in <code>Debug</code> and <code>Release</code> mode. In my own CMake project, I would like to include OpenCV as a dependency and based on whether my application runs in <code>Debug</code> or<code>Release</code> mode, I want to pick the correct OpenCV DLL's.</p>
  
  <p>My folder structure looks like this...</p>
  
  <pre><code>opencv_src
      .git
      ...
      build
          ...
          bin
              Debug
                  DLL's and PDB's of all Debug OpenCV modules
              Release
                  DLL's of all Rlease OpenCV modules
          ...
          OpenCV.sln
          OpenCVConfig.cmake
          ...
      include
      ...
      CMakeLists.txt
  </code></pre>
  
  <p>The build folder is created with CMake. I have an environment variable <code>OpenCV_DIR</code> pointed to the <code>build</code> directory such that OpenCV is found and CMake runs fine for my application. My question is now how to handle the DLL's. If you don't compile OpenCV yourself from source and instead use the binary installer, both the DLL's and PDB's for <code>Release</code> and <code>Debug</code> are in the same folder, and by adding this folder to the <code>PATH</code> variable in Windows, everything compiles and uns without errors. With the source build of OpenCV, I would theoretically have to add both the <code>Release</code> and <code>Debug</code> folder to the <code>PATH</code>. Is there a nicer solution to do this with CMake?</p>