0

I need to copy qt4 dlls used to the install directory using CMake on windows, I read this answer for Qt4 but it didn't work for me: Copying Qt DLLs to executable directory on Windows using CMake

Note that a similar approach as above works for linux for Qt4 but not for windows

How can I find the location of Qt4 dlls on windows and copy them?

Daniyal Yasin
  • 142
  • 1
  • 14

1 Answers1

0

I finally found help on this link: https://cmake.org/pipermail/cmake/2008-June/022461.html

The location of Qt4 dlls can be found using the variable ${QT_QMAKE_EXECUTABLE}

I used the following code to copy my dlls based on the above link:

SET (QTLIBLIST QtCore QtGui)

if (${CMAKE_HOST_UNIX})
   FOREACH(qtlib ${QTLIBLIST})
      string (TOUPPER ${qtlib} upper_qtlib)
      INSTALL(FILES ${QT_${upper_qtlib}_LIBRARY_DEBUG} DESTINATION ./bin/debug CONFIGURATIONS Debug)
      INSTALL(FILES ${QT_${upper_qtlib}_LIBRARY_RELEASE} DESTINATION ./bin CONFIGURATIONS Release)
   ENDFOREACH (qtlib)

else()
   GET_FILENAME_COMPONENT(QT_DLL_PATH_tmp ${QT_QMAKE_EXECUTABLE} PATH)

   FOREACH(qtlib ${QTLIBLIST})
         INSTALL(FILES ${QT_DLL_PATH_tmp}/${qtlib}d4.dll DESTINATION .//bin/debug CONFIGURATIONS Debug)
         INSTALL(FILES ${QT_DLL_PATH_tmp}/${qtlib}4.dll DESTINATION ./bin CONFIGURATIONS Release)
   ENDFOREACH (qtlib)
endif()
Daniyal Yasin
  • 142
  • 1
  • 14