# Windows testing.
# Syntax for this file:
# http://www.appveyor.com/docs/appveyor-yml

shallow_clone: true

platform: x64

cache:
  - x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z
  - i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z

environment:
  CTEST_OUTPUT_ON_FAILURE: 1
  matrix:
  - MINGW_DIR: mingw64
    MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.2/threads-win32/seh/x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z/download
    MINGW_ARCHIVE: x86_64-4.9.2-release-win32-seh-rt_v4-rev4.7z
  - MINGW_DIR: mingw32
    MINGW_URL: https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/4.9.2/threads-win32/dwarf/i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z/download
    MINGW_ARCHIVE: i686-4.9.2-release-win32-dwarf-rt_v4-rev4.7z

install:
  - if not exist "%MINGW_ARCHIVE%" appveyor DownloadFile "%MINGW_URL%" -FileName "%MINGW_ARCHIVE%"
  - 7z x -y "%MINGW_ARCHIVE%" > nul
  # CMake refuses to generate MinGW Makefiles if sh.exe is in the Path
  - ps: Get-Command sh.exe -All | Remove-Item

build_script:
  - echo "NUMBER_OF_PROCESSORS=%NUMBER_OF_PROCESSORS%"
  - set PATH=%CD%\%MINGW_DIR%\bin;%PATH%
  - g++ --version
  - mingw32-make --version
  - cmake --version
  - if "%APPVEYOR_REPO_TAG%"=="true" (set CMAKE_BUILD_TYPE=Release) else (set CMAKE_BUILD_TYPE=Debug)
  - set SRC_DIR=%CD%
  - echo %SRC_DIR%
  - set BLD_DIR=%SRC_DIR%\..\lapack-appveyor-bld
  - set INST_DIR=%SRC_DIR%\..\lapack-appveyor-install
  - mkdir -p %BLD_DIR%
  - cd %BLD_DIR%
    # See issue #17 on github dashboard.  Once resolved, use -DCBLAS=ON
    #  - cmake -DCMAKE_INSTALL_PREFIX=${INST_DIR} -DLAPACKE=ON ${SRC_DIR}
  - cmake
    -G "MinGW Makefiles"
    -DBUILDNAME:STRING="appveyor-%MINGW_DIR%-%APPVEYOR_REPO_BRANCH%"
    -DCMAKE_BUILD_TYPE=%CMAKE_BUILD_TYPE%
    -DCMAKE_INSTALL_PREFIX=%INST_DIR%
    -DCBLAS:BOOL=ON
    -DLAPACKE:BOOL=ON
    -DBUILD_TESTING=ON
    -DLAPACKE_WITH_TMG:BOOL=ON
    %SRC_DIR%
  - mingw32-make -j%NUMBER_OF_PROCESSORS%

test_script:
  - ctest -D ExperimentalStart
  - ctest -D ExperimentalConfigure
  - ctest -D ExperimentalBuild -j%NUMBER_OF_PROCESSORS%
  - ctest -D ExperimentalTest --schedule-random -j%NUMBER_OF_PROCESSORS% --output-on-failure --timeout 100 -E "CBLAS\-.*cblat1"
  - ctest -D ExperimentalSubmit

after_test:
  - mingw32-make install -j%NUMBER_OF_PROCESSORS%
