-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmake.lua
More file actions
102 lines (71 loc) · 2.72 KB
/
Copy pathxmake.lua
File metadata and controls
102 lines (71 loc) · 2.72 KB
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
includes("config.lua")
local version = "1.2.2"
set_version(version)
set_xmakever("3.0.9")
set_project("XMake Project")
set_description("A C/C++ Project Template Powered By Xmake.")
set_languages("cxx17")
add_rules("mode.debug", "mode.release")
set_configdir("$(builddir)/config/")
add_configfiles("src/config.h.in")
add_includedirs("$(builddir)/config/")
option("with_gtest")
set_default(false)
set_showmenu(true)
set_description("Enable GoogleTest-based unit tests.")
option_end()
option("install_in_place")
set_default(true)
set_showmenu(true)
set_description("Install to $(builddir)/$(plat)/$(arch)/$(mode)/install by default.")
option_end()
option("build_shared")
set_default(default_build_shared_for_current_platform())
set_showmenu(true)
set_description("Build the template library as a shared library.")
option_end()
define_current_platform_options()
local build_shared = get_config("build_shared")
if build_shared == nil then
build_shared = default_build_shared_for_current_platform()
end
local install_in_place = get_config("install_in_place")
if install_in_place == nil then
install_in_place = true
end
if install_in_place then
-- 请用 xmake install 安装。
set_installdir("$(builddir)/$(plat)/$(arch)/$(mode)/install")
end
target("xmake-project")
set_kind(build_shared and "shared" or "static")
apply_current_platform_target_config()
if build_shared and is_current_win32() then
add_rules("utils.symbols.export_all")
end
set_targetdir("$(builddir)/$(plat)/$(arch)/$(mode)/lib/")
-- 会将 src 根目录和所有子目录一起匹配。
add_files("src/**.cpp")
add_public_headers()
add_includedirs("src", {public = true})
before_build(function (target)
io.writefile(path.join(path.directory(target:targetdir()), ".version"), version)
end)
before_install(function (target)
os.tryrm(target:installdir())
os.mkdir(target:installdir())
os.cp("$(builddir)/$(plat)/$(arch)/$(mode)/.version", target:installdir())
os.cp("$(builddir)/config/config.h", path.join(target:installdir(), "config/config.h"))
end)
before_package(function (target)
os.tryrm(path.join(target:packagedir(), "$(plat)/$(arch)/$(mode)/"))
os.mkdir(target:packagedir())
os.cp("$(builddir)/$(plat)/$(arch)/$(mode)/.version", target:packagedir())
os.cp("$(builddir)/$(plat)/$(arch)/$(mode)/.version", path.join(target:packagedir(), "$(plat)/$(arch)/$(mode)/.version"))
os.cp("$(builddir)/config/config.h", path.join(target:packagedir(), "$(plat)/$(arch)/$(mode)/config/config.h"))
end)
target_end()
includes("snippet")
if get_config("with_gtest") then
includes("test")
end