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
|
option("foo")
set_default("foo")
set_description("The Foo Info")
option_end()
if has_config("foo") then
set_configvar("FOO_ENABLE", 1)
set_configvar("FOO_ENABLE2", false)
set_configvar("FOO_STRING", get_config("foo"))
set_configvar("FOO_DEFINE", get_config("foo"), {quote = false})
end
option("foo2")
set_default(true)
set_description("Enable Foo2")
set_configvar("FOO2_ENABLE", true)
set_configvar("FOO2_STRING", "foo")
option_end()
target("test")
set_kind("binary")
add_files("main.c")
set_configvar("module", "test")
set_configdir("$(builddir)/config")
add_configfiles("test.c.in", {filename = "mytest.c"})
add_configfiles("config.h.in", {variables = {hello = "xmake"}, prefixdir = "header",
preprocessor = function (preprocessor_name, name, value, opt)
if preprocessor_name == "define_custom" then
return string.format("#define CUSTOM_%s %s", name, value)
end
end})
add_configfiles("*.man", {onlycopy = true, prefixdir = "man"})
add_includedirs("$(builddir)/config/header")
target("test2")
set_kind("binary")
add_files("main2.c")
set_configvar("module", "test2")
set_configdir("$(builddir)/config2")
add_configfiles("test.c.in", {filename = "mytest.c"})
add_configfiles("config2.h.in", {variables = {hello = "xmake2"}, pattern = "@([^\n]-)@", prefixdir = "header"})
add_configfiles("*.man", {onlycopy = true, prefixdir = "man"})
add_includedirs("$(builddir)/config2/header")
add_options("foo2")
|