A simple xmake.lua
原文链接 https://waruqi.github.io/2016/06/26/a-simple-demo/
注:以下为加速网络访问所做的原文缓存,经过重新格式化,可能存在格式方面的问题,或偶有遗漏信息,请以原文为准。
A simplest xmake.lua
-- define a target with named 'demo'
target("demo")
-- set the target kind, .e.g 'binary' is a console program
-- - static: a static library
-- - shared: a shared library
set_kind("binary")
-- add all c source files in the directory: src
add_files("src/*.c")
And we run the following command for building it.
xmake
Next, we write another xmake.lua for switching 'debug' or 'release' mode.
-- is debug now?
if is_mode("debug") then
-- enable debug symbols for debugger
set_symbols("debug")
-- disable optimization
set_optimize("none")
end
-- is release now?
if is_mode("release") then
-- set visibility as hidden
set_symbols("hidden")
-- enable optimization for fastest mode
set_optimize("fastest")
-- strip all symbols
set_strip("all")
end
-- define a target
target("test")
-- set the program kind as a static library
set_kind("static")
-- add all c++ files recursively
add_files("src/**.cpp")
We configure this project with the debug mode now.
xmake f -m debug
#xmake config --mode=debug
And we build it.
xmake