<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>&nbsp;</div>
<div>(Note the the explicit specification of &quot;Debug and release in the WIN32 section.)</div>
<div>&nbsp;</div>
<div>#--------------------------&nbsp;Start of code ----------------------<br>&nbsp;</div>
<div>
<p>IF ( WIN32 )<br>&nbsp; # Only needed for windows.<br>&nbsp; # Note: We need to copy the dlls to two places in the build tree, namely<br>&nbsp; #&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}</p>
<p>&nbsp; IF(NOT STATIC_BUILD)<br>&nbsp;&nbsp;&nbsp; # Find the dlls we need.<br>&nbsp;&nbsp;&nbsp; FIND_FILE(LIBPQ_DLL libpq.dll PATHS ${POSTGRESQL_LIBRARY_DIRS} NO_DEFAULT_PATH )<br>&nbsp;&nbsp;&nbsp; FIND_FILE(LIBPQD_DLL libpqd.dll PATHS ${POSTGRESQL_LIBRARY_DIRS} NO_DEFAULT_PATH )
<br>&nbsp;&nbsp;&nbsp; FIND_FILE(LIBPQXX_DLL libpqxx.dll PATHS ${LIBPQXX_LIBRARY_DIRS} NO_DEFAULT_PATH )<br>&nbsp;&nbsp;&nbsp; FIND_FILE(LIBPQXXD_DLL libpqxxD.dll PATHS ${LIBPQXX_LIBRARY_DIRS} NO_DEFAULT_PATH )<br>&nbsp;&nbsp;&nbsp; SET ( ESSENTIAL_FILES ${ESSENTIAL_FILES}
<br>&nbsp;&nbsp; ${LIBPQ_DLL}<br>&nbsp;&nbsp; ${LIBPQXX_DLL}<br>&nbsp;)<br>&nbsp;SET ( ESSENTIAL_FILES_DEBUG ${ESSENTIAL_FILES_DEBUG}<br>&nbsp;&nbsp; ${LIBPQD_DLL}<br>&nbsp;&nbsp; ${LIBPQXXD_DLL}<br>&nbsp;)<br>&nbsp; ENDIF(NOT STATIC_BUILD)</p>
<p>&nbsp; # Copy these files to the build tree.<br>&nbsp; # We cannot determine whether Release or Debug is being used.<br>&nbsp; ADD_CUSTOM_TARGET(CopyDllCfg ALL echo &quot;Copying dlls and essential files ...&quot;)</p>
<p>&nbsp; FOREACH(file ${ESSENTIAL_FILES_DEBUG})<br>&nbsp;GET_FILENAME_COMPONENT(fn ${file} NAME)<br>&nbsp;SET(tgt ${EXECUTABLE_OUTPUT_PATH}/Debug/${fn})<br>&nbsp;SET(src ${file})<br>&nbsp;ADD_CUSTOM_COMMAND(<br>&nbsp;&nbsp; TARGET CopyDllCfg<br>&nbsp;&nbsp; COMMAND ${CMAKE_COMMAND}
<br>&nbsp;&nbsp; ARGS -E copy_if_different ${src} ${tgt}<br>&nbsp;&nbsp; COMMENT &quot;source copy dlls and essential files&quot;<br>&nbsp;)<br>&nbsp; ENDFOREACH(file)</p>
<p>&nbsp; FOREACH(file ${ESSENTIAL_FILES})<br>&nbsp;&nbsp;&nbsp; GET_FILENAME_COMPONENT(fn ${file} NAME)<br>&nbsp;&nbsp;&nbsp; SET(tgt ${EXECUTABLE_OUTPUT_PATH}/Release/${fn})<br>&nbsp;&nbsp;&nbsp; SET(src ${file})<br>&nbsp;&nbsp;&nbsp; ADD_CUSTOM_COMMAND(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TARGET CopyDllCfg<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND ${CMAKE_COMMAND}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ARGS -E copy_if_different ${src} ${tgt}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMENT &quot;source copy dlls and essential files&quot;<br>&nbsp;&nbsp;&nbsp; )<br>&nbsp; ENDFOREACH(file)</p>
<p>ELSE ( WIN32 )</p>
<p>&nbsp; # Copy these files to the build tree.<br>&nbsp; ADD_CUSTOM_TARGET(CopyCfg ALL echo &quot;Copying dlls and essential files ...&quot;)</p>
<p>&nbsp; FOREACH(file ${ESSENTIAL_FILES})<br>&nbsp;&nbsp;&nbsp; GET_FILENAME_COMPONENT(fn ${file} NAME)<br>&nbsp;&nbsp;&nbsp; SET(tgt ${EXECUTABLE_OUTPUT_PATH}/${CMAKE_CFG_INTDIR}/${fn})<br>&nbsp;&nbsp;&nbsp; SET(src ${file})<br>&nbsp;&nbsp;&nbsp; ADD_CUSTOM_COMMAND(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TARGET CopyCfg
<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMAND ${CMAKE_COMMAND}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ARGS -E copy_if_different ${src} ${tgt}<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; COMMENT &quot;source copy essential files&quot;<br>&nbsp;&nbsp;&nbsp; )<br>&nbsp; ENDFOREACH(file)</p>
<p>ENDIF ( WIN32 )<br></p><br>#-------------------------- End of code -----------------------<br>Regards</div>
<div>&nbsp;&nbsp; Andrew</div>
<div>&nbsp;</div>
<div>&nbsp;</div>
<div><span class="gmail_quote">On 9/18/07, <b class="gmail_sendername">McKay Davis</b> &lt;<a href="mailto:mckayd@yahoo.com">mckayd@yahoo.com</a>&gt; wrote:</span>
<blockquote class="gmail_quote" style="PADDING-LEFT: 1ex; MARGIN: 0px 0px 0px 0.8ex; BORDER-LEFT: #ccc 1px solid">I&#39;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: &quot;$&quot;(OutDir)<br><br>This causes the .dll files to be copied to the filename &#39;$(OutDir)&#39;, not into<br>the &#39;Debug&#39; or &#39;Release&#39; sub-directory as I would expect.
<br><br>Here is the relevant cmake code:<br><br>IF(WIN32)<br>FILE(GLOB QT_DLLS &quot;${QT_LIBRARY_DIR}/../bin/*.dll&quot;)<br><br>GET_FILENAME_COMPONENT(PTHREAD_LIBRARY_DIR &quot;${PTHREAD_LIBRARY}&quot; PATH)<br>FILE(GLOB PTHREAD_DLLS &quot;${PTHREAD_LIBRARY_DIR}/*.dll&quot;)
<br><br>SET(DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})<br><br>FOREACH(DLL_FILENAME ${QT_DLLS} ${PTHREAD_DLLS})<br>&nbsp;&nbsp; ADD_CUSTOM_COMMAND(<br>&nbsp;&nbsp;&nbsp;&nbsp; TARGET ${PROJECT_NAME}<br>&nbsp;&nbsp;&nbsp;&nbsp; POST_BUILD<br>&nbsp;&nbsp;&nbsp;&nbsp; COMMAND ${CMAKE_COMMAND} -E copy
<br>&nbsp;&nbsp;&nbsp;&nbsp; ${DLL_FILENAME} ${DESTINATION}<br>&nbsp;&nbsp;&nbsp;&nbsp; VERBATIM)<br>&nbsp;&nbsp;&nbsp;&nbsp; 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>&quot;C:\Program Files (x86)\CMake 2.4\bin\cmake.exe&quot; -E copy<br>C:/Qt/4.3.1/lib/../bin/QtXml4.dll C:/bin/viewer/&quot;$&quot;(OutDir)<br><br>&quot;C:\Program Files (x86)\CMake 2.4\bin\cmake.exe&quot; -E copy<br>
C:/Qt/4.3.1/lib/../bin/QtXmld4.dll C:/bin/viewer/&quot;$&quot;(OutDir)<br><br><br>For some reason either cmake is quoting the $ in the expansion of the<br>${CMAKE_CFG_INTDIR} variable.&nbsp;&nbsp;Does anyone know a fix for this?<br>
<br>-McKay D<br><br><br><br><br><br>&nbsp;&nbsp;&nbsp;&nbsp; ____________________________________________________________________________________<br>Don&#39;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&nbsp;&nbsp;2006&nbsp;&nbsp;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>___________________________________________