Skip to content

Have a canonical way to declare preprocessor defines #6269

Description

@marti4d

Hey there! I brought this up yesterday on Reddit, and I wanted to follow up here.

Perhaps this ticket is a good place to discuss whether or not it's worth adding a canonical "define" abstraction in Meson. Here are the reasons that I think such a thing should exist:

  1. Much like include dirs, defines are usually a property of the source code and the host/target machine, and are often needed independently of the mechanism used to pass them
  2. Different compilers may have different argument syntaxes for specifying defines. Even MSVC uses "/D" and GCC uses "-D". (And yes, I know that technically MSVC "tolerates" the -D syntax, but that's not its native syntax, and as a thought exercise one could imagine some compiler that doesn't)
  3. This is already done for other things like include dirs and libraries, where Meson will use the correct compiler argument syntax for whatever compiler is being used
  4. Other build systems already do it. CMake has this command and Visual Studio has a separate section altogether for preprocessor defines. In general, if there are higher-level semantics for something then isn't it a Good Thing(TM) to capture them rather than having them degrade to compiler flags?

Also - I'm willing to put my time where my mouth is here. With a perhaps a little help I'd be willing to be the one to add whatever feature to Meson - I'd just want to know what you folks think before I go trying to implement something.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions