cheshirekow / cmake_format

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

separate_arguments with single argument is mis-reported with E1120 #280

Closed Takishima closed 1 year ago

Takishima commented 2 years ago

MRE:

cmake_minimum_required(VERSION 3.0)

set(VAR "-f -a")

separate_arguments(VAR)

Expected:

No warnings

Actual:

/tmp/CMakeLists.txt
===================
/tmp/CMakeLists.txt:05,19: [E1120] Missing required positional argument

Summary
=======
files scanned: 1
found lint:
       Error: 1

According to the official CMake documentation, this syntax is valid since at least CMake 3.0: https://cmake.org/cmake/help/v3.0/command/separate_arguments.html:

separate_arguments(VARIABLE)

Convert the value of VARIABLE to a semi-colon separated list. All spaces are replaced with ‘;’. 
This helps with generating command lines.

I am not familiar with this code base yet, so I cannot propose a fix at the moment, but if nobody can take care of it, I'll have a look at implementing and submitting a fix in the coming weeks.

The function that needs to be fixed is here: https://github.com/cheshirekow/cmake_format/blob/904c42da298f7fda932d9ac774517c20e2667fb8/cmakelang/parse/funs/miscellaneous.py#L389

jtojnar commented 1 year ago

Duplicate of https://github.com/cheshirekow/cmake_format/issues/218