· 5 years ago · Aug 21, 2020, 04:40 PM
1newoption { trigger = "android", description = "Use non-working Android cross-compiling mode" }
2newoption { trigger = "atlas", description = "Include Atlas scenario editor projects" }
3newoption { trigger = "coverage", description = "Enable code coverage data collection (GCC only)" }
4newoption { trigger = "gles", description = "Use non-working OpenGL ES 2.0 mode" }
5newoption { trigger = "wgpu", description = "Use non-working WebGPU mode" }
6newoption { trigger = "icc", description = "Use Intel C++ Compiler (Linux only; should use either \"--cc icc\" or --without-pch too, and then set CXX=icpc before calling make)" }
7newoption { trigger = "jenkins-tests", description = "Configure CxxTest to use the XmlPrinter runner which produces Jenkins-compatible output" }
8newoption { trigger = "minimal-flags", description = "Only set compiler/linker flags that are really needed. Has no effect on Windows builds" }
9newoption { trigger = "outpath", description = "Location for generated project files" }
10newoption { trigger = "with-system-mozjs45", description = "Search standard paths for libmozjs45, instead of using bundled copy" }
11newoption { trigger = "with-system-nvtt", description = "Search standard paths for nvidia-texture-tools library, instead of using bundled copy" }
12newoption { trigger = "without-audio", description = "Disable use of OpenAL/Ogg/Vorbis APIs" }
13newoption { trigger = "without-lobby", description = "Disable the use of gloox and the multiplayer lobby" }
14newoption { trigger = "without-miniupnpc", description = "Disable use of miniupnpc for port forwarding" }
15newoption { trigger = "without-nvtt", description = "Disable use of NVTT" }
16newoption { trigger = "without-pch", description = "Disable generation and usage of precompiled headers" }
17newoption { trigger = "without-tests", description = "Disable generation of test projects" }
18
19-- Linux/BSD specific options
20newoption { trigger = "prefer-local-libs", description = "Prefer locally built libs. Any local libraries used must also be listed within a file within /etc/ld.so.conf.d so the dynamic linker can find them at runtime." }
21
22-- OS X specific options
23newoption { trigger = "macosx-bundle", description = "Enable OSX bundle, the argument is the bundle identifier string (e.g. com.wildfiregames.0ad)" }
24newoption { trigger = "macosx-version-min", description = "Set minimum required version of the OS X API, the build will possibly fail if an older SDK is used, while newer API functions will be weakly linked (i.e. resolved at runtime)" }
25newoption { trigger = "sysroot", description = "Set compiler system root path, used for building against a non-system SDK. For example /usr/local becomes SYSROOT/user/local" }
26
27-- Windows specific options
28newoption { trigger = "build-shared-glooxwrapper", description = "Rebuild glooxwrapper DLL for Windows. Requires the same compiler version that gloox was built with" }
29newoption { trigger = "use-shared-glooxwrapper", description = "Use prebuilt glooxwrapper DLL for Windows" }
30newoption { trigger = "large-address-aware", description = "Make the executable large address aware. Do not use for development, in order to spot memory issues easily" }
31
32-- Install options
33newoption { trigger = "bindir", description = "Directory for executables (typically '/usr/games'); default is to be relocatable" }
34newoption { trigger = "datadir", description = "Directory for data files (typically '/usr/share/games/0ad'); default is ../data/ relative to executable" }
35newoption { trigger = "libdir", description = "Directory for libraries (typically '/usr/lib/games/0ad'); default is ./ relative to executable" }
36
37-- Root directory of project checkout relative to this .lua file
38rootdir = "../.."
39
40dofile("extern_libs5.lua")
41
42-- detect compiler for non-Windows
43if os.istarget("macosx") then
44 cc = "clang"
45elseif os.istarget("linux") and _OPTIONS["icc"] then
46 cc = "icc"
47elseif not os.istarget("windows") then
48 cc = os.getenv("CC")
49 if cc == nil or cc == "" then
50 local hasgcc = os.execute("which gcc > .gccpath")
51 local f = io.open(".gccpath", "r")
52 local gccpath = f:read("*line")
53 f:close()
54 os.execute("rm .gccpath")
55 if gccpath == nil then
56 cc = "clang"
57 else
58 cc = "gcc"
59 end
60 end
61end
62
63-- detect CPU architecture (simplistic, currently only supports x86, amd64 and ARM)
64arch = "x86"
65if _OPTIONS["android"] then
66 arch = "arm"
67elseif os.istarget("windows") then
68 if os.getenv("PROCESSOR_ARCHITECTURE") == "amd64" or os.getenv("PROCESSOR_ARCHITEW6432") == "amd64" then
69 arch = "amd64"
70 end
71else
72 arch = os.getenv("HOSTTYPE")
73 if arch == "x86_64" or arch == "amd64" then
74 arch = "amd64"
75 else
76 os.execute(cc .. " -dumpmachine > .gccmachine.tmp")
77 local f = io.open(".gccmachine.tmp", "r")
78 local machine = f:read("*line")
79 f:close()
80 if string.find(machine, "x86_64") == 1 or string.find(machine, "amd64") == 1 then
81 arch = "amd64"
82 elseif string.find(machine, "i.86") == 1 then
83 arch = "x86"
84 elseif string.find(machine, "arm") == 1 then
85 arch = "arm"
86 elseif string.find(machine, "aarch64") == 1 then
87 arch = "aarch64"
88 else
89 print("WARNING: Cannot determine architecture from GCC, assuming x86")
90 end
91 end
92end
93
94-- Test whether we need to link libexecinfo.
95-- This is mostly the case on musl systems, as well as on BSD systems : only glibc provides the
96-- backtrace symbols we require in the libc, for other libcs we use the libexecinfo library.
97local link_execinfo = false
98if os.istarget("bsd") then
99 link_execinfo = true
100elseif os.istarget("linux") then
101 local _, link_errorCode = os.outputof(cc .. " ./tests/execinfo.c -o /dev/null")
102 if link_errorCode ~= 0 then
103 link_execinfo = true
104 end
105end
106
107-- Set up the Workspace
108workspace "pyrogenesis"
109targetdir(rootdir.."/binaries/system")
110libdirs(rootdir.."/binaries/system")
111if not _OPTIONS["outpath"] then
112 error("You must specify the 'outpath' parameter")
113end
114location(_OPTIONS["outpath"])
115configurations { "Release", "Debug" }
116
117source_root = rootdir.."/source/" -- default for most projects - overridden by local in others
118
119-- Rationale: projects should not have any additional include paths except for
120-- those required by external libraries. Instead, we should always write the
121-- full relative path, e.g. #include "maths/Vector3d.h". This avoids confusion
122-- ("which file is meant?") and avoids enormous include path lists.
123
124
125-- projects: engine static libs, main exe, atlas, atlas frontends, test.
126
127--------------------------------------------------------------------------------
128-- project helper functions
129--------------------------------------------------------------------------------
130
131function project_set_target(project_name)
132
133 -- Note: On Windows, ".exe" is added on the end, on unices the name is used directly
134
135 local obj_dir_prefix = _OPTIONS["outpath"].."/obj/"..project_name.."_"
136
137 filter "Debug"
138 objdir(obj_dir_prefix.."Debug")
139 targetsuffix("_dbg")
140
141 filter "Release"
142 objdir(obj_dir_prefix.."Release")
143
144 filter { }
145
146end
147
148
149function project_set_build_flags()
150
151 editandcontinue "Off"
152
153 if not _OPTIONS["minimal-flags"] then
154 symbols "On"
155 end
156
157 if cc ~= "icc" and (os.istarget("windows") or not _OPTIONS["minimal-flags"]) then
158 -- adds the -Wall compiler flag
159 warnings "Extra" -- this causes far too many warnings/remarks on ICC
160 end
161
162 -- disable Windows debug heap, since it makes malloc/free hugely slower when
163 -- running inside a debugger
164 if os.istarget("windows") then
165 debugenvs { "_NO_DEBUG_HEAP=1" }
166 end
167
168 filter "Debug"
169 defines { "DEBUG" }
170
171 filter "Release"
172 if os.istarget("windows") or not _OPTIONS["minimal-flags"] then
173 optimize "Speed"
174 end
175 defines { "NDEBUG", "CONFIG_FINAL=1" }
176
177 filter { }
178
179 if _OPTIONS["gles"] then
180 defines { "CONFIG2_GLES=1" }
181 end
182
183 if _OPTIONS["wgpu"] then
184 defines { "CONFIG2_WGPU=1" }
185 end
186
187 if _OPTIONS["without-audio"] then
188 defines { "CONFIG2_AUDIO=0" }
189 end
190
191 if _OPTIONS["without-nvtt"] then
192 defines { "CONFIG2_NVTT=0" }
193 end
194
195 if _OPTIONS["without-lobby"] then
196 defines { "CONFIG2_LOBBY=0" }
197 end
198
199 if _OPTIONS["without-miniupnpc"] then
200 defines { "CONFIG2_MINIUPNPC=0" }
201 end
202
203 -- required for the lowlevel library. must be set from all projects that use it, otherwise it assumes it is
204 -- being used as a DLL (which is currently not the case in 0ad)
205 defines { "LIB_STATIC_LINK" }
206
207 -- various platform-specific build flags
208 if os.istarget("windows") then
209
210 flags { "MultiProcessorCompile" }
211
212 -- use native wchar_t type (not typedef to unsigned short)
213 nativewchar "on"
214
215 else -- *nix
216
217 -- TODO, FIXME: This check is incorrect because it means that some additional flags will be added inside the "else" branch if the
218 -- compiler is ICC and minimal-flags is specified (ticket: #2994)
219 if cc == "icc" and not _OPTIONS["minimal-flags"] then
220 buildoptions {
221 "-w1",
222 -- "-Wabi",
223 -- "-Wp64", -- complains about OBJECT_TO_JSVAL which is annoying
224 "-Wpointer-arith",
225 "-Wreturn-type",
226 -- "-Wshadow",
227 "-Wuninitialized",
228 "-Wunknown-pragmas",
229 "-Wunused-function",
230 "-wd1292" -- avoid lots of 'attribute "__nonnull__" ignored'
231 }
232 filter "Debug"
233 buildoptions { "-O0" } -- ICC defaults to -O2
234 filter { }
235 if os.istarget("macosx") then
236 linkoptions { "-multiply_defined","suppress" }
237 end
238 else
239 -- exclude most non-essential build options for minimal-flags
240 if not _OPTIONS["minimal-flags"] then
241 buildoptions {
242 -- enable most of the standard warnings
243 "-Wno-switch", -- enumeration value not handled in switch (this is sometimes useful, but results in lots of noise)
244 "-Wno-reorder", -- order of initialization list in constructors (lots of noise)
245 "-Wno-invalid-offsetof", -- offsetof on non-POD types (see comment in renderer/PatchRData.cpp)
246
247 "-Wextra",
248 "-Wno-missing-field-initializers", -- (this is common in external headers we can't fix)
249
250 -- add some other useful warnings that need to be enabled explicitly
251 "-Wunused-parameter",
252 "-Wredundant-decls", -- (useful for finding some multiply-included header files)
253 -- "-Wformat=2", -- (useful sometimes, but a bit noisy, so skip it by default)
254 -- "-Wcast-qual", -- (useful for checking const-correctness, but a bit noisy, so skip it by default)
255 "-Wnon-virtual-dtor", -- (sometimes noisy but finds real bugs)
256 "-Wundef", -- (useful for finding macro name typos)
257
258 -- enable security features (stack checking etc) that shouldn't have
259 -- a significant effect on performance and can catch bugs
260 "-fstack-protector-all",
261 "-U_FORTIFY_SOURCE", -- (avoid redefinition warning if already defined)
262 "-D_FORTIFY_SOURCE=2",
263
264 -- always enable strict aliasing (useful in debug builds because of the warnings)
265 "-fstrict-aliasing",
266
267 -- don't omit frame pointers (for now), because performance will be impacted
268 -- negatively by the way this breaks profilers more than it will be impacted
269 -- positively by the optimisation
270 "-fno-omit-frame-pointer"
271 }
272
273 if not _OPTIONS["without-pch"] then
274 buildoptions {
275 -- do something (?) so that ccache can handle compilation with PCH enabled
276 -- (ccache 3.1+ also requires CCACHE_SLOPPINESS=time_macros for this to work)
277 "-fpch-preprocess"
278 }
279 end
280
281 if os.istarget("linux") or os.istarget("bsd") then
282 buildoptions { "-fPIC" }
283 linkoptions { "-Wl,--no-undefined", "-Wl,--as-needed", "-Wl,-z,relro" }
284 end
285
286 if arch == "x86" then
287 buildoptions {
288 -- To support intrinsics like __sync_bool_compare_and_swap on x86
289 -- we need to set -march to something that supports them (i686).
290 -- We use pentium3 to also enable other features like mmx and sse,
291 -- while tuning for generic to have good performance on every
292 -- supported CPU.
293 -- Note that all these features are already supported on amd64.
294 "-march=pentium3 -mtune=generic"
295 }
296 end
297 end
298
299 buildoptions {
300 -- Enable C++11 standard.
301 "-std=c++0x"
302 }
303
304 if arch == "arm" then
305 -- disable warnings about va_list ABI change and use
306 -- compile-time flags for futher configuration.
307 buildoptions { "-Wno-psabi" }
308 if _OPTIONS["android"] then
309 -- Android uses softfp, so we should too.
310 buildoptions { "-mfloat-abi=softfp" }
311 end
312 end
313
314 if _OPTIONS["coverage"] then
315 buildoptions { "-fprofile-arcs", "-ftest-coverage" }
316 links { "gcov" }
317 end
318
319 -- We don't want to require SSE2 everywhere yet, but OS X headers do
320 -- require it (and Intel Macs always have it) so enable it here
321 if os.istarget("macosx") then
322 buildoptions { "-msse2" }
323 end
324
325 -- Check if SDK path should be used
326 if _OPTIONS["sysroot"] then
327 buildoptions { "-isysroot " .. _OPTIONS["sysroot"] }
328 linkoptions { "-Wl,-syslibroot," .. _OPTIONS["sysroot"] }
329 end
330
331 -- On OS X, sometimes we need to specify the minimum API version to use
332 if _OPTIONS["macosx-version-min"] then
333 buildoptions { "-mmacosx-version-min=" .. _OPTIONS["macosx-version-min"] }
334 -- clang and llvm-gcc look at mmacosx-version-min to determine link target
335 -- and CRT version, and use it to set the macosx_version_min linker flag
336 linkoptions { "-mmacosx-version-min=" .. _OPTIONS["macosx-version-min"] }
337 end
338
339 -- Check if we're building a bundle
340 if _OPTIONS["macosx-bundle"] then
341 defines { "BUNDLE_IDENTIFIER=" .. _OPTIONS["macosx-bundle"] }
342 end
343
344 -- On OS X, force using libc++ since it has better C++11 support,
345 -- now required by the game
346 if os.istarget("macosx") then
347 buildoptions { "-stdlib=libc++" }
348 linkoptions { "-stdlib=libc++" }
349 end
350 end
351
352 buildoptions {
353 -- Hide symbols in dynamic shared objects by default, for efficiency and for equivalence with
354 -- Windows - they should be exported explicitly with __attribute__ ((visibility ("default")))
355 "-fvisibility=hidden"
356 }
357
358 if _OPTIONS["bindir"] then
359 defines { "INSTALLED_BINDIR=" .. _OPTIONS["bindir"] }
360 end
361 if _OPTIONS["datadir"] then
362 defines { "INSTALLED_DATADIR=" .. _OPTIONS["datadir"] }
363 end
364 if _OPTIONS["libdir"] then
365 defines { "INSTALLED_LIBDIR=" .. _OPTIONS["libdir"] }
366 end
367
368 if os.istarget("linux") or os.istarget("bsd") then
369 if _OPTIONS["prefer-local-libs"] then
370 libdirs { "/usr/local/lib" }
371 end
372
373 -- To use our local shared libraries, they need to be found in the
374 -- runtime dynamic linker path. Add their path to -rpath.
375 if _OPTIONS["libdir"] then
376 linkoptions {"-Wl,-rpath," .. _OPTIONS["libdir"] }
377 else
378 -- On FreeBSD we need to allow use of $ORIGIN
379 if os.istarget("bsd") then
380 linkoptions { "-Wl,-z,origin" }
381 end
382
383 -- Adding the executable path and taking care of correct escaping
384 if _ACTION == "gmake" then
385 linkoptions { "-Wl,-rpath,'$$ORIGIN'" }
386 elseif _ACTION == "codeblocks" then
387 linkoptions { "-Wl,-R\\\\$$$ORIGIN" }
388 end
389 end
390 end
391
392 end
393end
394
395-- create a project and set the attributes that are common to all projects.
396function project_create(project_name, target_type)
397
398 project(project_name)
399 language "C++"
400 kind(target_type)
401
402 filter "action:vs2015"
403 toolset "v140_xp"
404 filter {}
405
406 filter "action:vs*"
407 buildoptions "/utf-8"
408 filter {}
409
410 project_set_target(project_name)
411 project_set_build_flags()
412end
413
414
415-- OSX creates a .app bundle if the project type of the main application is set to "WindowedApp".
416-- We don't want this because this bundle would be broken (it lacks all the resources and external dependencies, Info.plist etc...)
417-- Windows opens a console in the background if it's set to ConsoleApp, which is not what we want.
418-- I didn't check if this setting matters for linux, but WindowedApp works there.
419function get_main_project_target_type()
420 if _OPTIONS["android"] then
421 return "SharedLib"
422 elseif os.istarget("macosx") then
423 return "ConsoleApp"
424 else
425 return "WindowedApp"
426 end
427end
428
429
430-- source_root: rel_source_dirs and rel_include_dirs are relative to this directory
431-- rel_source_dirs: A table of subdirectories. All source files in these directories are added.
432-- rel_include_dirs: A table of subdirectories to be included.
433-- extra_params: table including zero or more of the following:
434-- * no_pch: If specified, no precompiled headers are used for this project.
435-- * pch_dir: If specified, this directory will be used for precompiled headers instead of the default
436-- <source_root>/pch/<projectname>/.
437-- * extra_files: table of filenames (relative to source_root) to add to project
438-- * extra_links: table of library names to add to link step
439function project_add_contents(source_root, rel_source_dirs, rel_include_dirs, extra_params)
440
441 for i,v in pairs(rel_source_dirs) do
442 local prefix = source_root..v.."/"
443 files { prefix.."*.cpp", prefix.."*.h", prefix.."*.inl", prefix.."*.js", prefix.."*.asm", prefix.."*.mm" }
444 end
445
446 -- Put the project-specific PCH directory at the start of the
447 -- include path, so '#include "precompiled.h"' will look in
448 -- there first
449 local pch_dir
450 if not extra_params["pch_dir"] then
451 pch_dir = source_root .. "pch/" .. project().name .. "/"
452 else
453 pch_dir = extra_params["pch_dir"]
454 end
455 includedirs { pch_dir }
456
457 -- Precompiled Headers
458 -- rationale: we need one PCH per static lib, since one global header would
459 -- increase dependencies. To that end, we can either include them as
460 -- "projectdir/precompiled.h", or add "source/PCH/projectdir" to the
461 -- include path and put the PCH there. The latter is better because
462 -- many projects contain several dirs and it's unclear where there the
463 -- PCH should be stored. This way is also a bit easier to use in that
464 -- source files always include "precompiled.h".
465 -- Notes:
466 -- * Visual Assist manages to use the project include path and can
467 -- correctly open these files from the IDE.
468 -- * precompiled.cpp (needed to "Create" the PCH) also goes in
469 -- the abovementioned dir.
470 if (not _OPTIONS["without-pch"] and not extra_params["no_pch"]) then
471 filter "action:vs*"
472 pchheader("precompiled.h")
473 filter "action:xcode*"
474 pchheader("../"..pch_dir.."precompiled.h")
475 filter { "action:not vs*", "action:not xcode*" }
476 pchheader(pch_dir.."precompiled.h")
477 filter {}
478 pchsource(pch_dir.."precompiled.cpp")
479 defines { "CONFIG_ENABLE_PCH=1" }
480 files { pch_dir.."precompiled.h", pch_dir.."precompiled.cpp" }
481 else
482 defines { "CONFIG_ENABLE_PCH=0" }
483 flags { "NoPCH" }
484 end
485
486 -- next is source root dir, for absolute (nonrelative) includes
487 -- (e.g. "lib/precompiled.h")
488 includedirs { source_root }
489
490 for i,v in pairs(rel_include_dirs) do
491 includedirs { source_root .. v }
492 end
493
494 if extra_params["extra_files"] then
495 for i,v in pairs(extra_params["extra_files"]) do
496 -- .rc files are only needed on Windows
497 if path.getextension(v) ~= ".rc" or os.istarget("windows") then
498 files { source_root .. v }
499 end
500 end
501 end
502
503 if extra_params["extra_links"] then
504 links { extra_params["extra_links"] }
505 end
506end
507
508
509-- Add command-line options to set up the manifest dependencies for Windows
510-- (See lib/sysdep/os/win/manifest.cpp)
511function project_add_manifest()
512 linkoptions { "\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='X86' publicKeyToken='6595b64144ccf1df'\"" }
513end
514
515--------------------------------------------------------------------------------
516-- engine static libraries
517--------------------------------------------------------------------------------
518
519-- the engine is split up into several static libraries. this eases separate
520-- distribution of those components, reduces dependencies a bit, and can
521-- also speed up builds.
522-- more to the point, it is necessary to efficiently support a separate
523-- test executable that also includes much of the game code.
524
525-- names of all static libs created. automatically added to the
526-- main app project later (see explanation at end of this file)
527static_lib_names = {}
528static_lib_names_debug = {}
529static_lib_names_release = {}
530
531-- set up one of the static libraries into which the main engine code is split.
532-- extra_params:
533-- no_default_link: If specified, linking won't be done by default.
534-- For the rest of extra_params, see project_add_contents().
535-- note: rel_source_dirs and rel_include_dirs are relative to global source_root.
536function setup_static_lib_project (project_name, rel_source_dirs, extern_libs, extra_params)
537
538 local target_type = "StaticLib"
539 project_create(project_name, target_type)
540 project_add_contents(source_root, rel_source_dirs, {}, extra_params)
541 project_add_extern_libs(extern_libs, target_type)
542
543 if not extra_params["no_default_link"] then
544 table.insert(static_lib_names, project_name)
545 end
546
547 if os.istarget("windows") then
548 rtti "off"
549 elseif os.istarget("macosx") and _OPTIONS["macosx-version-min"] then
550 xcodebuildsettings { MACOSX_DEPLOYMENT_TARGET = _OPTIONS["macosx-version-min"] }
551 end
552end
553
554function setup_third_party_static_lib_project (project_name, rel_source_dirs, extern_libs, extra_params)
555
556 setup_static_lib_project(project_name, rel_source_dirs, extern_libs, extra_params)
557 includedirs { source_root .. "third_party/" .. project_name .. "/include/" }
558end
559
560function setup_shared_lib_project (project_name, rel_source_dirs, extern_libs, extra_params)
561
562 local target_type = "SharedLib"
563 project_create(project_name, target_type)
564 project_add_contents(source_root, rel_source_dirs, {}, extra_params)
565 project_add_extern_libs(extern_libs, target_type)
566
567 if not extra_params["no_default_link"] then
568 table.insert(static_lib_names, project_name)
569 end
570
571 if os.istarget("windows") then
572 rtti "off"
573 links { "delayimp" }
574 elseif os.istarget("macosx") and _OPTIONS["macosx-version-min"] then
575 xcodebuildsettings { MACOSX_DEPLOYMENT_TARGET = _OPTIONS["macosx-version-min"] }
576 end
577end
578
579
580-- this is where the source tree is chopped up into static libs.
581-- can be changed very easily; just copy+paste a new setup_static_lib_project,
582-- or remove existing ones. static libs are automagically added to
583-- main_exe link step.
584function setup_all_libs ()
585
586 -- relative to global source_root.
587 local source_dirs = {}
588 -- names of external libraries used (see libraries_dir comment)
589 local extern_libs = {}
590
591
592 source_dirs = {
593 "network",
594 }
595 extern_libs = {
596 "spidermonkey",
597 "enet",
598 "boost", -- dragged in via server->simulation.h->random
599 }
600 if not _OPTIONS["without-miniupnpc"] then
601 table.insert(extern_libs, "miniupnpc")
602 end
603 setup_static_lib_project("network", source_dirs, extern_libs, {})
604
605 source_dirs = {
606 "rlinterface",
607 }
608 extern_libs = {
609 "boost", -- dragged in via simulation.h and scriptinterface.h
610 "spidermonkey",
611 }
612 setup_static_lib_project("rlinterface", source_dirs, extern_libs, { no_pch = 1 })
613
614 source_dirs = {
615 "third_party/tinygettext/src",
616 }
617 extern_libs = {
618 "iconv",
619 "boost",
620 }
621 setup_third_party_static_lib_project("tinygettext", source_dirs, extern_libs, { } )
622
623 -- it's an external library and we don't want to modify its source to fix warnings, so we just disable them to avoid noise in the compile output
624 filter "action:vs*"
625 buildoptions {
626 "/wd4127",
627 "/wd4309",
628 "/wd4800",
629 "/wd4100",
630 "/wd4996",
631 "/wd4099",
632 "/wd4503"
633 }
634 filter {}
635
636
637 if not _OPTIONS["without-lobby"] then
638 source_dirs = {
639 "lobby",
640 "lobby/scripting",
641 "i18n",
642 "third_party/encryption"
643 }
644
645 extern_libs = {
646 "spidermonkey",
647 "boost",
648 "enet",
649 "gloox",
650 "icu",
651 "iconv",
652 "libsodium",
653 "tinygettext"
654 }
655 setup_static_lib_project("lobby", source_dirs, extern_libs, {})
656
657 if _OPTIONS["use-shared-glooxwrapper"] and not _OPTIONS["build-shared-glooxwrapper"] then
658 table.insert(static_lib_names_debug, "glooxwrapper_dbg")
659 table.insert(static_lib_names_release, "glooxwrapper")
660 else
661 source_dirs = {
662 "lobby/glooxwrapper",
663 }
664 extern_libs = {
665 "boost",
666 "gloox",
667 }
668 if _OPTIONS["build-shared-glooxwrapper"] then
669 setup_shared_lib_project("glooxwrapper", source_dirs, extern_libs, {})
670 else
671 setup_static_lib_project("glooxwrapper", source_dirs, extern_libs, {})
672 end
673 end
674 else
675 source_dirs = {
676 "lobby/scripting",
677 "third_party/encryption"
678 }
679 extern_libs = {
680 "spidermonkey",
681 "boost",
682 "libsodium"
683 }
684 setup_static_lib_project("lobby", source_dirs, extern_libs, {})
685 files { source_root.."lobby/Globals.cpp" }
686 end
687
688
689 source_dirs = {
690 "simulation2",
691 "simulation2/components",
692 "simulation2/helpers",
693 "simulation2/scripting",
694 "simulation2/serialization",
695 "simulation2/system",
696 "simulation2/testcomponents",
697 }
698 extern_libs = {
699 "boost",
700 "opengl",
701 "spidermonkey",
702 "wgpu",
703 }
704 setup_static_lib_project("simulation2", source_dirs, extern_libs, {})
705
706
707 source_dirs = {
708 "scriptinterface",
709 "scriptinterface/third_party"
710 }
711 extern_libs = {
712 "boost",
713 "spidermonkey",
714 "valgrind",
715 "sdl",
716 }
717 setup_static_lib_project("scriptinterface", source_dirs, extern_libs, {})
718
719
720 source_dirs = {
721 "ps",
722 "ps/scripting",
723 "network/scripting",
724 "ps/GameSetup",
725 "ps/XML",
726 "soundmanager",
727 "soundmanager/data",
728 "soundmanager/items",
729 "soundmanager/scripting",
730 "maths",
731 "maths/scripting",
732 "i18n",
733 "i18n/scripting",
734 "third_party/fmt",
735 }
736 extern_libs = {
737 "spidermonkey",
738 "sdl", -- key definitions
739 "libxml2",
740 "opengl",
741 "zlib",
742 "boost",
743 "enet",
744 "libcurl",
745 "tinygettext",
746 "icu",
747 "iconv",
748 "libsodium",
749 "wgpu"
750 }
751
752 if not _OPTIONS["without-audio"] then
753 table.insert(extern_libs, "openal")
754 table.insert(extern_libs, "vorbis")
755 end
756
757 setup_static_lib_project("engine", source_dirs, extern_libs, {})
758
759
760 source_dirs = {
761 "graphics",
762 "graphics/scripting",
763 "renderer",
764 "renderer/scripting",
765 "third_party/mikktspace",
766 "third_party/ogre3d_preprocessor"
767 }
768 extern_libs = {
769 "opengl",
770 "sdl", -- key definitions
771 "spidermonkey", -- for graphics/scripting
772 "boost",
773 "wgpu"
774 }
775 if not _OPTIONS["without-nvtt"] then
776 table.insert(extern_libs, "nvtt")
777 end
778 setup_static_lib_project("graphics", source_dirs, extern_libs, {})
779
780
781 source_dirs = {
782 "tools/atlas/GameInterface",
783 "tools/atlas/GameInterface/Handlers"
784 }
785 extern_libs = {
786 "boost",
787 "sdl", -- key definitions
788 "opengl",
789 "wgpu",
790 "spidermonkey"
791 }
792 setup_static_lib_project("atlas", source_dirs, extern_libs, {})
793
794
795 source_dirs = {
796 "gui",
797 "gui/ObjectTypes",
798 "gui/ObjectBases",
799 "gui/Scripting",
800 "gui/SettingTypes",
801 "i18n"
802 }
803 extern_libs = {
804 "spidermonkey",
805 "sdl", -- key definitions
806 "opengl",
807 "boost",
808 "enet",
809 "tinygettext",
810 "icu",
811 "iconv",
812 "wgpu"
813 }
814 if not _OPTIONS["without-audio"] then
815 table.insert(extern_libs, "openal")
816 end
817 setup_static_lib_project("gui", source_dirs, extern_libs, {})
818
819
820 source_dirs = {
821 "lib",
822 "lib/adts",
823 "lib/allocators",
824 "lib/external_libraries",
825 "lib/file",
826 "lib/file/archive",
827 "lib/file/common",
828 "lib/file/io",
829 "lib/file/vfs",
830 "lib/pch",
831 "lib/posix",
832 "lib/res",
833 "lib/res/graphics",
834 "lib/sysdep",
835 "lib/tex"
836 }
837 extern_libs = {
838 "boost",
839 "sdl",
840 "openal",
841 "opengl",
842 "libpng",
843 "zlib",
844 "valgrind",
845 "cxxtest",
846 "wgpu"
847 }
848
849 -- CPU architecture-specific
850 if arch == "amd64" then
851 table.insert(source_dirs, "lib/sysdep/arch/amd64");
852 table.insert(source_dirs, "lib/sysdep/arch/x86_x64");
853 elseif arch == "x86" then
854 table.insert(source_dirs, "lib/sysdep/arch/ia32");
855 table.insert(source_dirs, "lib/sysdep/arch/x86_x64");
856 elseif arch == "arm" then
857 table.insert(source_dirs, "lib/sysdep/arch/arm");
858 elseif arch == "aarch64" then
859 table.insert(source_dirs, "lib/sysdep/arch/aarch64");
860 end
861
862 -- OS-specific
863 sysdep_dirs = {
864 linux = { "lib/sysdep/os/linux", "lib/sysdep/os/unix" },
865 -- note: RC file must be added to main_exe project.
866 -- note: don't add "lib/sysdep/os/win/aken.cpp" because that must be compiled with the DDK.
867 windows = { "lib/sysdep/os/win", "lib/sysdep/os/win/wposix", "lib/sysdep/os/win/whrt" },
868 macosx = { "lib/sysdep/os/osx", "lib/sysdep/os/unix" },
869 bsd = { "lib/sysdep/os/bsd", "lib/sysdep/os/unix", "lib/sysdep/os/unix/x" },
870 }
871 for i,v in pairs(sysdep_dirs[os.target()]) do
872 table.insert(source_dirs, v);
873 end
874
875 if os.istarget("linux") then
876 if _OPTIONS["android"] then
877 table.insert(source_dirs, "lib/sysdep/os/android")
878 else
879 table.insert(source_dirs, "lib/sysdep/os/unix/x")
880 end
881 end
882
883 -- On OSX, disable precompiled headers because C++ files and Objective-C++ files are
884 -- mixed in this project. To fix that, we would need per-file basis configuration which
885 -- is not yet supported by the gmake action in premake. We should look into using gmake2.
886 extra_params = {}
887 if os.istarget("macosx") then
888 extra_params = { no_pch = 1 }
889 end
890
891 -- runtime-library-specific
892 if _ACTION == "vs2015" then
893 table.insert(source_dirs, "lib/sysdep/rtl/msc");
894 else
895 table.insert(source_dirs, "lib/sysdep/rtl/gcc");
896 end
897
898 setup_static_lib_project("lowlevel", source_dirs, extern_libs, extra_params)
899
900
901 -- Third-party libraries that are built as part of the main project,
902 -- not built externally and then linked
903 source_dirs = {
904 "third_party/mongoose",
905 }
906 extern_libs = {
907 }
908 setup_static_lib_project("mongoose", source_dirs, extern_libs, { no_pch = 1 })
909
910
911 -- CxxTest mock function support
912 extern_libs = {
913 "boost",
914 "cxxtest",
915 }
916
917 -- 'real' implementations, to be linked against the main executable
918 -- (files are added manually and not with setup_static_lib_project
919 -- because not all files in the directory are included)
920 setup_static_lib_project("mocks_real", {}, extern_libs, { no_default_link = 1, no_pch = 1 })
921 files { "mocks/*.h", source_root.."mocks/*_real.cpp" }
922 -- 'test' implementations, to be linked against the test executable
923 setup_static_lib_project("mocks_test", {}, extern_libs, { no_default_link = 1, no_pch = 1 })
924 files { source_root.."mocks/*.h", source_root.."mocks/*_test.cpp" }
925end
926
927--------------------------------------------------------------------------------
928-- main EXE
929--------------------------------------------------------------------------------
930
931-- used for main EXE as well as test
932used_extern_libs = {
933 "opengl",
934 "sdl",
935 "wgpu",
936
937 "libpng",
938 "zlib",
939
940 "spidermonkey",
941 "libxml2",
942
943 "boost",
944 "cxxtest",
945 "comsuppw",
946 "enet",
947 "libcurl",
948 "tinygettext",
949 "icu",
950 "iconv",
951 "libsodium",
952
953 "valgrind",
954}
955
956if not os.istarget("windows") and not _OPTIONS["android"] and not os.istarget("macosx") then
957 -- X11 should only be linked on *nix
958 table.insert(used_extern_libs, "x11")
959 table.insert(used_extern_libs, "xcursor")
960end
961
962if not _OPTIONS["without-audio"] then
963 table.insert(used_extern_libs, "openal")
964 table.insert(used_extern_libs, "vorbis")
965end
966
967if not _OPTIONS["without-nvtt"] then
968 table.insert(used_extern_libs, "nvtt")
969end
970
971if not _OPTIONS["without-lobby"] then
972 table.insert(used_extern_libs, "gloox")
973end
974
975if not _OPTIONS["without-miniupnpc"] then
976 table.insert(used_extern_libs, "miniupnpc")
977end
978
979-- Bundles static libs together with main.cpp and builds game executable.
980function setup_main_exe ()
981
982 local target_type = get_main_project_target_type()
983 project_create("pyrogenesis", target_type)
984
985 filter "system:not macosx"
986 linkgroups 'On'
987 filter {}
988
989 links { "mocks_real" }
990
991 local extra_params = {
992 extra_files = { "main.cpp" },
993 no_pch = 1
994 }
995 project_add_contents(source_root, {}, {}, extra_params)
996 project_add_extern_libs(used_extern_libs, target_type)
997
998 dependson { "Collada" }
999
1000 -- Platform Specifics
1001 if os.istarget("windows") then
1002
1003 files { source_root.."lib/sysdep/os/win/icon.rc" }
1004 -- from "lowlevel" static lib; must be added here to be linked in
1005 files { source_root.."lib/sysdep/os/win/error_dialog.rc" }
1006
1007 rtti "off"
1008
1009 linkoptions {
1010 -- wraps main thread in a __try block(see wseh.cpp). replace with mainCRTStartup if that's undesired.
1011 "/ENTRY:wseh_EntryPoint",
1012
1013 -- see wstartup.h
1014 "/INCLUDE:_wstartup_InitAndRegisterShutdown",
1015
1016 -- allow manual unload of delay-loaded DLLs
1017 "/DELAY:UNLOAD",
1018 }
1019
1020 -- allow the executable to use more than 2GB of RAM.
1021 -- this should not be enabled during development, so that memory issues are easily spotted.
1022 if _OPTIONS["large-address-aware"] then
1023 linkoptions { "/LARGEADDRESSAWARE" }
1024 end
1025
1026 -- see manifest.cpp
1027 project_add_manifest()
1028
1029 elseif os.istarget("linux") or os.istarget("bsd") then
1030
1031 if not _OPTIONS["android"] and not (os.getversion().description == "OpenBSD") then
1032 links { "rt" }
1033 end
1034
1035 if _OPTIONS["android"] then
1036 -- NDK's STANDALONE-TOOLCHAIN.html says this is required
1037 linkoptions { "-Wl,--fix-cortex-a8" }
1038
1039 links { "log" }
1040 end
1041
1042 if link_execinfo then
1043 links {
1044 "execinfo"
1045 }
1046 end
1047
1048 if os.istarget("linux") or os.getversion().description == "GNU/kFreeBSD" then
1049 links {
1050 -- Dynamic libraries (needed for linking for gold)
1051 "dl",
1052 }
1053 end
1054
1055 -- Threading support
1056 buildoptions { "-pthread" }
1057 if not _OPTIONS["android"] then
1058 linkoptions { "-pthread" }
1059 end
1060
1061 -- For debug_resolve_symbol
1062 filter "Debug"
1063 linkoptions { "-rdynamic" }
1064 filter { }
1065
1066 elseif os.istarget("macosx") then
1067
1068 links { "pthread" }
1069 links { "ApplicationServices.framework", "Cocoa.framework", "CoreFoundation.framework" }
1070 if _OPTIONS["macosx-version-min"] then
1071 xcodebuildsettings { MACOSX_DEPLOYMENT_TARGET = _OPTIONS["macosx-version-min"] }
1072 end
1073 end
1074end
1075
1076
1077--------------------------------------------------------------------------------
1078-- atlas
1079--------------------------------------------------------------------------------
1080
1081-- setup a typical Atlas component project
1082-- extra_params, rel_source_dirs and rel_include_dirs: as in project_add_contents;
1083function setup_atlas_project(project_name, target_type, rel_source_dirs, rel_include_dirs, extern_libs, extra_params)
1084
1085 local source_root = rootdir.."/source/tools/atlas/" .. project_name .. "/"
1086 project_create(project_name, target_type)
1087
1088 -- if not specified, the default for atlas pch files is in the project root.
1089 if not extra_params["pch_dir"] then
1090 extra_params["pch_dir"] = source_root
1091 end
1092
1093 project_add_contents(source_root, rel_source_dirs, rel_include_dirs, extra_params)
1094 project_add_extern_libs(extern_libs, target_type)
1095
1096 -- Platform Specifics
1097 if os.istarget("windows") then
1098 -- Link to required libraries
1099 links { "winmm", "comctl32", "rpcrt4", "delayimp", "ws2_32" }
1100
1101 elseif os.istarget("linux") or os.istarget("bsd") then
1102 buildoptions { "-rdynamic", "-fPIC" }
1103 linkoptions { "-fPIC", "-rdynamic" }
1104
1105 -- warnings triggered by wxWidgets
1106 buildoptions { "-Wno-unused-local-typedefs" }
1107
1108 elseif os.istarget("macosx") then
1109 -- install_name settings aren't really supported yet by premake, but there are plans for the future.
1110 -- we currently use this hack to work around some bugs with wrong install_names.
1111 if target_type == "SharedLib" then
1112 if _OPTIONS["macosx-bundle"] then
1113 -- If we're building a bundle, it will be in ../Frameworks
1114 filter "Debug"
1115 linkoptions { "-install_name @executable_path/../Frameworks/lib"..project_name.."_dbg.dylib" }
1116 filter "Release"
1117 linkoptions { "-install_name @executable_path/../Frameworks/lib"..project_name..".dylib" }
1118 filter { }
1119 else
1120 filter "Debug"
1121 linkoptions { "-install_name @executable_path/lib"..project_name.."_dbg.dylib" }
1122 filter "Release"
1123 linkoptions { "-install_name @executable_path/lib"..project_name..".dylib" }
1124 filter { }
1125 end
1126 end
1127 end
1128
1129end
1130
1131
1132-- build all Atlas component projects
1133function setup_atlas_projects()
1134
1135 setup_atlas_project("AtlasObject", "StaticLib",
1136 { -- src
1137 ".",
1138 "../../../third_party/jsonspirit"
1139
1140 },{ -- include
1141 "../../../third_party/jsonspirit"
1142 },{ -- extern_libs
1143 "boost",
1144 "iconv",
1145 "libxml2"
1146 },{ -- extra_params
1147 no_pch = 1
1148 })
1149
1150 atlas_src = {
1151 "ActorEditor",
1152 "CustomControls/Buttons",
1153 "CustomControls/Canvas",
1154 "CustomControls/ColorDialog",
1155 "CustomControls/DraggableListCtrl",
1156 "CustomControls/EditableListCtrl",
1157 "CustomControls/FileHistory",
1158 "CustomControls/HighResTimer",
1159 "CustomControls/MapDialog",
1160 "CustomControls/MapResizeDialog",
1161 "CustomControls/SnapSplitterWindow",
1162 "CustomControls/VirtualDirTreeCtrl",
1163 "CustomControls/Windows",
1164 "General",
1165 "General/VideoRecorder",
1166 "Misc",
1167 "ScenarioEditor",
1168 "ScenarioEditor/Sections/Common",
1169 "ScenarioEditor/Sections/Cinema",
1170 "ScenarioEditor/Sections/Environment",
1171 "ScenarioEditor/Sections/Map",
1172 "ScenarioEditor/Sections/Object",
1173 "ScenarioEditor/Sections/Player",
1174 "ScenarioEditor/Sections/Terrain",
1175 "ScenarioEditor/Tools",
1176 "ScenarioEditor/Tools/Common",
1177 }
1178 atlas_extra_links = {
1179 "AtlasObject"
1180 }
1181
1182 atlas_extern_libs = {
1183 "boost",
1184 "comsuppw",
1185 "iconv",
1186 "libxml2",
1187 "sdl", -- key definitions
1188 "wxwidgets",
1189 "zlib",
1190 }
1191 if not os.istarget("windows") and not os.istarget("macosx") then
1192 -- X11 should only be linked on *nix
1193 table.insert(atlas_extern_libs, "x11")
1194 end
1195
1196 setup_atlas_project("AtlasUI", "SharedLib", atlas_src,
1197 { -- include
1198 "..",
1199 "CustomControls",
1200 "Misc",
1201 "../../../third_party/jsonspirit"
1202 },
1203 atlas_extern_libs,
1204 { -- extra_params
1205 pch_dir = rootdir.."/source/tools/atlas/AtlasUI/Misc/",
1206 no_pch = false,
1207 extra_links = atlas_extra_links,
1208 extra_files = { "Misc/atlas.rc" }
1209 })
1210end
1211
1212
1213-- Atlas 'frontend' tool-launching projects
1214function setup_atlas_frontend_project (project_name)
1215
1216 local target_type = get_main_project_target_type()
1217 project_create(project_name, target_type)
1218
1219 local source_root = rootdir.."/source/tools/atlas/AtlasFrontends/"
1220 files { source_root..project_name..".cpp" }
1221
1222 if os.istarget("windows") then
1223 files { source_root..project_name..".rc" }
1224 end
1225
1226 includedirs { source_root .. ".." }
1227
1228 -- Platform Specifics
1229 if os.istarget("windows") then
1230 -- see manifest.cpp
1231 project_add_manifest()
1232
1233 else -- Non-Windows, = Unix
1234 links { "AtlasObject" }
1235 end
1236
1237 links { "AtlasUI" }
1238
1239end
1240
1241function setup_atlas_frontends()
1242 setup_atlas_frontend_project("ActorEditor")
1243end
1244
1245
1246--------------------------------------------------------------------------------
1247-- collada
1248--------------------------------------------------------------------------------
1249
1250function setup_collada_project(project_name, target_type, rel_source_dirs, rel_include_dirs, extern_libs, extra_params)
1251
1252 project_create(project_name, target_type)
1253 local source_root = source_root.."collada/"
1254 extra_params["pch_dir"] = source_root
1255 project_add_contents(source_root, rel_source_dirs, rel_include_dirs, extra_params)
1256 project_add_extern_libs(extern_libs, target_type)
1257
1258 -- Platform Specifics
1259 if os.istarget("windows") then
1260 characterset "MBCS"
1261 elseif os.istarget("linux") then
1262 defines { "LINUX" }
1263
1264 links {
1265 "dl",
1266 }
1267
1268 -- FCollada is not aliasing-safe, so disallow dangerous optimisations
1269 -- (TODO: It'd be nice to fix FCollada, but that looks hard)
1270 buildoptions { "-fno-strict-aliasing" }
1271
1272 buildoptions { "-rdynamic" }
1273 linkoptions { "-rdynamic" }
1274
1275 elseif os.istarget("bsd") then
1276 if os.getversion().description == "OpenBSD" then
1277 links { "c", }
1278 end
1279
1280 if os.getversion().description == "GNU/kFreeBSD" then
1281 links {
1282 "dl",
1283 }
1284 end
1285
1286 buildoptions { "-fno-strict-aliasing" }
1287
1288 buildoptions { "-rdynamic" }
1289 linkoptions { "-rdynamic" }
1290
1291 elseif os.istarget("macosx") then
1292 -- define MACOS-something?
1293
1294 -- install_name settings aren't really supported yet by premake, but there are plans for the future.
1295 -- we currently use this hack to work around some bugs with wrong install_names.
1296 if target_type == "SharedLib" then
1297 if _OPTIONS["macosx-bundle"] then
1298 -- If we're building a bundle, it will be in ../Frameworks
1299 linkoptions { "-install_name @executable_path/../Frameworks/lib"..project_name..".dylib" }
1300 else
1301 linkoptions { "-install_name @executable_path/lib"..project_name..".dylib" }
1302 end
1303 end
1304
1305 buildoptions { "-fno-strict-aliasing" }
1306 -- On OSX, fcollada uses a few utility functions from coreservices
1307 links { "CoreServices.framework" }
1308 end
1309
1310end
1311
1312-- build all Collada component projects
1313function setup_collada_projects()
1314
1315 setup_collada_project("Collada", "SharedLib",
1316 { -- src
1317 "."
1318 },{ -- include
1319 },{ -- extern_libs
1320 "fcollada",
1321 "iconv",
1322 "libxml2"
1323 },{ -- extra_params
1324 })
1325
1326end
1327
1328
1329--------------------------------------------------------------------------------
1330-- tests
1331--------------------------------------------------------------------------------
1332
1333function setup_tests()
1334
1335 local cxxtest = require "cxxtest"
1336
1337 if os.istarget("windows") then
1338 cxxtest.setpath(rootdir.."/build/bin/cxxtestgen.exe")
1339 else
1340 cxxtest.setpath(rootdir.."/libraries/source/cxxtest-4.4/bin/cxxtestgen")
1341 end
1342
1343 local runner = "ErrorPrinter"
1344 if _OPTIONS["jenkins-tests"] then
1345 runner = "XmlPrinter"
1346 end
1347
1348 local includefiles = {
1349 -- Precompiled headers - the header is added to all generated .cpp files
1350 -- note that the header isn't actually precompiled here, only #included
1351 -- so that the build stage can use it as a precompiled header.
1352 "precompiled.h",
1353 -- This is required to build against SDL 2.0.4 on Windows.
1354 "lib/external_libraries/libsdl.h",
1355 }
1356
1357 cxxtest.init(source_root, true, runner, includefiles)
1358
1359 local target_type = get_main_project_target_type()
1360 project_create("test", target_type)
1361
1362 -- Find header files in 'test' subdirectories
1363 local all_files = os.matchfiles(source_root .. "**/tests/*.h")
1364 local test_files = {}
1365 for i,v in pairs(all_files) do
1366 -- Don't include sysdep tests on the wrong sys
1367 -- Don't include Atlas tests unless Atlas is being built
1368 if not (string.find(v, "/sysdep/os/win/") and not os.istarget("windows")) and
1369 not (string.find(v, "/tools/atlas/") and not _OPTIONS["atlas"]) and
1370 not (string.find(v, "/sysdep/arch/x86_x64/") and ((arch ~= "amd64") or (arch ~= "x86")))
1371 then
1372 table.insert(test_files, v)
1373 end
1374 end
1375
1376 cxxtest.configure_project(test_files)
1377
1378 filter "system:not macosx"
1379 linkgroups 'On'
1380 filter {}
1381
1382 links { static_lib_names }
1383 filter "Debug"
1384 links { static_lib_names_debug }
1385 filter "Release"
1386 links { static_lib_names_release }
1387 filter { }
1388
1389 links { "mocks_test" }
1390 if _OPTIONS["atlas"] then
1391 links { "AtlasObject" }
1392 end
1393 extra_params = {
1394 extra_files = { "test_setup.cpp" },
1395 }
1396
1397 project_add_contents(source_root, {}, {}, extra_params)
1398 project_add_extern_libs(used_extern_libs, target_type)
1399
1400 dependson { "Collada" }
1401
1402 -- TODO: should fix the duplication between this OS-specific linking
1403 -- code, and the similar version in setup_main_exe
1404
1405 if os.istarget("windows") then
1406 -- from "lowlevel" static lib; must be added here to be linked in
1407 files { source_root.."lib/sysdep/os/win/error_dialog.rc" }
1408
1409 rtti "off"
1410
1411 -- see wstartup.h
1412 linkoptions { "/INCLUDE:_wstartup_InitAndRegisterShutdown" }
1413 -- Enables console for the TEST project on Windows
1414 linkoptions { "/SUBSYSTEM:CONSOLE" }
1415
1416 project_add_manifest()
1417
1418 elseif os.istarget("linux") or os.istarget("bsd") then
1419
1420 if link_execinfo then
1421 links {
1422 "execinfo"
1423 }
1424 end
1425 if not _OPTIONS["android"] and not (os.getversion().description == "OpenBSD") then
1426 links { "rt" }
1427 end
1428
1429 if _OPTIONS["android"] then
1430 -- NDK's STANDALONE-TOOLCHAIN.html says this is required
1431 linkoptions { "-Wl,--fix-cortex-a8" }
1432 end
1433
1434 if os.istarget("linux") or os.getversion().description == "GNU/kFreeBSD" then
1435 links {
1436 -- Dynamic libraries (needed for linking for gold)
1437 "dl",
1438 }
1439 end
1440
1441 -- Threading support
1442 buildoptions { "-pthread" }
1443 if not _OPTIONS["android"] then
1444 linkoptions { "-pthread" }
1445 end
1446
1447 -- For debug_resolve_symbol
1448 filter "Debug"
1449 linkoptions { "-rdynamic" }
1450 filter { }
1451
1452 includedirs { source_root .. "pch/test/" }
1453
1454 elseif os.istarget("macosx") and _OPTIONS["macosx-version-min"] then
1455 xcodebuildsettings { MACOSX_DEPLOYMENT_TARGET = _OPTIONS["macosx-version-min"] }
1456 end
1457end
1458
1459-- must come first, so that VC sets it as the default project and therefore
1460-- allows running via F5 without the "where is the EXE" dialog.
1461setup_main_exe()
1462
1463setup_all_libs()
1464
1465-- add the static libs to the main EXE project. only now (after
1466-- setup_all_libs has run) are the lib names known. cannot move
1467-- setup_main_exe to run after setup_all_libs (see comment above).
1468-- we also don't want to hardcode the names - that would require more
1469-- work when changing the static lib breakdown.
1470project("pyrogenesis") -- Set the main project active
1471 links { static_lib_names }
1472 filter "Debug"
1473 links { static_lib_names_debug }
1474 filter "Release"
1475 links { static_lib_names_release }
1476 filter { }
1477
1478if _OPTIONS["atlas"] then
1479 setup_atlas_projects()
1480 setup_atlas_frontends()
1481end
1482
1483setup_collada_projects()
1484
1485if not _OPTIONS["without-tests"] then
1486 setup_tests()
1487end
1488