language: cpp

matrix:
  include:
    - dist: trusty
      compiler: gcc
    - os: osx
      compiler: clang

install:
    - if [[ "$TRAVIS_OS_NAME" == "linux" ]];
      then
        sudo apt-get -qq update;
        sudo apt-get install libwxgtk3.0-dev libwxgtk3.0-0 libgps-dev libglu1-mesa-dev libgtk2.0-dev libbz2-dev libtinyxml-dev;
        sudo apt-get install libexpat1-dev libcairo2-dev;
        sudo apt-get install rpm;
      fi
    - if [[ "$TRAVIS_OS_NAME" == "osx" ]];
      then
        brew install cairo libexif xz libarchive;
        wget http://opencpn.navnux.org/build_deps/wx312_opencpn50_macos109.tar.xz;
        tar xJf wx312_opencpn50_macos109.tar.xz -C /tmp;
        export PATH="/usr/local/opt/gettext/bin:$PATH";
        echo 'export PATH="/usr/local/opt/gettext/bin:$PATH"' >> ~/.bash_profile;
        wget http://opencpn.navnux.org/build_deps/Packages.dmg;
        hdiutil attach Packages.dmg;
        sudo installer -pkg "/Volumes/Packages 1.2.5/Install Packages.pkg" -target "/";
      fi

script:
  - if [[ "${COVERITY_SCAN_BRANCH}" == 1 ]];
    then
      echo "Don't build on coverty_scan branch.";
      exit 0;
    fi
  - mkdir build && cd build
  - if [[ "$TRAVIS_OS_NAME" == "linux" ]];
    then
       cmake -DCMAKE_BUILD_TYPE=Release ../ && make -sj2 package;
    fi
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]];
    then
        cmake -DwxWidgets_CONFIG_EXECUTABLE=/tmp/wx312_opencpn50_macos109/bin/wx-config -DwxWidgets_CONFIG_OPTIONS="--prefix=/tmp/wx312_opencpn50_macos109" -DCMAKE_INSTALL_PREFIX=/tmp/opencpn -DCMAKE_OSX_DEPLOYMENT_TARGET=10.9 .. && make -sj2 && make create-pkg;
     fi
  - ls -l;

notifications:
    email: false
    
git:
    depth: 10

before_install:
      - if [ "$CXX" = "g++" ]; then export CXX="g++-6" CC="gcc-6"; fi
addons:
  apt:
    sources:
      - ubuntu-toolchain-r-test
    packages:
      - gcc-6
      - g++-6

# Set encrypted variable 'GitHub_auth_token' in Travis repo settings to deploy packages
# for tagged commits to GitHub Releases.
deploy:
- provider: releases
  api_key: $GitHub_auth_token
  file_glob: true
  file: $TRAVIS_BUILD_DIR/build/*.{deb,rpm,dmg,txz,pkg.tar.xz}
  skip_cleanup: true
  on: # Set deploy conditions
      # Deploy only when tag is specified
      tags: true
      # or his branch
      branch: dev
      # and only when API token is set
      condition: "${#GitHub_auth_token} != 0" 
