find_library with argument beginning in "lib" is a bad idea, warn about it

We need to support cases where the library might be called "foo.so" and
therefore we check for exact matches too. But this also allows
`cc.find_library('libfoo')` to find libfoo.so, which is strange and
won't work in many cases. Emit a warning when this happens.

Fixes #10838
pull/6267/merge
Eli Schwartz 2 years ago committed by Jussi Pakkanen
parent 05da4b087c
commit 56a6ee1e5d
  1. 2
      mesonbuild/compilers/mixins/clike.py

@ -1158,6 +1158,8 @@ class CLikeCompiler(Compiler):
trial = self._get_file_from_list(env, trials)
if not trial:
continue
if libname.startswith('lib') and trial.name.startswith(libname):
mlog.warning(f'find_library({libname!r}) starting in "lib" only works by accident and is not portable')
return [trial.as_posix()]
return None

Loading…
Cancel
Save