How to link with a library built using Meson custom_target()?

Viewed 201

I'm using Meson custom_target() to build a 3rd party foobar library:

foobar_ct = custom_target('foobar_build',
                   command: `script.sh`,
                   output: 'foobar.a')

The custom target calls my script, which in turn calls Make to use existing Makefiles to build the lib. The custom_target() is used as a subproject, and the resulting output file ends up located at ./subprojects/foobar/foobar.a.

When I try to link with it

foobar_dep = dependency('foobar', fallback:...)

exe = executable(
  'test',
  'main.c',
  dependencies: [foobar_dep]
  ...)

Meson gives me error:

builddir/subprojects/foobar/foobar.a: No such file or directory

How would I link with the foobar.a? Meson expects it at the build directory ./builddir/subprojects/foobar/foobar.a - would it be a proper solution just to add a copy step to my script which would copy foobar.a from the place where Make built it, into the builddir?

0 Answers
Related