Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add subproject_options documentation #3655

Merged
merged 5 commits into from Apr 30, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 9 additions & 2 deletions README.md
Expand Up @@ -5,16 +5,23 @@ Documentation for Conan C/C++ package manager: https://conan.io
How to build
============

- Install host package
- graphviz
- enchant
- Ubuntu: `# apt install graphviz enchant`
- Achlinux: `# pacman -Syu graphviz enchant`


- Install python and [pip docs](https://pip.pypa.io/en/stable/installing/).
- Install the requirements (sphinx):

`$ pip install -r requirements.txt`

- Point to the Conan source code folder (``git clone https://github.com/conan-io/conan && cd conan && git checkout develop2``)

Windows:
- Windows:
`$ set PYTHONPATH=<your/path/to/conan>;%PYTHONPATH%`
Linux:
- Linux:
`$ export PYTHONPATH=<your/path/to/conan>:$PYTHONPATH`


Expand Down
24 changes: 23 additions & 1 deletion reference/tools/meson/mesontoolchain.rst
Expand Up @@ -151,6 +151,24 @@ The ``wrap_mode: nofallback`` is defined by default as a project option, to make

Note that in this case, Meson might be able to find dependencies in "wraps", it is the responsibility of the user to check the behavior and make sure about the dependencies origin.

subproject_options
^^^^^^^^^^^^^^^^^^

This attribute allows defining Meson subproject options:

.. code:: python

def generate(self):
tc = MesonToolchain(self)
tc.subproject_options["SUBPROJECT"] = [{'MYVAR': 'MyValue'}]
tc.generate()

This is translated to:

- One subproject ``SUBPROJECT`` and option definition for ``MYVAR`` in the ``conan_meson_native.ini`` or ``conan_meson_cross.ini`` file.

Note that in contrast to ``project_options``, ``subproject_options`` is a dictionary of lists of dictionaries. This is because Meson allows multiple subprojects, and each subproject can have multiple options.

preprocessor_definitions
^^^^^^^^^^^^^^^^^^^^^^^^

Expand Down Expand Up @@ -209,7 +227,9 @@ values:
def generate(self):
tc = MesonToolchain(self)
tc.project_options["DYNAMIC"] = bool(self.options.shared) # shared is bool
tc.project_options["GREETINGS"] = str(self.options.with_msg) # with_msg is str
tc.project_options["GREETINGS"] = str(self.options.with_msg) # with_msg is str
tc.subproject_options["SUBPROJECT"] = [{'MYVAR': str(self.options.with_msg)}] # with_msg is str
tc.subproject_options["SUBPROJECT"].append({'MYVAR': bool(self.options.shared)}) # shared is bool
tc.generate()

In contrast, directly assigning a Conan option as a Meson value is strongly discouraged:
Expand All @@ -223,6 +243,8 @@ In contrast, directly assigning a Conan option as a Meson value is strongly disc
tc = MesonToolchain(self)
tc.project_options["DYNAMIC"] = self.options.shared # == <PackageOption object>
tc.project_options["GREETINGS"] = self.options.with_msg # == <PackageOption object>
tc.subproject_options["SUBPROJECT"] = [{'MYVAR': self.options.with_msg}] # == <PackageOption object>
tc.subproject_options["SUBPROJECT"].append({'MYVAR': self.options.shared}) # == <PackageOption object>
tc.generate()

These are not boolean or string values but an internal Conan class representing such
Expand Down
1 change: 1 addition & 0 deletions requirements.txt
Expand Up @@ -7,3 +7,4 @@ sphinxcontrib-youtube==1.4.1
docutils==0.20.1
jinja2==3.1.3
watchdog[watchmedo]==2.2.0
colorama