<div dir="ltr"><div dir="ltr"><br><br><div class="gmail_quote"><div dir="ltr">On Fri, Sep 21, 2018 at 3:00 PM Ke Gao <<a href="mailto:ke.gao.ut@gmail.com">ke.gao.ut@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div>Hi,</div><div><br></div><div>In a project, I need to first duplicate a source file and rename it. For example, I want to change "file.c" to "aaa_file.c", and after compiling, I will delete it. This is similar to using "cp file.c aaa_file.c". How to easily do this in CMake? I found "file" command doesn't work well for this.</div><div><br></div></div></blockquote><div><br></div><div><div><div>add_custom_command( OUTPUT aaa_file.c</div><div> DEPENDS file.c</div><div> COMMAND ${CMAKE_COMMAND} -E copy_if_different file.c aaa_file.c</div></div><div> )</div><div><br></div><div>then you just have to reference the source file 'aaa_file.c' and it will get updated if file.c is different. I also do</div></div><div> COMMAND ${CMAKE_COMMAND} -E touch aaa_file.c</div><div><br></div><div>just to make sure it is new.</div><div><br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div></div><div>Thank you very much.</div><div><br>-- <br><div dir="ltr" class="gmail-m_2135251374350216418gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><font size="1" face="arial,helvetica,sans-serif" color="#000000">..............................................................................................................................................</font></div><font face="tahoma,sans-serif" color="#3366ff"><div><font style="background-color:rgb(255,255,255)" face="arial black,sans-serif" color="#000000">Ke Gao</font></div></font></div></div></div></div></div></div></div></div>
-- <br>
<br>
Powered by <a href="http://www.kitware.com" rel="noreferrer" target="_blank">www.kitware.com</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" rel="noreferrer" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Kitware offers various services to support the CMake community. For more information on each offering, please visit:<br>
<br>
CMake Support: <a href="http://cmake.org/cmake/help/support.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/support.html</a><br>
CMake Consulting: <a href="http://cmake.org/cmake/help/consulting.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/consulting.html</a><br>
CMake Training Courses: <a href="http://cmake.org/cmake/help/training.html" rel="noreferrer" target="_blank">http://cmake.org/cmake/help/training.html</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" rel="noreferrer" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="https://cmake.org/mailman/listinfo/cmake" rel="noreferrer" target="_blank">https://cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div></div></div>