/xmake-skills:xmake-cudafrom xmake-skills
Builds CUDA projects with xmake: compiles .cu sources, pins SDK versions, selects GPU architectures, manages device linking, and mixes CUDA with C++ targets.
Ships in xmake-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Xmake detects CUDA automatically and handles device code + host code compilation, dependency scanning, and device linking.
xmake create -P test -l cuda
cd test
xmake
add_rules("mode.debug", "mode.release")
target("test")
set_kind("binary")
add_files("src/*.cu")
target("app") set_kind("binary")
target("staticcuda") set_kind("static")
target("sharedcuda") set_kind("shared")
xmake f --cuda=/usr/local/cuda-12.2 -- specific install
xmake f --cuda=12.2 -- version; looks up default install
xmake f --cuda_sdkver=11.8 -- v3.0.5+, per-project SDK version
xmake f --cuda_sdkver=11.x -- any 11.x
xmake f --cuda_sdkver=auto -- auto-detect (default)
Persist globally:
xmake g --cuda=/usr/local/cuda-12.2
target("app")
add_files("src/*.cu")
add_cugencodes("sm_70", "sm_86", "sm_90") -- compile for these archs
add_cugencodes("native") -- just the host GPU
add_cugencodes takes sm_XX strings or native. Multiple calls accumulate; xmake emits -gencode=arch=compute_XX,code=sm_XX per entry.
Device-linking is automatic for binary and shared targets:
target("app")
set_kind("binary")
add_files("src/*.cu")
-- device link runs automatically
Disable it (rarely needed):
set_policy("build.cuda.devlink", false)
static targets — manual device linkStatic libraries are not device-linked by default. If a downstream binary has no .cu files but depends on a static cuda lib, you'll hit "undefined reference to _device..." errors. Fix by opting in:
target("cudalib")
set_kind("static")
add_files("src/*.cu")
add_values("cuda.build.devlink", true) -- force device link for this static target
target("app")
set_kind("binary")
set_languages("c++17")
add_files("src/*.cpp", "src/*.cu")
add_cugencodes("sm_80")
Host code in .cpp and device code in .cu mix freely in one target. Xmake invokes nvcc for .cu and the normal C++ compiler for .cpp.
target("app")
add_files("src/*.cu")
add_cuflags("--use_fast_math", "-lineinfo") -- nvcc flags
add_cuflags("-Xcompiler=-fPIC", {force = true}) -- flags passed to host compiler via nvcc
add_cuflags = nvcc (cuda compiler) flags. For flags that must reach the host compiler (gcc/clang/msvc), use -Xcompiler=....
xmake f -p linux -a arm64 --cuda=/usr/local/cuda-cross-aarch64
xmake
Point --cuda at a cross CUDA SDK. Jetson deployment targets generally set -a arm64.
sm_xx vs compute capability. sm_86 means "Ampere RTX 30xx". add_cugencodes takes the binary code name, not the compute cap number.add_values("cuda.build.devlink", true) on the static target..cu file gets compiled through nvcc, which calls the host compiler. If you mix toolchains (clang + nvcc that expects gcc), you hit header incompatibilities. Stick with the nvcc-supported host compiler for the CUDA version.sm_ targets. Each add_cugencodes entry doubles compile time. List only the GPUs you actually target.xmake-cross-compilationxmake-targetsbuild.cuda.devlink) → xmake-policyWhat SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub xmake-io/xmake-skills --plugin xmake-skills58 skills in this plugin
/xmake-addon-developmentUse when writing an Xmake addon — the `addon.lua` manifest, the payload layout (plugins/rules/toolchains/modules/includes/templates), `@self` references, shipping package definitions with an addon, `add_globalmodules`, testing it locally, and publishing it to xmake-repo as an `addon` kind package./xmake-addonsUse when installing or using an Xmake addon — `xmake addon --install/--list/--remove/--upgrade/--search`, declaring `add_addons(...)` in a project, and referencing addon payloads with `@addon/<name>/<rule>`, `@addon.<name>.<module>` or `@self`. For writing and publishing one, see xmake-addon-development./xmake-async-jobsUse when running parallel / async work inside xmake scripts — `async.runjobs` for parallel job execution, `async.jobgraph` (DAG) for dependency-ordered jobs, `async.jobpool` (tree structure), `core.base.scheduler` coroutine scheduling, semaphores, and `on_build_files(..., {jobgraph = true})` in rules. For running external compile jobs faster, see `xmake-build-optimization`./xmake-basicsUse when the user is starting a new Xmake project, installing Xmake, or needs the minimal xmake.lua structure. Covers installation, `xmake create`, the project layout, and the smallest valid xmake.lua./xmake-build-cacheUse when configuring or debugging xmake's local build cache (built-in, replaces ccache) or the remote compile cache service (shared across machines via `xmake service --ccache`). Covers enabling/disabling, fallbacks to external ccache, remote cache server/client setup, and cache cleaning./xmake-build-optimizationUse when a project builds slowly and you want to make it faster — parallel jobs, unity build, precompiled headers, build cache, LTO, link-time improvements, binary package cache, and profiling with `XMAKE_PROFILE=perf:*`. Covers idiomatic xmake speedups and the order to try them.Other plugins' skills for the same job