image:
  - Visual Studio 2017
environment:
  matrix:
  # - CMAKE_GENERATOR: "Visual Studio 15 2017"
  #   CONFIG: Release
  #   PYTHON_VERSION: 2.7
  #   BUILD_SHARED_LIBS: ON
  #   ENABLE_PYTHON: ON
  #   MINICONDA: C:\Miniconda
  #   ENABLE_MPI: ON
  #   MPI_HOME: "C:/Program Files (x86)/Microsoft SDKs/MPI"
  - CMAKE_GENERATOR: "Visual Studio 15 2017"
    CONFIG: Release
    BUILD_SHARED_LIBS: ON
    ENABLE_PYTHON: ON
    ENABLE_MPI: ON
    MPI_HOME: "C:/Program Files (x86)/Microsoft SDKs/MPI"
  - CMAKE_GENERATOR: "Visual Studio 15 2017"
    CONFIG: Release
    BUILD_SHARED_LIBS: OFF
    ENABLE_PYTHON: OFF
    ENABLE_MPI: ON
    MPI_HOME: "C:/Program Files (x86)/Microsoft SDKs/MPI"

init:
  # line endings magic
  - git config --global core.autocrlf input
  - "ECHO %PYTHON_VERSION% %MINICONDA%"

install:
  # setup hdf5
  #- set PATH=%PATH%;%HDF5_BINDIR%
  #- ps: Invoke-WebRequest "https://support.hdfgroup.org/ftp/HDF5/current18/bin/windows/extra/hdf5-1.8.18-win64-vs2015-shared.zip" -OutFile hdf5.zip
  #- 7z x hdf5.zip -y
  # setup python via mini conda
  #- ps: Start-Process -FilePath msiexec -ArgumentList /i, "hdf5\HDF5-1.8.18-win64.msi", /quiet -Wait
  #
  # check path
  - "echo %PATH%"
  - "echo %PYTHONPATH%"
  - pip install numpy
  # try to import numpy to as conda gut-check
  - python -c "import numpy as n; print(n.__version__); print(n.get_include());"
  # try to import numpy to as conda gut-check
  # Install MS-MPI
  - ps: Start-FileDownload 'https://download.microsoft.com/download/B/2/E/B2EB83FE-98C2-4156-834A-E1711E6884FB/MSMpiSetup.exe'
  - MSMpiSetup.exe -unattend
  - set PATH=C:\Program Files\Microsoft MPI\Bin;%PATH%
  # Install MS-MPI SDK
  - ps: Start-FileDownload 'https://download.microsoft.com/download/B/2/E/B2EB83FE-98C2-4156-834A-E1711E6884FB/msmpisdk.msi'
  - msmpisdk.msi /passive
  - set PATH=C:\Program Files (x86)\Microsoft SDKs\MPI;%PATH% 
  # install mpi4py
  - pip install mpi4py
  
  # Install CMake 3.9
  ############################################################################
  - ps: Start-FileDownload 'http://ascent-dav.org/mirror/cmake-3.9.6-win64-x64.msi'
  - cmake-3.9.6-win64-x64.msi /passive
  - set PATH=C:\Program Files\CMake\bin;%PATH%
  - cmake --version

before_build:
  # remove some noisy warnings from Xamarin
  - del "C:\Program Files (x86)\MSBuild\14.0\Microsoft.Common.targets\ImportAfter\Xamarin.Common.targets"
  # init submodules
  - git submodule update --init --recursive
  # configure
  - echo Running cmake ...
  # TODO enable hdf5 support
  #- cmake -Hsrc -Bbuild -G "%CMAKE_GENERATOR%" -DHDF5_DIR="C:\\Program Files\\HDF_Group\\HDF5\\1.8.18" -DENABLE_PYTHON=TRUE
  #
  # enable mpi support and use default python
  - cmake -Hsrc -Bbuild -G "%CMAKE_GENERATOR%" ^
      -DBUILD_SHARED_LIBS=%BUILD_SHARED_LIBS% ^
      -DENABLE_PYTHON=%ENABLE_PYTHON% ^ 
      -DENABLE_MPI=%ENABLE_MPI% ^
      -DMPI_C_INCLUDE_PATH:PATH="%MPI_HOME%/Include" ^
      -DMPI_C_LIBRARIES:PATH="%MPI_HOME%/Lib/x86/msmpi.lib" ^
      -DMPI_CXX_INCLUDE_PATH:PATH="%MPI_HOME%/Include" ^
      -DMPI_CXX_LIBRARIES:PATH="%MPI_HOME%/Lib/x86/msmpi.lib"

build_script:
  #build
  - echo Building ...
  - cmake --build build --config %CONFIG%

after_build:
  # run our tests
  - ps: cd build
  - cmake -E env CTEST_OUTPUT_ON_FAILURE=1 cmake --build . --config %CONFIG% --target RUN_TESTS
