It was (and still is) quite painful to figure out what is possible/allowed with Travis CI and what isn't. My current solution looks like this:
language: cpp
matrix:
include:
- os: linux
compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.8']
env: COMPILER=g++-4.8
- os: linux
compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-4.9']
env: COMPILER=g++-4.9
- os: linux
compiler: gcc
addons:
apt:
sources: ['ubuntu-toolchain-r-test']
packages: ['g++-5']
env: COMPILER=g++-5
- os: linux
compiler: clang
env: COMPILER=clang++
- os: linux
compiler: clang
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.5']
packages: ['clang-3.5']
env: COMPILER=clang++-3.5
- os: linux
compiler: clang
addons:
apt:
sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.6']
packages: ['clang-3.6']
env: COMPILER=clang++-3.6
# Activate when 3.7 is released and the repository is available
# - os: linux
# compiler: clang
# addons:
# apt:
# sources: ['ubuntu-toolchain-r-test', 'llvm-toolchain-precise-3.7']
# packages: ['clang-3.7']
# env: COMPILER=clang++-3.7
# Activate when we are allowed to use MacOS X
# - os: osx
# compiler: clang
# env: COMPILER=clang++
script:
make CXX=$COMPILER -j3
Some remarks:
- The above uses the container-based infrastructure
- Only one compiler is installed per container - speeds up the build and avoids problems as you often can not install several packages/compilers in parallel
- You can not set
CXX
directly as Travis CI will overwrite it. You need an intermediate variable like COMPILER
- The
clang++
without extension is currently Clang 3.4
- Clang 3.7 is not yet available, but should be shortly
- Clang 3.8 (the development version) from the
llvm-toolchain-precise
repository is currently black-listed
(Note that the above will change/improve over time, now (2016-01-11) Clang 3.7 is available, as is MacOS X. The above is meant as a starting point, adapt as needed)