Repository: mesonbuild/meson

Issue:
wxWidgets dependency: static option not working
## Description
The option to link the dependency static is not working for wxWidgets. However, I've found a little hack to make it work, but I guess that's something that should be fixed.

## Expected behaviour:
if the dependency is declared as:
```
wxDep = dependency('wxwidgets',
                   version : '>=3.0.0',
                   required : true,
                   static : true,
                   modules : ['std', 'stc'])
```
The application should built with static linking of the wxWidgets-modules.

## What happens:
The application builds successful, but is not linked static.

## Temporary workarond
I've found a workaround, by doing this:
```
add_project_link_arguments('--static',
                           language : ['c', 'cpp']) #This is needed to also link other libraries static

wxDep = dependency('wxwidgets',
                   version : '>=3.0.0',
                   required : true,
                   modules : ['--static', 'std', 'stc'])
```
This way, it's build with fully static linking.

Build command used:
```
meson setup build_win --default-library=static && ninja -C build_win
```

Systeminfo: Windows 10, MSYS2/mingw64 subsystem
Meson Version: 0.53, installed within MSYS2

I'll attach the Testproject, so you can reproduce this (Includes buildfiles and logs).
[wxTest.zip](https://github.com/mesonbuild/meson/files/4142792/wxTest.zip)



Discussion:

Resolving patch:
diff --git a/mesonbuild/dependencies/ui.py b/mesonbuild/dependencies/ui.py
--- a/mesonbuild/dependencies/ui.py
+++ b/mesonbuild/dependencies/ui.py
@@ -32,6 +32,9 @@
 from .base import ExtraFrameworkDependency, PkgConfigDependency
 from .base import ConfigToolDependency, DependencyFactory
 
+if T.TYPE_CHECKING:
+    from ..environment import Environment
+
 
 class GLDependencySystem(ExternalDependency):
     def __init__(self, name: str, environment, kwargs):
@@ -530,17 +533,30 @@ class WxDependency(ConfigToolDependency):
     tools = ['wx-config-3.0', 'wx-config', 'wx-config-gtk3']
     tool_name = 'wx-config'
 
-    def __init__(self, environment, kwargs):
-        super().__init__('WxWidgets', environment, kwargs)
+    def __init__(self, environment: 'Environment', kwargs: T.Dict[str, T.Any]):
+        super().__init__('WxWidgets', environment, kwargs, language='cpp')
         if not self.is_found:
             return
         self.requested_modules = self.get_requested(kwargs)
+
+        extra_args = []
+        if self.static:
+            extra_args.append('--static=yes')
+
+            # Check to make sure static is going to work
+            err = Popen_safe(self.config + extra_args)[2]
+            if 'No config found to match' in err:
+                mlog.debug('WxWidgets is missing static libraries.')
+                self.is_found = False
+                return
+
         # wx-config seems to have a cflags as well but since it requires C++,
         # this should be good, at least for now.
-        self.compile_args = self.get_config_value(['--cxxflags'] + self.requested_modules, 'compile_args')
-        self.link_args = self.get_config_value(['--libs'] + self.requested_modules, 'link_args')
+        self.compile_args = self.get_config_value(['--cxxflags'] + extra_args + self.requested_modules, 'compile_args')
+        self.link_args = self.get_config_value(['--libs'] + extra_args + self.requested_modules, 'link_args')
 
-    def get_requested(self, kwargs):
+    @staticmethod
+    def get_requested(kwargs: T.Dict[str, T.Any]) -> T.List[str]:
         if 'modules' not in kwargs:
             return []
         candidates = extract_as_list(kwargs, 'modules')


Test patch: