Native library - disable build on specific OS

Is there a way to disable a library from being on a specific OS.
E.g. I have a library that I only want to build on windows.

I tried to set buildable flag to false on non windows platform, but then gradle complains that there are no buildable binaries when building on linux.

Thanks

I found a hacky solution to this.

The idea came from: https://stackoverflow.com/questions/11235614/how-to-detect-the-current-os-from-gradle

In the root build.gradle I added a function:

def isWindowsBuild() {
// TODO The implementation of this function uses an internal Gradle feature
//      this may become deprecated.
//      This was the only clean solution that seems to consistently work
//      for now.
return OperatingSystem.current().isWindows()
} // end of isWindowsBuild

This function is then called in each project that is only built on windows.

if (isWindowsBuild()) {
    // Put your project build code here
    apply plugin: ...
    dependencies {
    ...
    }
    model {
    ...
    }
}

The same function is added to the settings.gradle file, which now looks like

// needed for isWindowsBuild implementation
import org.gradle.internal.os.OperatingSystem

/**
* Check if the build is executed on Windows
*/
def isWindowsBuild() {
    // TODO The implementation of this function uses an internal Gradle feature
    //      this may become deprecated.
    //      This was the only clean solution that seems to consistenly work
    //      for now.
    return OperatingSystem.current().isWindows()
} // end of isWindowsBuild

def projects = [
    <cross_platform_project_0>,
    <cross_platform_project_1>,
]

if (isWindowsBuild()) {
    projects.add(<windows_only_project_0>)
}

include projects as String[]

Having to use an internal function for this purpose is bad !!!
However no other function gave consistent results in both build.gradle and settings.gradle.

I think it should be possible to mark a project to be built only on specific platforms - the whole project, not just parts of the code or a build configuration.