How to ensure consistent coding style for CMakeLists.txt and FindXXX.cmake

一个人想着一个人 提交于 2019-12-11 03:52:37

问题


There are clang-format etc to ensure a consistent coding style for .cpp and .h files among different developers.

But how can I ensure consistent coding style in CMake for CMakeLists.txt and FindXXX.cmake written from different developers?

The main rules I want to enforce is consistent indention/space, upper/lower case consistency, 80 character per line constraint


回答1:


Turning my comments into an answer

I don't know of a way to enforce CMakeLists.txt or other CMake script file's coding style in CMake itself. But there are editor extensions and format checkers available you can use:

  • Some of the very basic things I ensure with .editorconfig

    • You can configure: indent_style, indent_size, tab_width, end_of_line, charset, trim_trailing_whitespace and insert_final_newline
    • And there are EditorConfig plug-ins for a lot of editors available (if not supported out-of-the-box)
  • With cmake-lint you can check/filter for a few more rules

    • It has filters for e.g. convention/filename, linelength, package/consistency, readability/logic, readability/mixedcase, readability/wonkycase or syntax
  • And there is Tools for upper/lower case consistency in CMake source


来源:https://stackoverflow.com/questions/32467743/how-to-ensure-consistent-coding-style-for-cmakelists-txt-and-findxxx-cmake

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!