name: Build and Test Common C++

pr:
- master
- develop

trigger: none

stages:

- stage: Windows
  dependsOn: []
  pool:
    name: Hosted VS2017
    demands:
    - msbuild
    - vstest

  jobs:
  - job: Build_And_Test_VisualStudio
    strategy:
      matrix:
        debug x86 multi threads:
          BuildConfiguration: Debug
          BuildPlatform: x86
          BuildDirectory: Debug
        release x86 multi threads:
          BuildConfiguration: Release 
          BuildPlatform: x86
          BuildDirectory: Release
        debug x64 multi threads:
          BuildConfiguration: Debug
          BuildPlatform: x64
          BuildDirectory: x64/Debug
        release x64 multi threads:
          BuildConfiguration: Release  
          BuildPlatform: x64  
          BuildDirectory: x64/Release
        debug x86 single thread:
          BuildConfiguration: Debug-Single
          BuildPlatform: x86
          BuildDirectory: Debug
        release x86 single thread:
          BuildConfiguration: Release-Single
          BuildPlatform: x86
          BuildDirectory: Release
        debug x64 single thread:
          BuildConfiguration: Debug-Single
          BuildPlatform: x64
          BuildDirectory: x64/Debug
        release x64 single thread:
          BuildConfiguration: Release-Single
          BuildPlatform: x64  
          BuildDirectory: x64/Release
    steps:
    - template: ci/steps-windows-test-vs.yml
      parameters:
        buildPlatform: '$(BuildPlatform)'
        buildConfiguration: '$(BuildConfiguration)'
        buildDirectory: '$(BuildDirectory)'

  - job: Build_And_Test_CMake  
    strategy:
      matrix:
        debug x86 multi threads:
          BuildConfiguration: Debug
          BuildPlatform: Win32
          BuildArguments: -DNoThreading=OFF
        release x86 multi threads:
          BuildConfiguration: Release 
          BuildPlatform: Win32
          BuildArguments: -DNoThreading=OFF
        debug x64 multi threads:
          BuildConfiguration: Debug
          BuildPlatform: x64
          BuildArguments: -DNoThreading=OFF
        release x64 multi threads:
          BuildConfiguration: Release  
          BuildPlatform: x64
          BuildArguments: -DNoThreading=OFF
        debug x86 single thread:
          BuildConfiguration: Debug
          BuildPlatform: Win32
          BuildArguments: -DNoThreading=ON
        release x86 single thread:
          BuildConfiguration: Release 
          BuildPlatform: Win32
          BuildArguments: -DNoThreading=ON
        debug x64 single thread:
          BuildConfiguration: Debug
          BuildPlatform: x64
          BuildArguments: -DNoThreading=ON
        release x64 single thread:
          BuildConfiguration: Release  
          BuildPlatform: x64
          BuildArguments: -DNoThreading=ON
    steps:
    - template: ci/steps-windows-test-cmake.yml
      parameters:
        buildPlatform: '$(BuildPlatform)'
        buildConfiguration: '$(BuildConfiguration)'
        buildArguments: '$(BuildArguments)'

- stage: MacOS
  dependsOn: []
  jobs:
  - job: Build_And_Test_Mac
    pool:
      name: Azure Pipelines
      vmImage: 'macOS-10.14'
    strategy:
      matrix:
        debug x64 multi threads:
          BuildConfiguration: Debug
          BuildArguments: -DNoThreading=OFF
        release x64 multi threads:
          BuildConfiguration: Release 
          BuildArguments: -DNoThreading=OFF
        debug x64 single thread:
          BuildConfiguration: Debug
          BuildArguments: -DNoThreading=ON
        release x64 single thread:
          BuildConfiguration: Release  
          BuildArguments: -DNoThreading=ON
    steps:
    - template: ci/steps-cmake-test.yml
      parameters:
        platformName: 'Mac'
        buildConfiguration: '$(BuildConfiguration)'
        buildArguments: '$(BuildArguments)'
        
- stage: Linux
  dependsOn: []
  jobs:
  - job: Build_And_Test_Ubuntu
    pool:
      name: Hosted Ubuntu 1604
    strategy:
      matrix:
        debug x86 multi threads:
          BuildConfiguration: Debug
          BuildArguments: -D32bit=ON -DNoThreading=OFF
        release x86 multi threads:
          BuildConfiguration: Release 
          BuildArguments: -D32bit=ON -DNoThreading=OFF
        debug x64 multi threads:
          BuildConfiguration: Debug
          BuildArguments: -DNoThreading=OFF
        release x64 multi threads:
          BuildConfiguration: Release 
          BuildArguments: -DNoThreading=OFF
        debug x86 single thread:
          BuildConfiguration: Debug
          BuildArguments: -D32bit=ON -DNoThreading=ON
        release x86 single thread:
          BuildConfiguration: Release  
          BuildArguments: -D32bit=ON -DNoThreading=ON
        debug x64 single thread:
          BuildConfiguration: Debug
          BuildArguments: -DNoThreading=ON
        release x64 single thread:
          BuildConfiguration: Release  
          BuildArguments: -DNoThreading=ON
    steps:
    - script: |
        sudo apt-get -y install \
          gcc-multilib \
          g++-multilib        
      displayName: 'Install Required Packages'
    
    - template: ci/steps-cmake-test.yml
      parameters:
        platformName: 'Ubuntu'  
        buildConfiguration: '$(BuildConfiguration)'
        buildArguments: '$(BuildArguments)'
