# http://www.appveyor.com/docs/appveyor-yml

notifications:
  - provider: Email
    on_build_status_changed: false
    on_build_failure: false
    on_build_success: false
  # gitter
  - provider: Webhook
    url: https://webhooks.gitter.im/e/3a78202a235c0325e516
    on_build_status_changed: true
    on_build_failure: true
    on_build_success: false

clone_depth: 500
branches:
  except:
    - gh-pages
    - coverity_scan

matrix:
  fast_finish: false

environment:
  matrix:
  - gen: "MinGW Makefiles"
  - gen: "Visual Studio 14 2015"
    APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
  - gen: "Visual Studio 15 2017"
    APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
  - gen: "Visual Studio 16 2019"
    APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019

install:
  - IF "%gen%" == "MinGW Makefiles" appveyor-retry appveyor DownloadFile http://downloads.sourceforge.net/mingw-w64/x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z
  - IF "%gen%" == "MinGW Makefiles" 7z x x86_64-8.1.0-release-posix-seh-rt_v6-rev0.7z -oc:\mingw > nul

build_script:
  - cmake --version
  # workaround for CMake not wanting sh.exe on PATH for MinGW
  - IF "%gen%" == "MinGW Makefiles" set PATH=%PATH:C:\Program Files\Git\usr\bin;=%
  - IF "%gen%" == "MinGW Makefiles" set PATH=C:\mingw\mingw64\bin;%PATH%
  # generate and build everything for debug and release
  - IF "%gen%" == "MinGW Makefiles" mkdir debug_64
  - IF "%gen%" == "MinGW Makefiles" cd debug_64
  - IF "%gen%" == "MinGW Makefiles" cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Debug
  - IF "%gen%" == "MinGW Makefiles" cmake --build .
  - IF "%gen%" == "MinGW Makefiles" cd ..
  - IF "%gen%" == "MinGW Makefiles" mkdir release_64
  - IF "%gen%" == "MinGW Makefiles" cd release_64
  - IF "%gen%" == "MinGW Makefiles" cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release
  - IF "%gen%" == "MinGW Makefiles" cmake --build .
  - IF "%gen%" == "MinGW Makefiles" cd ..
  # adding git to the path again - for the dos2unix tool
  - IF "%gen%" == "MinGW Makefiles" set PATH=%PATH%;C:\Program Files\Git\usr\bin
  # execute tests
  - IF "%gen%" == "MinGW Makefiles" cd debug_64
  - IF "%gen%" == "MinGW Makefiles" ctest -j2 --output-on-failure
  - IF "%gen%" == "MinGW Makefiles" cd ..
  - IF "%gen%" == "MinGW Makefiles" cd release_64
  - IF "%gen%" == "MinGW Makefiles" ctest -j2 --output-on-failure
  - IF "%gen%" == "MinGW Makefiles" cd ..
  - IF "%gen%" == "MinGW Makefiles" appveyor exit
  # ============= VISUAL STUDIO
  - mkdir debug_64
  - cd debug_64
  - cmake .. -G "%gen%" -A x64
  - msbuild doctest.sln /p:Configuration=Debug;Platform=x64 /maxcpucount
  - ctest -C Debug -j2 --output-on-failure
  - cd ..
  - mkdir release_64
  - cd release_64
  - cmake .. -G "%gen%" -A x64
  - msbuild doctest.sln /p:Configuration=Release;Platform=x64 /maxcpucount
  - ctest -C Release -j2 --output-on-failure
  - cd ..
  # x86
  - mkdir debug_86
  - cd debug_86
  - cmake .. -G "%gen%" -A Win32
  - msbuild doctest.sln /p:Configuration=Debug;Platform=Win32 /maxcpucount
  - ctest -C Debug -j2 --output-on-failure
  - cd ..
  - mkdir release_86
  - cd release_86
  - cmake .. -G "%gen%" -A Win32
  - msbuild doctest.sln /p:Configuration=Release;Platform=Win32 /maxcpucount
  - ctest -C Release -j2 --output-on-failure
  - cd ..
  # static code analysis
  - IF "%gen%" == "Visual Studio 15 2017" mkdir analysis
  - IF "%gen%" == "Visual Studio 15 2017" cd analysis
  - IF "%gen%" == "Visual Studio 15 2017" cmake .. -G "%gen%" -A x64
  - IF "%gen%" == "Visual Studio 15 2017" msbuild doctest.sln /p:Configuration=Debug;Platform=x64 /maxcpucount /p:RunCodeAnalysis=true /p:CodeAnalysisTreatWarningsAsErrors=true
  - IF "%gen%" == "Visual Studio 15 2017" cd ..
