[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cmake
Subject:    Re: [CMake] write file if different?
From:       Matthew Woehlke <matthew.woehlke () kitware ! com>
Date:       2013-05-30 22:19:00
Message-ID: ko8j8f$m99$1 () ger ! gmane ! org
[Download RAW message or body]

On 2013-05-29 03:32, Michael Wild wrote:
> On 28.05.2013 22:07, Matthew Woehlke wrote:
>> Is there a built-in way to write a string to a file (a la FILE(WRITE))
>> that will only write the file if the content would be different? (Or
>> does FILE(WRITE) already work this way despite no obvious hint in the
>> documentation that it does?)
>>
>> Right now I am writing to a temporary file and running cmake -E
>> copy_if_different, then removing the temporary file, but this seems
>> inelegant and I am wondering if there is a better solution.
>
> AFAIK the file is written unconditionally, but you can then use
> configure_file(... COPYONLY) instead of a round-about execute_process()
> that calls cmake -E copy_if_different.

Actually... no. Well, I could (it would technically work), but because I 
always write the file, it causes the build rules to always be out of 
date (i.e. CMake is re-run every time), which is decidedly sub-optimal :-).

(Didn't realize that until I finally decided to try it, just now. 
Although I wonder now if I had actually tried configure_file originally 
and switched to execute_process for exactly this reason...)

So... stronger argument for maybe adding this as an enhancement to CMake.

-- 
Matthew

--

Powered by www.kitware.com

Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic