CMake Multiline Function Code Style

Currently there is no definition of a standard CMake code style, the closest thing are the vim/emacs plugins.

What should be the preferred indentation scheme?
a)

some_function(
    LOL rofl
    ASDF stuff
)

b)

some_function(
    LOL rofl
    ASDF stuff
    )

My vote is for a), since that’s more symmetric in my opinion, and is similar to the “usual” C++/Java/… styles.

What do you think?

@brad.king @ben.boeckel Seems we are not allowed to create polls, even though the UI allows us to use the feature. I tried editing the above post to add a poll to it, but was told I am not allowed to create polls when I tried to save my changes. Any idea why we can’t use polls?

It is not ideal to have to count comment replies for something like this, so the poll feature would be nice.

Well, seeing as my preferred style isn’t there, I’d be upset with this poll :wink: . I prefer to have something like:

some_function(
  FOO bar
  BAZ quux)

because I usually build up lists of things into other variables and keep things sorted there:

some_function(
  ARG1 ${values}
  ARG2 some_static_value)

I think I’d be more partial to hanging closing parens if there were argument separators to align with.

I don’t know who has the power to be able to enable polls. As an alternative, posts with “likes” might be suitable?

CMake is about as far from these languages in syntax as one can get, so the precedence doesn’t hold much sway with me at least :slight_smile: .

For reference, this style question comes from CMake Issue 22394. The main goal is to decide whether to update the indentation style provided by the Vim and Emacs modes. The only question we need answered is how much whitespace to put before the closing “)if the author has already chosen to put it on its own line.

The poll feature is activated for this discourse instance, so it should be possible to create one. Maybe it only works when creating a new topic.

I prefer the unindented option a) . Occasionally I use Ben’s suggestion for trailing parentheses of two- or three-line function calls, but for multi-line lists (e.g. list of source files) I always put the closing parens on a separate line to make version control diffs cleaner.

I prefer (a).

should we make it a poll, then?

What should be the preferred indentation scheme?
  • A
    some_function(
      Foo
      Bar
    )
    
  • B
    some_function(
      Foo
      Bar
      )
    
  • undecisive / don’t care

0 voters