Back to Blog home

Building Qt Creator plugins with GitHub Actions

Published on Wednesday December 18, 2019 by Cristian Adam in Marketplace Biz Circuit & Dev Loop Qt Creator plugin Github Actions | Comments
Qt Creator is a cross platform, highly modular, Qt C++ application.

In order to build a Qt Creator plugin you need:
  • A C++ compiler
  • The Qt SDK
  • The Qt Creator SDK

Not many plugin developers know that Qt Creator is shipping an SDK. You don't need to compile Qt Creator in order to develop a Qt Creator plugin. Also having access to all three platforms (Windows, Linux, macOS) is not a common thing for most C++ developers.

GitHub Actions


GitHub Actions is a CI/CD infrastructure provided by GitHub which would give access to all three platforms!
GitHub is also hosting a few Qt Creator plugin repositories, so I decided to try to build the Doxygen plugin (my fork with the GitHub Actions script).

GitHub Actions currently offers the following virtual machines (runners):

  • Ubuntu 16.04 LTS
  • Ubuntu 18.04 LTS
  • Windows Server 2016
  • Windows Server 2019
  • macOS 10.15

Qt SDK is not part of the software installed on the runners. This is not a problem since we want to build with the same Qt version that Qt Creator itself was build.

One can build a platform at a time, or multiple in parallel (matrix mode)

Prerequisites


Since GitHub is providing the virtual machines and the C++ compilers one just has to obtain Qt and Qt Creator SDKs and then just "compile". 

In order to download files, to extract them, and to start compilation I decided to use a scripting language that is installed on all three of them: CMake (in scripting mode via -P command line argument).

I downloaded the Qt SDK and Qt Creator Binaries, Sources, SDK from download.qt.io.

Building the plugin

In order to configure the plugin, one just needs to run 

qmake doxygen.pro CONFIG+=release QTC_SOURCE="$ENV{GITHUB_WORKSPACE}/qtcreator" QTC_BUILD="$ENV{GITHUB_WORKSPACE}/qtcreator"

Building is as easy as running make -j <number-of-cores> or jom.

At the end we will have a shared library (.dll, .so, .dynlib), which will be distributed to the users.

Triggering GitHub Actions

On git push the plugin will be built and the artifacts stored on every build. This looks like this:

github-actions-push

If we tag a commit with git tag -a v0.4.7-qtc-4.11 -m "Release v0.4.7-qtc-4.11" and then git push origin v0.4.7-qtc-4.11 will trigger the creation of a release, and the upload of artifacts to that release. This looks like:

github-actions-push-with-tag

The newly created release looks like:

github-actions-release

Does it run?

GitHub Actions has some differences in platforms and compilers when it comes to how Qt and Qt Creator are built:

  • Visual C++ 2019 vs Visual C++ 2017
  • Red Hat 7.2 vs Ubuntu 18.04

As it turns out Qt Creator was able to load the plugin on all three platforms!

qtc-4.11-doxygen-macos

qtc-4.11-doxygen-windows

qtc-4.11-doxygen-linux

Source code!

All of this was possible with a Yaml file that needs to be copied into qtcreator-doxygen/.github/workflows/build_qmake.yml

The source is below:

Feel free to copy and hack the script in order to release your own Qt Creator plugins! 😊

Subscribe to Our Blog

Stay up to date with the latest marketing, sales and service tips and news.