Is there any utility that can reformat a cmake fil

2019-04-29 01:29发布

I have relatively complex cmake files and I am wondering if there is any utility that can reformat a cmakeList.txt and beautify it for easier reading?

Some simple tricks would do the jobs, such as indenting if else endif sections and so on.

Is there any such tools?

I am using notepad++ for editing, but if there is any other tools, I can switch.

3条回答
SAY GOODBYE
2楼-- · 2019-04-29 01:56

I searched for a code beautifier supporting CMake, and I did not find any.

  • There is this thread on CMake mailing lists, which does not provide a good solution
  • This mailing list thread provides no answer too (some use emacs mode)
  • I checked most of the major code beautifiers using UniversalIndentGUI on Ubuntu. None of the provided beautifiers from the long list are working with CMake out of the box.

Looks like implementing CMake support in an existing beautifier, or writing a custom one is a great idea for a nice code project.

查看更多
一夜七次
3楼-- · 2019-04-29 01:59

Take a look at Atom and its plugin language-cmake (you can install easily with Atom package manager).

Once both are installed, open your CMakeLists.txt and go to Edit > Lines > Auto Indent.

查看更多
forever°为你锁心
4楼-- · 2019-04-29 02:13

Someone recently wrote a CMake autoformatter called cmake_format. Still under development but should be good enough for basic CMake files.

查看更多
登录 后发表回答