ManuelAtWork
ManuelAtWork

Reputation: 2458

How can I detect the availability of cmake from a meson build config?

In my meson.build there is a line

cmake = import('cmake')

which returns a CMake module object. How can I determine whether CMake is actually available?

I would like to do something like

if not cmake.found()
   # Do something without the cmake module.
endif

Upvotes: 1

Views: 155

Answers (1)

pmod
pmod

Reputation: 10997

You can try using find_program function:

cmake_bin = find_program('cmake', required: false)
if not cmake_bin.found()
  # Do something without the cmake module.
else
  cmake = import('cmake')
  ...
endif

Upvotes: 1

Related Questions