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...
MACRO(GetDLLs DEBUG_NAME RELEASE_NAME) #Copy Debug dlls LIST(APPEND ${DEBUG_NAME} "${QT_BINARY_DIR}/QtGuid4.dll") ... On Thu, Apr 18, 2013 at 6:51 PM, Thomas Richard <thomas.rich...@imgtec.com>wrote: > 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. > > For example I have: > > find_package(Qt4 REQUIRED) > > # loads of crap about my libraries > > set (QT_USE_QTGUI TRUE) > include(${QT_USE_FILE}) > > set (SOURCES #with my sources) > set (HEADERS # with my headers) > set(HEADERS_MOC) # to define an empty variable > QT4_WRAP_CPP(HEADERS_MOC ${HEADERS}) > > add_executable(ParamGui ${SOURCES} ${HEADERS_MOC} ${HEADERS}) > set_source_files_properties(${HEADERS_MOC} PROPERTIES GENERATED TRUE) > target_link_libraries(ParamGui ${QT_LIBRARIES}) > > From: cmake-boun...@cmake.org [mailto:cmake-boun...@cmake.org] On Behalf > Of Lloyd > Sent: 18 April 2013 12:40 > To: Thomas Richard > Cc: CMake ML > Subject: Re: [CMake] Copy dlls to release and debug folder > > I assume that this is the recommended approach. > > 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? > > > Thanks, > Lloyd > > On Thu, Apr 18, 2013 at 4:21 PM, Thomas Richard <thomas.rich...@imgtec.com> > wrote: > Hi Lloyd, > > Personally I copy the DLLs to the VS folder (so that the program can be > run from visual studio) using the following script. > It looks more complicated than it is. > > A macro is available to several of my projects to select which Qt module > they use and create a list of dlls to copy. > Then I simply choose where to copy the DLLs according to the generator. > I also add them to the list of files to install. > Finally the last line is to remove the command prompt opening. > > > > MACRO(GetQtDLLs DEBUG_NAME RELEASE_NAME) > > FOREACH(module QT3SUPPORT QTOPENGL QTASSISTANT QTDESIGNER QTMOTIF > QTNSPLUGIN > QAXSERVER QAXCONTAINER QTDECLARATIVE QTSCRIPT QTSVG > QTUITOOLS QTHELP > QTWEBKIT PHONON QTSCRIPTTOOLS QTMULTIMEDIA QTGUI QTTEST > QTDBUS QTXML QTSQL > QTXMLPATTERNS QTNETWORK QTCORE) > > if (QT_USE_${module} OR QT_USE_${module}_DEPENDS) > > string(REPLACE ".lib" ".dll" QT_${module}_DLL > "${QT_${module}_LIBRARY_DEBUG}") > set (${DEBUG_NAME} ${${DEBUG_NAME}} ${QT_${module}_DLL}) > > string(REPLACE ".lib" ".dll" QT_${module}_DLL > "${QT_${module}_LIBRARY_RELEASE}") > set (${RELEASE_NAME} ${${RELEASE_NAME}} > ${QT_${module}_DLL}) > > endif() > > ENDFOREACH(module) > > ENDMACRO() > > if (WIN32) > GetQtDLLs(DEBUG_DLLS RELEASE_DLLS) > > if (${CMAKE_GENERATOR} MATCHES "Visual Studio 11") > # visual studio 12 expects the DLLs in the executable > folder. > # but not the resources! > # can be changed into the environment property of the > project to include the project's directory > set (DLL_TO_DBG ${CMAKE_CURRENT_BINARY_DIR}/Debug) > set (DLL_TO_RELEASE ${CMAKE_CURRENT_BINARY_DIR}/Release) > else() > # for other version of visual studio the DLLs are expected > into the project folder > set (DLL_TO_DBG ${CMAKE_CURRENT_BINARY_DIR}) > set (DLL_TO_RELEASE ${CMAKE_CURRENT_BINARY_DIR}) > endif() > > foreach(dll ${DEBUG_DLLS}) > file(COPY ${dll} DESTINATION ${DLL_TO_DBG}) > endforeach() > > foreach(dll ${RELEASE_DLLS}) > file(COPY ${dll} DESTINATION ${DLL_TO_RELEASE}) > endforeach() > > install(FILES ${RELEASE_DLLS} DESTINATION > ${INSTALL_FELIXPARAMGUI_PATH} CONFIGURATIONS Release) > > # > # this is disabled for debug only (so signal/slots connect > failures are seen)! > # > # this property is used to remove the prompt window when running > the GUI from the explorer on WIN32 > # doesn't have effect on linux > # > set_target_properties(FelixParamGui PROPERTIES WIN32_EXECUTABLE > ${FELIXPARAMGUI_WIN32EXE}) > endif() > > From: cmake-boun...@cmake.org [mailto:cmake-boun...@cmake.org] On Behalf > Of Lloyd > Sent: 18 April 2013 11:33 > To: CMake ML > Subject: [CMake] Copy dlls to release and debug folder > > Hi, > > 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? > > Can you please suggest me the right way? > > Thanks, > Lloyd > > > -- > > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake >
-- Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake