We ‘d like to introduce Meson to build our existing C++ application. Our structure is as follows:
- Wie have 8 main modules (mod_X)
- Every module has 20-40 subdirs, each with 5 – 100 cpp files; separated in libs and executables.
mod_INFRA/apps/myparser
has a target that creates a code generator executable- Which depends only on
mod_INFRA/libs/A
- Which depends only on
- The code generator must be applied to certain files (*.rules) in numerous subdirs in all modules and subdirs, including mod_INFRA itself.
- The generated source code must be compiled and considered with the target in
subdir_X
What I’d like to achieve:
- In
root/meson.build
define a common and re-usablecustom_target
orgenerator
that I can invoke/apply in every module and subdir as needed.
Problem:
- In
root/meson.build
, we define common variables such as compiler flags etc., and we dosubdir(‘mod_INFRA’)
for each module. Inmod_INFRA/meson.build
I dosubdir(‘apps/xyz’), subdir(‘libs/abc’),
etc. for each subdir. That’s all fine - However I struggle to define the
custom_target or generator
inroot/meson.build
. The required executable is not yet available beforesubdir('mod_INFRA')
. And aftersubdir(..)
it is too late, as I need the generator already to build files in other subdirs inmod_INFRA
.
A possible solution could be a “proxy” that lazily resolves the executable by target name. E.g. if I could do (pseudo code): generator(getTargetOutput(‘myparser’), …)
. But I could not find out if that is available.
Any other thoughts on how to resolve it, without completely restructuring the directory structure?
- meson.build - mod_INFRA - meson.build - apps - meson.build - myparser - meson.build - libs - subdir_INFRA_A (required to build myparser) - meson.build - subdir_INFRA_B - meson.build - subdir_INFRA_C (requires parser to generate code) - meson.build - mod_A - meson.build - subdir_A_A (requires parser to generate code) - meson.build - subdir_A_B (requires parser to generate code) - meson.build - mod_B ...