cmakecmake-format

How can I automatically format a CMake file?


I have relatively complex CMake files and I am wondering if there is a way to automatically reformat a CMakeLists.txt and beautify it for easier reading.

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

How can I do this?


Solution

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