Hi,<div><br></div><div>I have different projects that generate a .lib and a .dll file, and I would like to copy these 2 files in a given directory as a post-build event. My main problem is that my debug libraries are post-fixed with _d, which require that I use the following code:<br clear="all">

<div><br></div><div>SET(MY_PROJECT project)</div><div>ADD_LIBRARY(${MY_PROJECT } SHARED ${HDRS} ${SOURCES} ... )</div><div>[...]</div><div><div>ADD_CUSTOM_COMMAND(TARGET ${MY_PROJECT } POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $&lt;TARGET_FILE:${MY_PROJECT }&gt; ${EXTERNAL_DIR} VERBATIM)</div>

<div>ADD_CUSTOM_COMMAND(TARGET ${MY_PROJECT } POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/debug/${MY_PROJECT }_d.lib ${EXTERNAL_DIR}/${MY_PROJECT }_d.lib VERBATIM)</div><div>ADD_CUSTOM_COMMAND(TARGET ${MY_PROJECT } POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/release/${MY_PROJECT }.lib ${EXTERNAL_DIR}/${MY_PROJECT }.lib VERBATIM)</div>

</div><div><br></div><div>The main problem is that the tool crash when I compile it the first time. For instance if I start to compile in Release the _d.lib file does not exist and it does not even process to copying the release .lib. Ok, it works if I compile it in the right order, but I would prefer to have a clean code for this.</div>

<div><br></div><div>I have been looking at using </div><div><div>INSTALL(TARGETS ${MY_PROJECT} DESTINATION ${EXTERNAL_DIR} COMPONENT Libraries)</div></div><div>but it creates a separate install vcproj that runs after all my projects, and I need my libraries copied right after the compilation as other projects depend on these output. So this is not a solution for me.</div>

<div><br></div>So I tryied to have a look at per configuration ADD_CUSTOM_COMMAND. I  found different discussion about this problem, but I don&#39;t manage to make it work:</div><div><a href="http://public.kitware.com/Bug/view.php?id=9974">http://public.kitware.com/Bug/view.php?id=9974</a></div>

<div><a href="http://public.kitware.com/Bug/view.php?id=11209">http://public.kitware.com/Bug/view.php?id=11209</a></div><div><br></div><div>The first one provide a patch, but I don&#39;t manage to get it working with cmake. Is there a special way to include these &quot;patches&quot; to our configurations?</div>

<div><br></div><div>Thanks</div><div><br></div><div>Ludovic<br>_______________________________________<br><br>Ludovic Hoyet<br>Research Fellow, <div><span style="font-family:Tahoma, Helvetica, sans-serif;font-size:13px;line-height:16px;background-color:rgb(255, 255, 255)">Graphics Vision and Visualisation group,</span><br>

Trinity College Dublin<br><a href="http://www.scss.tcd.ie/~hoyetl/" target="_blank">http://www.scss.tcd.ie/~hoyetl/</a></div><br>
</div>