1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
|
target("demo")
-- disable this target if only build libaries
if has_config("onlylib") then
set_default(false)
end
-- add deps
add_deps("xmake")
-- make as a binary
set_kind("binary")
-- add defines
add_defines("__tb_prefix__=\"xmake\"")
-- add includes directory
add_includedirs("$(projectdir)", "$(projectdir)/src")
-- add the common source files
add_files("**.c")
-- add the resource files (it will be enabled after publishing new version)
if is_plat("windows") then
add_files("*.rc")
end
-- add links
if is_plat("windows") then
add_links("ws2_32", "advapi32", "shell32")
add_ldflags("/export:malloc", "/export:free")
elseif is_plat("android") then
add_links("m", "c")
elseif is_plat("macosx") then
add_ldflags("-all_load", "-pagezero_size 10000", "-image_base 100000000")
elseif is_plat("mingw") then
add_ldflags("-static-libgcc", {force = true})
else
add_links("pthread", "dl", "m", "c")
end
-- enable xp compatibility mode
if is_plat("windows") then
if is_arch("x86") then
add_ldflags("/subsystem:console,5.01")
else
add_ldflags("/subsystem:console,5.02")
end
end
-- copy target to the build directory
after_build(function (target)
os.cp(target:targetfile(), "$(buildir)/xmake" .. (is_plat("windows") and ".exe" or ""))
end)
|