Skip to content

Xmake v3.1.3 Release Preview, Qt/QML Compilation and C# Assembly Support ​

Xmake v3.1.3 adds QML AOT and type compilation, automatic moc header detection, external C# assembly references, and default test selection.

This version also improves incremental builds for C++ modules and Verilator, fixes package-installation hangs, and adds subsecond file timestamps.

Qt/QML support ​

QML modules and AOT compilation ​

The new qt_add_qml_module helper adds QML files and resources to a Qt Quick application:

lua
add_rules("mode.debug", "mode.release")
includes("@builtin/qt")

target("qmlapp")
    add_rules("qt.quickapp")
    add_files("main.cpp")
    qt_add_qml_module("*.qml", "*.js", "assets/*.svg", {
        uri = "MyApp",
        version = "1.0"
    })

By default, qmlcachegen generates C++ cache sources for compilation. This requires Qt >= 6.2 and its qmlcachegen tool. A URI such as MyApp places resources under /qt/qml/MyApp/, so the application can load qrc:/qt/qml/MyApp/Main.qml.

For Qt >= 6.4, {type_compiler = true} also enables qmltc. Xmake generates the required qmldir files and integrates the generated C++ sources and moc steps. AOT statistics can be requested with {aot_stats = true} on Qt >= 6.8 when the SDK supports them; leaving this option unset uses automatic capability detection.

These are separate controls: cachegen = false disables cache generation, only_bytecode = true requests bytecode-only output, and AOT reports require native AOT compilation. See the Qt example and options. Changes: #7885, #7900, and #7903.

Automatic moc header detection ​

Qt headers no longer all need separate add_files entries when automoc is enabled:

lua
target("widgets")
    add_rules("qt.widgetapp")
    set_policy("build.qt.automoc", true)
    add_files("src/*.cpp")
    add_headerfiles("src/*.h")
    add_includedirs("src")

Xmake looks for Qt meta-object macros, pairs headers with matching source basenames, and follows transitive local includes for the remaining candidates. Cycles and same-basename headers in different directories are handled, without recursively scanning package include trees. The policy defaults to false, so existing explicit moc configurations remain valid. See #7899, #7924, and the policy reference.

External C# assemblies ​

Prebuilt managed DLLs can now use the familiar link interfaces:

lua
target("app")
    set_kind("binary")
    add_files("src/*.cs")
    add_linkdirs("lib")
    add_links("MyLib")

For lib/MyLib.dll, Xmake writes a Reference item with a HintPath, tracks the DLL as a build dependency, and exports per-configuration references to vsxmake. A reference not found in these directories is left for MSBuild's framework/GAC resolution. Other C# targets still use add_deps, and NuGet packages retain their existing integration.

See #7725, #7923, and external assembly examples.

Default test selection ​

test.respect_default lets a project omit tests of non-default targets from a plain xmake test. The policy is disabled by default:

lua
set_policy("test.respect_default", true)

target("slow_tests")
    set_kind("binary")
    set_default(false)
    add_files("tests/slow.cpp")
    add_tests("default")

Run everything with xmake test -a or xmake test --all. An explicit test name or group filter can also select non-default tests, and a test-level default setting takes precedence. See #7910 and the test guide.

Incremental build improvements ​

Generating compile_commands.json should not cause the next build to recompile unchanged GCC modules. Mapper files are now written only when their contents change. Compilation databases also include non-default targets, and module caches are invalidated correctly on reconfiguration. Other fixes cover nested GCC header units, clang-cl module reuse and implementation ordering, and Clang fallback scanning's language-standard flags. See #7921, #7871, #7893, #7882, #7902, and #7872.

File time APIs now retain fractional seconds where supported, and serialized caches preserve floating-point precision. This lets dependency checks detect edits made within the same second as a build output. Actual resolution still depends on the filesystem. See #7879 and os.mtime.

Other updates ​

  • Verilator accepts .vlt control files and avoids repeated incremental rebuilds. See #7904 and #7901.
  • Wasm release modes default to size optimization. Explicit target settings still take precedence. See #7887.
  • vsxmake supports per-file C/C++ language standards and fixes namespaced project references. See #7912 and #7926.
  • MSVC ARM64 linker flag probes, Windows SDK host-tool selection, Qt Linux packaging and target-level install.strip_packagelibs settings receive fixes. See #7859, #7881, #7892 and #7907.
  • Background host probes no longer leave wget log files in a project directory. See #7876.

Changelog ​

New features ​

  • #7885: Support QML AOT compilation with qmlcachegen
  • #7900: Support the QML type compiler qmltc
  • #7903: Support QML AOT statistics with qmlaotstats
  • #7899: Add Qt automoc with the build.qt.automoc policy
  • #7725, #7923: Reference external C# assemblies with add_links and add_linkdirs
  • #7904: Support Verilator .vlt control files
  • #7910: Add test.respect_default and xmake test --all
  • #7912: Support per-file C/C++ language standards in vsxmake projects

Changes ​

  • #7879: Preserve subsecond file timestamps and serialized floating-point precision
  • #7887: Optimize WebAssembly release builds for size by default
  • #7867: Reuse Clang flag handling for Emscripten
  • #7863: Expand C/C++ compiler name compatibility mappings
  • #7866: Avoid warnings for unavailable automatic Ascend C toolchain candidates
  • #7890: Add QML module examples and regression tests
  • #7874: Correct build-directory ignore rules
  • #7913: Fix package-management demo images in the README

Bugs fixed ​

  • #7870: Fix root-directory entries in GCC module mapper files
  • #7882: Fix nested GCC header units and relative include paths
  • #7850, #7902: Fix clang-cl module reuse and implementation-unit scheduling
  • #7889: Fix reduced-BMI flag forwarding for clang-cl
  • #7893: Invalidate stale C++ module caches after reconfiguration
  • #7895: Fix Emscripten compiler detection for C++ modules
  • #7871: Include non-default targets when generating compilation databases
  • #7921: Avoid GCC module rebuilds after generating compilation databases
  • #7872: Preserve language standards in Clang fallback module scanning
  • #7872: Fix missing libc++ ABI symbols when linking on Linux
  • #7872: Fix Unix child-process polling in the bundled tbox
  • #7881: Select Windows SDK tools by host architecture
  • #7859: Fix MSVC linker flag probes when cross-compiling to ARM64
  • #7898: Fix hangs after dependency or serial-package installation failures
  • #7876: Prevent background host probes from creating wget log files
  • #7883, #7901: Fix repeated Verilator rebuilds during incremental compilation
  • #7892: Include Qt executables in Linux xpack packages
  • #7907: Honor target-level install.strip_packagelibs settings
  • #7909: Fix format file selection, deduplication and Qt rule matching
  • #7924: Detect transitively included headers in Qt automoc
  • #7926: Fix vsxmake project references to namespaced targets
  • #7920: Fix PDCurses compilation with newer MSVC toolchains