version: '{build}'

branches:
  only:
    - master
    - next
shallow_clone: true
clone_depth: 1

clone_folder: c:\dev\grantlee

environment:
  matrix:
  - CMAKE_GENERATOR: "NMake Makefiles JOM"
    QT5: C:\Qt\5.6\msvc2015
    PLATFORM: X86
    VCVARSALL: "%VS140COMNTOOLS%/../../VC/vcvarsall.bat"
  - CMAKE_GENERATOR: "Ninja"
    QT5: C:\Qt\5.6\msvc2015
    PLATFORM: X86
    VCVARSALL: "%VS140COMNTOOLS%/../../VC/vcvarsall.bat"
  - CMAKE_GENERATOR: "Ninja"
    QT5: C:\Qt\5.6\msvc2015_64
    PLATFORM: X64
    VCVARSALL: "%VS140COMNTOOLS%/../../VC/vcvarsall.bat"
  - CMAKE_GENERATOR: "Visual Studio 14"
    QT5: C:\Qt\5.6\msvc2015
    PLATFORM: X86
    VCVARSALL: "%VS140COMNTOOLS%/../../VC/vcvarsall.bat"
  - CMAKE_GENERATOR: "Visual Studio 14 Win64"
    QT5: C:\Qt\5.6\msvc2015_64
    PLATFORM: X64
    VCVARSALL: "%VS140COMNTOOLS%/../../VC/vcvarsall.bat"
  - CMAKE_GENERATOR: "NMake Makefiles JOM"
    QT5: C:\Qt\5.6\msvc2015_64
    PLATFORM: X64
    VCVARSALL: "%VS140COMNTOOLS%/../../VC/vcvarsall.bat"
  - CMAKE_GENERATOR: "MinGW Makefiles"
    QT5: C:\Qt\5.6\mingw49_32
    MINGW_PATH: C:\Qt\Tools\mingw492_32
  - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
    CMAKE_GENERATOR: "Ninja"
    QT5: C:\Qt\5.12\msvc2017
    PLATFORM: X86
    VCVARSALL: "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsall.bat"
  - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
    CMAKE_GENERATOR: "Ninja"
    QT5: C:\Qt\5.12\msvc2017_64
    PLATFORM: X64
    VCVARSALL: "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsall.bat"
  - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
    CMAKE_GENERATOR: "Visual Studio 15"
    QT5: C:\Qt\5.12\msvc2017
    PLATFORM: X86
    VCVARSALL: "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsall.bat"
  - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
    CMAKE_GENERATOR: "Visual Studio 15 Win64"
    QT5: C:\Qt\5.12\msvc2017_64
    PLATFORM: X64
    VCVARSALL: "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsall.bat"
  - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
    CMAKE_GENERATOR: "NMake Makefiles JOM"
    QT5: C:\Qt\5.12\msvc2017
    PLATFORM: X86
    VCVARSALL: "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsall.bat"
  - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
    CMAKE_GENERATOR: "NMake Makefiles JOM"
    QT5: C:\Qt\5.12\msvc2017_64
    PLATFORM: X64
    VCVARSALL: "C:/Program Files (x86)/Microsoft Visual Studio/2017/Community/VC/Auxiliary/Build/vcvarsall.bat"
  - CMAKE_GENERATOR: "MinGW Makefiles"
    QT5: C:\Qt\5.12\mingw73_32
    MINGW_PATH: C:\Qt\Tools\mingw730_32
  - CMAKE_GENERATOR: "MinGW Makefiles"
    QT5: C:\Qt\5.12\mingw73_64
    MINGW_PATH: C:\Qt\Tools\mingw730_64

install:
  - ps: |
      choco install ninja

init:
  - if NOT "%VCVARSALL%" == "" call "%VCVARSALL%" %PLATFORM%
  - git config --global core.autocrlf input

before_build:
  - set PATH=C:\cygwin\bin;%QT5%\bin;c:\dev\grantlee\build\templates\lib;c:\dev\grantlee\build\textdocument\lib;%PATH%
  - sed -i "s|std::equal(b, e, lb)|std::equal(b, e,\n#if defined(Q_CC_MSVC)\nstdext::make_unchecked_array_iterator(lb)\n#else\nlb\n#endif\n)|" %QT5%\include\QtCore\qlist.h
  - set PATH=%PATH:C:\cygwin\bin;=%
  - if "%CMAKE_GENERATOR%" == "MinGW Makefiles" set PATH=%MINGW_PATH%\bin;%PATH:C:\Program Files\Git\usr\bin;=%
  - if "%CMAKE_GENERATOR%" == "NMake Makefiles JOM" set PATH=C:\Qt\Tools\QtCreator\bin;%PATH%

build:

build_script:
  - cd c:\dev\grantlee
  - md build
  - cd build
  - cmake .. -G "%CMAKE_GENERATOR%" "-DCMAKE_PREFIX_PATH=%QT5%"
  - cmake --build . --config Debug
  - cmake --build . --config Release

test_script:
  - cmd: ctest --output-on-failure -C "Debug"
  - cmd: ctest --output-on-failure -C "Release"
