Added MSVC also to the IF statement so that when using MinGW the DLLIMPORT and DLLEXPORT is set to empty strings
Replace the ${SETUPAPI_LIBRARY} in the TARGET_LINK_LIBRARIES with the library name, otherwise the fullpath is added to the TARGET_LINK_LIBRARIES list.
Changed the directive to #if defined(Q_WS_WIN32) || defined(WIN32) so that when using MinGW the putenv methods is used.
Otherwise you will get unsetenv and setenv is not declared in this scope.