language: cpp

env:
  global:
    - CTEST_PARALLEL_LEVEL=4
    - CTEST_OUTPUT_ON_FAILURE=1
    - CXX_FLAGS_DEBUG="-O1"
    - BUILD_PYTHON_INTERFACE=ON

matrix:
  include:
    - name: "Trusty - Debug - g++"
      env: BUILD_TYPE=Debug
      dist: trusty
      compiler: g++
      addons:
        apt:
          packages:
            - cmake
            - libboost-all-dev
            - libassimp-dev
            - libeigen3-dev

    - name: "Xenial - Debug - g++"
      env: BUILD_TYPE=Debug
      dist: xenial
      compiler: g++
      addons:
        apt:
          packages:
            - cmake
            - libboost-all-dev
            - libassimp-dev
            - libeigen3-dev
            - liboctomap-dev
    - name: "Xenial - Release - g++"
      env: BUILD_TYPE=Release
      dist: xenial
      compiler: g++
      addons:
        apt:
          packages:
            - cmake
            - libboost-all-dev
            - libassimp-dev
            - libeigen3-dev
            - liboctomap-dev
    - name: "Xenial - Debug - clang"
      env: BUILD_TYPE=Debug
      dist: xenial
      compiler: clang
      addons:
        apt:
          packages:
            - cmake
            - libboost-all-dev
            - libassimp-dev
            - libeigen3-dev
            - liboctomap-dev

    - name: "Bionic - Debug - g++"
      env: BUILD_TYPE=Debug
      dist: xenial
      compiler: g++
      addons:
        apt:
          packages:
            - cmake
            - libboost-all-dev
            - libassimp-dev
            - libeigen3-dev
            - liboctomap-dev

    - name: "OSX - Debug - clang"
      env: BUILD_TYPE=Debug
      os: osx
      compiler: clang
      addons:
        homebrew:
          taps: homebrew/science
          update: true
          packages:
            - git
            - cmake
            - boost
            - libccd
            - assimp
            - eigen
            - octomap

before_install:
  - if [ "$TRAVIS_OS_NAME" = "linux" ]; then source travis_custom/custom_before_install_linux.sh ; fi
  - if [ "$TRAVIS_OS_NAME" = "osx" ]; then source travis_custom/custom_before_install_osx.sh ; fi

script:
  # Create build directory
  - mkdir build
  - cd build

  # Configure
  - cmake -DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCMAKE_CXX_FLAGS=-w -DCMAKE_CXX_FLAGS_DEBUG=${CXX_FLAGS_DEBUG} -DBUILD_PYTHON_INTERFACE=${BUILD_PYTHON_INTERFACE} ..

  # Build
  - make -j4

  # Run unit tests
  - travis_wait 30 ctest

  # Make sure we can install and uninstall with no issues
  - sudo make -j4 install
  - sudo make -j4 uninstall
