[CMake] installation of properly line ended text files

Dizzy dizzy at roedu.net
Fri Aug 24 05:08:34 EDT 2007


On Friday 24 August 2007 11:48:27 Andreas Pakulat wrote:
> You can have a different lineending on the working copy really easily by
> using svn:eol-style property (on each file where you want it). That way
> you could checkout on win32 and automatically get win32-lineendings for
> those files that should have them. Then you can build/install/package
> that without problems. (only drawback here is that you can't use such a
> win32 working copy from unix, via nfs or such and you need to take extra
> care when copying diffs around)

And that problem is really important. Almost all the time I copy the files 
from the linux FS to the Windows FS before using them there. I thought about 
svn:eol-style property some time ago (cmake unrelated) and this was why I 
didn't used it in the first place.

Plus this would be a repository specific solution, not a general one. What if 
we move to some over source repository?

> Alternatively you could let your program be intelligent enough to guess
> the lineending by checking wether its \r\n or just \n and adjust the
> reading of the conf files apropriately.

The program is already able to deal with these files, the problem is that 
being configuration files means the admin should be able to easily edit them. 
I find it very logical to require the project to properly deal with all 
portability issues and when using cmake which is used to do all system 
detection with the various check_include_file, find_library, 
check_function_exists, check_type_size, etc

>
> > Any idea how to do this? (I was thinking that a INSTALL(TEXT ... )
> > signature that does this could be perfect no?)
>
> I'm not sure its the buildsystems job to fix lineendings for you.

I would see cmake as something one uses to generate files for a specific build 
system taking care of all portability issues in such a way that when using 
that build system to build and install you get the proper result. Considering 
that cmake already has the logic that portably generates proper line endings 
for the target platform (ex. used by configure_file()) it would be great to 
be able to use that same functionality.

Having cmake convert the line endings it's the same as having cmake generate 
the config.h file from its input version by replacing those #cmakedefines. In 
the line endings case the #cmakedefines are the UNIX line endings and the 
filled values which normally are the value of HAVE_UNISTD_H & co are the 
current platform line ending. Since cmake already works by changing something 
platform independent as #cmakedefine to a platform dependent (as found out by 
the checks) string (filling "#define HAVE_UNISTD_H "or "/* #undef 
HAVE_UNISTD_H *" depends on the platform in the end) it would be normal to be 
able to do so just for a little thing such as line endings.

-- 
Mihai RUSU					Email: dizzy at roedu.net
			"Linux is obsolete" -- AST


More information about the CMake mailing list