That&#39;s perfect, TARGET_LINKER_FILE exactly did the job<div><br></div><div>Thanks a million</div><div><br></div><div>Ludo<br><br><div class="gmail_quote">2011/11/9 David Cole <span dir="ltr">&lt;<a href="mailto:david.cole@kitware.com">david.cole@kitware.com</a>&gt;</span><br>

<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">There are also generator expressions for TARGET_LINKER_FILE and<br>
TARGET_SONAME_FILE -- have you tried those? I think when the target is<br>
a .dll, the TARGET_LINKER_FILE expression yields the name of the<br>
corresponding .lib file...<br>
<br>
<br>
HTH,<br>
David<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On Wed, Nov 9, 2011 at 10:28 AM, Ludovic Hoyet &lt;<a href="mailto:lhoyet@gmail.com">lhoyet@gmail.com</a>&gt; wrote:<br>
&gt; I just tried it (maybe I did something wrong) but it does not work:<br>
&gt; ADD_CUSTOM_COMMAND(TARGET ${MY_PROJECT } POST_BUILD COMMAND ${CMAKE_COMMAND}<br>
&gt; -E copy $&lt;TARGET_FILE:${MY_PROJECT }&gt; ${EXTERNAL_DIR} VERBATIM)<br>
&gt; ADD_CUSTOM_COMMAND(TARGET ${MY_PROJECT } POST_BUILD COMMAND ${CMAKE_COMMAND}<br>
&gt; -E copy $&lt;TARGET_FILE:${MY_PROJECT }&gt;.lib ${EXTERNAL_DIR} VERBATIM)<br>
&gt; The first line copy the dll, no pb with this it was already working. The<br>
&gt; second line try to copy project_d.dll.lib for Debug and project.dll.lib for<br>
&gt; Release<br>
&gt; How can I access the name of the output file without the extension?<br>
&gt; 2011/11/9 Rolf Eike Beer &lt;<a href="mailto:eike@sf-mail.de">eike@sf-mail.de</a>&gt;<br>
&gt;&gt;<br>
&gt;&gt; &gt; Hi,<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I have different projects that generate a .lib and a .dll file, and I<br>
&gt;&gt; &gt; would<br>
&gt;&gt; &gt; like to copy these 2 files in a given directory as a post-build event.<br>
&gt;&gt; &gt; My<br>
&gt;&gt; &gt; main problem is that my debug libraries are post-fixed with _d, which<br>
&gt;&gt; &gt; require that I use the following code:<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; SET(MY_PROJECT project)<br>
&gt;&gt; &gt; ADD_LIBRARY(${MY_PROJECT } SHARED ${HDRS} ${SOURCES} ... )<br>
&gt;&gt; &gt; [...]<br>
&gt;&gt; &gt; ADD_CUSTOM_COMMAND(TARGET ${MY_PROJECT } POST_BUILD COMMAND<br>
&gt;&gt; &gt; ${CMAKE_COMMAND} -E copy $&lt;TARGET_FILE:${MY_PROJECT }&gt; ${EXTERNAL_DIR}<br>
&gt;&gt; &gt; VERBATIM)<br>
&gt;&gt; &gt; ADD_CUSTOM_COMMAND(TARGET ${MY_PROJECT } POST_BUILD COMMAND<br>
&gt;&gt; &gt; ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/debug/${MY_PROJECT<br>
&gt;&gt; &gt; }_d.lib<br>
&gt;&gt; &gt; ${EXTERNAL_DIR}/${MY_PROJECT }_d.lib VERBATIM)<br>
&gt;&gt; &gt; ADD_CUSTOM_COMMAND(TARGET ${MY_PROJECT } POST_BUILD COMMAND<br>
&gt;&gt; &gt; ${CMAKE_COMMAND} -E copy ${LIBRARY_OUTPUT_PATH}/release/${MY_PROJECT<br>
&gt;&gt; &gt; }.lib<br>
&gt;&gt; &gt; ${EXTERNAL_DIR}/${MY_PROJECT }.lib VERBATIM)<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; The main problem is that the tool crash when I compile it the first<br>
&gt;&gt; &gt; time.<br>
&gt;&gt; &gt; For instance if I start to compile in Release the _d.lib file does not<br>
&gt;&gt; &gt; exist and it does not even process to copying the release .lib. Ok, it<br>
&gt;&gt; &gt; works if I compile it in the right order, but I would prefer to have a<br>
&gt;&gt; &gt; clean code for this.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; I have been looking at using<br>
&gt;&gt; &gt; INSTALL(TARGETS ${MY_PROJECT} DESTINATION ${EXTERNAL_DIR} COMPONENT<br>
&gt;&gt; &gt; Libraries)<br>
&gt;&gt; &gt; but it creates a separate install vcproj that runs after all my<br>
&gt;&gt; &gt; projects,<br>
&gt;&gt; &gt; and I need my libraries copied right after the compilation as other<br>
&gt;&gt; &gt; projects depend on these output. So this is not a solution for me.<br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; So I tryied to have a look at per configuration ADD_CUSTOM_COMMAND. I<br>
&gt;&gt; &gt;  found different discussion about this problem, but I don&#39;t manage to<br>
&gt;&gt; &gt; make<br>
&gt;&gt; &gt; it work:<br>
&gt;&gt; &gt; <a href="http://public.kitware.com/Bug/view.php?id=9974" target="_blank">http://public.kitware.com/Bug/view.php?id=9974</a><br>
&gt;&gt; &gt; <a href="http://public.kitware.com/Bug/view.php?id=11209" target="_blank">http://public.kitware.com/Bug/view.php?id=11209</a><br>
&gt;&gt; &gt;<br>
&gt;&gt; &gt; The first one provide a patch, but I don&#39;t manage to get it working with<br>
&gt;&gt; &gt; cmake. Is there a special way to include these &quot;patches&quot; to our<br>
&gt;&gt; &gt; configurations?<br>
&gt;&gt;<br>
&gt;&gt; Use generator expressions to get the name of the generated files.<br>
&gt;&gt;<br>
&gt;&gt; Eike<br>
&gt;&gt; --<br>
&gt;&gt;<br>
&gt;&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;&gt;<br>
&gt;&gt; Visit other Kitware open-source projects at<br>
&gt;&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;&gt;<br>
&gt;&gt; Please keep messages on-topic and check the CMake FAQ at:<br>
&gt;&gt; <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
&gt;&gt;<br>
&gt;&gt; Follow this link to subscribe/unsubscribe:<br>
&gt;&gt; <a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
&gt;<br>
&gt;<br>
&gt;<br>
&gt; --<br>
&gt; _______________________________________<br>
&gt;<br>
&gt; Ludovic Hoyet<br>
&gt; Research Fellow,<br>
&gt; Graphics Vision and Visualisation group,<br>
&gt; Trinity College Dublin<br>
&gt; <a href="http://www.scss.tcd.ie/~hoyetl/" target="_blank">http://www.scss.tcd.ie/~hoyetl/</a><br>
&gt;<br>
&gt; --<br>
&gt;<br>
&gt; Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
&gt;<br>
&gt; Visit other Kitware open-source projects at<br>
&gt; <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
&gt;<br>
&gt; Please keep messages on-topic and check the CMake FAQ at:<br>
&gt; <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
&gt;<br>
&gt; Follow this link to subscribe/unsubscribe:<br>
&gt; <a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
&gt;<br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <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>