Repository: godotengine/godot (language: cpp)

Issue:
When compiling with `so_wrap=false` libdecor's pkg-config is incorrect
### Tested versions

Reproducible in 4.4.beta.custom_build.261e7d32d

### System information

NixOS 25.05

### Issue description

libdecor's pkg-config file has it's include as `$prefix/include/libdecor-0` when godot includes it as `$prefix/include` causing a compilation error.

I have a PR for this but feel like changing the dynwrappers as to be consistent would be better than only changing the system include.

### Steps to reproduce

Compile with `scons use_sowrap=false werror=false` (werror is needed because system headers may have warnings)

### Minimal reproduction project (MRP)

N/A


Discussion / hints:
Confirmed on Fedora 41:
```
$ pkg-config --cflags libdecor-0
-I/usr/include/libdecor-0
```

So we should just include `/usr/include/libdecor-0/libdecor.h` as `#include <libdecor.h>`, not `#include <libdecor-0/libdecor.h`>`. This should also be changed in the dynwrappers indeed.
From a quick look though, there are more issues with the way we deal with system libraries for Wayland in `platform/linuxbsd/detect.py`. Even when `use_sowrap=no`, we still add `#thirdparty/linuxbsd_headers/wayland/` to the include path, so we take the risk of dynamically linking against a system wide version of Wayland but compiling against a different, builtin version of the headers.

We should only append the builtin headers when using sowrap.

Fix patch:
diff --git a/platform/linuxbsd/detect.py b/platform/linuxbsd/detect.py
index 75e05f1ddd4d..b5e80f4a4dbc 100644
--- a/platform/linuxbsd/detect.py
+++ b/platform/linuxbsd/detect.py
@@ -455,11 +455,14 @@ def configure(env: "SConsEnvironment"):
                 print_error("Wayland EGL library not found. Aborting.")
                 sys.exit(255)
             env.ParseConfig("pkg-config wayland-egl --cflags --libs")
+        else:
+            env.Prepend(CPPPATH=["#thirdparty/linuxbsd_headers/wayland/"])
+            if env["libdecor"]:
+                env.Prepend(CPPPATH=["#thirdparty/linuxbsd_headers/libdecor-0/"])
 
         if env["libdecor"]:
             env.Append(CPPDEFINES=["LIBDECOR_ENABLED"])
 
-        env.Prepend(CPPPATH=["#platform/linuxbsd", "#thirdparty/linuxbsd_headers/wayland/"])
         env.Append(CPPDEFINES=["WAYLAND_ENABLED"])
         env.Append(LIBS=["rt"])  # Needed by glibc, used by _allocate_shm_file
 
diff --git a/platform/linuxbsd/wayland/dynwrappers/libdecor-so_wrap.c b/platform/linuxbsd/wayland/dynwrappers/libdecor-so_wrap.c
index eaf43215cecb..dbb107c8e334 100644
--- a/platform/linuxbsd/wayland/dynwrappers/libdecor-so_wrap.c
+++ b/platform/linuxbsd/wayland/dynwrappers/libdecor-so_wrap.c
@@ -1,7 +1,7 @@
 // This file is generated. Do not edit!
 // see https://github.com/hpvb/dynload-wrapper for details
 // generated by ./generate-wrapper.py 0.3 on 2022-12-12 10:55:19
-// flags: ./generate-wrapper.py --include /usr/include/libdecor-0/libdecor.h --sys-include <libdecor-0/libdecor.h> --soname libdecor-0.so.0 --init-name libdecor --output-header libdecor-so_wrap.h --output-implementation libdecor-so_wrap.c --omit-prefix wl_
+// flags: ./generate-wrapper.py --include /usr/include/libdecor-0/libdecor.h --sys-include <libdecor.h> --soname libdecor-0.so.0 --init-name libdecor --output-header libdecor-so_wrap.h --output-implementation libdecor-so_wrap.c --omit-prefix wl_
 //
 // EDIT: This has been handpatched to properly report the pointer type of the window_state argument of libdecor_configuration_get_window_state.
 #include <stdint.h>
@@ -45,7 +45,7 @@
 #define libdecor_state_free libdecor_state_free_dylibloader_orig_libdecor
 #define libdecor_configuration_get_content_size libdecor_configuration_get_content_size_dylibloader_orig_libdecor
 #define libdecor_configuration_get_window_state libdecor_configuration_get_window_state_dylibloader_orig_libdecor
-#include <libdecor-0/libdecor.h>
+#include <libdecor.h>
 #undef libdecor_unref
 #undef libdecor_new
 #undef libdecor_get_fd
diff --git a/platform/linuxbsd/wayland/dynwrappers/libdecor-so_wrap.h b/platform/linuxbsd/wayland/dynwrappers/libdecor-so_wrap.h
index bf3f5200086b..6373886bbe2d 100644
--- a/platform/linuxbsd/wayland/dynwrappers/libdecor-so_wrap.h
+++ b/platform/linuxbsd/wayland/dynwrappers/libdecor-so_wrap.h
@@ -3,7 +3,7 @@
 // This file is generated. Do not edit!
 // see https://github.com/hpvb/dynload-wrapper for details
 // generated by ./generate-wrapper.py 0.3 on 2022-12-12 10:55:19
-// flags: ./generate-wrapper.py --include /usr/include/libdecor-0/libdecor.h --sys-include <libdecor-0/libdecor.h> --soname libdecor-0.so.0 --init-name libdecor --output-header libdecor-so_wrap.h --output-implementation libdecor-so_wrap.c --omit-prefix wl_
+// flags: ./generate-wrapper.py --include /usr/include/libdecor-0/libdecor.h --sys-include <libdecor.h> --soname libdecor-0.so.0 --init-name libdecor --output-header libdecor-so_wrap.h --output-implementation libdecor-so_wrap.c --omit-prefix wl_
 //
 // EDIT: This has been handpatched to properly report the pointer type of the window_state argument of libdecor_configuration_get_window_state.
 #include <stdint.h>
@@ -47,7 +47,7 @@
 #define libdecor_state_free libdecor_state_free_dylibloader_orig_libdecor
 #define libdecor_configuration_get_content_size libdecor_configuration_get_content_size_dylibloader_orig_libdecor
 #define libdecor_configuration_get_window_state libdecor_configuration_get_window_state_dylibloader_orig_libdecor
-#include <libdecor-0/libdecor.h>
+#include <libdecor.h>
 #undef libdecor_unref
 #undef libdecor_new
 #undef libdecor_get_fd
diff --git a/platform/linuxbsd/wayland/wayland_thread.h b/platform/linuxbsd/wayland/wayland_thread.h
index 5172bf4087b7..a1b59eba5d47 100644
--- a/platform/linuxbsd/wayland/wayland_thread.h
+++ b/platform/linuxbsd/wayland/wayland_thread.h
@@ -78,7 +78,7 @@
 #ifdef SOWRAP_ENABLED
 #include "dynwrappers/libdecor-so_wrap.h"
 #else
-#include <libdecor-0/libdecor.h>
+#include <libdecor.h>
 #endif // SOWRAP_ENABLED
 #endif // LIBDECOR_ENABLED
 


Test patch: