Skip to content

Feature: format-as #120

Description

@sikraemer

Hello,

I often found the need to store the parameters passed to a command in a variable.
e.g. the options of find_package, so they can be exported into the find-module definition.

It would be nice if these instances could be marked as such:
e.g.:

set(boost_find_package_args Boost 1.81 REQUIRED CONFIG
  COMPONENTS
    chrono
    date_time
    filesystem
)
find_package($(boost_find_package_args})
export_dependency("Boost" $(boost_find_package_args})

It would be nice to annotate the set command with the information that the parameters are used as parameters of a find_package.
e.g.:

# gersemi: format-as=find_package[offset=1] # offset=1 to skip `boost_find_package_args`
set(boost_find_package_args Boost 1.81 REQUIRED CONFIG
  COMPONENTS
    chrono
    date_time
    filesystem
)
find_package($(boost_find_package_args})
export_dependency("Boost" $(boost_find_package_args})

Similar ideas have also been thought of in cmake-format:
https://cmake-format.readthedocs.io/en/latest/format-case_studies.html#set

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions