Skip to content
Skills Library
Programming · Building & coding

xmake-trybuild

/xmake-trybuild

Use when you want to build a third-party project that uses CMake, Autotools, Meson, Ninja, Bazel, Make, MSBuild, Xcodebuild, or NdkBuild — through xmake, so you inherit xmake's cross-compilation and toolchain detection. Covers `xmake` auto-detection, `--trybuild=<system>`, `--tryconfigs="..."`, and cross-compile recipes for Android / iOS / MinGW / custom SDKs.

Licence
Apache-2.0
Last repository change
24.08.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
1
Deprecation

No signals detected. Repository changed on 24.08.2026, without references to retired models or APIs.

Licence

Apache-2.0, otwarta: można używać i zmieniać, z zachowaniem licencji i informacji o zmianach.

What it does and when to use it

Use when you want to build a third-party project that uses CMake, Autotools, Meson, Ninja, Bazel, Make, MSBuild, Xcodebuild, or NdkBuild — through xmake, so you inherit xmake's cross-compilation and toolchain detection. Covers `xmake` auto-detection, `--trybuild=<system>`, `--tryconfigs="..."`, and cross-compile recipes for Android / iOS / MinGW / custom SDKs.

Triggers from the description

...
Original author description

Use when you want to build a third-party project that uses CMake, Autotools, Meson, Ninja, Bazel, Make, MSBuild, Xcodebuild, or NdkBuild — through xmake, so you inherit xmake's cross-compilation and toolchain detection. Covers `xmake` auto-detection, `--trybuild=<system>`, `--tryconfigs="..."`, and cross-compile recipes for Android / iOS / MinGW / custom SDKs.

How it works

  1. Supported backends
  2. 1. Auto-detect mode
  3. 2. Force a specific backend
  4. 3. Standard xmake commands work
  5. 4. Cross-compilation via trybuild
  6. 5. Passing arguments to the backend
  7. 6. Android JNI (ndkbuild)
  8. 7. Typical recipes
  9. 8. When to prefer trybuild vs a package recipe
  10. Pitfalls
Original SKILL.md headings · 209 lines, 836 words
SKILL.md preview
---
name: xmake-trybuild
description: Use when you want to build a third-party project that uses CMake, Autotools, Meson, Ninja, Bazel, Make, MSBuild, Xcodebuild, or NdkBuild — through xmake, so you inherit xmake's cross-compilation and toolchain detection. Covers `xmake` auto-detection, `--trybuild=<system>`, `--tryconfigs="..."`, and cross-compile recipes for Android / iOS / MinGW / custom SDKs.
---

# Xmake TryBuild — Drive Third-Party Build Systems

`trybuild` lets xmake invoke **another build system** (CMake, Autotools, Meson, …) while still providing its own platform/toolchain detection, cross-compile support, and incremental-build wrappers. Use it when you need to build an upstream project that doesn't use `xmake.lua`, but still want xmake's cross-compilation ergonomics.

## Supported backends

| `--trybuild=` | Backend |
| --- | --- |
| `autotools` | `./configure` + `make` (cross-compile supported) |
| `cmake` | `cmake` + generator (cross-compile supported) |
| `meson` | `meson` + `ninja` |
| `ninja` | direct `ninja` |
| `make` | `make` / `Makefile` |
| `msbuild` | Visual Studio MSBuild |
| `xcodebuild` | Xcode CLI builds |
| `scons` | SCons |
| `bazel` | Bazel |
| `ndkbuild` | Android NDK ndk-build |

## 1. Auto-detect mode

Run plain `xmake` inside a project root that has a recognized file (`CMakeLists.txt`, `configure`, `Makefile`, `meson.build`, …). Xmake prompts before building:

```bash
$ cd libpng-1.6.35
$ xmake
note: CMakeLists.txt found, try building it (pass -y or --confirm=y/n/d to skip confirm)?
please input: y (y/n)
-- Configuring done
-- Generating done
...
output to /Users/ruki/Downloads/libpng-1.6.35/build/artifacts
build ok!
```

Add `-y` to skip the prompt in CI:

```bash
xmake -y
```

Artifacts land under `build/artifacts/`.

## 2. Force a specific backend

When a project ships multiple build systems (e.g. both `configure` and `CMakeLists.txt`):

```bash
xmake f --trybuild=cmake
xmake
```

Once set, subsequent `xmake` / `xmake clean` calls use the configured backend — no re-prompting.

## 3. Standard xmake commands work

Once trybuild is configured, normal xmake commands drive the upstream build:

```bash
xmake                    # build
xmake --rebuild          # force full rebuild
xmake clean              # clean objects
xmake clean --all        # wipe everything (configure cache, artifacts)
xmake f -m debug         # switch to debug build
xmake f -m release
```

Behavior is mapped onto each backend — e.g. for autotools, `xmake clean --all` runs `make distclean`.

## 4. Cross-compilation via trybuild

The killer feature: xmake's cross-compilation config works for CMake/Autotools projects too.

### Android

```bash
xmake f -p android --trybuild=cmake [--ndk=/path/to/ndk]
xmake
```

Equivalent of setting up `CMAKE_TOOLCHAIN_FILE=$NDK/build/cmake/android.toolchain.cmake` + `ANDROID_ABI` + `ANDROID_NATIVE_API_LEVEL` by hand.

```bash
xmake f -p android --trybuild=autotools [--ndk=/path/to/ndk]
xmake
```

Equivalent of exporting `CC`, `CXX`, `AR`, `LD`, `RANLIB`, `STRIP` and passing `--host=aarch64-linux-android` to `./configure`.

### iOS / macOS

```bash
xmake f -p iphoneos --trybuild=cmake
xmake

xmake f -p iphoneos --trybuild=autotools
xmake
```

