<div dir="ltr">Thankyou Thomas, it works now... Another issue I was faced with the first script is, it assumes that the dlls are in the lib folder of Qt (I think you build qt from source). I have downloaded the prebuilt Qt library, in that the dlls are in the bin folder. I modified the macro you have given, as below...<div>
<br></div><div><div>MACRO(GetDLLs DEBUG_NAME RELEASE_NAME)</div><div><br></div><div>#Copy Debug dlls</div><div>LIST(APPEND ${DEBUG_NAME} "${QT_BINARY_DIR}/QtGuid4.dll")<br></div></div><div>...</div></div><div class="gmail_extra">
<br><br><div class="gmail_quote">On Thu, Apr 18, 2013 at 6:51 PM, Thomas Richard <span dir="ltr"><<a href="mailto:Thomas.Richard@imgtec.com" target="_blank">Thomas.Richard@imgtec.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Normally when you find the Qt4 package it selects some defaults libraries (and the QT_USE_FILE). But you have to specify some extra modules you may need before including the QT_USE_FILE. The QT_USE_FILE defines the dependencies and includes the folders you need.<br>
<br>
For example I have:<br>
<br>
find_package(Qt4 REQUIRED)<br>
<br>
# loads of crap about my libraries<br>
<br>
set (QT_USE_QTGUI TRUE)<br>
include(${QT_USE_FILE})<br>
<br>
set (SOURCES #with my sources)<br>
set (HEADERS # with my headers)<br>
set(HEADERS_MOC) # to define an empty variable<br>
QT4_WRAP_CPP(HEADERS_MOC ${HEADERS})<br>
<br>
add_executable(ParamGui ${SOURCES} ${HEADERS_MOC} ${HEADERS})<br>
set_source_files_properties(${HEADERS_MOC} PROPERTIES GENERATED TRUE)<br>
target_link_libraries(ParamGui ${QT_LIBRARIES})<br>
<div class="im"><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>
</div>Sent: 18 April 2013 12:40<br>
To: Thomas Richard<br>
Cc: CMake ML<br>
Subject: Re: [CMake] Copy dlls to release and debug folder<br>
<div><div class="h5"><br>
I assume that this is the recommended approach.<br>
<br>
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?<br>
<br>
<br>
Thanks,<br>
Lloyd<br>
<br>
On Thu, Apr 18, 2013 at 4:21 PM, Thomas Richard <<a href="mailto:Thomas.Richard@imgtec.com">Thomas.Richard@imgtec.com</a>> wrote:<br>
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 ".lib" ".dll" QT_${module}_DLL "${QT_${module}_LIBRARY_DEBUG}")<br>
set (${DEBUG_NAME} ${${DEBUG_NAME}} ${QT_${module}_DLL})<br>
<br>
string(REPLACE ".lib" ".dll" QT_${module}_DLL "${QT_${module}_LIBRARY_RELEASE}")<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 "Visual Studio 11")<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'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'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>
<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 "add_custom_command(TARGET ...)". 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>
<br>
</div></div>--<br>
<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br></div>