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

dependency() should have an option to override globally defined paths #10910

Open
themightyoarfish opened this issue Oct 9, 2022 · 9 comments

Comments

@themightyoarfish
Copy link

themightyoarfish commented Oct 9, 2022

I might be misunderstanding something completely, but here goes.

Describe the bug
dependency() cannot be told to look for a dependency in a specific prefix.

To Reproduce
Assume you have multiple versions of a library installed in different installation prefixes. During development you might want to switch between them (e.g. debug and release builds). But you can only set cmake_prefix_path and the like globally, there is no way I can see to override this path for a single dependency. The default_options argument to dependency() cannot be used to override cmake_prefix_path.

project('foo', 'cpp',
  version : '0.1',
  default_options : ['warning_level=3',
                     'cpp_std=c++17',
                     'cmake_prefix_path=/custom/prefix1',
                     'pkg_config_path=/custom/prefix1/lib/pkgconfig'])

cv2 = dependency('OpenCV', version : '>=4.0.0', method : 'cmake')
pcl = dependency('PCL', version : '>=1.12', components : [ 'common' ])

exe = executable('foo', 'foo.cpp',
  dependencies : [ cv2, pcl ])

Expected behavior

An option to modify the environment for the execution of the function should be available. The doc sounds like default_options should be for this purpose, but it seems I am misunderstanding it

system parameters

  • native
  • macOs 12.4
  • Python 3.8.8
  • Meson verion 0.63.0
  • Ninja 1.11.0
@eli-schwartz
Copy link
Member

Why can't you just use the global path for this? If you have multiple versions of a dependency installed to different install paths, then I would assume those dependencies are isolated on their own. Adding that path to the global path will only affect one dependency anyway.

@themightyoarfish
Copy link
Author

themightyoarfish commented Oct 10, 2022 via email

@eli-schwartz
Copy link
Member

How does it influence other dependencies?

@themightyoarfish
Copy link
Author

Because the global path influences where they are found, in case of multiple versions.

@eli-schwartz
Copy link
Member

Shouldn't you just be adding one version of the original dependency to your cmake path?

It's not really clear to me what you're trying to do here.

@themightyoarfish
Copy link
Author

Let me try again:

  • Dependency A debug build is in prefix prefixDebug/
  • Dependency A release build is in prefix prefixRelease/
  • Dependency B debug build is in prefix prefixDebug/
  • Dependency B release build is in prefix prefixRelease/
    I want meson to find dependency A's debug build, but dependency B's release build.

CMake has the PATHS and HINTS argument to find_package() for this.

@eli-schwartz
Copy link
Member

And how do you toggle between these without editing CMakeLists.txt?

Wouldn't it make more sense to have:

  • Dependency A debug build is in prefix prefixADebug/

  • Dependency A release build is in prefix prefixARelease/

  • Dependency B debug build is in prefix prefixBDebug/

  • Dependency B release build is in prefix prefixBRelease/

Since prefixDebug/ is not intended to be a general environment for finding multiple software components, it seems odd to store multiple software components in it.

@eli-schwartz
Copy link
Member

Anyway: https://mesonbuild.com/Dependencies.html#cmake

You can set cmake_module_path inside the dependency() kwargs, which corresponds to CMake's -DCMAKE_MODULE_PATH but not to -DCMAKE_PREFIX_PATH. You will unfortunately then have to edit meson.build just like you'd have to edit CMakeLists.txt, which I would say is suboptimal, but if you really want it...

@themightyoarfish
Copy link
Author

I need to set the prefix path, not the module path.

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

2 participants