# Notes:
#   - Minimal appveyor.yml file is an empty file. All sections are optional.
#   - Indent each level of configuration with 2 spaces. Do not use tabs!
#   - All section names are case-sensitive.
#   - Section names should be unique on each level.

#---------------------------------#
#      general configuration      #
#---------------------------------#

# version format
version: 4.1.{build}

# branches to build
branches:
  # whitelist
  only:
    - develop

  # blacklist
  # except:
  #   - gh-pages

# Do not build on tags (GitHub only)
skip_tags: true

#---------------------------------#
#    environment configuration    #
#---------------------------------#

environment:
  global:
    1_8: &1_8 1.8.21
    1_10: &1_10 1.10.5
    HDF5_1_8_VER: *1_8   
    HDF5_1_10_VER: *1_10
  matrix:
  - build_opt: -D CGNS_BUILD_SHARED:BOOL=OFF -D CGNS_USE_SHARED:BOOL=OFF -D CGNS_ENABLE_64BIT:BOOL=OFF
    HDF5_VER: *1_8
    HDF_DIR: "/Program Files/HDF_Group/HDF5/%HDF5_VER%/cmake"
  - build_opt: -D CGNS_BUILD_SHARED:BOOL=OFF -D CGNS_USE_SHARED:BOOL=OFF -D CGNS_ENABLE_64BIT:BOOL=ON
    HDF5_VER: *1_10
    HDF_DIR: "/Program Files/HDF_Group/HDF5/%HDF5_VER%/cmake"

# Operating system (build VM template)
os: Visual Studio 2015

# scripts that are called at very beginning, before repo cloning
init:
  - git config --global core.autocrlf input

# clone directory
clone_folder: c:\projects\CGNS

# scripts that run after cloning repository
install:
  # by default, all script lines are interpreted as batch
  #- echo This is batch
  # to run script as a PowerShell command prepend it with ps:
  #- ps: Write-Host 'This is PowerShell'
  # batch commands start from cmd:
  #- cmd: echo This is batch again
  #- cmd: set MY_VAR=12345

# install hdf5
  - set PATH=C:\Program Files\Git\mingw64\bin;%PATH%
  - mkdir 1.8
  - cd 1.8
  - set HDF5_1_8_VER=%HDF5_1_8_VER%
  - curl -O https://gamma.hdfgroup.org/ftp/pub/outgoing/QATEST/hdf518/relbinaries/windows/hdf5-%HDF5_1_8_VER%-Std-win10_64-vs14.zip
  - ps: Expand-Archive hdf5-$($env:HDF5_1_8_VER)-Std-win10_64-vs14.zip -DestinationPath .
  - cd hdf
  - msiexec /i HDF5-%HDF5_1_8_VER%-win64.msi /quiet /qn /norestart /log install.log
  - type install.log
  - cd ..\..
  - mkdir 1.10
  - cd 1.10
  - set HDF5_1_10=%HDF5_1_10_VER%
  - curl -O https://gamma.hdfgroup.org/ftp/pub/outgoing/QATEST/hdf5110/relbinaries/windows/hdf5-%HDF5_1_10_VER%-Std-win10_64-vs14.zip
  - ps: Expand-Archive hdf5-$($env:HDF5_1_10_VER)-Std-win10_64-vs14.zip -DestinationPath .
  - cd hdf
  - msiexec /i HDF5-%HDF5_1_10_VER%-win64.msi /quiet /qn /norestart /log install.log
  - type install.log
  - cd ..\..

#---------------------------------#
#       build configuration       #
#---------------------------------#

# build platform, i.e. x86, x64, Any CPU. This setting is optional.
platform: Any CPU

# to add several platforms to build matrix:
#platform:
#  - x86
#  - Any CPU

# build Configuration, i.e. Debug, Release, etc.
configuration:
  - Release

# scripts to run before build
before_build:
  - echo Running cmake...
  - mkdir c:\projects\CGNS_BUILD
  - cd c:\projects\CGNS_BUILD
  - cmake --version
  - SET HDF5_DIR=/Program Files/HDF_Group/HDF5/%HDF5_VER%/cmake
  - cmake -G "Visual Studio 14 Win64" ^
     %build_opt% ^
     -D CMAKE_C_FLAGS:STRING="" ^
     -D CMAKE_BUILD_TYPE:STRING=Release ^
     -D HDF5_NEED_ZLIB:BOOL=ON ^
     -D CMAKE_STATIC_LINKER_FLAGS:STRING="" ^
     -D CGNS_ENABLE_HDF5:BOOL=ON ^
     -D CGNS_ENABLE_TESTS:BOOL=ON ^
     -D CGNS_ENABLE_LFS:BOOL=OFF ^
     -D CGNS_BUILD_CGNSTOOLS:BOOL=OFF ^
     -D CGNS_ENABLE_SCOPING:BOOL=OFF ^
     -D CGNS_ENABLE_FORTRAN:BOOL=OFF ^
     -D CGNS_ENABLE_PARALLEL:BOOL=OFF ^
     -D CMAKE_INSTALL_PREFIX:PATH="." c:\projects\CGNS

build_script:
  - cmd: cmake --build . --config "%configuration%"

test_script:
  - cmd: ctest .
