steps:
- bash: |
    sudo apt-get install g++ wget make libgl1-mesa-dev mesa-common-dev
    source ${CONDA}/etc/profile.d/conda.sh
    sudo chown -R ${USER} ${CONDA}
    conda config --set always_yes yes --set changeps1 no
    conda update -q conda
    conda info -a
    conda create --name rdkit_build $(python) cmake \
        boost-cpp=$(boost_version) \
        py-boost=$(boost_version) \
        numpy pillow eigen pandas=2.0 matplotlib-base=3.7 \
        qt=5.9.7 cairo
    conda activate rdkit_build
    conda install -c conda-forge pytest nbval ipykernel>=6.0
  displayName: Setup build environment
- bash: |
    source ${CONDA}/etc/profile.d/conda.sh
    conda activate rdkit_build
    export CXXFLAGS="${CXXFLAGS} -Wall -Werror"
    mkdir build && cd build && \
    cmake .. \
    -DCMAKE_BUILD_TYPE=Release \
    -DRDK_INSTALL_INTREE=ON \
    -DRDK_INSTALL_STATIC_LIBS=OFF \
    -DRDK_BUILD_CPP_TESTS=ON \
    -DRDK_BUILD_PYTHON_WRAPPERS=ON \
    -DRDK_BUILD_COORDGEN_SUPPORT=ON \
    -DRDK_BUILD_MAEPARSER_SUPPORT=ON \
    -DRDK_OPTIMIZE_POPCNT=ON \
    -DRDK_BUILD_TEST_GZIP=ON \
    -DRDK_BUILD_FREESASA_SUPPORT=ON \
    -DRDK_BUILD_AVALON_SUPPORT=ON \
    -DRDK_BUILD_INCHI_SUPPORT=ON \
    -DRDK_BUILD_YAEHMOP_SUPPORT=ON \
    -DRDK_BUILD_XYZ2MOL_SUPPORT=ON \
    -DRDK_BUILD_CAIRO_SUPPORT=ON \
    -DRDK_BUILD_QT_SUPPORT=ON \
    -DQt5_DIR=/usr/lib/x86_64-linux-gnu/cmake/Qt5 \
    -DRDK_BUILD_SWIG_WRAPPERS=OFF \
    -DRDK_SWIG_STATIC=OFF \
    -DRDK_BUILD_THREADSAFE_SSS=ON \
    -DRDK_TEST_MULTITHREADED=ON \
    -DRDK_BUILD_CFFI_LIB=ON \
    -DBoost_NO_SYSTEM_PATHS=ON \
    -DBoost_NO_BOOST_CMAKE=TRUE \
    -DRDK_BOOST_PYTHON3_NAME=$(python_name) \
    -DPYTHON_EXECUTABLE=${CONDA_PREFIX}/bin/python3 \
    -DCMAKE_INCLUDE_PATH="${CONDA_PREFIX}/include" \
    -DCMAKE_LIBRARY_PATH="${CONDA_PREFIX}/lib"
  displayName: Configure build (Run CMake)
- bash: |
    source ${CONDA}/etc/profile.d/conda.sh
    conda activate rdkit_build
    cd build
    make -j $( $(number_of_cores) ) install
  displayName: Build
- bash: |
    source ${CONDA}/etc/profile.d/conda.sh
    conda activate rdkit_build
    export RDBASE=`pwd`
    export PYTHONPATH=${RDBASE}:${PYTHONPATH}
    export LD_LIBRARY_PATH=${RDBASE}/lib:${CONDA_PREFIX}/lib:${LD_LIBRARY_PATH}
    echo "LD_LIBRARY_PATH: " $LD_LIBRARY_PATH
    export QT_QPA_PLATFORM='offscreen'
    cd build
    ctest -j $( $(number_of_cores) ) --output-on-failure -T Test
  displayName: Run tests
- bash: |
    source ${CONDA}/etc/profile.d/conda.sh
    conda activate rdkit_build
    conda install -c conda-forge ipython=8.12 sphinx myst-parser
    export RDBASE=`pwd`
    export PYTHONPATH=${RDBASE}:${PYTHONPATH}
    export LD_LIBRARY_PATH=${RDBASE}/lib:${LD_LIBRARY_PATH}
    export QT_QPA_PLATFORM='offscreen'
    cd Docs/Book
    make doctest
  displayName: Run documentation tests
- task: PublishTestResults@2
  inputs:
    testResultsFormat: 'CTest'
    testResultsFiles: 'build/Testing/*/Test.xml'
    testRunTitle: $(system.phasedisplayname) CTest Test Run
