[cmake-developers] CMake code style

Michael Wild themiwi at gmail.com
Tue Sep 21 15:33:34 EDT 2010


On 21. Sep, 2010, at 18:13 , Alexander Neundorf wrote:

> On Tuesday 21 September 2010, Alan W. Irwin wrote:
>> 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 guess Kitware would favour kwstyle for that job ?
> Last time I checked a few years ago it still had to mature a bit, don't know 
> how it looks today.
> 
> Alex

IMHO the style should be checked using a commit-hook, and if it doesn't match, the commit should be refused. The reason why I prefer this over periodically run cleanup-scripts is that these scripts make the "blame" operation nearly useless. Similarly, I loath "whitespace errors" (inconsistent indentation, mixing of tabs/spaces for indents, tabs for alignment, trailing whitespace), but I'm also against fixing them for their own sake. I rather keep them until that particular line/block needs to be changed otherwise.

Michael

--
There is always a well-known solution to every human problem -- neat, plausible, and wrong.
H. L. Mencken

-------------- next part --------------
A non-text attachment was scrubbed...
Name: PGP.sig
Type: application/pgp-signature
Size: 195 bytes
Desc: This is a digitally signed message part
URL: <http://public.kitware.com/pipermail/cmake-developers/attachments/20100921/f4076bfa/attachment.sig>


More information about the cmake-developers mailing list