-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpremake5.lua
241 lines (189 loc) · 7.56 KB
/
premake5.lua
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
require("premake_modules/export-compile-commands")
require("premake_modules/cmake")
local function get_vcpkg_root()
local handle = io.popen([[for /f "tokens=*" %a in ('where vcpkg.exe') do echo %~dpa]])
local result = handle:read("*a")
handle:close()
local result2 = string.gsub(result, "([^\n]+)\n(.*)\n", "%2"):sub(2)
return result2
end
local vcpkg_root = (get_vcpkg_root())
print("vcpkg root is \"" .. vcpkg_root .. "\"")
local function vcpkg_common()
filter {"system:windows", "platforms:x64"}
includedirs{vcpkg_root .. "installed\\x64-windows\\include"}
filter {"system:windows", "platforms:x32"}
includedirs{vcpkg_root .. "installed\\x86-windows\\include"}
filter {}
filter {"system:windows", "platforms:x64", "configurations:Debug"}
libdirs {vcpkg_root .. "installed\\x64-windows\\debug\\lib"}
filter {"system:windows", "platforms:x32", "configurations:Debug"}
libdirs {vcpkg_root .. "installed\\x86-windows\\debug\\lib"}
filter {}
filter {"system:windows", "platforms:x64", "configurations:Release"}
libdirs {vcpkg_root .. "installed\\x64-windows\\lib"}
filter {"system:windows", "platforms:x32", "configurations:Debug"}
libdirs {vcpkg_root .. "installed\\x86-windows\\lib"}
filter {}
end
local function copy_compile_commands()
-- For moving the compile commands into the root directory of the project
-- so that autocomplete tools can see them (cquery...)
-- This is messy but was the only way to get it to work consistently
-- across multiple platforms (circleci, windows 10, vsts...)
filter "system:linux"
prebuildcommands {
"{MKDIR} %{wks.location}/compile_commands/",
"{TOUCH} %{wks.location}/compile_commands/%{cfg.shortname}.json",
"{COPY} %{wks.location}/compile_commands/%{cfg.shortname}.json ../compile_commands.json"
}
filter "system:windows"
prebuildcommands {
"cmd.exe /c \"" .. "{MKDIR} %{wks.location}/compile_commands/",
"cmd.exe /c \"" .. "{TOUCH} %{wks.location}/compile_commands/%{cfg.shortname}.json",
"cmd.exe /c \"" .. "{COPY} %{wks.location}/compile_commands/%{cfg.shortname}.json ../compile_commands.json*"
}
end
local function protogen()
end
workspace "workspace"
configurations { "Debug", "Release" }
platforms { "x64", "x32" }
targetdir "bin/%{cfg.platform}_%{cfg.buildcfg}/%{prj.name}"
location "premake"
-- Set up platforms
filter {"platforms:x32"}
architecture "x32"
defines {"ARGONX_32"}
filter {"platforms:x64"}
architecture "x64"
defines {"ARGONX_64"}
filter {}
cppdialect "C++17"
-- Setup c++ spec per platform
-- Linux uses a buildoption to allow for more
-- up to date standards (2a)
filter {"system:windows"}
toolset "msc-v142"
characterset "MBCS"
flags {"MultiProcessorCompile"}
buildoptions {"-experimental:external -external:W0 -external:anglebrackets -external:templates-"}
defines {"ARGONX_WIN"}
filter {"system:linux"}
toolset "clang" -- prefer clang over gcc
defines {"ARGONX_UNIX"}
filter {}
-- Setup configurations
filter "configurations:Debug"
defines { "DEBUG", "_DEBUG" }
optimize "Off"
runtime "Debug"
filter {"system:windows"}
symbols "Full" -- We need symbols Full instead of just On
filter {"system:linux"}
symbols "On"
buildoptions "-g3 -fdiagnostics-absolute-paths" -- need this for gdb
filter {}
filter {"configurations:Release"}
defines { "NDEBUG" }
optimize "Full"
symbols "Full"
flags {"LinkTimeOptimization"}
filter {}
project "protobufs"
kind "StaticLib"
language "C++"
warnings "off"
vcpkg_common()
includedirs { "protogen" }
targetdir "protogen/lib/%{cfg.platform}_%{cfg.buildcfg}/%{prj.name}"
files { "protogen/**.pb.*" }
project "client"
kind "ConsoleApp"
language "C++"
-- Windows and linux use different precompiled header path locations
filter {"system:linux"}
pchheader "client/precompiled.hh"
filter {"system:windows"}
pchheader "precompiled.hh"
filter {}
pchsource "client/precompiled.cc"
filter {"files:**.pb.cc or files:**.cpp"}
flags { "NoPCH" }
warnings "off"
filter {}
vcpkg_common()
includedirs { "client", "protogen", "common", "external", "external/OpenSteamworks", "." }
files { "client/**.hh", "client/**.cc",
"common/**.cc", "common/**.hh",
-- "protogen/**.pb.h",
"steam/**.hh", "steam/**.cc",
"external/SteamStructs/**.h",
"external/OpenSteamworks/Open Steamworks/**.h",
"argonx/**.cc", "argonx/**.hh",
"external/loguru/loguru.cpp"
}
filter {"system:linux"}
links {"cryptopp", "pthread", "protobuf", "archive", "zmq", "dl", "protobufs"}
filter {"system:windows"}
links {"cryptopp-static", "protobufs"}
filter {}
copy_compile_commands()
project "server"
kind "ConsoleApp"
language "C++"
-- Windows and linux use different precompiled header path locations
filter {"system:linux"}
pchheader "server/precompiled.hh"
filter {"system:windows"}
pchheader "precompiled.hh"
filter {}
pchsource "server/precompiled.cc"
filter {"files:**.pb.cc or files:**.cpp"}
flags { "NoPCH" }
warnings "off"
filter {}
vcpkg_common()
includedirs { "server", "protogen", "common", "external", "external/OpenSteamworks", "." }
files { "server/**.hh", "server/**.cc",
"common/**.cc", "common/**.hh",
-- "protogen/**.pb.*",
"steam/**.hh", "steam/**.cc",
"external/SteamStructs/**.h",
"external/OpenSteamworks/Open Steamworks/**.h",
"argonx/**.cc", "argonx/**.hh",
"external/loguru/loguru.cpp"
}
filter {"system:linux"}
links {"cryptopp", "pthread", "protobuf", "archive", "zmq", "dl", "protobufs"}
filter {"system:windows"}
links {"cryptopp-static", "protobufs"}
filter {}
copy_compile_commands()
project "tests"
kind "ConsoleApp"
language "C++"
-- Windows and linux use different precompiled header path locations
filter {"system:linux"}
pchheader "tests/precompiled.hh"
filter {"system:windows"}
pchheader "precompiled.hh"
filter {}
pchsource "tests/precompiled.cc"
filter {"files:**.pb.cc or files:**.cpp"}
flags { "NoPCH" }
warnings "off"
filter {}
filter {"files:**/main.cc"}
flags {"NoPCH"}
filter {}
includedirs {"external", "steam", "tests", "common", "."}
files { "common/**.cc", "common/**.hh",
"tests/**.cc", "tests/**.hh",
"steam/interfaces/helpers.cc",
"steam/interfaces/createinterface.cc",
"external/loguru/loguru.cpp"
}
filter {"system:linux"}
links {"cryptopp", "pthread", "protobuf", "archive", "zmq", "dl", "protobufs"}
filter {}