summaryrefslogtreecommitdiff
path: root/lib/spack/docs/build_systems
diff options
context:
space:
mode:
authorHarmen Stoppels <harmenstoppels@gmail.com>2021-11-22 10:47:09 +0100
committerGitHub <noreply@github.com>2021-11-22 10:47:09 +0100
commit0024e5cc9b5fe2f803d314e80ed14ade22d3bb55 (patch)
treea8deb401b264228c41a3e817384058ba112ed087 /lib/spack/docs/build_systems
parentcda9d6d98133e6a2eae89d91b0cabce1ce36d48a (diff)
downloadspack-0024e5cc9b5fe2f803d314e80ed14ade22d3bb55.tar.gz
spack-0024e5cc9b5fe2f803d314e80ed14ade22d3bb55.tar.bz2
spack-0024e5cc9b5fe2f803d314e80ed14ade22d3bb55.tar.xz
spack-0024e5cc9b5fe2f803d314e80ed14ade22d3bb55.zip
Make _enable_or_disable(...) return an empty array for conditional variants whose condition is not met (#27504)
Diffstat (limited to 'lib/spack/docs/build_systems')
-rw-r--r--lib/spack/docs/build_systems/autotoolspackage.rst18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/spack/docs/build_systems/autotoolspackage.rst b/lib/spack/docs/build_systems/autotoolspackage.rst
index 71d8d7d866..d62fb08ce8 100644
--- a/lib/spack/docs/build_systems/autotoolspackage.rst
+++ b/lib/spack/docs/build_systems/autotoolspackage.rst
@@ -420,6 +420,24 @@ Or when one variant controls multiple flags:
config_args += self.with_or_without('memchecker', variant='debug_tools')
config_args += self.with_or_without('profiler', variant='debug_tools')
+
+""""""""""""""""""""
+Conditional variants
+""""""""""""""""""""
+
+When a variant is conditional and its condition is not met on the concrete spec, the
+``with_or_without`` and ``enable_or_disable`` methods will simply return an empty list.
+
+For example:
+
+.. code-block:: python
+
+ variant('profiler', when='@2.0:')
+ config_args += self.with_or_without('profiler)
+
+will neither add ``--with-profiler`` nor ``--without-profiler`` when the version is
+below ``2.0``.
+
""""""""""""""""""""
Activation overrides
""""""""""""""""""""