question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Meson treats paths differently for porjects vs subprojects

See original GitHub issue

Describe 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:closed
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
eli-schwartzcommented, Oct 3, 2021

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.

0reactions
Makogancommented, Oct 3, 2021

Yup I used meson.current_build_dir() to calculate the CWD.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Subprojects - The Meson Build system
At the top level of your project create subprojects directory. ... you need to do something more complicated, such as extract several different...
Read more >
Subproject limitations · Issue #422 · mesonbuild/meson - GitHub
I think the case where two subprojects use the same library (possibly with different versions) is kinda rare compared to the more common...
Read more >
File path issue with Meson and Eigen - c++ - Stack Overflow
For dependency management, meson allows you to manually declare include_directories() in your build files. However, there is another way do ...
Read more >
Are subprojects the right thing for my team? - Google Groups
Hello Meson community,. In my team we are considering to update our project structure to use Meson subprojects (+wrap) instead of git submodules...
Read more >
Quick CMake tutorial | CLion Documentation - JetBrains
This tutorial will guide you through the process of creating and developing a simple CMake project. Step by step, we will learn the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found