Building C++ with different Visual Studio versions

Hello,
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?

Vision:
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
e.g.:

  • 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?

Thanks,
Jonathan