From ffe2a678d59b2d4184cadd5e4a8f31e8e6108968 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Wed, 8 May 2019 16:09:06 -0700 Subject: docs: Add docs for Dependency.get_variable --- .../markdown/snippets/dependency_get_variable_method.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 docs/markdown/snippets/dependency_get_variable_method.md (limited to 'docs/markdown/snippets') diff --git a/docs/markdown/snippets/dependency_get_variable_method.md b/docs/markdown/snippets/dependency_get_variable_method.md new file mode 100644 index 0000000..5804865 --- /dev/null +++ b/docs/markdown/snippets/dependency_get_variable_method.md @@ -0,0 +1,17 @@ +## Dependency objects now have a get_variable method + +This is a generic replacement for type specific variable getters such as +`ConfigToolDependency.get_configtool_variable` and +`PkgConfigDependency.get_pkgconfig_variable`, and is the only way to query +such variables from cmake dependencies. + +This method allows you to get variables without knowing the kind of +dependency you have. + +```meson +dep = dependency('could_be_cmake_or_pkgconfig') +# cmake returns 'YES', pkg-config returns 'ON' +if ['YES', 'ON'].contains(dep.get_variable(pkg-config : 'var-name', cmake : 'COP_VAR_NAME', default : 'NO')) + error('Cannot build your project when dep is built with var-name support') +endif +``` -- cgit v1.1 From c890c947fad17423f98b1cdfb5c49db296acc502 Mon Sep 17 00:00:00 2001 From: Dylan Baker Date: Mon, 20 May 2019 10:41:26 -0700 Subject: fixup! tests: Add test for Dependency.get_variable --- docs/markdown/snippets/dependency_get_variable_method.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'docs/markdown/snippets') diff --git a/docs/markdown/snippets/dependency_get_variable_method.md b/docs/markdown/snippets/dependency_get_variable_method.md index 5804865..aaeac9c 100644 --- a/docs/markdown/snippets/dependency_get_variable_method.md +++ b/docs/markdown/snippets/dependency_get_variable_method.md @@ -11,7 +11,7 @@ dependency you have. ```meson dep = dependency('could_be_cmake_or_pkgconfig') # cmake returns 'YES', pkg-config returns 'ON' -if ['YES', 'ON'].contains(dep.get_variable(pkg-config : 'var-name', cmake : 'COP_VAR_NAME', default : 'NO')) +if ['YES', 'ON'].contains(dep.get_variable(pkg-config : 'var-name', cmake : 'COP_VAR_NAME', default_value : 'NO')) error('Cannot build your project when dep is built with var-name support') endif ``` -- cgit v1.1