aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--docs/markdown/snippets/customimplicit.md17
-rw-r--r--mesonbuild/backend/ninjabackend.py6
2 files changed, 19 insertions, 4 deletions
diff --git a/docs/markdown/snippets/customimplicit.md b/docs/markdown/snippets/customimplicit.md
new file mode 100644
index 0000000..fb33367
--- /dev/null
+++ b/docs/markdown/snippets/customimplicit.md
@@ -0,0 +1,17 @@
+# Do not add custom target dir to header path if `implicit_include_directories` is `false`
+
+If you do the following:
+
+```meson
+# in some subdirectory
+gen_h = custom_target(...)
+# in some other directory
+executable('foo', 'foo.c', gen_h)
+```
+
+then the output directory of the custom target is automatically added
+to the header search path. This is convenient, but sometimes it can
+lead to problems. Starting with this version, the directory will no
+longer be put in the search path if the target has
+`implicit_include_directories: false`. In these cases you need to set
+up the path manually with `include_directories`.
diff --git a/mesonbuild/backend/ninjabackend.py b/mesonbuild/backend/ninjabackend.py
index 594e297..aa89932 100644
--- a/mesonbuild/backend/ninjabackend.py
+++ b/mesonbuild/backend/ninjabackend.py
@@ -2377,10 +2377,8 @@ https://gcc.gnu.org/bugzilla/show_bug.cgi?id=47485'''))
commands += self.generate_basic_compiler_args(target, compiler, no_warn_args)
# Add custom target dirs as includes automatically, but before
# target-specific include directories.
- # XXX: Not sure if anyone actually uses this? It can cause problems in
- # situations which increase the likelihood for a header name collision,
- # such as in subprojects.
- commands += self.get_custom_target_dir_include_args(target, compiler)
+ if target.implicit_include_directories:
+ commands += self.get_custom_target_dir_include_args(target, compiler)
# Add include dirs from the `include_directories:` kwarg on the target
# and from `include_directories:` of internal deps of the target.
#