[CMake] write file if different?
j s
j.s4403 at gmail.com
Thu May 30 14:01:56 EDT 2013
On Thu, May 30, 2013 at 12:36 PM, Matthew Woehlke
<matthew.woehlke at kitware.com> wrote:
> On 2013-05-30 12:11, j s wrote:
>>
>> On Wed, May 29, 2013 at 11:14 PM, themiwi at gmail.com wrote:
>>>
>>> "j s" 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?)
>>>>
>>>>
>>>> You can always use the rsync command, which is available for all
>>>> systems, including Windows.
>>>
>>>
>>> That's probably the worst possible solution... CMake has everything that
>>> iy
>>> required to accomplish this built-in, so adding a unnecessary dependency
>>> that is only needed by the build system is a really bad idea...
>>
>>
>> You are entitled to your opinion, but there are several system
>> utilities that are available by default on many systems, including
>> rsync.
>
>
> Really? I have yet to encounter a Windows system that has rsync "by
> default". (For that matter, even on Linux it is not required, and I wouldn't
> put a lot of faith in finding it on a 'stock' non-Linux/BSD UNIX platform.)
It is available by default on both Mac OS X and Ubuntu Linux, and is
readily available as a package on many others. In fact, many package
management software require rsync to even run. It is readily
available on Windows by installing Cygwin.
>
> Besides, using rsync for a single file where cmake -E copy_if_different (or
> even configure_file as elsewhere mentioned) is clearly overkill. Not to
> mention that rsync is not guaranteed to be present even on UNIX systems,
The original poster's test case may not be the best example for using
an external utility. In fact, they'd be better off using something
like a custom target having the appropriate dependencies. Barring
that they should use a script written in a real scripting language
that unambigously performs the steps needed.
>
>
>> The way CMake does things is often kludgy and just feels wrong. I
>> often write scripts in more effective languages and then run from
>> within CMake on Windows, Linux, and Mac OS X. Perl and Python are
>> often a much better way to go than trying to do everything in CMake.
>
>
> Sure, and where a) it makes sense and b) I *already require the relevant
> tools for other reasons*, I do also. But I try to avoid it, because these
> dependencies are usually NOT present on Windows, especially for end users
> that want to build from a tarball. (Which is why, when I wrote test
> discovery for gtest, I did it in pure CMake. It may not be the
> easiest/cleanest, but I strongly prefer to avoid large external dependencies
> without much stronger motivation for needing them.)
Standard system utilities are the cleanest, and easiest. These tools
are readily available on Windows via Cygwin. Most every program I
write requires already Boost, Bison, Flex and a Python interpreter, so
a Unix like environment is going to be required anyways. I use cmake
because it is an accurate Makefile and Visual Studio generator. It's
main fault is it's domain specific language.
>
> --
> 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
More information about the CMake
mailing list