How can I configure c++ source sets depending on the toolchain?


(contact) #1
apply plugin: "cpp"
   sources {
     main {
         cpp {
             source {
                 srcDirs "src/main/cpp"
                 include "xxxxxx"
                   // add some include patterns if we are compiling with Visual C++, or Clang ...?
                 }
               // or maybe add an extra set here instead ?
           }
     }
 }

#2

Take a look at the ‘native-binaries/assembler’ sample for an example of how you can currently do this.

Longer term, this is not how we’d like this to work: the plan is for you to define the requirements of the source set (like OS, architecture, etc) and have Gradle choose the correct source set based on the target platform. The tool chain may be an explicit requirement, or it more likely the requirement will be some attribute of the target platform that influences selection of both tool chain and source set.