diff --git a/mesonbuild/dependencies/base.py b/mesonbuild/dependencies/base.py index 7d6bf625e..fd2b0699b 100644 --- a/mesonbuild/dependencies/base.py +++ b/mesonbuild/dependencies/base.py @@ -22,7 +22,7 @@ from enum import Enum from .. import mlog from ..compilers import clib_langs -from ..mesonlib import MachineChoice, MesonException, HoldableObject +from ..mesonlib import LibType, MachineChoice, MesonException, HoldableObject from ..mesonlib import version_compare_many from ..interpreterbase import FeatureDeprecated @@ -319,6 +319,7 @@ class ExternalDependency(Dependency, HasNativeKwarg): self.required = kwargs.get('required', True) self.silent = kwargs.get('silent', False) self.static = kwargs.get('static', False) + self.libtype = LibType.STATIC if self.static else LibType.PREFER_SHARED if not isinstance(self.static, bool): raise DependencyException('Static keyword must be boolean') # Is this dependency to be run on the build platform? diff --git a/mesonbuild/dependencies/pkgconfig.py b/mesonbuild/dependencies/pkgconfig.py index 28a3f7467..97869189a 100644 --- a/mesonbuild/dependencies/pkgconfig.py +++ b/mesonbuild/dependencies/pkgconfig.py @@ -13,7 +13,7 @@ # limitations under the License. from .base import ExternalDependency, DependencyException, sort_libpaths, DependencyTypeName -from ..mesonlib import LibType, MachineChoice, OptionKey, OrderedSet, PerMachine, Popen_safe +from ..mesonlib import MachineChoice, OptionKey, OrderedSet, PerMachine, Popen_safe from ..programs import find_external_program, ExternalProgram from .. import mlog from pathlib import PurePath @@ -267,7 +267,6 @@ class PkgConfigDependency(ExternalDependency): libs_found: OrderedSet[str] = OrderedSet() # Track not-found libraries to know whether to add library paths libs_notfound = [] - libtype = LibType.STATIC if self.static else LibType.PREFER_SHARED # Generate link arguments for this library link_args = [] for lib in full_args: @@ -283,7 +282,7 @@ class PkgConfigDependency(ExternalDependency): continue if self.clib_compiler: args = self.clib_compiler.find_library(lib[2:], self.env, - libpaths, libtype) + libpaths, self.libtype) # If the project only uses a non-clib language such as D, Rust, # C#, Python, etc, all we can do is limp along by adding the # arguments as-is and then adding the libpaths at the end.