title: Setting QTDIR based on generator in use
body: <p>I am trying to setup a CMake project which consists of multiple static libraries and one main executable which has dependencies on QT. I would like to be able to select either a MinGW or a MSVC build when I run the cmake build.</p>
  
  <p>I recently learned that the QT specific parts of CMake will find the installed library binaries for QT automatically if <code>QTDIR</code> is set as an environment variable and if <code>QTDIR/bin</code> is in the PATH.</p>
  
  <p>Now I am wondering how I can set this information dynamically depending on the compiler that I am using. Since I would need to point cmake to either one of <code>C:\Qt\5.3\mingw482_32</code> or <code>C:\Qt\5.3\msvc2013_64</code>, or possibly others if I extend the list of targets in the future.</p>
  
  <p>Note that I do not need to build both compiler targets at the same time, I would usually select on target in my IDE and build that one, but I would like to be able to switch between both targets.</p>
  
  <p>The solution should be in such a way, that on Linux the CMake build will still find the libraries which are installed through the package manager automatically.</p>
  
  <p>Can I easily achieve this with CMake?</p>
  
  <p>As a side note, in the future I might also need to select the QT version on demand? So an extensible solution would be nice.</p>