language: cpp
sudo: required
dist: trusty

os:
  - linux
  - osx

compiler:
  - gcc
  - clang

before_install:
  - if [ $TRAVIS_OS_NAME == linux ]; then 
      sudo apt-get update -qq;
      sudo apt-get install -y --no-install-recommends libxrandr-dev libxi-dev libxxf86vm-dev libsdl2-dev;
      wget https://github.com/glfw/glfw/releases/download/3.2.1/glfw-3.2.1.zip;
      unzip glfw-3.2.1.zip && cd glfw-3.2.1; 
      cmake -DBUILD_SHARED_LIBS=true -DGLFW_BUILD_EXAMPLES=false -DGLFW_BUILD_TESTS=false -DGLFW_BUILD_DOCS=false .;
      sudo make -j $CPU_NUM install && cd ..;
    fi
  - if [ $TRAVIS_OS_NAME == osx ]; then 
      brew update;
      brew install glfw3;
      brew install sdl2;
    fi

script: 
  - make -C examples/example_glfw_opengl2
  - make -C examples/example_glfw_opengl3
  - make -C examples/example_sdl_opengl3
  - if [ $TRAVIS_OS_NAME == osx ]; then 
      xcodebuild -project examples/example_apple_metal/example_apple_metal.xcodeproj -target example_apple_metal_macos;
    fi