How to choose the versions of visual studio to compile native binaries with?

My system has several different versions of Visual Studio installed (all of 2005, 2008, 2010, 2012, 2013). Right now it seems that gradle is picking 2013 as the version it’s compiling with, which is not what I want it to do at moment. I would like it to use both 2010 and 2012 to build the native binary. That is, make one version of the binary with 2010 and another version of the binary with 2012.

Is there a way to accomplish this?

Thanks,

maybe you can reconfigure the toolchain settings:

model { toolchains{

visualCpp(VisualCpp) {

// Specify the installDir if Visual Studio cannot be located by default

installDir “C:/Apps/Microsoft Visual Studio 10.0” } } }

if you want a different VS version you would have to modify the installDir - not sure if you can modify this property during the execution.

you could use different build types that modify the installDir if necessary:

model {

buildTypes {

VS2010

VS2012

VS2013 } }

To use a specific version of VS you would then query the build type in each component:

if ( buildType == buildTypes.VS2010) {

model.toolchains.visualCpp.installDir = ‘…’

}

Hi Tyler,

I’m already actually using buildTypes for debug/release type builds, so would ‘flavors’ work instead? This appears to be rather clunky to get working because I would like to use flavors for a different purpose (other than toolchain versioning) later.

It feels like there should be the ability in the toolchains DSL to specify the list toolchains and optionally their versions to build with… maybe this is simply upcoming.

Do you use this snippet in your own build. I’m surprised you can modify ‘model.toolchains.visualCpp.installDir’ depending on the buildType. I would assume that with the current implementation the last installDir assignment wins. In the following snippet I guess it’s always pointing to VS2012 as you modify a global variable here

executables {
 main {
  binaries.all {
      if ( buildType == buildTypes.VS2010) {
       model.toolchains.visualCpp.installDir = '......'
          }
   if ( buildType == buildTypes.VS2012) {
              //this will always be used
      model.toolchains.visualCpp.installDir = '......'
    }
     }
 }
}

For gcc compatible toolchains (gcc + clang) you could define a targetplatform per visualstudio implementation but with visualstudio I think this is currently not possible.