cheshirekow / cmake_format

Source code formatter for cmake listfiles.
GNU General Public License v3.0
941 stars 103 forks source link

Feature for control the style of `endif()` statement? #339

Open hehaoqian opened 7 months ago

hehaoqian commented 7 months ago

Accoridng to CMake doc

Per legacy, the else() and endif() commands admit an optional argument. If used, it must be a verbatim repeat of the argument of the opening if command.

So there are two styles for endif()

if (foo)
endif ()
if (foo)
endif (foo)

Similar issues exists for endforeach(), endfunction, endmacro

Can cmake format automatically handle this?

Add option to control the style of endif()

  1. Empty inside endif()
  2. Repeat the argument of if()
  3. Keep the original code, AS-IS