MSVC: support -LIBPATH

Fixes #6101 (with a test), following up #5881
pull/6120/head
Aleksey Gurtovoy 5 years ago committed by Jussi Pakkanen
parent 6e18e5b0b3
commit 6eee9e48bb
  1. 6
      mesonbuild/compilers/mixins/visualstudio.py
  2. 3
      run_unittests.py

@ -217,7 +217,9 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta):
# -pthread is only valid for GCC
if i in ('-mms-bitfields', '-pthread'):
continue
if i.startswith('-L'):
if i.startswith('-LIBPATH:'):
i = '/LIBPATH:' + i[9:]
elif i.startswith('-L'):
i = '/LIBPATH:' + i[2:]
# Translate GNU-style -lfoo library name to the import library
elif i.startswith('-l'):
@ -250,7 +252,7 @@ class VisualStudioLikeCompiler(metaclass=abc.ABCMeta):
def native_args_to_unix(cls, args: typing.List[str]) -> typing.List[str]:
result = []
for arg in args:
if arg.startswith('/LIBPATH:'):
if arg.startswith(('/LIBPATH:', '-LIBPATH:')):
result.append('-L' + arg[9:])
elif arg.endswith(('.a', '.lib')) and not os.path.isabs(arg):
result.append('-l' + arg)

@ -3162,7 +3162,7 @@ recommended as it is not supported on some platforms''')
env = get_fake_env(testdirlib, self.builddir, self.prefix)
if env.detect_c_compiler(MachineChoice.HOST).get_id() in {'msvc', 'clang-cl', 'intel-cl'}:
# msvc-like compiler, also test it with msvc-specific flags
libdir_flags += ['/LIBPATH:']
libdir_flags += ['/LIBPATH:', '-LIBPATH:']
else:
# static libraries are not linkable with -l with msvc because meson installs them
# as .a files which unix_args_to_native will not know as it expects libraries to use
@ -3176,6 +3176,7 @@ recommended as it is not supported on some platforms''')
for libdir_flag in libdir_flags:
# build library
self.new_builddir()
self.init(testdirlib, extra_args=extra_args)
self.build()
self.install()

Loading…
Cancel
Save