Search code examples
windowsclangwxwidgetsmeson-build

How do I set up meson project with wxWidgets depends for Windows?


I'm trying out a new setup. I'm on a 64-bit Windows 10. I've meson example project and clang compiler stack over Visual Studio 2017. Both of those are in my PATH.

[0/1] Regenerating build files.
The Meson build system Version: 0.49.0
Source dir: C:\WORK\cpp-example\wx-example
Build dir: C:\WORK\cpp-example\wx-example\builddir
Build type: native build
Project name: wx-example
Project version: undefined
Native C++ compiler: clang++ (clang 7.0.0 "clang version 7.0.0 (tags/RELEASE_700/final)")
Build machine cpu family: x86_64
Build machine cpu: x86_64
Found wx-config '>=3.0.0' NO
Dependency WxWidgets found: NO (tried config-tool)

meson.build:8:2: ERROR:  Dependency "wxwidgets" not found, tried config-tool

A full log can be found at C:\WORK\cpp-example\wx-example\builddir\meson-logs\meson-log.txt
FAILED: build.ninja

My meson.build is

project('wx-example', 'cpp')

#if build_machine.system() == 'windows'
#  cpp = meson.get_compiler('cpp')
#  add_project_link_arguments(['C:\WORK\wxWidgets-3.1.2\include'], language : 'cpp')
#  wx_dep = cpp.find_library('wxwidgets', dirs : ['C:\WORK\wxWidgets-3.1.2\lib\vc_x64_dll'])
#else
  wx_dep = dependency('wxwidgets', version : '>=3.0.0', required : true)
#endif

executable('wx-example.exe', ['main.cpp'], dependencies : [wx_dep])

Do u have any idea how to compile my example? Maybe I should use MinGW wxWitgets package?


Solution

  • Meson's dependency for wxWidgets only supports wx-config tool, which was originally intended for *nix only. So you need to get wx-config Windows native port first to make it work with VC++.

    BTW. Maybe even the easiest thing to do is to write it on your own, as it's just a regular console application, which parses the command line and spits to stdout the corresponding compiler/linker flags.

    Maybe I should use MinGW wxWitgets package?

    Well, that's, of course, possible but then you will also have to switch to gcc/g++. Moreover, Meson's wxWidgets dependency is still broken under MSYS2/MinGW. The problem is that Meson erroneously tries to execute wx-config directly, while under Windows it must be prefixed with env/sh/bash or whatever. Not a big problem to fix it, but you'll still have some work to do.

    UPD.: The issue appears to be fixed in Meson 0.51.0