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