This tutorial provides a method on how to use Travis for your code project which is dependant upon Qt and OpenSceneGraph libraries. It is mainly aimed towards beginners who never dealt with Travis files, and as a result the full script example will be provided for a minimalistic code project. Note, there could be always few ways to solve the problem, and it is only one of them; hopefully, simple and intuitive.
Also, this tutorial is not aimed on providing definitions and explaining how Travis works; there is always official documentation for this.
While Travis web-site contains very detailed tutorials on how to do all kinds of setups, as a beginner I found it challenging to set it up for my project which is dependent on Qt and OpenSceneGraph. It is possible to scrape some information and examples on how to use Travis for Qt projects, however it took me a while to figure out the best procedure for OpenSceneGraph.
Keeping in mind that Travis uses Ubuntu OS for the builds, we can take advantage of the available Qt ppa, and perform installation from there.
Inside the project’s
.travis.yml, before the installation commands, we add the chosen repository (we chose Trusty package since that’s the distribution used by Travis):
Once the ppa is added as a repository, we can install the necessary Qt packages, for example:
After that, we need to make sure CMake knows where the Qt packages are located. We need to edit the
$PATH variable for that. In
.travis.yml this can be put under the
before_script part, e.g.:
And this is all for the Qt part! Depending on the build tool, you might need to run
qmake commands to prepare the
Makefile so that the
script part of the Travis file would only have to run
Unfortunately, there are no ppa packages for OpenSceneGraph like there are for Qt. One of the best options would be to introduce them, however, there is an easier work-around that requires less time.
The solution I approached was to build OSG for Linux and upload the built files into my github repository. Then for each project commit, Travis would download the installation files, set them up and use to perform the project’s compilation and testing (if needed). The steps are described in more details below.
I do not have access to the Linux environment on day to day work basis. I decided to use cloud9 for my OSG builds, and it worked out great. If you have a Linux machine available, then you can follow official documentation steps for OSG build.
Assuming you had built and installed the OSG library on Linux, now is the time to prepare an archive containing your version of the OSG. We will copy our “distribution” into a folder called
osg-340-deb. These are the commands I used:
Now is the time to archive the folder:
Upload the package, for example, to your github account. In my case, I forked an official github OpenSceneGraph repository and uploaded (the link will start archive download) the
.tar.gz file under the tag of the version
3.4.0. The total archive size came out to be about 11 Mb.
Before doing the installation, we need to obtain the necessary OSG release:
The installation step includes copying the release files into the standard location where CMake will be searching for OSG files:
Before running the script and
cmake command, we need to make sure the
$PATH variables are set correctly:
And this is all you need for the OpenSceneGraph part.
I had prepared a small “Hello World” project which is based on Qt and OpenSceneGraph. The main repository includes
.travis.yml file which summarizes all the code discussed above. As you can see from the project’s description, below the file tree, a proof of Travis doing its work is placed: