Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relative paths for include_directories is enforced on Ubuntu but not on Windows #8640

Open
nanthony21 opened this issue Apr 11, 2021 · 4 comments

Comments

@nanthony21
Copy link

I have a large collection of 3rd party libraries that various parts of my project need to link to. I've been doing this like so:

At the top level of my project I have an absolute path to the collection of libraries: DEPS_REPO = join_paths(meson.current_source_dir(), '../../../3rdPartyRepo)

Having this as an absolute path is nice since:

  • find_library requires an absolute path for its dirs argument.
  • The path remains valid even when using it from nested subdirectories in my project.

I then do this:

SDK_dir = join_paths(DEPS_REPO, 'path_to_specific_sdk')
SDK_lib = meson.compiler('cpp').find_library('sdklibname', dirs: join_paths(SDK_dir, 'lib64'), static: true)
SDK_inc = include_directories(join_paths(SDK_dir, 'include'))
library('MyDriver', sources, include_directories: SDK_inc, dependencies: SDK_dep, install: true)

This works fine for me on Windows with Meson 0.57.1, however with the same version of Meson on Ubuntu 20.04 I get ERROR: Tried to form an absolute path to a source dir. You should not do that but use relative paths instead.

Aside from the issue of getting inconsistent behavior between OS's I don't understand why these restrictions are in place. It would be nice if both include_directories and find_library(..., dir: would allow the usage of both relative and absolute paths.

Is there an entirely different way that I should go about this? I had considered using declare_dependency since it would allow me to bundle the linker path and the include directory into a single dependency object but it seemed like this was going against the intended behavior since these aren't dependencies which will be used in other parts of the project, as soon as they are created they are passed to library(..., dependencies: and never used again.

As final note, I think it would be really useful if the "FS" module had functionality similar to Python's os.path.abspath and os.path.relpath for converting paths as needed.

@jeffreyrcarey
Copy link

Was this ever addressed?

@eli-schwartz
Copy link
Member

As final note, I think it would be really useful if the "FS" module had functionality similar to Python's os.path.abspath and os.path.relpath for converting paths as needed.

#2184

Incidentally I don't know why this would fail to report an error on Windows, the build_incdir_object() method does not distinguish between Windows and Linux. What is the current value of meson.current_source_dir()?

@nanthony21
Copy link
Author

I'm no longer working in that project and don't really have an easy way to go back and test it. This was on Meson 0.57 so it's possible that something has changed since then.

@tristan957
Copy link
Contributor

Seems like we should close this

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants