[sysprof/wip/issue49: 2/2] libsysprof, libsysprof-ui: Generate pkg-config dependencies




commit 04b6fdfcbeac41ffc9ccbaf05d74424f4ececa26
Author: Simon McVittie <smcv debian org>
Date:   Tue Sep 15 20:03:19 2020 +0100

    libsysprof, libsysprof-ui: Generate pkg-config dependencies
    
    Otherwise, using libsysprof-ui will usually fail because <dazzle.h>
    is not added to the search path.
    
    Resolves: https://gitlab.gnome.org/GNOME/sysprof/-/issues/49
    Signed-off-by: Simon McVittie <smcv debian org>

 src/libsysprof-capture/meson.build |  1 +
 src/libsysprof-ui/meson.build      | 19 +++++++++++++++++--
 src/libsysprof/meson.build         | 18 ++++++++++++++----
 3 files changed, 32 insertions(+), 6 deletions(-)
---
diff --git a/src/libsysprof-capture/meson.build b/src/libsysprof-capture/meson.build
index b30c0ac..961e2ce 100644
--- a/src/libsysprof-capture/meson.build
+++ b/src/libsysprof-capture/meson.build
@@ -72,5 +72,6 @@ if not meson.is_subproject()
     description: 'The static capture library for tools that generate profiling capture data',
     install_dir: join_paths(get_option('libdir'), 'pkgconfig'),
       variables: [ 'datadir=' + datadir_for_pc_file ],
+    requires_private: libsysprof_capture_deps,
   )
 endif
diff --git a/src/libsysprof-ui/meson.build b/src/libsysprof-ui/meson.build
index 0574ae6..7aac541 100644
--- a/src/libsysprof-ui/meson.build
+++ b/src/libsysprof-ui/meson.build
@@ -84,13 +84,27 @@ libsysprof_ui_resources = gnome.compile_resources(
   c_name: 'lisysprof_ui',
 )
 
-libsysprof_ui_deps = [
+# Subset of dependencies used in generating the pkg-config file
+libsysprof_ui_pkg_deps = [
   dependency('gio-2.0', version: glib_req_version),
   dependency('gtk+-3.0', version: gtk_req_version),
-  dependency('libdazzle-1.0', version: dazzle_req_version, fallback: ['libdazzle', 'libdazzle_dep']),
+]
+
+libsysprof_ui_deps = libsysprof_ui_pkg_deps + [
   libsysprof_dep,
 ]
 
+# Meson's pkgconfig module wants to see a library here, not an internal
+# dependency object
+libsysprof_ui_pkg_deps += libsysprof
+
+dazzle_dep = dependency('libdazzle-1.0', version: dazzle_req_version, fallback: ['libdazzle', 
'libdazzle_dep'])
+libsysprof_ui_deps += dazzle_dep
+
+if dazzle_dep.type_name() == 'pkgconfig'
+  libsysprof_ui_pkg_deps += dazzle_dep
+endif
+
 libsysprof_ui = shared_library(
   'sysprof-ui-@0@'.format(libsysprof_api_version),
   libsysprof_ui_public_sources + libsysprof_ui_private_sources + libsysprof_ui_resources,
@@ -117,6 +131,7 @@ pkgconfig.generate(
   description: 'The UI library for GTK applications embedding sysprof',
   install_dir: join_paths(get_option('libdir'), 'pkgconfig'),
      requires: [ 'gio-2.0', 'gtk+-3.0' ],
+     requires_private: libsysprof_ui_pkg_deps,
      variables: [
        'datadir=' + datadir_for_pc_file,
      ],
diff --git a/src/libsysprof/meson.build b/src/libsysprof/meson.build
index 107970f..d485414 100644
--- a/src/libsysprof/meson.build
+++ b/src/libsysprof/meson.build
@@ -109,12 +109,12 @@ if dependency('polkit-gobject-1', version: '>= 0.114', required: false).found()
   libsysprof_c_args += ['-DHAVE_POLKIT_AUTOPTR']
 endif
 
-libsysprof_deps = [
-  libsysprof_capture_deps,
+# Subset of dependencies used in generating the pkg-config file
+libsysprof_pkg_deps = [
   dependency('gio-2.0', version: glib_req_version),
   dependency('gio-unix-2.0', version: glib_req_version),
   polkit_dep,
-  librax_dep,
+  libsysprof_capture_deps,
 ]
 
 if host_machine.system() == 'linux'
@@ -134,12 +134,20 @@ if host_machine.system() == 'linux'
 endif
 
 if host_machine.system() == 'darwin'
-  libsysprof_deps += [ dependency('libelf') ]
+  libsysprof_pkg_deps += [ dependency('libelf') ]
   libsysprof_c_args += [ '-DNT_GNU_BUILD_ID=3', '-DELF_NOTE_GNU="GNU"', '-D__LIBELF_INTERNAL__' ]
 endif
 
+# Meson's pkgconfig module doesn't understand this one
+libsysprof_deps = libsysprof_pkg_deps + [
+  librax_dep,
+]
+
+libsysprof_libs_private = []
+
 if host_machine.system() != 'darwin'
   libsysprof_deps += [cxx.find_library('stdc++')]
+  libsysprof_libs_private += '-lstdc++'
 endif
 
 libsysprof = shared_library(
@@ -171,6 +179,8 @@ pkgconfig.generate(
   description: 'The library for console applications embedding sysprof',
   install_dir: join_paths(get_option('libdir'), 'pkgconfig'),
      requires: [ 'gio-2.0' ],
+     requires_private: libsysprof_pkg_deps,
+    libraries_private: libsysprof_libs_private,
      variables: [
        'datadir=' + datadir_for_pc_file,
      ],


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