-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmake.lua
More file actions
144 lines (126 loc) · 3.44 KB
/
xmake.lua
File metadata and controls
144 lines (126 loc) · 3.44 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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
-- xmake.lua
-- Build configuration for Modern C++ Calculator v2.0
set_project("calculator")
set_version("2.1.0")
set_xmakever("2.5.0")
-- Set C++ standard
set_languages("c++17")
-- Build options
option("tests")
set_default(true)
set_showmenu(true)
set_description("Build tests")
option_end()
option("examples")
set_default(true)
set_showmenu(true)
set_description("Build examples")
option_end()
option("benchmarks")
set_default(false)
set_showmenu(true)
set_description("Build benchmarks")
option_end()
option("repl")
set_default(true)
set_showmenu(true)
set_description("Build REPL executable")
option_end()
-- Header-only library
target("calculator")
set_kind("headeronly")
add_headerfiles("calculator.hpp")
add_headerfiles("include/calculator/*.hpp")
add_includedirs(".", "include", {public = true})
target_end()
-- Examples
if has_config("examples") then
target("example")
set_kind("binary")
add_files("example/main.cpp")
add_deps("calculator")
set_targetdir("$(builddir)/example")
if is_plat("windows") then
add_defines("_USE_MATH_DEFINES")
end
target_end()
target("example_functions")
set_kind("binary")
add_files("example/functions.cpp")
add_deps("calculator")
set_targetdir("$(builddir)/example")
if is_plat("windows") then
add_defines("_USE_MATH_DEFINES")
end
target_end()
target("example_errors")
set_kind("binary")
add_files("example/errors.cpp")
add_deps("calculator")
set_targetdir("$(builddir)/example")
if is_plat("windows") then
add_defines("_USE_MATH_DEFINES")
end
target_end()
target("example_types")
set_kind("binary")
add_files("example/types.cpp")
add_deps("calculator")
set_targetdir("$(builddir)/example")
if is_plat("windows") then
add_defines("_USE_MATH_DEFINES")
end
target_end()
end
-- REPL
if has_config("repl") then
target("calc_repl")
set_kind("binary")
add_files("example/repl_main.cpp")
add_deps("calculator")
set_targetdir("$(builddir)/bin")
if is_plat("windows") then
add_defines("_USE_MATH_DEFINES")
end
target_end()
end
-- Tests
if has_config("tests") then
add_requires("gtest")
target("calc_test")
set_kind("binary")
add_files("test/main.cpp", "test/test_parser.cpp")
add_deps("calculator")
add_packages("gtest")
set_targetdir("$(builddir)/test")
if is_plat("windows") then
add_defines("_USE_MATH_DEFINES")
end
-- Add test
on_run(function (target)
os.execv(target:targetfile())
end)
target_end()
end
-- Benchmarks
if has_config("benchmarks") then
add_requires("benchmark")
target("calc_benchmark")
set_kind("binary")
add_files("benchmark/main.cpp")
add_deps("calculator")
add_packages("benchmark")
set_targetdir("$(builddir)/benchmark")
if is_plat("windows") then
add_defines("_USE_MATH_DEFINES")
end
target_end()
end
-- Install rules
target("install")
set_kind("phony")
on_install(function (target)
os.cp("calculator.hpp", "$(installdir)/include/")
os.cp("include/calculator", "$(installdir)/include/")
end)
target_end()