build: Add subproject support for libsysprof-capture

This will be used to build libsysprof-capture as a subproject within
libglib, with the symbols from libglib being left unresolved until the
static libsysprof-capture is linked into libglib.

When built as a subproject, libsysprof-capture won’t install anything.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
This commit is contained in:
Philip Withnall
2020-06-25 15:38:42 +01:00
parent e03b54fca5
commit d6e8d39292

View File

@ -13,7 +13,9 @@ libsysprof_capture_headers = files([
'sysprof-version-macros.h', 'sysprof-version-macros.h',
]) ])
install_headers(libsysprof_capture_headers, subdir: sysprof_header_subdir) if not meson.is_subproject()
install_headers(libsysprof_capture_headers, subdir: sysprof_header_subdir)
endif
libsysprof_capture_sources = files([ libsysprof_capture_sources = files([
'mapped-ring-buffer.c', 'mapped-ring-buffer.c',
@ -34,6 +36,7 @@ configure_file(
output: 'sysprof-version.h', output: 'sysprof-version.h',
configuration: sysprof_version_conf, configuration: sysprof_version_conf,
install_dir: join_paths(get_option('includedir'), sysprof_header_subdir), install_dir: join_paths(get_option('includedir'), sysprof_header_subdir),
install: not meson.is_subproject(),
) )
libsysprof_capture_deps = [ libsysprof_capture_deps = [
@ -47,7 +50,7 @@ libsysprof_capture = static_library(
dependencies: libsysprof_capture_deps, dependencies: libsysprof_capture_deps,
c_args: [ '-DSYSPROF_CAPTURE_COMPILATION' ], c_args: [ '-DSYSPROF_CAPTURE_COMPILATION' ],
install_dir: get_option('libdir'), install_dir: get_option('libdir'),
install: true, install: not meson.is_subproject(),
gnu_symbol_visibility: 'hidden', gnu_symbol_visibility: 'hidden',
) )
@ -59,15 +62,17 @@ libsysprof_capture_dep = declare_dependency(
include_directories: libsysprof_capture_include_dirs, include_directories: libsysprof_capture_include_dirs,
) )
pkgconfig.generate( if not meson.is_subproject()
libraries: [libsysprof_capture], pkgconfig.generate(
subdirs: [ sysprof_header_subdir ], libraries: [libsysprof_capture],
version: meson.project_version(), subdirs: [ sysprof_header_subdir ],
name: 'sysprof-capture-@0@'.format(libsysprof_api_version), version: meson.project_version(),
filebase: 'sysprof-capture-@0@'.format(libsysprof_api_version), name: 'sysprof-capture-@0@'.format(libsysprof_api_version),
description: 'The static capture library for tools that generate profiling capture data', filebase: 'sysprof-capture-@0@'.format(libsysprof_api_version),
install_dir: join_paths(get_option('libdir'), 'pkgconfig'), description: 'The static capture library for tools that generate profiling capture data',
variables: [ install_dir: join_paths(get_option('libdir'), 'pkgconfig'),
'datadir=' + datadir_for_pc_file, variables: [
], 'datadir=' + datadir_for_pc_file,
) ],
)
endif