language: cpp
dist: xenial

compiler:
  - gcc
  - clang

env:
  global:
    - ORIGINAL_CXXFLAGS="-pedantic -Wall -Wextra -Wcast-qual -Wno-deprecated-declarations -Wfloat-equal -Wmissing-declarations -Wmissing-format-attribute -Wno-long-long -Wpacked -Wredundant-decls -Wundef -Wno-shadow -Wno-missing-field-initializers -Wno-missing-braces -Wno-sign-compare -Wno-multichar -D_GLIBCXX_DEBUG -g"
#   unfortunately we need this to stay within 50min timelimit given by travis.
    - CXXFLAGS="${ORIGINAL_CXXFLAGS} -O2 -march=native -Wstrict-aliasing=2 -Werror=strict-aliasing"
    - CPPCHECK=${TRAVIS_BUILD_DIR}/cppcheck
  matrix:
    - CXXFLAGS="${CXXFLAGS} -DCHECK_INTERNAL"
    - CXXFLAGS="${CXXFLAGS} -DCHECK_INTERNAL" MAKEFLAGS="HAVE_RULES=yes" MATCHCOMPILER=yes VERIFY=1

before_install:
# install needed deps
 - travis_retry sudo apt-get update -qq
 - travis_retry sudo apt-get install -qq libxml2-utils libpcre3 gdb unzip wx-common xmlstarlet liblua5.3-dev libcurl3 libcairo2-dev libsigc++-2.0-dev tidy libopencv-dev

matrix:
# do notify immediately about it when a job of a build fails.
  fast_finish: true
# defined extra jobs that run besides what is configured in the build matrix
  include:

# check a lot of stuff that only needs to be checked in a single configuration
    - name: "misc"
      compiler: clang
      script:
        - make -j$(nproc) -s
# check if DESTDIR works  TODO: actually execute this
        - mkdir install_test
        - echo $CXXFLAGS
        - make -s DESTDIR=install_test FILESDIR=/usr/share/cppcheck install
# rm everything
        - git clean -dfx
# check what happens if we want to install it to some other dir,
        - echo $CXXFLAGS
        - make -s MATCHCOMPILER=yes FILESDIR=/usr/share/cppcheck -j$(nproc)
        - sudo make MATCHCOMPILER=yes FILESDIR=/usr/share/cppcheck install
