<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;"><div id="yiv2123885337">Thanks Michael for your reply.<br>I should have mentioned that every time I run 'make' (not cmake) I want to copy file only if <br>the original file in the source directory has changed.<br><br>I tried your suggestion, it works on cmake 2.4 but it still doesn't work on cmake 2.6<br>mladhe@linux:~/cmake_expt/bld] make<br>Built target sample.bash<br>mladhe@linux:~/cmake_expt/bld] ls<br>CMakeCache.txt&nbsp; CMakeFiles&nbsp; Makefile&nbsp; cmake_install.cmake<br><br>So though it says 'Built target sample.bash', the file has not been copied.<br>Also I believe CONFIGURE_FILE(... COPYONLY) will copy file only when running<br>'cmake' and not when running 'make'<br><br>I googled, but didn't find a solution that will work on both cmake versions.<br><br>Thanks,<br>Mahendra<br><br>--- On <b>Thu, 24/12/09, Michael Wild
 <i>&lt;themiwi@gmail.com&gt;</i></b> wrote:<br><blockquote style="border-left: 2px solid rgb(16, 16, 255); margin-left: 5px; padding-left: 5px;"><br>From: Michael Wild &lt;themiwi@gmail.com&gt;<br>Subject: Re: [CMake] Simple CMakeLists.txt file not working with cmake version 2.6<br>To: "Mahendra Ladhe" &lt;lml108@yahoo.com&gt;<br>Cc: cmake@cmake.org<br>Date: Thursday, 24 December, 2009, 1:06 AM<br><br><div class="plainMail"><br>On 24. Dec, 2009, at 9:26 , Mahendra Ladhe wrote:<br><br>&gt; Hi,<br>&gt;&nbsp;&nbsp;&nbsp;shown below is a simplified and relevant part of my CMakeLists.txt file.<br>&gt; <br>&gt; add_custom_command
 (<br>&gt;&nbsp;&nbsp;&nbsp;OUTPUT&nbsp; ${CMAKE_CURRENT_BINARY_DIR}/sample.bash<br>&gt;&nbsp;&nbsp;&nbsp;DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sample.bash<br>&gt;&nbsp;&nbsp;&nbsp;COMMAND cp ARGS -f&nbsp; ${CMAKE_CURRENT_SOURCE_DIR}/sample.bash .)<br><br>make the last line<br><br>&nbsp; &nbsp; COMMAND "${CMAKE_COMMAND}" -E copy_if_different<br>&nbsp; &nbsp; &nbsp; "${CMAKE_CURRENT_SOURCE_DIR}/sample.bash"<br>&nbsp; &nbsp; &nbsp; "${CMAKE_CURRENT_BINARY_DIR}/sample.bash")<br><br>However, if it really is only copying you are interested in, why don't you use CONFIGURE_FILE(... COPYONLY)?<br><br>&gt; <br>&gt; add_custom_target (sample.bash ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sample.bash)<br><br>I don't see why you want this... In any case, you need to rename this custom target, because it probably clashes with the custom command.<br><br>&gt; <br>&gt;&nbsp;&nbsp;&nbsp;Basically, I want to copy the 'sample.bash' script from source directory to the<br>&gt;
 binary (build) directory when 'make' is run.<br>&gt; I want this CMakeLists.txt to work on cmake version 2.4 as well as 2.6<br>&gt; <br>&gt; On cmake 2.4, this works fine.<br>&gt; mladhe@linux:~/cmake_expt/bld] make<br>&gt; [&nbsp; 0%] Generating sample.bash<br>&gt; [100%] Built target sample.bash<br>&gt; mladhe@linux45:~/cmake_expt/bld] ls<br>&gt; CMakeCache.txt&nbsp; CMakeFiles&nbsp; Makefile&nbsp; cmake_install.cmake&nbsp; sample.bash<br>&gt; <br>&gt; However on cmake 2.6, I get the following.<br>&gt; <br>&gt; mladhe@linux:~/cmake_expt/bld] make<br>&gt; Scanning dependencies of target sample.bash<br>&gt; make[2]: Circular CMakeFiles/sample.bash &lt;- sample.bash dependency dropped.<br>&gt; Built target sample.bash<br>&gt; mladhe@linux45:~/cmake_expt/bld] ls<br>&gt; CMakeCache.txt&nbsp; CMakeFiles&nbsp; Makefile&nbsp; cmake_install.cmake<br>&gt; <br>&gt; As can be seen, sample.bash file has not been copied.<br>&gt; <br>&gt; How to make this
 CMakeLists.txt work on both cmake versions ?<br>&gt; <br>&gt; Thank you,<br>&gt; Regards,<br>&gt; Mahendra Ladhe<br>&gt; <br><br>HTH<br><br>Michael<br><br></div></blockquote></div></td></tr></table><br>



      <!--1--><hr size=1></hr> 
The INTERNET now has a personality. YOURS! <a href="http://in.rd.yahoo.com/tagline_yyi_1/*http://in.yahoo.com/" target="_blank">See your Yahoo! Homepage</a>.