name: Build Eigenpy on Windows via Conda
on: [push,pull_request]

jobs:
  build:
    runs-on: ${{ matrix.os }}
    strategy:
      fail-fast: false
      matrix:
          os: [windows-latest]
    steps:
    - uses: actions/checkout@v2
    - name: Checkout submodules
      run: |
        git submodule update --init
    - uses: goanpeca/setup-miniconda@v1
      with:
        activate-environment: eigenpy
        environment-file: .github/workflows/conda/environment.yml
        python-version: 3.7
    - name: Build Eigenpy
      shell: cmd /C CALL {0}
      run: |
        :: unset extra Boost envs
        set Boost_ROOT=
        set BOOST_ROOT_1_69_0=
        set BOOST_ROOT_1_72_0=
        set PATH=%PATH:C:\hostedtoolcache\windows\Boost\1.72.0;=%

        :: start building
        call "%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64
        mkdir build
        pushd build
        cmake ^
          -G "NMake Makefiles" ^
          -DCMAKE_INSTALL_PREFIX=%CONDA_PREFIX%\Library ^
          -DCMAKE_BUILD_TYPE=Release ^
          -DEIGENPY_SITELIB_ROOT=%CONDA_PREFIX% ^
          -DPYTHON_EXECUTABLE=%CONDA_PREFIX%\python.exe ^
          ..
        cmake --build . --config Release --target install
        ctest --output-on-failure -C Release -V
