我需要在Windows上使用CMake将用于安装目录的qt4 dll复制到安装目录中,我已经阅读了有关Qt4的答案,但对我不起作用: Copying Qt DLLs to executable directory on Windows using CMake
请注意,与上述类似的方法适用于Qt4的Linux,但不适用于Windows
如何在Windows上找到Qt4 dll的位置并将其复制?
答案 0 :(得分:0)
我终于在此链接上找到了帮助: https://cmake.org/pipermail/cmake/2008-June/022461.html
使用变量$ {QT_QMAKE_EXECUTABLE}可以找到Qt4 dll的位置
我使用以下代码根据上述链接复制了dll:
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()