From b1119d8fcfe646f3ff108a3bf3685dfce6f049e4 Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Wed, 7 Feb 2018 13:12:54 +0000 Subject: [PATCH] meson: Generate the pkg-config file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Instead of using a template file, and filling in the blanks, we can use the Meson pkgconfig module to generate the pkg-config file mostly from the library object itself — including dependencies and flags. The template file remains in tree for the Autotools build. --- meson.build | 6 ----- src/meson.build | 63 +++++++++++++++++++++++++++---------------------- 2 files changed, 35 insertions(+), 34 deletions(-) diff --git a/meson.build b/meson.build index eb7e5cd..0f6dc71 100644 --- a/meson.build +++ b/meson.build @@ -231,12 +231,6 @@ if dl_dep.found() pkgconf.set('DLOPEN_LIBS', '-ldl') endif -configure_file(input: 'epoxy.pc.in', - output: 'epoxy.pc', - configuration: pkgconf, - install: true, - install_dir: join_paths(epoxy_libdir, 'pkgconfig')) - # Python python = import('python3').find_python() if not python.found() diff --git a/src/meson.build b/src/meson.build index 2b38466..e54eed2 100644 --- a/src/meson.build +++ b/src/meson.build @@ -67,31 +67,38 @@ if host_system == 'windows' epoxy_deps += [ opengl32_dep, gdi32_dep ] endif -# Allow building a static version of epoxy -if libtype != 'shared' - libepoxy_static = static_library('epoxy', - sources: epoxy_sources + epoxy_headers, - install: true, - dependencies: epoxy_deps, - include_directories: libepoxy_inc, - c_args: common_cflags + visibility_cflags, - link_args: common_ldflags) - libepoxy = libepoxy_static -endif - -if libtype != 'static' - libepoxy_shared = shared_library('epoxy', - sources: epoxy_sources + epoxy_headers, - version: '0.0.0', - install: true, - dependencies: epoxy_deps, - include_directories: libepoxy_inc, - c_args: common_cflags + visibility_cflags, - link_args: common_ldflags) - libepoxy = libepoxy_shared -endif - -libepoxy_dep = declare_dependency(link_with: libepoxy, - include_directories: libepoxy_inc, - dependencies: epoxy_deps, - sources: epoxy_headers) +libepoxy = library( + 'epoxy', + sources: epoxy_sources + epoxy_headers, + version: '0.0.0', + install: true, + dependencies: epoxy_deps, + include_directories: libepoxy_inc, + c_args: common_cflags + visibility_cflags, + link_args: common_ldflags, +) + +libepoxy_dep = declare_dependency( + link_with: libepoxy, + include_directories: libepoxy_inc, + dependencies: epoxy_deps, + sources: epoxy_headers, +) + +epoxy_has_glx = build_glx ? '1' : '0' +epoxy_has_egl = build_egl ? '1' : '0' +epoxy_has_wgl = build_wgl ? '1' : '0' + +pkg = import('pkgconfig') +pkg.generate( + libraries: libepoxy, + name: 'epoxy', + description: 'GL dispatch library', + version: meson.project_version(), + variables: [ + 'epoxy_has_glx=@0@'.format(epoxy_has_glx), + 'epoxy_has_egl=@0@'.format(epoxy_has_egl), + 'epoxy_has_wgl=@0@'.format(epoxy_has_wgl), + ], + filebase: 'epoxy', +)