build/meson: fix x11 test/demo compilation with non-standard xcb
authorRan Benita <ran234@gmail.com>
Sun, 25 Feb 2018 09:51:05 +0000 (11:51 +0200)
committerRan Benita <ran234@gmail.com>
Sun, 25 Feb 2018 09:59:04 +0000 (11:59 +0200)
The x11 tests/demos did not depend on xcb and xcb-xkb directly, only
indirectly through link_with: libxkbcommon_x11_internal. So linking
worked, but the xcb and xcb-xkb cflags were *not* included when
compiling them. So when using xcb installed in a non-standard location,
what would happen is:

- Library will link with custom xcb and compile with custom xcb headers.
- Test will link with custom xcb and compile with system xcb headers (if
  exist, otherwise fail).

Fixes: https://github.com/xkbcommon/libxkbcommon/issues/57
Reported-by: @remexre
Signed-off-by: Ran Benita <ran234@gmail.com>
meson.build

index 22b33d7..bf4a5f8 100644 (file)
@@ -284,6 +284,16 @@ test_dep = declare_dependency(
     include_directories: include_directories('src'),
     link_with: libxkbcommon_test_internal,
 )
+if get_option('enable-x11')
+    x11_test_dep = declare_dependency(
+        link_with: libxkbcommon_x11_internal,
+        dependencies: [
+            test_dep,
+            xcb_dep,
+            xcb_xkb_dep,
+        ],
+    )
+endif
 test(
     'keysym',
     executable('test-keysym', 'test/keysym.c', dependencies: test_dep),
@@ -362,12 +372,12 @@ test(
 if get_option('enable-x11')
     test(
         'x11',
-        executable('test-x11', 'test/x11.c', dependencies: test_dep, link_with: libxkbcommon_x11_internal),
+        executable('test-x11', 'test/x11.c', dependencies: x11_test_dep),
         env: test_env,
     )
     # test/x11comp is meant to be run, but it is (temporarily?) disabled.
     # See: https://github.com/xkbcommon/libxkbcommon/issues/30
-    executable('test-x11comp', 'test/x11comp.c', dependencies: test_dep, link_with: libxkbcommon_x11_internal)
+    executable('test-x11comp', 'test/x11comp.c', dependencies: x11_test_dep)
 endif
 
 
@@ -378,7 +388,7 @@ if cc.has_header('linux/input.h')
     executable('interactive-evdev', 'test/interactive-evdev.c', dependencies: test_dep)
 endif
 if get_option('enable-x11')
-    executable('interactive-x11', 'test/interactive-x11.c', dependencies: test_dep, link_with: libxkbcommon_x11_internal)
+    executable('interactive-x11', 'test/interactive-x11.c', dependencies: x11_test_dep)
 endif
 if get_option('enable-wayland')
     wayland_client_dep = dependency('wayland-client', version: '>=1.2.0', required: false)