Skip to content

Commit

Permalink
(conan-io#20688) Update meson template package
Browse files Browse the repository at this point in the history
* Add comments and show how to disable all features by default

* Use a lambda
  • Loading branch information
jwillikers authored Oct 19, 2023
1 parent 5975070 commit 8f1829e
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion docs/package_templates/meson_package/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,18 @@ def source(self):
get(self, **self.conan_data["sources"][self.version], strip_root=True)

def generate(self):
# Meson feature options must be set to "enabled" or "disabled"
feature = lambda option: "enabled" if option else "disabled"

# default_library and b_staticpic are automatically parsed when self.options.shared and self.options.fpic exist
# buildtype is automatically parsed for self.settings
tc = MesonToolchain(self)
# In case need to pass definitions directly to the compiler
tc.preprocessor_definitions["MYDEFINE"] = "MYDEF_VALUE"
tc.project_options["feature"] = "enabled" if self.options.get_safe("feature") else "disabled"
# Meson features are typically enabled automatically when possible.
# The default behavior can be changed to disable all features by setting "auto_features" to "disabled".
tc.project_options["auto_features"] = "disabled"
tc.project_options["feature"] = feature(self.options.get_safe("feature"))
# Meson project options may vary their types
tc.project_options["tests"] = False
tc.generate()
Expand Down

0 comments on commit 8f1829e

Please sign in to comment.