language: cpp

notifications:
  email: false

env:
  global:
    - /usr/local/bin:$PATH

matrix:
  include:
    - os: linux
      compiler: gcc
      env:
        - COMPILER=g++
        - BUILD_TYPE=Debug
        - EXTRA_FLAGS="-Wall -pedantic"
    - os: linux
      compiler: gcc
      env:
        - COMPILER=g++
        - BUILD_TYPE=Release
        - EXTRA_FLAGS="-Wall -pedantic"
    - os: linux
      compiler: clang
      env:
        - COMPILER=clang++
        - BUILD_TYPE=Debug
        - EXTRA_FLAGS="-Weverything -Wno-weak-vtables -Wno-global-constructors -Wno-exit-time-destructors -Wno-padded"
    - os: linux
      compiler: clang
      env:
        - COMPILER=clang++
        - BUILD_TYPE=Release
        - EXTRA_FLAGS="-Weverything -Wno-weak-vtables -Wno-global-constructors -Wno-exit-time-destructors -Wno-padded"
    - os: linux
      compiler: clang
      env:
        - COMPILER=clang++
        - BUILD_TYPE=Release
        - EXTRA_FLAGS="-std=c++11 -Weverything -Wno-weak-vtables -Wno-global-constructors -Wno-exit-time-destructors -Wno-padded -Wno-breserved-id-macro -Wno-zero-as-null-pointer-constant"
    - os: linux
      compiler: clang
      env:
        - COMPILER=clang++
        - BUILD_TYPE=Release
        - EXTRA_FLAGS="-std=c++14 -Weverything -Wno-weak-vtables -Wno-global-constructors -Wno-exit-time-destructors -Wno-padded -Wno-reserved-id-macro -Wno-zero-as-null-pointer-constant"
    - os: linux
      compiler: clang
      env:
        - COMPILER=clang++
        - BUILD_TYPE=Release
        - EXTRA_FLAGS="-std=c++17 -Weverything -Wno-weak-vtables -Wno-global-constructors -Wno-exit-time-destructors -Wno-padded -Wno-reserved-id-macro -Wno-zero-as-null-pointer-constant"
    - os: linux
      compiler: clang
      env:
        - COMPILER=clang++
        - BUILD_TYPE=Release
        - EXTRA_FLAGS="-stdlib=libc++ -std=c++17 -Weverything -Wno-weak-vtables -Wno-global-constructors -Wno-exit-time-destructors -Wno-padded -Wno-reserved-id-macro -Wno-zero-as-null-pointer-constant"

before_install:
  - if [ "${TRAVIS_OS_NAME}" == "linux" ]; then
      set -e;
      sudo apt-get update -qq;
      sudo apt-get -y install valgrind;
    fi

before_script:
  - mkdir build && cd build
  - mkdir install_tmp

script:
  - export CXXFLAGS="${EXTRA_FLAGS}"
  - export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/usr/local/clang-5.0.0/lib"
  - cmake -DCMAKE_CXX_COMPILER=${COMPILER} -DCMAKE_VERBOSE_MAKEFILE=ON -DCMAKE_BUILD_TYPE=${BUILD_TYPE} -DTEST=ON ..
  - make VERBOSE=1
  - DESTDIR=install_tmp make install
  - if [ "${TRAVIS_OS_NAME}" == "linux" -a "${BUILD_TYPE}" == "Debug" ]; then
      set -e;
      valgrind --leak-check=full --error-exitcode=1 ./sample/sample;
    fi
  - ctest -C ${BUILD_TYPE} -V
