Building C++ with different Visual Studio versions

I am very new to gradle and I want to migrate a project to it. Is it possible to choose a specific Visual Studio verison for compiling the C++ project?

I want to be able to run one gradle task, which then compiles the same project multiple times. Each time a different Visual Studio version is used for compiling. In the end I would have multiple builds

  • file1.exe → compiled with vscode 2015
  • file2.exe → compiled with vscode 2017
  • file3. exe → compiled with vscode 2019

Is there any way to achieve this?