[cmake-developers] CMake code style

Alan W. Irwin irwin at beluga.phys.uvic.ca
Mon Sep 20 19:27:47 EDT 2010


On 2010-09-20 16:20-0400 Bill Hoffman wrote:

> BTW, this type of code is not allowed in CMake:
>
>   if (fi!=files.begin()) os << ";";
>
> Needs to be:
>
> if((fi!=files.begin())
> {
> os << ";";
> }

If you want a consistent coding style in CMake, I suggest you give
uncrustify a look.  It is extremely powerful and configurable, and we
are quite pleased with the results it gives in the PLplot case.

Let's face it, with a variety of humans involved with a code base some
inconsistent coding style is constantly creeping in.  To stop that you
need (1) some sort of style czar or (2) some semi-automatic script
that does the job which one core developer runs by hand aperiodically
to bring all code into conformance with a uniform style.  I feel that
(2) is the better choice since it gives consistent results and better
feelings amongst developers since it is easier to come to consensus on
uncrustify options you are going to use then argue over styling of
individual files.

I have put together a shell script that is based on uncrustify and
which has options for listing all files that don't conform to the
ideal standard, showing differences between the ideal style and
actuality for those files (both in diff -auw format and diff -au
format), and a final option that fixes all those differences once you
are satisfied you like the changes that the diff options show.  You
are welcome to modify the script any way you like for your needs.  See
http://plplot.svn.sourceforge.net/viewvc/plplot/trunk/uncrustify.cfg?view=log
and
http://plplot.svn.sourceforge.net/viewvc/plplot/trunk/scripts/style_source.sh?view=log.

Alan
__________________________
Alan W. Irwin

Astronomical research affiliation with Department of Physics and Astronomy,
University of Victoria (astrowww.phys.uvic.ca).

Programming affiliations with the FreeEOS equation-of-state implementation
for stellar interiors (freeeos.sf.net); PLplot scientific plotting software
package (plplot.org); the libLASi project (unifont.org/lasi); the Loads of
Linux Links project (loll.sf.net); and the Linux Brochure Project
(lbproject.sf.net).
__________________________

Linux-powered Science
__________________________



More information about the cmake-developers mailing list