Native Desktop GUI apps: wxWidgets with conan and premake

I'm always looking for better ways to create desktop applications.

See here. And here.

Today: wxWidgets

undefined undefined undefined

The repo for my experiment is here: https://github.com/andreas-mausch/wxwidgets-conan-premake

1. Stats

Binary sizes on Linux are 7 MB and 11 MB (with XRC).

2. Conan and Premake

Conan is a C/C++ Package Manager.
Premake is a build configuration tool.

They work very well together.

2.1. Conan

As someone who never used a dependency manager for C++, I was positively surprised by the ease to add third-party code.

It's feels like adding a maven dependency to a Java project. I might take a bit longer the first time you install it (because you might need to compile it first), but then it's just nice to have the include and library directories set up automatically.

As you can see in the whatsapp-viewer repo, I still copy/pasted the dependencies into my own repo, something which is a very bad practice and something I've criticized myself for good reasons.

It's a joy to quickly add a new dependency, even if you might have to build it first.

The only thing which was tricky and not so easy was the 'imports' section.
I had to execute the wxrc binary (which comes with wxwidgets). So I have to use the binary from the dependency. Unfortunately, the executable name on Windows and Linux/Mac is different (of course!).
The solution was to write two lines into the conanfile: One for the wxrc-3.1 for Linux and Mac, and another for the wxrc.exe on Windows.

Update 2020-10-05: Okay, dependencies or their receipes must be maintained by somebody, and apparently this isn't the case for SqLiteCpp which is available in version 3.0 since nine months now. The newest version in conan is 2.5, even though it is part of the offical conan-center-index. Someone reported an issue, but there is no reaction yet..

2.2. Premake

Premake can generate either makefiles, visual studio projects or xcode projects, all with a single description file. Very useful for cross-platform development.

I've decided to try it out instead of CMake, because while CMake is widely used, it's syntax is ugly and harder to understand than Premake's. The main reason I found on the internet to use CMake was "because others use it", which by itself is not a very strong argument..

Premake was ok to set up, but I didn't manage to properly clear the generated folder if you call make clean.

There is something like cleancommands, but they are not intended to be used in a WindowedApp. Well.

Also, I've started by using os.mkdir() to create the directory, however I've discovered later the much better way is to use {MKDIR} inside the prebuildcommands. The downside of os.mkdir() is: The directory is created at the time you excecute premake5, rather than in front of every single build. The directory might have been deleted in between.

3. Critism on wxWidgets

I always thought wxWidgets is some very old technology and pretty much deprecated. It is old, but actively maintained and not deprecated at all.

I really really dislike some things though, like:

The 'Hello World' wxWidgets on Linux results in a 7 MB executable. Imo that's bloated, and imo wxWidgets carries a lot of stuff which might be convenient, but doesn't belong in a pure GUI lib (implementations of jpeg, png, zlib, html, webview (a complete browser!), ..). I'm not quite sure why the linker doesn't discard the unused bits. I can't believe there is 7 MB code needed to render an empty window.

If you add support for XRC, my binary increases to 11mb. :(

In my opinion they should decide to be either a pure GUI library or a full-blown "app-environment", which features almost everything an OS offers, but in an OS-independet way. They are neither fish nor fowl.

4. Alternatives?

Most of my critism also applies to Qt, which I dislike a lot more for their bloatiness.

Unfortunately, libui doesn't seem to be moving. :(

However, if you look for a GUI library which renders native controls and can be linked statically on all platforms, you don't have much of a choice but to use wxWidgets. That's why I have to say it is my preferred library to build native desktop apps today.

If you know any other/better library, please let me know.