-
Notifications
You must be signed in to change notification settings - Fork 1
/
premake.lua
131 lines (94 loc) · 3.15 KB
/
premake.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
-- /premake5.lua
-- COURSEWORK APP PREMAKE --
function success ( name )
print ( name .. " is configured successfully!" )
end
local project_name = "CourseWork"
local config_path = "config.json"
workspace ( project_name )
architecture "x86_64"
startproject ( project_name )
configurations { "Debug", "Release" }
local config, err = json.decode ( io.readfile ( config_path ))
if not config then
print ( "\n" .. err )
os.exit()
end
root_dir = "%{wks.location}"
output_dir = "%{cfg.buildcfg}_%{cfg.system}"
bin_dir = config.dir.binaries .. "\\" .. output_dir
bininter_dir = config.dir.binaries_intermediate .. "\\" .. output_dir
local src_dir = root_dir .. "\\" .. config.dir.src
local inc_dir = root_dir .. "\\" .. config.dir.include
local deps_dir = root_dir .. "\\" .. config.dir.deps
local build_dir = root_dir .. "\\" .. config.dir.build .. "\\" .. output_dir .. "\\" .. project_name
-- Virtual dir to contain several projects
group "DEPENDENCIES"
include ( config.dir.deps .. "\\glfw.lua" )
include ( config.dir.deps .. "\\imgui.lua" )
-- 'glm' does not require compilation, it's header only
-- 'freetype' does not require compilation, it has a compiled lib & is used only inside imgui
group ""
flags {
"FatalWarnings", -- Treat all warnings as errors
"MultiProcessorCompile" -- Enable VS to use multiple compiler processes when building
}
project ( project_name )
targetname ( project_name .. " App" ) -- Executable name
kind "ConsoleApp" -- Kind of binary object created by the project (https://premake.github.io/docs/kind/)
language "C++"
cppdialect "C++latest"
staticruntime "off"
dependson {
"GLFW",
"ImGui"
}
targetdir ( root_dir .. "\\" .. bin_dir ) -- Destination dir for compiled binary target
objdir ( root_dir .. "\\" .. bininter_dir ) -- Destination dir for object and other intermediate files
-- Include file search paths for the compiler
includedirs {
src_dir,
inc_dir,
deps_dir .. "\\glfw\\include",
deps_dir .. "\\glfw\\include\\GLFW",
deps_dir .. "\\imgui",
deps_dir .. "\\glm"
}
files {
src_dir .. "\\**.h",
src_dir .. "\\**.c",
src_dir .. "\\**.hpp",
src_dir .. "\\**.cpp",
deps_dir .. "\\glm\\glm\\**.hpp",
deps_dir .. "\\glm\\glm\\**.inl",
deps_dir .. "\\imgui\\backends\\imgui_impl_glfw.cpp",
deps_dir .. "\\imgui\\backends\\imgui_impl_opengl3.cpp",
}
-- Library search paths for the linker
libdirs { deps_dir }
-- List of libraries & projects to link against
links {
"glfw\\" .. bin_dir .. "\\GLFW.lib",
"imgui\\" .. bin_dir .. "\\ImGui.lib",
"Glu32.lib",
"opengl32.lib"
}
postbuildcommands {
"python \"" .. root_dir .. config.dir.script.. "\\" .. "setup.py\" solution copy " .. build_dir
}
filter "system:windows"
systemversion "latest"
filter "system:linux"
-- links { }
filter "system:macosx"
-- links { }
filter "configurations:Debug"
defines "CW_DEBUG"
runtime "Debug"
symbols "on"
filter "configurations:Release"
defines "CW_RELEASE"
runtime "Release"
optimize "on"
filter {} -- reset filter
success ( project_name )