Binaries.all inside a source set appears not properly scoped (2.0-rc1 and 1.12)


(Jay Berkenbilt) #1

Create src/main/hello.cpp that behaves differently when EXTRA_CHEERY is defined. Build with the following:

apply plugin: 'cpp'
executables {
  hello
  helloCheery
}
sources {
  helloCheery {
    cpp {
      source {
        srcDir "src/hello/cpp"
      }
    }
    // affects all binaries, not just helloCheery
    binaries.all {
      cppCompiler.define 'EXTRA_CHEERY'
    }
  }
}

observe that both executables, not just helloCheery, were built with -DEXTRA_CHEERY.


(Peter Niederwieser) #2

This is expected, as ‘binaries.all’ refers to ‘project.binaries.all’ here. Perhaps what you want is ‘executables.helloCheery.binaries.all’.


(Jay Berkenbilt) #3

Yes, you’re right. Thanks.