-
Notifications
You must be signed in to change notification settings - Fork 0
/
premake5.lua
146 lines (119 loc) · 5.49 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
-- ex: build/Linux_debug
output_dir = "build/%{cfg.system}_%{cfg.action}_%{cfg.buildcfg}"
workspace "C++_Platform_Adventure"
configurations { "Debug", "Release" }
location "build"
targetdir(output_dir .. "/bin")
objdir(output_dir .. "/obj")
project "Game"
kind "WindowedApp"
language "C++"
-- premake doesn't support cppdialect "C++20" yet,
-- so use std option directly
-- g++-10 and clang-10 support "c++20" on Linux, but clang 11 on OSX only uses "c++2a"
buildoptions "-std=c++2a"
includedirs { "src" }
flags { "FatalWarnings" }
enablewarnings { "all" }
-- Dependency: {fmt} --
includedirs { "engine/third-party/install/fmt/include" }
libdirs {"engine/third-party/install/fmt/lib"}
links {"fmt"}
-- Dependency: SFML --
-- Unfortunately, SFML uses the convention of including its headers with <> instead of ""
-- gmake will tolerate this but Xcode will reject USER library headers include with <> unless
-- ALWAYS_SEARCH_USER_PATHS is YES (deprecated, and hardcoded to NO in premake anyway)
-- or we are using a framework (only possible when building SFML dynamically).
-- So, when building SFML statically, to support Xcode we need to use sysincludedirs
-- instead of includedirs to set HEADER_SEARCH_PATHS instead of USER_SEARCH_PATHS in Xcode.
sysincludedirs { "engine/third-party/install/SFML/include" }
libdirs {"engine/third-party/install/SFML/lib"}
-- link to static SFML libs (for GCC compatibility, make sure to put dependent libs
-- before dependees)
defines { "SFML_STATIC" }
links {"sfml-graphics-s", "sfml-window-s", "sfml-audio-s", "sfml-system-s"}
-- static linking of SFML requires linking to their own dependencies
filter { "system:windows" }
libdirs {"engine/third-party/SFML/extlibs/libs-msvc/x64"}
links {
"flac",
"ogg",
"openal32",
"vorbis",
"vorbisenc",
"vorbisfile"
}
-- on OSX, SFML deps are pre-installed in the repository, so just use them
-- frameworkdirs will work with Xcode only, so for gmake pass -F manually
-- https://github.com/premake/premake-core/issues/196
filter { "system:macosx", "action:xcode*"}
frameworkdirs {"engine/third-party/SFML/extlibs/libs-osx/Frameworks"}
filter { "system:macosx", "action:gmake*"}
-- it seems that even with gmake, OSX builds an .app, so no need to add target suffix "_OSX"
-- unlike ...dirs {}, linkoptions does not interpret paths
-- so we must enter them relatively to location "build", hence "../"
linkoptions {"-F ../engine/third-party/SFML/extlibs/libs-osx/Frameworks"}
filter { "system:macosx" }
-- to avoid undefined symbols from various frameworks used by Xcode, we link those below:
links {
-- SFML's own dependencies, OSX-specific
"AppKit.framework", -- includes CoreFoundation, CoreGraphics, etc.
"Carbon.framework", -- old, but required for _LM, _TIS and _kTIS symbols
"IOKit.framework",
-- SFML's own dependencies, generic
"OpenGL.framework",
"FLAC.framework",
"ogg.framework",
"OpenAL.framework",
"vorbis.framework",
"vorbisenc.framework",
"vorbisfile.framework"
}
filter { "system:linux" }
-- only Linux can generate extensionless executables, but we keep the target suffix
-- we prepared when we thought OSX gmake would also build one, for now
targetsuffix "_Linux"
-- on Linux, we basically use the list on https://www.sfml-dev.org/tutorials/2.5/compile-with-cmake.php
-- without freetype, changing opengl -> GL (to have GLX functions) and uppercase FLAC
-- they must be installed locally on the machine
links {
"freetype",
"X11",
"Xrandr",
"udev",
"GL",
"pthread",
"FLAC",
"ogg",
"openal",
"vorbis",
"vorbisenc",
"vorbisfile"
}
filter {}
-- Dependency: yaml-cpp --
includedirs { "engine/third-party/install/yaml-cpp/include" }
libdirs {"engine/third-party/install/yaml-cpp/lib"}
links {"yaml-cpp"}
-- add all files recursively to project
files { "src/**.h", "src/**.cpp" }
filter { "configurations:Debug" }
defines { "DEBUG" }
symbols "On"
buildoptions "-O0"
filter { "configurations:Release" }
defines { "NDEBUG" }
-- `optimize "On"` sets -O2 instead of -O3, so prefer manual options
buildoptions "-O3"
filter {}
-- Copy assets and config folders near executable
-- Note that paths are relative to location "build", so we access project root with ".." (else we'd need to use project_root = os.realpath("."))
-- (%{wks.location} and %{prj.location} are both relative to location themselves, so ".")
-- We prefer prebuild to postbuild, simply because in case of failure, the whole process fails and next time we try to build,
-- it will also try to copy again (in postbuild, the executable has already been generated and `make` does nothing on next build,
-- even if there are files to copy)
-- OSX note: this is not the standard way to do it, we should Copy Bundle Resources into the .app.
prebuildcommands {
"{MKDIR} %{cfg.targetdir}",
"{COPY} ../assets ../config %{cfg.targetdir}",
}