Wang
Wang

Reputation: 8222

is there any similar way in meson as `cmake -LAH`?

I am debugging my meson build. I want to see all the cached variables as we do in cmake. Is there any way to do this? currently I have to go into the meson.build and add all the message() calls which is very inefficient. The python tricks vars() does not work either, but this is no surprising since meson.build is not python.

Upvotes: 0

Views: 239

Answers (2)

blubase
blubase

Reputation: 855

Run meson configure build/ on your existing build directory, without any other parameters, to see the current configuration and possible values. Adapt build to your preferred build directory. You'll get something like this:

Main project options:                                                                              
                                                                                                   
  Core options        Current Value  Possible Values                                               Description
  ------------        -------------  ---------------                                               -----------
  auto_features       auto           [enabled, disabled, auto]                                     Override value of all 'auto' features
  backend             ninja          [ninja, vs, vs2010, vs2015, vs2017, vs2019, xcode]            Backend to use
  buildtype           plain          [plain, debug, debugoptimized, release, minsize, custom]      Build type to use
  debug               false          [true, false]                                                 Debug
  default_library     shared         [shared, static, both]                                        Default library type
  install_umask       0022           [preserve, 0000-0777]                                         Default umask to apply on permissions of installed files
  layout              mirror         [mirror, flat]                                                Build directory layout
  optimization        0              [0, g, 1, 2, 3, s]                                            Optimization level
  strip               false          [true, false]                                                 Strip targets on install
  unity               off            [on, off, subprojects]                                        Unity build
  unity_size          4              >=2                                                           Unity block size
  warning_level       3              [0, 1, 2, 3]                                                  Compiler warning level to use
  werror              true           [true, false]                                                 Treat warnings as errors
  wrap_mode           default        [default, nofallback, nodownload, forcefallback]              Wrap mode
  cmake_prefix_path   []                                                                           List of additional prefixes for cmake to search
  pkg_config_path     []                                                                           List of additional paths for pkg-config to search
                                                                                                   
  Backend options     Current Value  Possible Values                                               Description
  ...

and at the end of that list, the options defined in your meson_options.txt:

 ...
 Project options     Current Value  Possible Values                                               Description
  ---------------     -------------  ---------------                                               -----------
  docs                true           [true, false]                                                 Build documentation
  tests               true           [true, false]                                                 Build and run unit tests
  tools               true           [true, false]                                                 Build conversion tools

Upvotes: 2

Brecht Sanders
Brecht Sanders

Reputation: 7305

Before building I always check meson_options.txt for possible options.

I noticed there is a file meson-info/intro-buildoptions.json under the build directory after configuring with meson.

The options from meson_options.txt reappear in meson-info/intro-buildoptions.json with their configured values.

Since that file is in json format you will need to make it more readable if needed. This is a quick and dirty way that seems to work:

sed -e 's/},/&\n/g' meson-info/intro-buildoptions.json|sed -ne 's/^.*{"name": "\([^"]*\)", "value": \(\[[^]]*\]\|"[^"]*"\|[^,]*\).*$/\1 = \2/p'

Upvotes: 0

Related Questions