### MinGW (Windows from any host)

```bash
xmake f -p mingw --trybuild=cmake [--mingw=/opt/llvm-mingw]
xmake
```

### Generic cross-SDK

```bash
xmake f -p cross --trybuild=cmake --sdk=/opt/arm-linux-gnueabihf
xmake
```

All the cross flags from `xmake-cross-compilation` work identically with `--trybuild=...` appended.

## 5. Passing arguments to the backend

### `--tryconfigs`

Extra flags forwarded to the backend's config step:

```bash
# autotools: passed to ./configure
xmake f --trybuild=autotools --tryconfigs="--enable-shared=no --disable-tests"

# cmake: passed to cmake
xmake f --trybuild=cmake --tryconfigs="-DBUILD_SHARED_LIBS=ON -DBUILD_TESTING=OFF"

# meson: passed to meson setup
xmake f --trybuild=meson --tryconfigs="-Doption=value"
```

### Compile/link flag passthrough

Built-in xmake flags automatically propagate — no `--tryconfigs` needed for these:

```bash
xmake f --trybuild=cmake --cflags="-DNDEBUG" --ldflags="-lm" --includedirs=/opt/xyz/include
xmake
```

## 6. Android JNI (`ndkbuild`)

If `jni/Android.mk` exists:

```bash
xmake f -p android --trybuild=ndkbuild [--ndk=...]
xmake
```

For gradle integration see the [xmake-gradle plugin](https://github.com/xmake-io/xmake-gradle).

## 7. Typical recipes

### Build a CMake project for the host

```bash
cd upstream-project
xmake f --trybuild=cmake --tryconfigs="-DBUILD_SHARED_LIBS=ON"
xmake
ls build/artifacts
```

### Cross-compile libpng for Android

```bash
cd libpng-1.6.40
xmake f -p android -a arm64-v8a --trybuild=cmake --ndk=~/android-ndk-r26 \
        --tryconfigs="-DPNG_SHARED=ON -DPNG_STATIC=OFF"
xmake
```

### Autotools project for MinGW from Linux

```bash
cd autotools-thing
xmake f -p mingw --mingw=/usr/x86_64-w64-mingw32 --trybuild=autotools \
        --tryconfigs="--disable-tests"
xmake
```

### Meson + Ninja for the host

```bash
xmake f --trybuild=meson
xmake -j $(nproc)
```

## 8. When to prefer trybuild vs a package recipe

- **One-off local build of upstream code** → trybuild.
- **Reusable dependency consumed by `add_requires`** → write a package recipe that uses `import("package.tools.cmake")` (or `autoconf`, `meson`) — see `xmake-private-packages` and `xmake-repo-testing`. The recipe gets proper version pinning, hash checks, and caching, which trybuild does not.

## Pitfalls

- **Missing backend tool.** Trybuild shells out to `cmake`/`autotools`/`meson`/… — make sure the binary is installed. On failure, `xmake -vD` shows the missing tool.
- **Auto-detect picks the wrong backend.** Projects that ship both `Makefile` and `CMakeLists.txt` may auto-select the "wrong" one; use `xmake f --trybuild=cmake` to pin.
- **Clean doesn't clean configure cache.** `xmake clean` removes objects only. Use `xmake clean --all` to also wipe the backend's configure state.
- **Cross-compile of Bazel / SCons.** Not supported to the same depth as CMake/Autotools — check `--trybuild=`'s doc for the given backend.
- **`--tryconfigs` doesn't support `=` inside quoted values easily.** Cross-shell quoting can be tricky; prefer multiple small flags.
- **Artifacts path is backend-specific.** Usually `build/artifacts/`, but some backends emit to their own layout. Look for the "output to ..." line in `xmake` output.

## When to branch out

- Cross toolchain flags (`--sdk`/`--ndk`/`--mingw`/`--cross`) → `xmake-cross-compilation`
- Packaging *upstream* code as a reusable dependency → `xmake-private-packages` / `xmake-repo-testing`
- Full xmake CLI reference → `xmake-commands`

Versions

The database has no other skills named xmake-trybuild.

Database snapshot: 13.11.2026 · package version df094afc6ed9 (SHA-256 digest of the entire package)

Downloads in the last 30 days: 2 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100meson
    Meson build system skill for C/C++ projects. Use when setting up a Meson project, configuring build options, managing dependencies with the wrap system, cross-compiling, or integrating Meson with CI. Activates on queries about meson setup, meson compile, meson wrap, meson test,…
  • 100meson
    Use when setting up a Meson project, meson setup/compile/test, wrap dependencies, cross-file cross-compiling, meson.build, or migrating from CMake/Autotools to Meson.
  • 100xmake-cross-compilation
    Use when the user is cross-compiling a C/C++ project with xmake — targeting Android/iOS/embedded/MinGW/WASM, pointing at an SDK/NDK root, overriding cc/cxx/ld/ar, selecting a built-in cross toolchain, or defining a custom toolchain in xmake.lua. Covers the full `xmake f` flag…
  • 95xmake-toolchains
    Use when switching compilers (gcc/clang/msvc/mingw), setting up cross-compilation for Android/iOS/embedded/wasm, or defining a custom toolchain.
  • 95cmake
    CMake build system for C/C++ projects. Modern CMake (3.20+) with targets, properties, presets (CMakePresets.json), FetchContent, find_package, generator expressions, install rules, vcpkg/Conan integration. USE WHEN: user mentions "CMake", "CMakeLists.txt", "CMakePresets",…
  • 100bazel
    Bazel build system skill for C/C++ projects. Use when writing BUILD files with cc_library and cc_binary rules, registering toolchains, configuring remote execution, debugging sandbox issues, using query and cquery for dependency graphs, or migrating from CMake to Bazel.…

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.