diff options
author | Wade Berrier <wberrier@gmail.com> | 2017-04-06 23:10:09 -0600 |
---|---|---|
committer | Jussi Pakkanen <jpakkane@gmail.com> | 2017-04-14 00:40:19 +0300 |
commit | dcc95d7f705c5fbc036d7d6511f6df50beaac44a (patch) | |
tree | 25e3e888287de0051a24aab0dbb6401cc957a394 | |
parent | b951e60f0683c9198d62004a5ef3d4c1cb9ba38f (diff) | |
download | meson-dcc95d7f705c5fbc036d7d6511f6df50beaac44a.zip meson-dcc95d7f705c5fbc036d7d6511f6df50beaac44a.tar.gz meson-dcc95d7f705c5fbc036d7d6511f6df50beaac44a.tar.bz2 |
dependencies: boost: use system include flag for header includes
... based on the compiler object
This addresses issue #1569
Need to be careful about using -isystem with the standard include
dirs (thanks to the unit tests for catching this). It may be
worthwhile trying to detect what the include dirs are.
Other dependencies (GTest) just avoid adding the include dir for those
system includes. Do the same here.
-rw-r--r-- | mesonbuild/dependencies.py | 31 |
1 files changed, 28 insertions, 3 deletions
diff --git a/mesonbuild/dependencies.py b/mesonbuild/dependencies.py index 25ca411..39bf2b1 100644 --- a/mesonbuild/dependencies.py +++ b/mesonbuild/dependencies.py @@ -675,13 +675,38 @@ class BoostDependency(Dependency): def get_compile_args(self): args = [] + include_dir = '' if self.boost_root is not None: if mesonlib.is_windows(): - args.append('-I' + self.boost_root) + include_dir = self.boost_root else: - args.append('-I' + os.path.join(self.boost_root, 'include')) + include_dir = os.path.join(self.boost_root, 'include') else: - args.append('-I' + self.incdir) + include_dir = self.incdir + + # Use "-isystem" when including boost headers instead of "-I" + # to avoid compiler warnings/failures when "-Werror" is used + + # Careful not to use "-isystem" on default include dirs as it + # breaks some of the headers for certain gcc versions + + # For example, doing g++ -isystem /usr/include on a simple + # "int main()" source results in the error: + # "/usr/include/c++/6.3.1/cstdlib:75:25: fatal error: stdlib.h: No such file or directory" + + # See https://gcc.gnu.org/bugzilla/show_bug.cgi?id=70129 + # and http://stackoverflow.com/questions/37218953/isystem-on-a-system-include-directory-causes-errors + # for more details + + # TODO: The correct solution would probably be to ask the + # compiler for it's default include paths (ie: "gcc -xc++ -E + # -v -") and avoid including those with -isystem + + # For now, use -isystem for all includes except for some + # typical defaults (which don't need to be included at all + # since they are in the default include paths) + if include_dir != '/usr/include' and include_dir != '/usr/local/include': + args.append("".join(self.cpp_compiler.get_include_args(include_dir, True))) return args def get_requested(self, kwargs): |