[CMake] AStyle or similar code beautifier

Clifford Yapp cliffyapp at gmail.com
Fri Jan 31 08:08:47 EST 2014


On Fri, Jan 31, 2014 at 2:01 AM, Rob McDonald <rob.a.mcdonald at gmail.com> wrote:
> All,
>
> I'm interested in adding a code beautifier to my project.  I'm looking at
> AStyle, but am open to others.
>
> Implementing a FindAStyle.cmake is pretty trivial.  Likewise, implementing
> custom targets is pretty straightforward in the simple case.
>
> However, I thought there might be some canonical/idiomatic examples of this
> sort of thing.  Any pointers to projects that do this particularly well?
> Are there any other code beautifiers that already have CMake support?

I don't know of any "canonical" way of doing this - it's going to
pretty similar to targets that run doxygen or otherwise trigger custom
action, assuming the idea is to have "make astyle-format" or something
similar that runs astyle on all your source files.

BRL-CAD has implemented (working but not yet activated for default
use) an integration of astyle that makes incorrect styling of source
code files a compile-time error when building the system.  It's both
more elaborate and more invasive than a "run astyle" build target, but
does compel developers to take styling rules seriously.  Sort of like
"-Werror" for code formatting.  There's also the option of "print
noisy warnings but keep building" for a less draconian approach that's
still hard to ignore.

Cheers,
CY


More information about the CMake mailing list