| project('generated header dep', 'c', meson_version : '>= 1.10.0') |
| |
| # Regression test case for a very specific case: |
| # - Uses both_libraries(), or library() with default_library=both. |
| # - A header file is generated by a custom_target() and passed as source. |
| # - A C file that uses that header is passed as a declare_dependency() source. |
| # Under those specific conditions, the static library used to miss an order |
| # dependency on the header file. This happened in GLib: |
| # https://gitlab.gnome.org/GNOME/glib/-/merge_requests/2917. |
| |
| python = find_program('python3') |
| header = custom_target( |
| output: 'foo.h', |
| capture: true, |
| command: [python, '-c', 'print("#define FOO")'], |
| ) |
| |
| sources_dep = declare_dependency(sources: files('foo.c')) |
| |
| both_libraries('foo', header, |
| dependencies: sources_dep, |
| ) |
| |
| # include_directories() can point to a build_subdir that a custom_target() |
| # generated into, so the subdir must exist in the build tree at setup time |
| subheader = custom_target( |
| output: 'sub.h', |
| capture: true, |
| command: [python, '-c', 'print("#define SUB 0")'], |
| build_subdir: 'generated_includes', |
| ) |
| |
| inc = include_directories('generated_includes') |
| |
| subprog = executable('subprog', 'subprog.c', subheader, |
| include_directories: inc, |
| ) |
| test('subprog', subprog) |