<table cellspacing="0" cellpadding="0" border="0" ><tr><td valign="top" style="font: inherit;">Yes, that works for me too.<br>In add_custom_target, the target name should not be the same as<br>the name of the file one wants to copy, then it works on both cmake versions.<br><br>Thanks Michael.<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, 4:50 AM<br><br><div class="plainMail">This small test project works fine for me:<br><br>cmake_minimum_required(VERSION 2.6 FATAL_ERROR)<br>project(test NONE)<br>add_custom_command(<br>&nbsp; OUTPUT
 "${CMAKE_CURRENT_BINARY_DIR}/test.bash"<br>&nbsp; COMMAND "${CMAKE_COMMAND}" -E copy_if_different<br>&nbsp; "${CMAKE_CURRENT_SOURCE_DIR}/test.bash"<br>&nbsp; "${CMAKE_CURRENT_BINARY_DIR}/test.bash"<br>&nbsp; COMMENT "Creating ${CMAKE_CURRENT_BINARY_DIR}/test.bash"<br>&nbsp; VERBATIM)<br>add_custom_target(create_test_bash ALL DEPENDS<br>&nbsp; "${CMAKE_CURRENT_BINARY_DIR}/test.bash")<br><br><br>HTH<br><br>Michael<br><br>On 24. Dec, 2009, at 13:27 , Mahendra Ladhe wrote:<br><br>&gt; Thanks Michael for your reply.<br>&gt; I should have mentioned that every time I run 'make' (not cmake) I want to copy file only if <br>&gt; the original file in the source directory has changed.<br>&gt; <br>&gt; I tried your suggestion, it works on cmake 2.4 but it still doesn't work on cmake 2.6<br>&gt; mladhe@linux:~/cmake_expt/bld] make<br>&gt; Built target sample.bash<br>&gt; mladhe@linux:~/cmake_expt/bld] ls<br>&gt; CMakeCache.txt&nbsp; CMakeFiles&nbsp; Makefile&nbsp;
 cmake_install.cmake<br>&gt; <br>&gt; So though it says 'Built target sample.bash', the file has not been copied.<br>&gt; Also I believe CONFIGURE_FILE(... COPYONLY) will copy file only when running<br>&gt; 'cmake' and not when running 'make'<br>&gt; <br>&gt; I googled, but didn't find a solution that will work on both cmake versions.<br>&gt; <br>&gt; Thanks,<br>&gt; Mahendra<br>&gt; <br>&gt; --- On Thu, 24/12/09, Michael Wild &lt;<a ymailto="mailto:themiwi@gmail.com" href="/mc/compose?to=themiwi@gmail.com">themiwi@gmail.com</a>&gt; wrote:<br>&gt; <br>&gt; From: Michael Wild &lt;<a ymailto="mailto:themiwi@gmail.com" href="/mc/compose?to=themiwi@gmail.com">themiwi@gmail.com</a>&gt;<br>&gt; Subject: Re: [CMake] Simple CMakeLists.txt file not working with cmake version 2.6<br>&gt; To: "Mahendra Ladhe" &lt;<a ymailto="mailto:lml108@yahoo.com" href="/mc/compose?to=lml108@yahoo.com">lml108@yahoo.com</a>&gt;<br>&gt; Cc: <a ymailto="mailto:cmake@cmake.org"
 href="/mc/compose?to=cmake@cmake.org">cmake@cmake.org</a><br>&gt; Date: Thursday, 24 December, 2009, 1:06 AM<br>&gt; <br>&gt; <br>&gt; On 24. Dec, 2009, at 9:26 , Mahendra Ladhe wrote:<br>&gt; <br>&gt;&gt; Hi,<br>&gt;&gt;&nbsp; &nbsp; shown below is a simplified and relevant part of my CMakeLists.txt file.<br>&gt;&gt; <br>&gt;&gt; add_custom_command<br>&gt; (<br>&gt;&gt;&nbsp; &nbsp; OUTPUT&nbsp; ${CMAKE_CURRENT_BINARY_DIR}/sample.bash<br>&gt;&gt;&nbsp; &nbsp; DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/sample.bash<br>&gt;&gt;&nbsp; &nbsp; COMMAND cp ARGS -f&nbsp; ${CMAKE_CURRENT_SOURCE_DIR}/sample.bash .)<br>&gt; <br>&gt; make the last line<br>&gt; <br>&gt;&nbsp; &nbsp;&nbsp;&nbsp;COMMAND "${CMAKE_COMMAND}" -E copy_if_different<br>&gt;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;"${CMAKE_CURRENT_SOURCE_DIR}/sample.bash"<br>&gt;&nbsp; &nbsp; &nbsp;&nbsp;&nbsp;"${CMAKE_CURRENT_BINARY_DIR}/sample.bash")<br>&gt; <br>&gt; However, if it really is only copying you are interested
 in, why don't you use CONFIGURE_FILE(... COPYONLY)?<br>&gt; <br>&gt;&gt; <br>&gt;&gt; add_custom_target (sample.bash ALL DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/sample.bash)<br>&gt; <br>&gt; 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>&gt; <br>&gt;&gt; <br>&gt;&gt;&nbsp; &nbsp; Basically, I want to copy the 'sample.bash' script from source directory to the<br>&gt;&gt; <br>&gt; binary (build) directory when 'make' is run.<br>&gt;&gt; I want this CMakeLists.txt to work on cmake version 2.4 as well as 2.6<br>&gt;&gt; <br>&gt;&gt; On cmake 2.4, this works fine.<br>&gt;&gt; mladhe@linux:~/cmake_expt/bld] make<br>&gt;&gt; [&nbsp; 0%] Generating sample.bash<br>&gt;&gt; [100%] Built target sample.bash<br>&gt;&gt; mladhe@linux45:~/cmake_expt/bld] ls<br>&gt;&gt; CMakeCache.txt&nbsp; CMakeFiles&nbsp; Makefile&nbsp; cmake_install.cmake&nbsp; sample.bash<br>&gt;&gt;
 <br>&gt;&gt; However on cmake 2.6, I get the following.<br>&gt;&gt; <br>&gt;&gt; mladhe@linux:~/cmake_expt/bld] make<br>&gt;&gt; Scanning dependencies of target sample.bash<br>&gt;&gt; make[2]: Circular CMakeFiles/sample.bash &lt;- sample.bash dependency dropped.<br>&gt;&gt; Built target sample.bash<br>&gt;&gt; mladhe@linux45:~/cmake_expt/bld] ls<br>&gt;&gt; CMakeCache.txt&nbsp; CMakeFiles&nbsp; Makefile&nbsp; cmake_install.cmake<br>&gt;&gt; <br>&gt;&gt; As can be seen, sample.bash file has not been copied.<br>&gt;&gt; <br>&gt;&gt; How to make this<br>&gt; CMakeLists.txt work on both cmake versions ?<br>&gt;&gt; <br>&gt;&gt; Thank you,<br>&gt;&gt; Regards,<br>&gt;&gt; Mahendra Ladhe<br>&gt;&gt; <br>&gt; <br>&gt; HTH<br>&gt; <br>&gt; Michael<br>&gt; <br>&gt; <br>&gt; <br>&gt; <br>&gt;&nbsp; &nbsp; &nbsp; The INTERNET now has a personality. YOURS! See your Yahoo! Homepage. <a href="http://in.yahoo.com/"
 target="_blank">http://in.yahoo.com/</a><br><br></div></blockquote></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>.