| 1 |
project('pkgconfig-gen-dependencies', 'c', version: '1.0') |
| 2 |
|
| 3 |
if find_program('pkg-config').version() == '2.0.1' |
| 4 |
error('MESON_SKIP_TEST: cannot test uninstalled.pc due to https://github.com/pkgconf/pkgconf/issues/310#issuecomment-1677844842') |
| 5 |
endif |
| 6 |
|
| 7 |
pkgg = import('pkgconfig') |
| 8 |
|
| 9 |
# libmain internally use libinternal and expose libexpose in its API |
| 10 |
exposed_lib = shared_library('libexposed', 'exposed.c') |
| 11 |
internal_lib = shared_library('libinternal', 'internal.c') |
| 12 |
main_lib = both_libraries('libmain', 'dummy.c', link_with : [exposed_lib, internal_lib]) |
| 13 |
custom_lib = shared_library('custom', 'custom.c') |
| 14 |
|
| 15 |
pkgg.generate(exposed_lib) |
| 16 |
|
| 17 |
# Declare a few different Dependency objects |
| 18 |
pc_dep = dependency('libfoo', version : '>=1.0') |
| 19 |
pc_dep_dup = dependency('libfoo', version : '>= 1.0') |
| 20 |
notfound_dep = dependency('notfound', required : false) |
| 21 |
threads_dep = dependency('threads') |
| 22 |
custom_dep = declare_dependency(link_with : custom_lib, compile_args : ['-DCUSTOM']) |
| 23 |
custom2_dep = declare_dependency(link_args : ['-lcustom2'], compile_args : ['-DCUSTOM2']) |
| 24 |
|
| 25 |
exe = executable('test1', 'main.c', dependencies : [pc_dep]) |
| 26 |
test('Test1', exe) |
| 27 |
|
| 28 |
# Generate a PC file: |
| 29 |
# - Having libmain in libraries should pull implicitly libexposed and libinternal in Libs.private |
| 30 |
# - Having libexposed in libraries should remove it from Libs.private |
| 31 |
# - We generated a pc file for libexposed so it should be in Requires instead of Libs |
| 32 |
# - Having threads_dep in libraries should add '-pthread' in both Libs and Cflags |
| 33 |
# - Having custom_dep in libraries and libraries_private should only add it in Libs |
| 34 |
# - Having custom2_dep in libraries_private should not add its Cflags |
| 35 |
# - Having pc_dep in libraries_private should add it in Requires.private |
| 36 |
# - pc_dep_dup is the same library and same version, should be ignored |
| 37 |
# - notfound_dep is not required so it shouldn't appear in the pc file. |
| 38 |
pkgg.generate(libraries : [main_lib, exposed_lib, threads_dep, threads_dep, custom_dep, custom_dep, '-pthread'], |
| 39 |
libraries_private : [custom_dep, custom2_dep, custom2_dep, pc_dep, pc_dep_dup, notfound_dep], |
| 40 |
version : '1.0', |
| 41 |
name : 'dependency-test', |
| 42 |
filebase : 'dependency-test', |
| 43 |
description : 'A dependency test.' |
| 44 |
) |
| 45 |
|
| 46 |
pkgg.generate( |
| 47 |
name : 'requires-test', |
| 48 |
version : '1.0', |
| 49 |
description : 'Dependency Requires field test.', |
| 50 |
requires : [exposed_lib, pc_dep, 'libhello'], |
| 51 |
) |
| 52 |
|
| 53 |
pkgg.generate( |
| 54 |
name : 'requires-private-test', |
| 55 |
version : '1.0', |
| 56 |
description : 'Dependency Requires.private field test.', |
| 57 |
requires_private : [exposed_lib, pc_dep, 'libhello', notfound_dep], |
| 58 |
) |
| 59 |
|
| 60 |
# Verify that if we promote internal_lib as public dependency, it comes after |
| 61 |
# the main library. |
| 62 |
main_lib2 = both_libraries('libmain2', 'dummy.c', link_with : internal_lib) |
| 63 |
pkgg.generate(main_lib2, |
| 64 |
libraries : internal_lib, |
| 65 |
filebase : 'pub-lib-order', |
| 66 |
) |
| 67 |
|
| 68 |
# This will be built against both simple7.pc and simple7-uninstalled.pc, check |
| 69 |
# that include directories works in both cases. |
| 70 |
simple7 = dependency('simple7') |
| 71 |
exe = executable('test2', 'test2.c', |
| 72 |
dependencies: simple7, |
| 73 |
) |
| 74 |
test('Test2', exe) |