2

I need to modify install prefix option in meson build script...

My idea is, when the user select some special option, the install prefix is getting from external tool (specifically, using ${CORSS}gcc -print-sysroot)

pmod
  • 10,450
  • 1
  • 37
  • 50

2 Answers2

4

It's not possible to set prefix inside the meson build script itself, it's a built-in project option (check this), thus can be only set in command line:

meson --prefix `${CROSS}gcc --print-sysroot` builddir 

It shouldn't be a problem as it should done once to setup build directory. But anyway it's good idea to put this in some script (since most likely several options must be configured to setup project from scratch, e.g. I guess you need also setup cross-compilation file with --cross-file <> ).

If you really need fine control over where to install, there is argument install_dir for executable() command that allows to override prefix, and a number of install related commands: install_headers(), install_data() with the same capability. There is even possibility to add custom install script with

meson.add_install_script('myscript.sh')

Check this doc page for details. But the cons of this, however, is that script can be become not portable or hard to maintain.

pmod
  • 10,450
  • 1
  • 37
  • 50
2

You can change the prefix in the meson.build by using the default_options of the project() command (https://mesonbuild.com/Reference-manual.html#project).

For example:

project('myproj', 'c', default_options : 'prefix=/my/prefix')

Note that it would be applied only the first time you configure the Meson build directory.

Pastecator
  • 21
  • 1