Open mikedld opened 4 years ago
Hi,
I agree that this is an issue and it needs some action. I thought some time about it and first I would need a bit more investigation about the problem before choosing a solution (eg. cmake_parse_arguments
approach).
Some points that need to be taken into account: (Sorry that the points are quite unsystematic - there are mainly notes made during the day)
INTERFACE
as option:
add_library(a_library INTERFACE)
INTERFACE
as multi-value keyword:
target_sources(a_target
INTERFACE
a_header.hpp
another_one.hpp
)
This means that cmake-tidy
would need to have information about keyword type connected to each command. Which leads to couple of next questions:
properties
, similarly acquiring command names should be easy - but getting all keywords with type (option/argument keyword) will be more complex problem.cmake_parse_arguments
. CMake
changes in builtin commands (adding/deprecating keywords) - how will they affect formatting with older/newer version of cmake-tidy
cmake_parse_arguments
handling is not enough to properly format all cases (for builtin commands):
example https://cmake.org/cmake/help/latest/command/install.html#command:install
install(TARGETS mylib
LIBRARY
COMPONENT Libraries
NAMELINK_COMPONENT Development
PERMISSIONS GROUP_READ OWNER_WRITE
PUBLIC_HEADER
COMPONENT Development
)
cmake_parse_arguments
command handling by CMake
will most likely result in breaking change for users of cmake-tidy
at least for configurations.I will play around with the idea on a branch and come back with some more thoughts/answers.
Just as
cmake_parse_arguments
distincts between "options", "one-value keywords", and "multi-value keywords", cmake-tidy may need to as well. Currently, formatting may yield odd results for e.g.add_executable
oradd_library
.Input (source files list shortened for the purposes of this issue):
Expected output: same as input (?) Actual output:
Although the results looks kind of okay, they are inconsistent with other formatting in that they give an impression that "bar" and "baz" are values of
WIN32
andSTATIC
keywords which is not true.With decent CMake version one may want to workaround this by using
target_sources
which would be formatted properly, as in