0

To do an out-of-source build in Meson:

cd /path/to/source/
mkdir ../builddir

Then:

cd /path/to/source/
meson ../builddir
cd ../builddir
ninja

Is it possible to do anything like this (from builddir):

meson --pathToSource ../source     // pseudocode
ninja

I.e. avoid jumping from the source to the build directory and back.

For CMake, this is the default.

Pietro
  • 12,086
  • 26
  • 100
  • 193

1 Answers1

1

Once you've run meson to create build directory (which meson can create automatically), there is no need to run it everytime you change meson.build. When you run ninja, meson can regenerate build configurations itself depending on the changes in the sources.

To run ninja in other places than build directory, you can you -C option (from ninja -h):

-C DIR change to DIR before doing anything else

Given your example, it will be:

$ cd /path/to/source/
$ meson ../builddir
$ ninja -C ../builddir
barsoosayque
  • 329
  • 2
  • 11
  • Do you mean that if I add a new file to my project, and update the `meson.build` file, I do not need to launch meson again? – Pietro Jun 28 '18 at 14:48
  • 2
    @Pietro yes, running `ninja` within meson-generated project will update build files for `ninja` (from `meson.build`) if it's necessary. I don't really sure about other backends.. – barsoosayque Jun 28 '18 at 16:40