[CMake] copy_if_different on build
Matthew Woehlke
matthew.woehlke at kitware.com
Fri Mar 29 15:33:47 EDT 2013
On 2013-03-29 15:15, Skippy VonDrake wrote:
> I'm using:
> execute_process(COMMAND ${CMAKE_COMMAND} -E copy_if_different
> <some-file> <some-dest-dir>)
>
> Should the file be copied when:
> the file has changed AND a build is executed?
> Or
> the file has changed AND CMakeLists.txt has changed AND a build is executed?
>
> Only the 2nd method (when the CMakeLists.txt file is touched) results in the
> changed file being copied.
>
> I'd expect the 1st method to also cause a file copy.
> If this assumption is wrong please tell me why.
execute_process is a configure step. It does not create build rules and
will ONLY execute when CMake is run.
If you want to create a build rule, use add_custom_command or
add_custom_target instead.
Anyway, the above is silly; if you really only wanted the file copied at
cmake time, you should instead use configure_file(... COPY_ONLY) :-)
rather than unnecessarily invoking an extra process.
--
Matthew
More information about the CMake
mailing list