# ExternalNativeBuildFlags

[View Source](https://cs.android.com/search?q=file:com/android/build/api/dsl/ExternalNativeBuildFlags.kt+class:com.android.build.api.dsl.ExternalNativeBuildFlags) Added in 8.0.2


```
@Incubating
interface ExternalNativeBuildFlags
```

<br />

*** ** * ** ***

DSL object for per-variant CMake and ndk-build configurations, such as toolchain arguments and compiler flags.

```
android {
    // Similar to other properties in the defaultConfig block, you can override
    // these properties for each product flavor you configure.
    defaultConfig {
        // This block is different from the one you use to link Gradle
        // to your CMake or ndk-build script.
        externalNativeBuild {
            // For ndk-build, instead use the ndkBuild block.
            cmake {
                // Passes optional arguments to CMake.
                arguments "-DANDROID_ARM_NEON=TRUE", "-DANDROID_TOOLCHAIN=clang"

                // Sets a flag to enable format macro constants for the C compiler.
                cFlags "-D__STDC_FORMAT_MACROS"

                // Sets optional flags for the C++ compiler.
                cppFlags "-fexceptions", "-frtti"

                // Specifies the library and executable targets from your CMake project
                // that Gradle should build.
                targets "libexample-one", "my-executible-demo"
            }
        }
    }
}
```

To enable external native builds and set the path to your CMake or ndk-build script, use `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/ExternalNativeBuild`.

## Summary

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/ExternalNativeBuildFlags#cmake(kotlin.Function1)(action: https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/CmakeFlags.() -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)` Encapsulates per-variant CMake configurations, such as compiler flags and toolchain arguments. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/ExternalNativeBuildFlags#ndkBuild(kotlin.Function1)(action: https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/NdkBuildFlags.() -> https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-unit/index.html)` Encapsulates per-variant ndk-build configurations, such as compiler flags and toolchain arguments. |

| ### Public properties |
|---|---|
| `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/CmakeFlags` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/ExternalNativeBuildFlags#cmake()` Encapsulates per-variant CMake configurations, such as compiler flags and toolchain arguments. |
| `https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.collections/-mutable-map/index.html<https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html, https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html>` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/ExternalNativeBuildFlags#experimentalProperties()` Additional per-variant experimental properties for C and C++. |
| `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/NdkBuildFlags` | `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/ExternalNativeBuildFlags#ndkBuild()` Encapsulates per-variant ndk-build configurations, such as compiler flags and toolchain arguments. |

## Public functions

### cmake

Added in 8.0.2

```
fun cmake(action: CmakeFlags.() -> Unit): Unit
```

Encapsulates per-variant CMake configurations, such as compiler flags and toolchain arguments.

To enable external native builds and set the path to your `CMakeLists.txt` script, use `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/Cmake#path(kotlin.Any)`.

### ndkBuild

Added in 8.0.2

```
fun ndkBuild(action: NdkBuildFlags.() -> Unit): Unit
```

Encapsulates per-variant ndk-build configurations, such as compiler flags and toolchain arguments.

To enable external native builds and set the path to your `Android.mk` script, use `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/NdkBuild#path(kotlin.Any)`.

## Public properties

### cmake

Added in 8.0.2

```
val cmake: CmakeFlags
```

Encapsulates per-variant CMake configurations, such as compiler flags and toolchain arguments.

To enable external native builds and set the path to your `CMakeLists.txt` script, use `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/Cmake#path(kotlin.Any)`.

### experimentalProperties

Added in 8.0.2

```
val experimentalProperties: MutableMap<String, Any>
```

Additional per-variant experimental properties for C and C++.

### ndkBuild

Added in 8.0.2

```
val ndkBuild: NdkBuildFlags
```

Encapsulates per-variant ndk-build configurations, such as compiler flags and toolchain arguments.

To enable external native builds and set the path to your `Android.mk` script, use `https://developer.android.com/reference/tools/gradle-api/9.6/com/android/build/api/dsl/NdkBuild#path(kotlin.Any)`.