# Add [ci skip] to the commit message to prevent test execution
# whitelist
branches:
  only:
    - master
    - testing

notifications:
  slack:
    on_success: change

cache:
  directories:
    - wxWidgets
    - wxWidgets/build_osx

language: cpp
os:
  - linux
  - osx

dist: trusty
sudo: required

compiler: gcc

env:
  - WXLIB="libwxgtk3.1-dev"

matrix:
  allow_failures:
    - os: linux
      env: WXLIB="libwxgtk3.1-dev"
  include:
    - os: linux
      env: WXLIB="libwxgtk3.0-dev"
    - os: osx
      osx_image: xcode10.2
      compiler: gcc clang
      env: WXLIB="libwxgtk3.1-dev"
  exclude:
    - os: osx
      compiler: gcc
      env: WXLIB="libwxgtk3.1-dev"

before_install:
  - if  [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
      sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test;
      sudo apt-get update -qq;
    fi

install:
  - if  [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
      sudo apt-get install -qq g++-7;
      sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-7 90;
    fi
  - if  [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
      rm -rf wxWidgets;
      if  [[ ! -d wxWidgets ]]; then
         git submodule init &&
         git submodule add -f https://github.com/wxWidgets/wxWidgets.git;
      fi;
      git submodule update --init --recursive;
      if  [[ ! -d wxWidgets/build_osx ]]; then
         mkdir -p wxWidgets/build_osx ;
      fi;
      pushd wxWidgets/build_osx &&
      ../configure --enable-unicode --disable-shared --with-osx_cocoa --without-libtiff CXXFLAGS="-stdlib=libc++" LDFLAGS="-stdlib=libc++" OBJCXXFLAGS="-stdlib=libc++" --with-macosx-sdk=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk --with-macosx-version-min=10.7 CC=clang CXX=clang++ &&
      make &&
      sudo make install &&
      popd ;
    else
      if  [[ "$WXLIB" = "libwxgtk3.1-dev" ]]; then
        sudo apt-key adv --fetch-keys http://repos.codelite.org/CodeLite.asc &&
        sudo apt-add-repository 'deb http://repos.codelite.org/wx3.1.0/ubuntu/ trusty universe';
      fi;
      sudo apt-get update &&
      sudo apt-get install -y $WXLIB ;
    fi

script:
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
      xcodebuild -project osx/TreeSheets/TreeSheets.xcodeproj ;
    else
      cmake . && make -j 4;
    fi
