Meson treats paths differently for porjects vs subprojects
See original GitHub issueDescribe the bug
I have 2 projects, A and B, where B is a dependency of A. B compiles on its own. B has a custom target that relies on a script that outputs files to B/build
i.e. the build directory of the B project. And again this works fine with meson if B is the main project.
B then declares a dependency that uses this custom target that is to be used by A.
A has a subprojects/B
directory. And A’s meson.build file includes the dependency like this:
B_proj = subproject('B')
b_custom_dep = neverengine_proj.get_variable('b_custom_dep')
Meson returns the following error:
subprojects/B/custom_dep.cpp: No such file or directory
Which makes sense, because it should be trying to find that file in subprojects/B/build/custom_dep.cpp
Since that’s where output files need to go.
Since you can only declare custom targets like this:
custom_target = custom_target(
'custom_target',
output : [
'custom_target.cpp',
'custom_target.hpp'],
build_always_stale : true,
command : ['python3', meson.current_source_dir() / 'Scripts/script.py', meson.current_source_dir()])
Meson does not allow you to specify where the targets go, so when using it as main project, it assumes the files go into build, so why is it assuming they go into the project root when it is a subproject?
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Ok, happy to help (I think).
FWIW, at least with the ninja backend (no idea about VS or xcode) the cwd is always going to be meson.global_build_root() which is where the ninja build file (
build.ninja
) is written to. ninja always launches all build commands using that directory as the cwd.You can get the outdir as meson.current_build_dir() as well, which unlike replacing
@OUTDIR@
as a template string should generally be a full path. It should amount to the same thing either way.Yup I used
meson.current_build_dir()
to calculate the CWD.