[CMake] About CMakeLists.txt coding style

Philip Lowman philip at yhbt.com
Sat May 17 11:59:11 EDT 2008


On Fri, May 16, 2008 at 9:56 PM, Edson Tadeu <e.tadeu at gmail.com> wrote:

>   (Not even mentioning the indent style). It seems that there is a
> transition going on from uppercase to lowercase in the recent CMakeLists...
> I don't know what style to settle for my new CMakeLists.txt's, because if I
> use lowercase, to copy&paste from other projects would be a real pain... but
> maybe the projects will convert their CMakeLists to lowercase? A tool to
> automatically convert from uppercase commands to lowercase would help.


I wrote this quick and dirty shell script which should work on most Unix
systems and Cygwin but I obviously haven't tested it extensively so run with
caution (i.e. backup first).  Also you'll want to make sure that "cmake"
version 2.6.0 or greater is in your path for it to work properly.

I'm sure someone that's out there who has the time could write this in CMake
script to make it more portable.  That would be a lot cooler actually, just
add INCLUDE(convert_my_project_commands_to_lowercase) once, configure, and
then you're done. =)

=====


#!/bin/sh
command_list=`cmake --help-command-list | grep -v 'cmake version '`

fix_case ()
{
    LC_COMMAND=$1
    UC_COMMAND=`echo $LC_COMMAND | tr '[a-z]' '[A-Z]'`
    echo "Replacing \"$UC_COMMAND\" with \"$LC_COMMAND\"..."
    find . -name CMakeLists.txt -exec sed -i s/$UC_COMMAND\
*\(/$LC_COMMAND\(/ {} \;
    find . -name \*.cmake       -exec sed -i s/$UC_COMMAND\
*\(/$LC_COMMAND\(/ {} \;
}

for command in $command_list
do
    fix_case $command
done



-- 
Philip Lowman
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20080517/43281345/attachment.htm>


More information about the CMake mailing list