wxWidgets + CMake: Multiplatform Superbuild

LukesDevTutorials
2 min readOct 26, 2020

In this article I’ll show you how to create a native-looking UI application in C++ and build it on each of the major platforms (Windows, Linux, Mac OS) using a single build script code.

You can download the full source code of the sample program from github: https://github.com/lszl84/wx_cmake_template . Also, check the YouTube video below, which describes the process in detail, showing how this works on each of the aforementioned platforms:

Single Codebase UI Apps in C++ for Linux, Windows and MacOS — building with wxWidgets and CMake

Objectives

We’d like to automatize the building of a UI application written in C++ so that:

  • it can be built on Windows, Mac OS and Linux using the same set of commands,
  • the build script automatically detects the environment, compiler, etc. to use for compiling the app,
  • the script checks if the UI library (wxWidgets in this case) is already installed in the operating system. If not found, the script downloads it from github, compiles and installs the library in a temporary directory containing build artifacts.

In this way, we can greatly simplify the build process for each platform, while also making the dependency management easier and more flexible. We save the user the hassle of downloading and installing necessary libraries by automatizing the process, while also giving them an option to link against a preinstalled copy of the library, if they so choose (e.g. when using our project as part of a larger system which already depends on the same libraries).

Post moved to: https://www.lukesdevtutorials.com/post/wxwidgets-cmake/

--

--