add_rules("mode.debug", "mode.release")
target("console")
set_kind("binary")
//二进制.
add_files("src/*.c")
if is_mode("debug") then
add_defines("DEBUG")
end
target("test")
set_kind("binary")
add_files("src/*.c")
after_build(function (target)
print("hello: %s", target:name())
os.exec("echo %s", target:targetfile())
end)
用xmake-repo
来下载.
add_requires("tbox >1.6.1", "libuv master", "vcpkg::ffmpeg", "brew::pcre2/libpcre2-8")
add_requires("conan::openssl/1.1.1g", {alias = "openssl", optional = true, debug = true})
target("test")
set_kind("binary")
add_files("src/*.c")
add_packages("tbox", "libuv", "vcpkg::ffmpeg", "brew::pcre2/libpcre2-8", "openssl")
target("test")
add_rules("qt.quickapp")
add_files("src/*.cpp")
add_files("src/qml.qrc")
target("echo")
add_rules("wdk.driver", "wdk.env.umdf")
add_files("driver/*.c")
add_files("driver/*.inx")
add_includedirs("exe")
//这里加包含文件.
target("app")
add_rules("wdk.binary", "wdk.env.umdf")
add_files("exe/*.cpp")
$ xmake project -k vsxmake -m "debug;release" # 新版vs工程生成插件(推荐)
$ xmake project -k vs -m "debug;release"
$ xmake project -k cmake
$ xmake project -k ninja
$ xmake project -k compile_commands
$ xmake l ./test.lua
$ xmake l -c "print('hello xmake!')"
$ xmake l lib.detect.find_tool gcc
$ xmake l
> print("hello xmake!")
> {1, 2, 3}
< {
1,
2,
3
}
target("library")
set_kind("static")
add_files("src/library/*.c")
target("test")
set_kind("binary")
add_files("src/*c")
add_deps("library")
//链接静态库至exe
$ xmake f --wdk="G:\Program Files\Windows Kits\10" -c
$ xmake
target("echo")
add_rules("wdk.driver", "wdk.env.umdf")
add_files("driver/*.c")
add_files("driver/*.inx")
add_includedirs("exe")
target("app")
add_rules("wdk.binary", "wdk.env.umdf")
add_files("exe/*.cpp")
target("nonpnp")
add_rules("wdk.driver", "wdk.env.kmdf")
add_values("wdk.tracewpp.flags", "-func:TraceEvents(LEVEL,FLAGS,MSG,...)", "-func:Hexdump((LEVEL,FLAGS,MSG,...))")
add_files("driver/*.c", {rule = "wdk.tracewpp"})
add_files("driver/*.rc")
target("app")
add_rules("wdk.binary", "wdk.env.kmdf")
add_files("exe/*.c")
add_files("exe/*.inf")
target("kcs")
add_rules("wdk.driver", "wdk.env.wdm")
add_values("wdk.man.flags", "-prefix Kcs")
add_values("wdk.man.resource", "kcsCounters.rc")
add_values("wdk.man.header", "kcsCounters.h")
add_values("wdk.man.counter_header", "kcsCounters_counters.h")
add_files("*.c", "*.rc", "*.man")
默认禁用签名,可set_values("wdk.sign.mode", ...)
来设置签名.,自带测试签名.
target("msdsm")
add_rules("wdk.driver", "wdk.env.wdm")
set_values("wdk.sign.mode", "test")
手动管理员
$xmake l utils.wdk.testcert install
add_requires("protobuf-cpp")
target("console_c++")
set_kind("binary")
set_languages("c++11")
add_packages("protobuf-cpp")
add_files("src/*.cpp")
add_files("src/*.proto", {rules = "protobuf.cpp"})
target("calc")
set_kind("binary")
add_rules("lex", "yacc")
add_files("src/*.l", "src/*.y")
add_rules("mode.debug", "mode.release")
target("test")
set_kind("binary")
add_files("src/*.d")
add_rules("mode.debug", "mode.release")
add_requires("dub::log 0.4.3", {alias = "log"})
add_requires("dub::dateparser", {alias = "dateparser"})
add_requires("dub::emsi_containers", {alias = "emsi_containers"})
add_requires("dub::stdx-allocator", {alias = "stdx-allocator"})
add_requires("dub::mir-core", {alias = "mir-core"})
target("test")
set_kind("binary")
add_files("src/*.d")
add_packages("log", "dateparser", "emsi_containers", "stdx-allocator", "mir-core")
set_languages("c++20")
target("class")
set_kind("binary")
add_files("src/*.cpp", "src/*.mpp")