aboutsummaryrefslogtreecommitdiff
path: root/docs/markdown/howtox.md
diff options
context:
space:
mode:
authorDylan Baker <dylan@pnwbakers.com>2020-05-12 10:06:41 -0700
committerJussi Pakkanen <jpakkane@gmail.com>2020-05-14 01:59:34 +0300
commit7ad8b5f221ed23ff9ca60349f76e91f79ecd211d (patch)
tree47d66d54755e3c8e3e8cd0bc1e424d6cc43e7d1e /docs/markdown/howtox.md
parent85708facaea88f0909e3e58eb42738eb11729b88 (diff)
downloadmeson-7ad8b5f221ed23ff9ca60349f76e91f79ecd211d.zip
meson-7ad8b5f221ed23ff9ca60349f76e91f79ecd211d.tar.gz
meson-7ad8b5f221ed23ff9ca60349f76e91f79ecd211d.tar.bz2
docs: Add a Howto about the null dependency [skip ci]
Diffstat (limited to 'docs/markdown/howtox.md')
-rw-r--r--docs/markdown/howtox.md23
1 files changed, 23 insertions, 0 deletions
diff --git a/docs/markdown/howtox.md b/docs/markdown/howtox.md
index 8231d3d..abf7519 100644
--- a/docs/markdown/howtox.md
+++ b/docs/markdown/howtox.md
@@ -260,3 +260,26 @@ The `cmake_module_path` property is only needed for custom CMake scripts. System
wide CMake scripts are found automatically.
More information can be found [here](Dependencies.md#cmake)
+
+## Get a default not-found dependency?
+
+```meson
+null_dep = dependency('', required : false)
+```
+
+This can be used in cases where you want a default value, but might override it
+later.
+
+```meson
+my_dep = dependency('', required : false)
+if host_machine.system() in ['freebsd', 'netbsd', 'openbsd', 'dragonfly']
+ my_dep = dependency('some dep', required : false)
+elif host_machine.system() == 'linux'
+ my_dep = dependency('some other dep', required : false)
+endif
+
+# Last ditch effort!
+if no my_dep.found()
+ my_dep = meson.get_compiler('c').find_library('dep')
+endif
+```