0

With the following project structure

pj
|-src
   |-pj.c
   |-meson.build
|-meson.build

where pj/meson.build is

project('pj', 'c', version : '0.1')
subdir('src')
library('pj', sources : srcs)

and pj/src/meson.build is

srcs = 'pj.c'

then running

pj$ meson build
pj$ ninja -C build

gives the ninja error

File pj.c does not exist.

The only way I can get it to work is by setting pj/src/meson.build to

srcs='src/pj.c'

Easy enough when there's only 1 file but suppose there was 1,000.I found this earlier

Meson targets that depend on subdir siblings

and I'd like to do it the way rellenberg's answer suggested however I can't see why my code won't work.

NoComprende
  • 731
  • 4
  • 14

1 Answers1

1

The problem is that you're using a plain string to enumerate your source files. It becomes clear when you just do a plain variable substitution in your toplevel meson.build: that now gives library('pj', sources : 'pj.c'), so Meson doesn't know about it.

To mitigate this, you can use the files() function to enumerate your source files.

In other words, you can do the following:

srcs = files('pj.c')
# and later: files('pj1.c', 'pj2.c', ...)

And it will work again

nielsdg
  • 2,318
  • 1
  • 13
  • 22