buildprefixninjameson-build

Meson and NInja build system: specify where binaries are stored


I have a project that needs to be built like this:

  1. ./meson.py build

  2. ./ninja -C build install

This works well. The only thing is: the binaries are stored in (on Linux): /usr/local/bin. This would require me to input root password because the binaries are being written to a root-access folder, aka /usr/local/bin.

Is there a way to install the binaries in some folder in the /user/home directory, so that no passwords are required?

The thing is that everytime I debug and change something, the rebuilding process forces the binaries to be rewritten, which asks for password everytime.

This is what I tried:

  1. Create a folder in home: mkdir ~/projectbin
  2. Use ninja with --prefix option: ./ninja -C --prefix=~/projectbin install

This throws an error of unrecognized option --prefix.

I am new to ninja and meson, please let me know how to resolve this.


Solution

  • The way to pass an option to Meson is using the -D option. So to set the prefix, you should use meson -Dprefix=$HOME/projectbin build.

    Note that you set this at configure time (ie when calling meson), not at build time (when calling ninja).