aboutsummaryrefslogtreecommitdiff
path: root/mesonbuild/dependencies/base.py
diff options
context:
space:
mode:
authorDaniel Stone <daniels@collabora.com>2020-04-15 12:34:16 +0100
committerDaniel Stone <daniels@collabora.com>2020-04-15 21:19:13 +0100
commit0f4e88b181ef73f73a27f5443974c73d69f3b630 (patch)
treedb17419c5aca8aa1bedd01c74566ef0e03bd9230 /mesonbuild/dependencies/base.py
parent98e5e1ddc5f7f75eea7622dbdbd67bada1cd00ef (diff)
downloadmeson-0f4e88b181ef73f73a27f5443974c73d69f3b630.zip
meson-0f4e88b181ef73f73a27f5443974c73d69f3b630.tar.gz
meson-0f4e88b181ef73f73a27f5443974c73d69f3b630.tar.bz2
dependencies/cmake: Suffix bare library dependencies on Windows
On Windows, library dependencies can be passed with no prefix or suffix; rather than -lfoo or foo.dll, they can just be passed as 'foo'. CMake handles this and suffixes the library with '.lib' or '.dll', depending on the link mode. Do the same here, and if we've been passed an unqualified non-option bare name on Windows, add the appropriate suffix and pass it through to the linker. This fixes dependencies on system libraries.
Diffstat (limited to 'mesonbuild/dependencies/base.py')
-rw-r--r--mesonbuild/dependencies/base.py9
1 files changed, 9 insertions, 0 deletions
diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py
index 068e45e..ea1fff8 100644
--- a/mesonbuild/dependencies/base.py
+++ b/mesonbuild/dependencies/base.py
@@ -1413,6 +1413,7 @@ class CMakeDependency(ExternalDependency):
# Set dependencies with CMake targets
# recognise arguments we should pass directly to the linker
reg_is_lib = re.compile(r'^(-l[a-zA-Z0-9_]+|-pthread|-delayload:[a-zA-Z0-9_\.]+|[a-zA-Z0-9_]+\.lib)$')
+ reg_is_maybe_bare_lib = re.compile(r'^[a-zA-Z0-9_]+$')
processed_targets = []
incDirs = []
compileDefinitions = []
@@ -1482,6 +1483,14 @@ class CMakeDependency(ExternalDependency):
targets += [j]
elif reg_is_lib.match(j) or os.path.exists(j):
libraries += [j]
+ elif mesonlib.is_windows() and reg_is_maybe_bare_lib.match(j):
+ # On Windows, CMake library dependencies can be passed as bare library names,
+ # e.g. 'version' should translate into 'version.lib'. CMake brute-forces a
+ # combination of prefix/suffix combinations to find the right library, however
+ # as we do not have a compiler environment available to us, we cannot do the
+ # same, but must assume any bare argument passed which is not also a CMake
+ # target must be a system library we should try to link against
+ libraries += ["{}.lib".format(j)]
processed_targets += [curr]