In CMake I have a folder containing predefined Gettext catalogs, which at build time I copy to a folder and then modify them. But the problem is that every time I run the target it'll copy the predefined file on the local copy (which is probably modified). Is there a way to copy if the file is different to a state it was before, otherwise leave it alone?
I was also thinking that a way to do this would be to copy them across at CMake generation time, but I feel a little weary of doing that as people may delete the folders and screw things up. Also I don't know how to perform commands at generation time, only at build time.
Another option is to use
configure_file
withCOPYONLY
argument.This won't perform any variable substitution and will copy "input_file" when you run
make
. But it triggers a cmake run and this may be undesirable because of time consumption.I believe you should be able to use a custom command that depends on the file. Something like:
Let me know if that doesn't do it. It might help to provide the CMake code you're currently using.
You might also try "${CMAKE_COMMAND} -E copy_if_different"; it's not clear to me whether this would be different given the dependencies of the command, but I could certainly be missing something, or it could be different if you're not using "make" output.
In case you want to try doing the copy at "generation time" (when you run cmake), you can use this command (I think my syntax is correct but I didn't test it):
Using INSTALL instead of COPY gives slightly different behavior.
If you need to run an arbitrary process at generation time, try the
execute_process
command.Of course for details see the CMake documentation.
Alrighty, I managed to fix this a while back but forgot about this answer. Sorry all the people who've skipped over this and not had the answer!
stockDir is the directory containing the stocked po files that aren't meant to be user edited (unless committing to the repo). langDir is in the build directory under 'lang'. It goes through, and either copies or updates it based on the files' age.