<div>Hello,<br></div><div><br></div><div>I have a custom target which runs a command to generate</div><div>a C source file say test1.c</div><div><br></div><div>ADD_CUSTOM_TARGET(TestGen ALL<br>COMMAND genExec ${PROJECT_SOURCE_DIR}/Main.java</div>
<div>DEPENDS ${PROJECT_SOURCE_DIR}/Main.java<br>   )</div><div><br></div><div>And I have a custom command that moves the generated <strong>test1.c </strong></div><div>to a new directory inside the build directory.</div><div>
<br></div><div>ADD_CUSTOM_COMMAND(<br>  TARGET TestGen<br>  POST_BUILD<br>COMMAND mv</div><div>ARGS ${PROJECT_BINARY_DIR}/test1.c ${PROJECT_BINARY_DIR}/tests/</div><div>)</div><div><br></div><div>Each time I run make, the custom target is run (since custom targets are always<br>
</div><div>out-of-date). But I want to avoid moving the new test1.c generated each time</div><div>if build/test1.c is the same as build/tests/test1.c since there are other targets</div><div>like add_executable and add_library later in the CMakelists file that are  re-built</div>
<div>each time since they depend on test1.c</div><div><br></div><div>I tried cmake -E compare_files inside execute_process, but it would not be</div><div>executed before the custom command.</div><div><br></div><div>I tried cmake -E compare_files inside a custom command as well, but that would give an</div>
<div>error and halt the make process if the files differ.</div><div><br></div><div>I want to avoid re-building later targets that depend on test1.c.</div><div><br></div><div>Thanks</div><div>Ajay</div>