<div dir="ltr">I assume that this is the recommended approach.<div><br></div><div style>I tried to use the script you have provided, the call GetQtDLLs(DEBUG_DLLS RELEASE_DLLS) is not populating any of the variables (DEBUG_DLLS or RELEASE_DLLS) with qt dll names. I am new to cmake, Am I missing something?</div>
<div style><br></div><div style><br></div><div style>Thanks,</div><div style>  Lloyd</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Thu, Apr 18, 2013 at 4:21 PM, Thomas Richard <span dir="ltr">&lt;<a href="mailto:Thomas.Richard@imgtec.com" target="_blank">Thomas.Richard@imgtec.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Lloyd,<br>
<br>
Personally I copy the DLLs to the VS folder (so that the program can be run from visual studio) using the following script.<br>
It looks more complicated than it is.<br>
<br>
A macro is available to several of my projects to select which Qt module they use and create a list of dlls to copy.<br>
Then I simply choose where to copy the DLLs according to the generator.<br>
I also add them to the list of files to install.<br>
Finally the last line is to remove the command prompt opening.<br>
<br>
<br>
<br>
MACRO(GetQtDLLs DEBUG_NAME RELEASE_NAME)<br>
<br>
FOREACH(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF QTNSPLUGIN<br>
               QAXSERVER QAXCONTAINER QTDECLARATIVE QTSCRIPT QTSVG QTUITOOLS QTHELP<br>
               QTWEBKIT PHONON QTSCRIPTTOOLS QTMULTIMEDIA QTGUI QTTEST QTDBUS QTXML QTSQL<br>
               QTXMLPATTERNS QTNETWORK QTCORE)<br>
<br>
        if (QT_USE_${module} OR QT_USE_${module}_DEPENDS)<br>
<br>
                string(REPLACE &quot;.lib&quot; &quot;.dll&quot; QT_${module}_DLL &quot;${QT_${module}_LIBRARY_DEBUG}&quot;)<br>
                set (${DEBUG_NAME} ${${DEBUG_NAME}} ${QT_${module}_DLL})<br>
<br>
                string(REPLACE &quot;.lib&quot; &quot;.dll&quot; QT_${module}_DLL &quot;${QT_${module}_LIBRARY_RELEASE}&quot;)<br>
                set (${RELEASE_NAME} ${${RELEASE_NAME}} ${QT_${module}_DLL})<br>
<br>
        endif()<br>
<br>
ENDFOREACH(module)<br>
<br>
ENDMACRO()<br>
<br>
if (WIN32)<br>
        GetQtDLLs(DEBUG_DLLS RELEASE_DLLS)<br>
<br>
        if (${CMAKE_GENERATOR} MATCHES &quot;Visual Studio 11&quot;)<br>
                # visual studio 12 expects the DLLs in the executable folder.<br>
                # but not the resources!<br>
                # can be changed into the environment property of the project to include the project&#39;s directory<br>
                set (DLL_TO_DBG ${CMAKE_CURRENT_BINARY_DIR}/Debug)<br>
                set (DLL_TO_RELEASE ${CMAKE_CURRENT_BINARY_DIR}/Release)<br>
        else()<br>
                # for other version of visual studio the DLLs are expected into the project folder<br>
                set (DLL_TO_DBG ${CMAKE_CURRENT_BINARY_DIR})<br>
                set (DLL_TO_RELEASE ${CMAKE_CURRENT_BINARY_DIR})<br>
        endif()<br>
<br>
        foreach(dll ${DEBUG_DLLS})<br>
                file(COPY ${dll} DESTINATION ${DLL_TO_DBG})<br>
        endforeach()<br>
<br>
        foreach(dll ${RELEASE_DLLS})<br>
                file(COPY ${dll} DESTINATION ${DLL_TO_RELEASE})<br>
        endforeach()<br>
<br>
        install(FILES ${RELEASE_DLLS} DESTINATION ${INSTALL_FELIXPARAMGUI_PATH} CONFIGURATIONS Release)<br>
<br>
        #<br>
        # this is disabled for debug only (so signal/slots connect failures are seen)!<br>
        #<br>
        # this property is used to remove the prompt window when running the GUI from the explorer on WIN32<br>
        # doesn&#39;t have effect on linux<br>
        #<br>
        set_target_properties(FelixParamGui PROPERTIES WIN32_EXECUTABLE ${FELIXPARAMGUI_WIN32EXE})<br>
endif()<br>
<br>
From: <a href="mailto:cmake-bounces@cmake.org">cmake-bounces@cmake.org</a> [mailto:<a href="mailto:cmake-bounces@cmake.org">cmake-bounces@cmake.org</a>] On Behalf Of Lloyd<br>
Sent: 18 April 2013 11:33<br>
To: CMake ML<br>
Subject: [CMake] Copy dlls to release and debug folder<br>
<div class="HOEnZb"><div class="h5"><br>
Hi,<br>
<br>
I was successful in creating and building a project using CMake on Windows (Visual Studio). After the build when I try to run the application it throws an error asking for the dlls of Qt (I know it is a common case in Windows, usually we do copy the dlls to debug/release folder where the exe resides). When I searched the mailing list, I have seen an advise to use &quot;add_custom_command(TARGET ...)&quot;. Is this the right approach? Wont it be executed after each build, thus causing repeated dll copies? <br>

<br>
Can you please suggest me the right way?<br>
<br>
Thanks,<br>
  Lloyd<br>
<br>
</div></div></blockquote></div><br></div>