colcon / colcon-meson

Extension for colcon to support Meson packages
http://colcon.readthedocs.io
Apache License 2.0
0 stars 0 forks source link

Parsing arguments in a workspace with more than one meson package #16

Closed leorich closed 3 months ago

leorich commented 3 months ago

Since there is just one global way to set meson options, the options given are passed to all of the meson projects in the source tree.

Meson errors out if it gets non existent options:

ERROR: Unknown options: "foo_option"

This limits the number of meson projects you can have in your workspace to one (at least if you need to pass in any options).

christianrauch commented 3 months ago

Passing the options to all projects mirrors the behaviour of colcon-cmake.

Which meson version are you using? In version 0.60, passing unknown options turned from a warning into a fatal error (https://mesonbuild.com/Release-notes-for-0-60-0.html#unknown-options-are-now-always-fatal).

If you want to use different options for different projects, you have to create a yaml file colcon.meta of the form:

names:
  package1:
    meson-args: ["--buildtype=debug", "--auto-features=disabled", "-Dparam1=arg1", "-Dparam2=arg2"]
  package2:
    meson-args: ["--warnlevel=0", "--buildtype=release", "-Dparam1=arg1", "-Dparam2=arg2"]

This is also applicable to CMake projects, so using meson and CMake projects in one workspace could look like:

names:
  meson_package1:
    meson-args:
    - --buildtype=debug
    - --auto-features=disabled
    - -D param1=arg1
    - -D param2=arg2
  cmake_package1:
    cmake-args:
    - -D CMAKE_BUILD_TYPE=Release
    - -D param1=arg1
leorich commented 3 months ago

@christianrauch That solves my issue. I expected the colcon framework would support this, but did not know about meta files.

Thank you!

christianrauch commented 3 months ago

Yes. This feature is not well documented and examples are hard to find.

If you found this helpful and have some time left, you could send a PR that documents the feature :-)