| 1 |
project('generated header dep', 'c', meson_version : '>= 1.10.0') |
| 2 |
|
| 3 |
# Regression test case for a very specific case: |
| 4 |
# - Uses both_libraries(), or library() with default_library=both. |
| 5 |
# - A header file is generated by a custom_target() and passed as source. |
| 6 |
# - A C file that uses that header is passed as a declare_dependency() source. |
| 7 |
# Under those specific conditions, the static library used to miss an order |
| 8 |
# dependency on the header file. This happened in GLib: |
| 9 |
# https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2917. |
| 10 |
|
| 11 |
python = find_program('python3') |
| 12 |
header = custom_target( |
| 13 |
output: 'foo.h', |
| 14 |
capture: true, |
| 15 |
command: [python, '-c', 'print("#define FOO")'], |
| 16 |
) |
| 17 |
|
| 18 |
sources_dep = declare_dependency(sources: files('foo.c')) |
| 19 |
|
| 20 |
both_libraries('foo', header, |
| 21 |
dependencies: sources_dep, |
| 22 |
) |
| 23 |
|
| 24 |
# include_directories() can point to a build_subdir that a custom_target() |
| 25 |
# generated into, so the subdir must exist in the build tree at setup time |
| 26 |
subheader = custom_target( |
| 27 |
output: 'sub.h', |
| 28 |
capture: true, |
| 29 |
command: [python, '-c', 'print("#define SUB 0")'], |
| 30 |
build_subdir: 'generated_includes', |
| 31 |
) |
| 32 |
|
| 33 |
inc = include_directories('generated_includes') |
| 34 |
|
| 35 |
subprog = executable('subprog', 'subprog.c', subheader, |
| 36 |
include_directories: inc, |
| 37 |
) |
| 38 |
test('subprog', subprog) |