More generic version of subdir(if_found: list[dep])
#12446
mitchgrout
started this conversation in
Ideas
Replies: 1 comment
-
Just a bit of a concrete example for motivation: # Under the proposed enhancement:
is_test = not(meson.is_cross_build())
subdir('code') # Set up all of the code libraries
subdir('tests', if: is_test ) # Set up all the test executables
subdir('targets/exe', if: not(is_test)) # Set up the final on-target executable
subdir('targets/test', if: is_test ) # Attach our test executables via `test()`
# Without the proposed enhancement:
subdir('code')
if is_test
subdir('tests')
endif
if not(is_test)
subdir('targets/exe')
else
subdir('targets/test')
endif
# Abusing if_found:
is_test = meson.is_cross_build()? disabler() : declare_dependency()
is_build = not meson.is_cross_build()? disabler() : declare_dependency()
subdir('code')
subdir('tests', if_found: is_test)
subdir('targets/exe', if_found: is_build)
subdir('targets/test', if_found: is_test) |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Often, you'll see code like the following within library code intended to be pulled in as a
dependency
:...where
is_test
tends to be things likenot meson.is_subproject()
orget_option(...)
. There currently exists a kwarg onsubdir()
which allows for the subdir to be optionally visit if a list of dependencies hasdep.found()
to be all true, with the following equivalence:My thought is to deprecate
if_found
in favour of a more potent argument which would support a wider array of argument types, including but not limited to:dep
--> Decides based offdep.found()
bool
--> Decides based off value beingtrue
feature
--> Decides based offfeature.enabled()
such that the following statements could all be written:
There is some ambiguity as to how
feature
would be supported here, since there is bothfeature.enabled()
andfeature.allowed()
which could both seemingly make sense here. Thoughts?Beta Was this translation helpful? Give feedback.
All reactions