Skip to content

How to check if a variable is not defined? #12411

Answered by mitchgrout
ilg-ul asked this question in Q&A
Discussion options

You must be logged in to vote

https://mesonbuild.com/Reference-manual_functions.html#is_variable

A one-to-one conversion from cmake to meson would be

if not is_variable('xpack_platform_compile_defintion')
  error('Define xpack_platform_compile_definition in <...>')
endif

however I would probably pick a more natural expression like

assert(is_variable('xpack_platfrm_compile_definition', ...), 'diagnostic message goes here')

There are other options on how to deal with this depending on how you're getting these values; if you could provide a simplified project structure, we could discuss how best to set this up?

Replies: 1 comment 3 replies

Comment options

You must be logged in to vote
3 replies
@ilg-ul
Comment options

@mitchgrout
Comment options

Answer selected by ilg-ul
@ilg-ul
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants