name: conda-windows-eigen
on:
  push:
    branches:
      - master
      - 'stable/*'

jobs:
  build:
    runs-on: windows-2019

    steps:
    - uses: actions/checkout@v2
    - uses: conda-incubator/setup-miniconda@v2
      with:
        activate-environment: conda_env

    - name: Use conda to install eigen
      shell: cmd /C CALL {0}
      run: |
        echo conda install --yes eigen
             conda install --yes eigen

    - name: Check location of Eigen directory
      shell: cmd /C CALL {0}
      run: |
        mklink /d %CONDA_PREFIX%\Library\include\Eigen^
                  %CONDA_PREFIX%\Library\include\eigen3\Eigen
        echo dir %CONDA_PREFIX%\Library\include\Eigen\Core
             dir %CONDA_PREFIX%\Library\include\Eigen\Core

    - name: Build and test CppAD with Eigen
      shell: cmd /C CALL {0}
      run: |
        echo Use vcvarsall.bat to get proper version of cmake
        call "%programfiles(x86)%\Microsoft Visual Studio\2019\Enterprise\VC\Auxiliary\Build\vcvarsall.bat" amd64
        echo where camke
             where cmake
        echo mkdir build
             mkdir build
        echo cd build
             cd build
        echo set eigen_prefix=%CONDA_PREFIX%\Library
             set eigen_prefix=%CONDA_PREFIX%\Library
        echo Configure using eigen_prefix
        cmake ^
          -D CMAKE_CXX_COMPILER=cl ^
          -D CMAKE_C_COMPILER=cl ^
          -D CMAKE_BUILD_TYPE=release ^
          -G "NMake Makefiles" ^
          -D eigen_prefix=%eigen_prefix% ^
          -D cppad_static_lib=TRUE ^
          ..
        REM Build and run tests.
        echo cmake --build . --target check
             cmake --build . --target check
