<div class="gmail_quote">On Wed, Feb 3, 2010 at 1:09 AM, Michael Wild <span dir="ltr"><<a href="mailto:themiwi@gmail.com">themiwi@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="im"><br>
On 2. Feb, 2010, at 22:31 , <a href="mailto:Aaron_Wright@selinc.com">Aaron_Wright@selinc.com</a> wrote:<br>
<br>
> I run CONFIGURE_FILE on a file that is read only. The output file is also<br>
> read only, which is a problem because I need to append to it. Is there a<br>
> way to change this behavior? Or a work around?<br>
><br>
<br>
</div>Either change the source-file permissions or use file(COPY ...) after configure_file.<br></blockquote></div><br>There doesn't seem to be a way in cmake to change file permissions, which is an odd hole (there's lots of stuff about setting permissions at install-time, but nothing else). You'd have to do something system-specific like execute_process(COMMAND chmod).<br>
<br>There's also no file(COPY). I tried an experiment using cmake -E copy, but it also maintains permissions just like configure_file()!<br><br>The only work-around I've found is to copy the file "manually":<br>
<br>configure_file("${CMAKE_SOURCE_DIR}/readonly.txt" "${CMAKE_BINARY_DIR}/readonly.txt")<br>file(READ "${CMAKE_BINARY_DIR}/readonly.txt" myfile)<br>file(REMOVE "${CMAKE_BINARY_DIR}/readonly.txt")<br>
file(WRITE "${CMAKE_BINARY_DIR}/readonly.txt" "${myfile}")<br><br>This actually works, because it creates a new file with default permissions. Alternately, you could write to a new file with a different name; in that case you could skip the file(REMOVE).<br>
<br>I do agree, though, that ideally you wouldn't want to muck with a configured file after configuring it. However, I expect there are some non-ideal situations which might require that, so the above work-around should get you going.<br>
<br>Ceej<br>aka Chris Hillery<br>