I was going to chime in with my own macro: # -------------------------------------------------------------------- #-- Copy all the Qt4 dependent DLLs into the current build directory so that #-- one can debug an application or library that depends on Qt4 libraries. macro (CMP_COPY_QT4_RUNTIME_LIBRARIES QTLIBLIST) #message(STATUS "CMP_COPY_QT4_RUNTIME_LIBRARIES") if (MSVC) if (DEFINED QT_QMAKE_EXECUTABLE) set(TYPE "d") FOREACH(qtlib ${QTLIBLIST}) GET_FILENAME_COMPONENT(QT_DLL_PATH_tmp ${QT_QMAKE_EXECUTABLE} PATH) message(STATUS "Generating Copy Rule for Qt Debug DLL Library ${QT_DLL_PATH_tmp}/${qtlib}d4.dll") add_custom_target(ZZ_${qtlib}-Debug-Copy ALL COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QT_DLL_PATH_tmp}/${qtlib}${TYPE}4.dll ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug/ COMMENT "Copying ${qtlib}${TYPE}4.dll to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Debug/") message(STATUS "Generating Copy Rule for Qt Release DLL Library ${QT_DLL_PATH_tmp}/${qtlib}d4.dll") add_custom_target(ZZ_${qtlib}-Release-Copy ALL COMMAND ${CMAKE_COMMAND} -E copy_if_different ${QT_DLL_PATH_tmp}/${qtlib}4.dll ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release/ COMMENT "Copying ${qtlib}4.dll to ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/Release/") ENDFOREACH(qtlib) endif(DEFINED QT_QMAKE_EXECUTABLE) endif() endmacro()
The only issue I really have with this is that this macro requires there to be BOTH debug and Release libraries available and will copy BOTH no matter which configuration is being built. I am thinking that the "yourCopyDlls.cmake" could be auto generated based on what the programmer says they need and then do the appropriate copy. I may look into this today. Thanks for sharing. ___________________________________________________________ Mike Jackson Principal Software Engineer BlueQuartz Software Dayton, Ohio mike.jack...@bluequartz.net www.bluequartz.net On Jan 9, 2012, at 9:51 AM, John Drescher wrote: > 2012/1/9 Hauke Heibel <hauke.hei...@googlemail.com>: >> Hi Michael, >> >> What I do is running a custom command which itself executes a CMake >> script. Usually similar to >> >> add_custom_command(TARGET CopyDlls >> COMMAND ${CMAKE_COMMAND} >> -DMSVC_BUILD_CONFIG_DIR=${CMAKE_CFG_INTDIR} >> -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} >> -P "<pathto>/yourCopyDlls.cmake" >> VERBATIM >> ) >> >> In the "yourCopyDlls.cmake", you can GLOB your DLLs with or without >> the "d" postfix depending on MSVC_BUILD_CONFIG_DIR. You can now even >> copy additional files such as e.g. PDB files. >> > > Thanks for sharing this. I use cmake generate a batch file (using > FILE(append ...) ) that calls cmake -E copy_if_different for each > file. then add this as a custom target however your method looks much > cleaner.. > > > John > -- > > 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