Keep multiple space-aligned `set(VARIABLE value)` the way they were during cmake-format

165 Views Asked by At

We have a lot of CMake files that contain set()-sequences like

set(VERSION_MAJOR 1)
set(VERSION_MINOR 2)
set(VERSION_ABI   3)
set(VERSION_PATCH 0-rc2)

I can't find a for cmake-format to keep things aligned like that; it will always condense the repeated whitespaces (here, after _ABI) into one.

Is there a way to tell cmake-format to keep this alignment?

1

There are 1 best solutions below

0
On BEST ANSWER

I would suggest simply disabling cmake-format locally around these few lines. See the manual: https://cmake-format.readthedocs.io/en/stable/format-features.html?highlight=disable#disable-formatting-locally

# cmake-format: off
set(VERSION_MAJOR 1)
set(VERSION_MINOR 2)
set(VERSION_ABI   3)
set(VERSION_PATCH 0-rc2)
# cmake-format: on