language: generic

notifications:
    email: false
os:
  - linux

sudo: true #for beineri qt561
dist: trusty

before_install:
  - sudo add-apt-repository --yes ppa:beineri/opt-qt562-trusty
  - sudo add-apt-repository --yes ppa:ubuntu-toolchain-r/test
  - sudo apt-get -qq update
  - sudo apt-get -qq install ${AF} qt56base  qt56tools # qttools5-dev
  - sudo apt-get -qq install ${AF} cmake libhidapi-dev ${COMP}
  - sudo apt-get -qq remove gcc-4.8 g++-4.8 --purge

cache:
  - ccache
  - apt


script: |
    echo "${TRAVIS_OS_NAME}"
    if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
      source /opt/qt56/bin/qt56-env.sh ;
      export QMAKE=/opt/qt56/bin/qmake;
    fi
    if [ "$builder" == "qmake" ]; then pushd libnitrokey/build/ && cmake .. && make; popd ; fi
    if [ "$builder" == "qmake" -a "${TRAVIS_OS_NAME}" == "osx" ]; then ${QMAKE} && make ; fi
    if [ "$builder" == "qmake" -a "${TRAVIS_OS_NAME}" == "linux" ]; then ${QMAKE} && make CXX=${CXX} CC=${CC} LINK=${CXX} ; fi
    if [ "$builder" == "cmake" ]; then cmake -DERROR_ON_WARNING=ON . && make VERBOSE=1; fi

env:
  matrix:
    - builder=cmake CXX=clang++-3.8 CC=clang-3.8 COMP="clang-3.8 g++-5"
    - builder=qmake CXX=clang++-3.8 CC=clang-3.8 COMP="clang-3.8 g++-5"
    - builder=cmake CXX=g++-5 CC=gcc-5 COMP=g++-5
    - builder=qmake CXX=g++-5 CC=gcc-5 COMP=g++-5
    - builder=qmake CXX=g++-6 CC=gcc-6 COMP=g++-6
  global:
    - AF="-yq --no-install-suggests --no-install-recommends --force-yes" QMAKE=qmake


matrix:
  exclude:
  include:
    - os: osx
      osx_image: xcode7.3 #default
      before_install: &before
        - brew update
        - brew install qt5
        - brew unlink cmake
        - brew install cmake
        - export
      env: builder=cmake PATH="/usr/local/opt/qt5/bin:$PATH" CMAKE_PREFIX_PATH=/usr/local/lib/cmake MACOS_DEPLOYMENT_TARGET=10.9
    - os: osx
      osx_image: xcode7.3 #default
      before_install: *before
      env: builder=qmake PATH="/usr/local/opt/qt5/bin:$PATH" CMAKE_PREFIX_PATH=/usr/local/lib/cmake MACOS_DEPLOYMENT_TARGET=10.9
    - os: osx
      osx_image: xcode8.3
      before_install: *before
      env: builder=qmake PATH="/usr/local/opt/qt5/bin:$PATH" CMAKE_PREFIX_PATH=/usr/local/lib/cmake MACOS_DEPLOYMENT_TARGET=10.9
    - os: osx
      osx_image: xcode9.1
      before_install: *before
      env: builder=qmake PATH="/usr/local/opt/qt5/bin:$PATH" CMAKE_PREFIX_PATH=/usr/local/lib/cmake MACOS_DEPLOYMENT_TARGET=10.9
