Repository: mesonbuild/meson

Issue:
Boost dependency is ignoring compiler include paths
In my cross compilation setup, boost dependecy is not using the compiler search paths e.g:

```
touch foo.cpp
x86_64-w64-mingw32.static-g++ -v -c foo.cpp
```
Output:
```
Using built-in specs.
COLLECT_GCC=x86_64-w64-mingw32.static-g++
Target: x86_64-w64-mingw32.static
Configured with: /wd/mxe/tmp-gcc-x86_64-w64-mingw32.static/gcc-9.3.0/configure ac_cv_prog_HAVE_DOXYGEN=false --enable-doc=no --enable-gtk-doc=no --enable-gtk-doc-html=no --enable-gtk-doc-pdf=no --docdir=/wd/mxe/tmp-gcc-x86_64-w64-mingw32.static/gcc-9.3.0.build_.sink --infodir=/wd/mxe/tmp-gcc-x86_64-w64-mingw32.static/gcc-9.3.0.build_.sink --mandir=/wd/mxe/tmp-gcc-x86_64-w64-mingw32.static/gcc-9.3.0.build_.sink --with-html-dir=/wd/mxe/tmp-gcc-x86_64-w64-mingw32.static/gcc-9.3.0.build_.sink --disable-doxygen --target=x86_64-w64-mingw32.static --build=x86_64-pc-linux-gnu --prefix=/usr --libdir=/usr/lib --with-sysroot=/usr/x86_64-w64-mingw32.static --enable-languages=c,c++,objc,fortran --enable-version-specific-runtime-libs --with-gcc --with-gnu-ld --with-gnu-as --disable-nls --disable-shared --disable-multilib --without-x --disable-win32-registry --enable-threads=posix --enable-libgomp --with-gmp=/usr/x86_64-pc-linux-gnu --with-isl=/usr/x86_64-pc-linux-gnu --with-mpc=/usr/x86_64-pc-linux-gnu --with-mpfr=/usr/x86_64-pc-linux-gnu --with-as=/usr/bin/x86_64-w64-mingw32.static-as --with-ld=/usr/bin/x86_64-w64-mingw32.static-ld --with-nm=/usr/bin/x86_64-w64-mingw32.static-nm
Thread model: posix
gcc version 9.3.0 (GCC)
COLLECT_GCC_OPTIONS='-v' '-c' '-mtune=generic' '-march=x86-64'
 /usr/libexec/gcc/x86_64-w64-mingw32.static/9.3.0/cc1plus -quiet -v -D_REENTRANT foo.cpp -quiet -dumpbase foo.cpp -mtune=generic -march=x86-64 -auxbase foo -version -o /tmp/cc6USNGl.sGNU C++14 (GCC) version 9.3.0 (x86_64-w64-mingw32.static)
        compiled by GNU C version 7.5.0, GMP version 6.1.2, MPFR version 3.1.5, MPC version 1.1.0, isl version isl-0.16.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring nonexistent directory "/usr/x86_64-w64-mingw32.static/usr/local/include"
ignoring duplicate directory "/usr/x86_64-w64-mingw32.static/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-w64-mingw32.static/9.3.0/include/c++
 /usr/lib/gcc/x86_64-w64-mingw32.static/9.3.0/include/c++/x86_64-w64-mingw32.static
 /usr/lib/gcc/x86_64-w64-mingw32.static/9.3.0/include/c++/backward
 /usr/lib/gcc/x86_64-w64-mingw32.static/9.3.0/include
 /usr/lib/gcc/x86_64-w64-mingw32.static/9.3.0/include-fixed
 /usr/lib/gcc/x86_64-w64-mingw32.static/9.3.0/../../../../x86_64-w64-mingw32.static/include
End of search list.
GNU C++14 (GCC) version 9.3.0 (x86_64-w64-mingw32.static)
        compiled by GNU C version 7.5.0, GMP version 6.1.2, MPFR version 3.1.5, MPC version 1.1.0, isl version isl-0.16.1-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 7e1b1f13249d5831c6a285caa8d05954
COLLECT_GCC_OPTIONS='-v' '-c' '-mtune=generic' '-march=x86-64'
 /usr/bin/x86_64-w64-mingw32.static-as -v -o foo.o /tmp/cc6USNGl.s
GNU assembler version 2.28 (x86_64-w64-mingw32.static) using BFD version (GNU Binutils) 2.28
COMPILER_PATH=/usr/libexec/gcc/x86_64-w64-mingw32.static/9.3.0/:/usr/libexec/gcc/x86_64-w64-mingw32.static/9.3.0/:/usr/libexec/gcc/x86_64-w64-mingw32.static/:/usr/lib/gcc/x86_64-w64-mingw32.static/9.3.0/:/usr/lib/gcc/x86_64-w64-mingw32.static/:/usr/lib/gcc/x86_64-w64-mingw32.static/9.3.0/../../../../x86_64-w64-mingw32.static/bin/
LIBRARY_PATH=/usr/lib/gcc/x86_64-w64-mingw32.static/9.3.0/:/usr/lib/gcc/x86_64-w64-mingw32.static/9.3.0/../../../../x86_64-w64-mingw32.static/lib/../lib/:/usr/lib/gcc/x86_64-w64-mingw32.static/9.3.0/../../../../x86_64-w64-mingw32.static/lib/
COLLECT_GCC_OPTIONS='-v' '-c' '-mtune=generic' '-march=x86-64'
```

where the main include path `/usr/x86_64-w64-mingw32.static` is displayed, but I have to peovide an environment variable `BOOST_ROOT=/usr/x86_64-w64-mingw32.static` for boost to find it.


Discussion:
Could you please provide the `meson-logs/meson-log.txt` via pastebin, etc.?
This issue is marked for the 0.54.2 release, which will be tagged today. Please poke if we should delay for this issue.

Resolving patch:
diff --git a/mesonbuild/dependencies/boost.py b/mesonbuild/dependencies/boost.py
--- a/mesonbuild/dependencies/boost.py
+++ b/mesonbuild/dependencies/boost.py
@@ -605,6 +605,12 @@ def detect_roots(self) -> T.List[Path]:
                 roots += paths
                 return roots  # Do not add system paths if BOOST_ROOT is present
 
+        # Add roots from system paths
+        inc_paths = [Path(x) for x in self.clib_compiler.get_default_include_dirs()]
+        inc_paths = [x.parent for x in inc_paths if x.exists()]
+        inc_paths = [x.resolve() for x in inc_paths]
+        roots += inc_paths
+
         # Add system paths
         if self.env.machines[self.for_machine].is_windows():
             # Where boost built from source actually installs it
@@ -626,8 +632,6 @@ def detect_roots(self) -> T.List[Path]:
             roots += [x for x in candidates if x.name.lower().startswith('boost') and x.is_dir()]
         else:
             tmp = []  # type: T.List[Path]
-            # Add unix paths
-            tmp += [Path(x).parent for x in self.clib_compiler.get_default_include_dirs()]
 
             # Homebrew
             brew_boost = Path('/usr/local/Cellar/boost')


Test patch: