LinuxCommandLibrary

xmake

Build projects using a configuration file

TLDR

Create an Xmake C project, consisting of a hello world and xmake.lua

$ xmake create [[-l|--language]] [[c|clean]] [[-P|--project]] [project_name]
copy

Build and run an Xmake project
$ xmake [[b|build]] [[r|run]]
copy

Run a compiled Xmake target directly
$ xmake [[r|run]] [target_name]
copy

Configure a project's build targets
$ xmake [[f|config]] [[-p |--plat=]][macosx|linux|iphoneos|...] [[-a |--arch=]][x86_64|i386|arm64|...] [[-m |--mode=]][debug|release]
copy

Install the compiled target to a directory
$ xmake [[i|install]] [[-o |--installdir=]][path/to/directory]
copy

SYNOPSIS

xmake [options] [command] [arguments...]

Common commands include:
xmake config [--plat=<platform>] [--arch=<architecture>] [--mode=<mode>]
xmake build [-j<jobs>] [target]
xmake run [target] [--args=<arguments>]
xmake install [target]
xmake clean [--all]
xmake update [--self]

PARAMETERS

-h, --help
    Displays help information for xmake or a specific command.

-v, --verbose
    Enables verbose output, showing more details during the build process.

--version
    Prints the xmake version information.

config
    Configures the project build environment. Used to set platform, architecture, build mode (debug/release), toolchain, and other global build settings.

build
    Compiles and links the project. Can specify a particular target to build or build all targets.

run
    Executes a specified target (e.g., an executable) after building. Additional arguments can be passed to the target program.

install
    Installs the built targets to a specified or default installation directory.

clean
    Removes intermediate build files and outputs. Use '--all' to remove cached packages and configuration.

package
    Packages the built targets, often creating archives or distribution packages.

project
    Generates project files for various IDEs (e.g., Visual Studio, Xcode, Makefiles, CMakeLists).

update
    Updates xmake itself or its built-in package repository. Use '--self' to update xmake.

create
    Creates a new xmake project from a template.

test
    Executes project tests defined in the xmake.lua file.

DESCRIPTION


xmake is a lightweight, cross-platform build utility that aims to provide a simple and powerful solution for building projects. Unlike traditional build systems like Make or CMake, xmake uses a Lua-based syntax for its project configuration files (xmake.lua), making it highly flexible and easy to read and write. It simplifies the build process by integrating various features typically found in separate tools, such as dependency management, package management, cross-compilation support, and project generation for various IDEs.

It supports a wide range of platforms, including Windows, macOS, Linux, Android, iOS, and WebAssembly, and works with numerous compilers like GCC, Clang, MSVC, and MinGW. xmake's built-in package manager allows seamless integration and automatic downloading of third-party libraries, reducing the complexity of managing external dependencies. Its design emphasizes ease of use, high performance through parallel compilation, and extensibility via plugins and custom rules, making it suitable for projects of all sizes.

CAVEATS

While xmake simplifies many aspects of project building, its custom Lua-based configuration syntax (xmake.lua) requires some learning, especially for advanced build rules or custom scenarios. Although it's cross-platform, subtle differences in toolchains or system configurations can sometimes lead to platform-specific issues that require detailed debugging. Its community and ecosystem, while growing, are still smaller compared to more established build systems like Make or CMake.

XMAKE.LUA CONFIGURATION

The core of an xmake project is the xmake.lua file. This Lua script defines project targets (executables, libraries), source files, dependencies, build rules, and configurations. Its declarative syntax makes it easy to read and maintain, allowing developers to quickly understand and modify build logic.

INTEGRATED PACKAGE MANAGEMENT

xmake includes a powerful built-in package manager that can automatically fetch, compile, and link third-party dependencies from various sources (e.g., Conan, Vcpkg, Homebrew, or xmake's own repository). This significantly simplifies dependency management across different platforms and environments.

CROSS-COMPILATION AND TOOLCHAINS

xmake provides robust support for cross-compilation. Users can easily specify target platforms and architectures, and xmake will automatically manage the necessary toolchains and SDKs. This is particularly useful for embedded systems, mobile development (Android/iOS), and WebAssembly.

HISTORY

xmake was first released around 2017 by Ruki and has been under continuous development since. It emerged as a response to the perceived complexities of existing build systems, aiming to offer a more intuitive and integrated experience. Its design emphasizes a modern approach to build automation, combining features like package management and IDE project generation directly into the core tool, which were often handled by separate utilities in older systems. It quickly gained popularity among developers looking for a simpler yet powerful alternative, especially in cross-platform development contexts.

SEE ALSO

make(1), cmake(1), ninja(1), meson(1)

Copied to clipboard