<div>I think setting LIBRARY_OUTPUT_PATH instead only works on the libraries you build. I also need to copy configuration files etc. so ... how about something like this:</div>
<div> </div>
<div>(Note the the explicit specification of "Debug and release in the WIN32 section.)</div>
<div> </div>
<div>#-------------------------- Start of code ----------------------<br> </div>
<div>
<p>IF ( WIN32 )<br> # Only needed for windows.<br> # Note: We need to copy the dlls to two places in the build tree, namely<br> # ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}</p>
<p> IF(NOT STATIC_BUILD)<br> # Find the dlls we need.<br> FIND_FILE(LIBPQ_DLL libpq.dll PATHS ${POSTGRESQL_LIBRARY_DIRS} NO_DEFAULT_PATH )<br> FIND_FILE(LIBPQD_DLL libpqd.dll PATHS ${POSTGRESQL_LIBRARY_DIRS} NO_DEFAULT_PATH )
<br> FIND_FILE(LIBPQXX_DLL libpqxx.dll PATHS ${LIBPQXX_LIBRARY_DIRS} NO_DEFAULT_PATH )<br> FIND_FILE(LIBPQXXD_DLL libpqxxD.dll PATHS ${LIBPQXX_LIBRARY_DIRS} NO_DEFAULT_PATH )<br> SET ( ESSENTIAL_FILES ${ESSENTIAL_FILES}
<br> ${LIBPQ_DLL}<br> ${LIBPQXX_DLL}<br> )<br> SET ( ESSENTIAL_FILES_DEBUG ${ESSENTIAL_FILES_DEBUG}<br> ${LIBPQD_DLL}<br> ${LIBPQXXD_DLL}<br> )<br> ENDIF(NOT STATIC_BUILD)</p>
<p> # Copy these files to the build tree.<br> # We cannot determine whether Release or Debug is being used.<br> ADD_CUSTOM_TARGET(CopyDllCfg ALL echo "Copying dlls and essential files ...")</p>
<p> FOREACH(file ${ESSENTIAL_FILES_DEBUG})<br> GET_FILENAME_COMPONENT(fn ${file} NAME)<br> SET(tgt ${EXECUTABLE_OUTPUT_PATH}/Debug/${fn})<br> SET(src ${file})<br> ADD_CUSTOM_COMMAND(<br> TARGET CopyDllCfg<br> COMMAND ${CMAKE_COMMAND}
<br> ARGS -E copy_if_different ${src} ${tgt}<br> COMMENT "source copy dlls and essential files"<br> )<br> ENDFOREACH(file)</p>
<p> FOREACH(file ${ESSENTIAL_FILES})<br> GET_FILENAME_COMPONENT(fn ${file} NAME)<br> SET(tgt ${EXECUTABLE_OUTPUT_PATH}/Release/${fn})<br> SET(src ${file})<br> ADD_CUSTOM_COMMAND(<br> TARGET CopyDllCfg<br>
COMMAND ${CMAKE_COMMAND}<br> ARGS -E copy_if_different ${src} ${tgt}<br> COMMENT "source copy dlls and essential files"<br> )<br> ENDFOREACH(file)</p>
<p>ELSE ( WIN32 )</p>
<p> # Copy these files to the build tree.<br> ADD_CUSTOM_TARGET(CopyCfg ALL echo "Copying dlls and essential files ...")</p>
<p> FOREACH(file ${ESSENTIAL_FILES})<br> GET_FILENAME_COMPONENT(fn ${file} NAME)<br> SET(tgt ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${fn})<br> SET(src ${file})<br> ADD_CUSTOM_COMMAND(<br> TARGET CopyCfg
<br> COMMAND ${CMAKE_COMMAND}<br> ARGS -E copy_if_different ${src} ${tgt}<br> COMMENT "source copy essential files"<br> )<br> ENDFOREACH(file)</p>
<p>ENDIF ( WIN32 )<br></p><br>#-------------------------- End of code -----------------------<br>Regards</div>
<div> Andrew</div>
<div> </div>
<div> </div>
<div><span class="gmail_quote">On 9/18/07, <b class="gmail_sendername">McKay Davis</b> <<a href="mailto:mckayd@yahoo.com">mckayd@yahoo.com</a>> wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">I'm experiencing trouble getting cmake to copy DLL files to my executable<br>output path in visual studio after the target is built.
<br><br>It seems that the CMAKE_CFG_INTDIR variable is being expanded to: "$"(OutDir)<br><br>This causes the .dll files to be copied to the filename '$(OutDir)', not into<br>the 'Debug' or 'Release' sub-directory as I would expect.
<br><br>Here is the relevant cmake code:<br><br>IF(WIN32)<br>FILE(GLOB QT_DLLS "${QT_LIBRARY_DIR}/../bin/*.dll")<br><br>GET_FILENAME_COMPONENT(PTHREAD_LIBRARY_DIR "${PTHREAD_LIBRARY}" PATH)<br>FILE(GLOB PTHREAD_DLLS "${PTHREAD_LIBRARY_DIR}/*.dll")
<br><br>SET(DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})<br><br>FOREACH(DLL_FILENAME ${QT_DLLS} ${PTHREAD_DLLS})<br> ADD_CUSTOM_COMMAND(<br> TARGET ${PROJECT_NAME}<br> POST_BUILD<br> COMMAND ${CMAKE_COMMAND} -E copy
<br> ${DLL_FILENAME} ${DESTINATION}<br> VERBATIM)<br> MESSAGE(COPY ${DLL_FILENAME} ${DESTINATION})<br>ENDFOREACH(DLL_FILENAME)<br>ENDIF(WIN32)<br><br><br>And here are a few lines from my VC++ buildlog.htm:<br>
<br>"C:\Program Files (x86)\CMake 2.4\bin\cmake.exe" -E copy<br>C:/Qt/4.3.1/lib/../bin/QtXml4.dll C:/bin/viewer/"$"(OutDir)<br><br>"C:\Program Files (x86)\CMake 2.4\bin\cmake.exe" -E copy<br>
C:/Qt/4.3.1/lib/../bin/QtXmld4.dll C:/bin/viewer/"$"(OutDir)<br><br><br>For some reason either cmake is quoting the $ in the expansion of the<br>${CMAKE_CFG_INTDIR} variable. Does anyone know a fix for this?<br>
<br>-McKay D<br><br><br><br><br><br> ____________________________________________________________________________________<br>Don't let your dream ride pass you by. Make it a reality with Yahoo! Autos.<br><a href="http://autos.yahoo.com/index.html">
http://autos.yahoo.com/index.html</a><br><br><br><br>_______________________________________________<br>CMake mailing list<br><a href="mailto:CMake@cmake.org">CMake@cmake.org</a><br><a href="http://www.cmake.org/mailman/listinfo/cmake">
http://www.cmake.org/mailman/listinfo/cmake</a><br></blockquote></div><br><br clear="all"><br>-- <br>___________________________________________<br>Andrew J. P. Maclean<br>Centre for Autonomous Systems<br>The Rose Street Building J04
<br>The University of Sydney 2006 NSW<br>AUSTRALIA<br>Ph: +61 2 9351 3283<br>Fax: +61 2 9351 7474<br>URL: <a href="http://www.acfr.usyd.edu.au/">http://www.acfr.usyd.edu.au/</a><br>___________________________________________