language: cpp

os:
 - linux
 - osx

compiler:
 - gcc
 - clang

dist: trusty

env:
 - QT=5  BREW=5
 - QT=56 BREW=5  PPA=beineri/opt-qt562-trusty
 - QT=57 BREW=ex PPA=beineri/opt-qt571-trusty
 - QT=58 BREW=ex   PPA=beineri/opt-qt58-trusty
 - QT=59 BREW=ex   PPA=beineri/opt-qt593-trusty
 - QT=510 BREW=@ex PPA=beineri/opt-qt-5.10.1-trusty

matrix:
 exclude:
  - { os: linux, env: QT=5  BREW=5 }
  - { os: osx, env: QT=57 BREW=ex PPA=beineri/opt-qt571-trusty }
  - { os: osx, compiler: gcc, env: QT=5  BREW=5 } # Qt 5.6 no longer supports gcc on OS X.
  - { os: osx, compiler: gcc, env: QT=56 BREW=5  PPA=beineri/opt-qt561-trusty } # Qt 5.6 no longer supports gcc on OS X.
  - { os: osx, env: QT=57 BREW=ex   PPA=beineri/opt-qt571-trusty }
  - { os: osx, env: QT=58 BREW=ex   PPA=beineri/opt-qt58-trusty  }
  - { os: osx, env: QT=59 BREW=ex   PPA=beineri/opt-qt593-trusty }
  - { os: osx, env: QT=510 BREW=@ex PPA=beineri/opt-qt-5.10.1-trusty }

before_install:
 - '[[ "$TRAVIS_OS_NAME" != linux || -z "$PPA" ]] || sudo add-apt-repository -y ppa:$PPA'
 - '[ "$TRAVIS_OS_NAME" != linux ] || sudo apt-get -qy update'
 - '[ "$TRAVIS_OS_NAME" != osx ] || brew update'

install:
 - '[[ "$TRAVIS_OS_NAME" != linux || "$PPA" != */opt-* ]] || travis_wait sudo apt-get -qy install qt$QT-meta-full'
 - '[[ "$TRAVIS_OS_NAME" != linux || "$PPA" == */opt-* ]] || travis_wait sudo apt-get -qy install qt5-qmake qtbase5-dev qttools5-dev qttools5-dev-tools qtscript5-dev qtmultimedia5-dev'
 - '[ "$TRAVIS_OS_NAME" != osx ] || travis_wait brew install qt$BREW'
 - '[ "$TRAVIS_OS_NAME" != osx ] || travis_wait brew link --force qt$BREW'
 - '[ "$TRAVIS_OS_NAME" != osx ] || travis_wait brew info openssl'

script:
 - '[[ "$TRAVIS_OS_NAME" != linux || "$PPA" != */opt-* ]] || . /opt/qt$QT/bin/qt$QT-env.sh'
 - '[[ "$TRAVIS_OS_NAME" != linux || "$PPA" == */opt-* ]] || export QT_SELECT=qt5'
 - mkdir -p "$TRAVIS_BUILD_DIR-build"
 - pushd "$TRAVIS_BUILD_DIR-build"
 - '[ "$TRAVIS_OS_NAME" != osx ] || cmake $TRAVIS_BUILD_DIR -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH=`brew --prefix qt$BREW` -DQTERM_ENABLE_SCRIPT_DEBUGGER=On -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl -DQT5=Yes'
 - '[ "$TRAVIS_OS_NAME" != linux ] || cmake $TRAVIS_BUILD_DIR -DCMAKE_BUILD_TYPE=Release -DQTERM_ENABLE_SCRIPT_DEBUGGER=On -DQT5=Yes'
 - make VERBOSE=1
 - '[ "$TRAVIS_OS_NAME" != osx ] || make package'
 - popd

deploy:
  provider: releases
  api_key:
    secure: QUO3Xl2AsNDQKm9s+vI68/pfdjtMVU/Y5ugcC7RNtxueL8dLzF5nCX1zEEDyIggBFYi0oHeLf2sdaHji9A9BqJxdu1y6Uay+TkCPnyIIkgOfn4W+xPkVBz9v8kAvMx6VaZ8kE6G3k79k+/r77QuSiicDoRXLJY4BshvBJIXdzzfwRicBvEe6sMPR06hXBFQktmnn+u+yUKaqXO9qKyqJhQr5mn4+dGFAkLyZg5XmnYqfjPSCR+N1Aci0Viyoidfqb7plEBrgLnDSeXaqmAl6FnMb0huFXRF/yBH6GM5RfN6KMY5J6SOZKAcOS3IlpBtmawPXpjnyYN8Jhev9wy7FbxaTmSQjj5oB7HmEj9noUPx6AlhbuYp9O0vYmZ6ZD5S5hoELQYcZwY19bbtWuM3Jl3i9TaeD+D1kmaTVEg7/hwqJP6BseE9lKY8Yw+1+Mnp4mfDRCq5lhUIEUk9lDrf8fT9oaQfzZgVnujYu8Guldbd+PlUfjJTEaRIIa8MjIgoUmqzEzLk4kBK/8ENzFTxWqGS+bM4L69VyvTGf4fCZpu2TEfk54rlDq1oZ1tNACjXAet6zSLV4dJqLJMz1MRPMpu9sx278lT3eyT29BnwyhyRZMd4renv8vIFEeczTEAOal0HtMH9Fkz7Pda2tKGw4x55MdbnSG459nl78acZ/Pio=
  file_glob: true
  file: $TRAVIS_BUILD_DIR-build/QTerm-*-Darwin.dmg
  on:
    condition: '"$TRAVIS_OS_NAME" == osx && "$CXX" == clang++ && "$QT" == 56'
    tags: true
