[glibmm] Meson build: examples and tests: Add dependency('threads')



commit c0e5395a1bc40b3e12b3bc3bbd5fae7d81f8029f
Author: Kjell Ahlstedt <kjellahlstedt gmail com>
Date:   Fri Mar 12 16:55:40 2021 +0100

    Meson build: examples and tests: Add dependency('threads')
    
    Multithreaded examples and tests depend on 'threads'.
    I noticed this when I started experimenting with subprojects.
    Strange that it was not reported as a missing dependency long ago.

 examples/meson.build | 6 +++++-
 tests/meson.build    | 7 ++++++-
 2 files changed, 11 insertions(+), 2 deletions(-)
---
diff --git a/examples/meson.build b/examples/meson.build
index 18c0d832..43e79d4a 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -28,6 +28,7 @@ if not is_host_windows
   ]
 endif
 
+thread_dep = dependency('threads')
 
 # import('gnome').compile_schemas() can't be use here.
 # It can only compile schemas in the current directory.
@@ -61,9 +62,12 @@ foreach ex : examples
     endif
   endforeach
 
+  is_multithread = ex[0][0] == 'network' or ex[0][0] == 'thread'
+  mm_dep = ex[3] ? giomm_dep : glibmm_dep
+
   executable(ex_name, ex_sources,
     cpp_args: ['-DGLIBMM_DISABLE_DEPRECATED', '-DGIOMM_DISABLE_DEPRECATED'],
-    dependencies: ex[3] ? giomm_dep : glibmm_dep,
+    dependencies: is_multithread ? [mm_dep, thread_dep] : mm_dep,
     gui_app: false,
     build_by_default: build_examples,
     install: false,
diff --git a/tests/meson.build b/tests/meson.build
index d7cc5a30..07985851 100644
--- a/tests/meson.build
+++ b/tests/meson.build
@@ -40,6 +40,8 @@ test_programs = [
   [['glibmm_vector'], 'test', ['main.cc'], true],
 ]
 
+thread_dep = dependency('threads')
+
 foreach ex : test_programs
   dir = ''
   foreach dir_part : ex[0]
@@ -51,9 +53,12 @@ foreach ex : test_programs
     ex_sources += dir / src
   endforeach
 
+  is_multithread = ex[0][0] == 'glibmm_mainloop'
+  mm_dep = ex[3] ? giomm_dep : glibmm_dep
+
   exe_file = executable(ex_name, ex_sources,
     cpp_args: ['-DGLIBMM_DISABLE_DEPRECATED', '-DGIOMM_DISABLE_DEPRECATED'],
-    dependencies: ex[3] ? giomm_dep : glibmm_dep,
+    dependencies: is_multithread ? [mm_dep, thread_dep] : mm_dep,
     gui_app: false,
     build_by_default: true,
     install: false,


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]