forked from paulftw/hiberlite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
premake4.lua
149 lines (131 loc) · 3.63 KB
/
premake4.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
local OS=os.get()
local settings = {
dir = {
linux = "ls",
windows = "dir"
},
gcc_link = {
linux = { "dl" , "pthread" },
windows = {}
}
}
function print_table(t)
print "-----------------"
assert(type(t)=='table')
for k,v in pairs(t) do
print(k,v)
end
end
function merge_tables(...)
local t = {}
for n = 1,select("#",...) do
local arg = select(n,...)
if type(arg)=="table" then
for k,v in pairs(arg) do
t[#t+1] = v
end
else
t[#t+1] = arg
end
end
return t
end
local Settings={}
for i,v in pairs(settings) do
Settings[i]=settings[i][OS]
end
-- Apply to current "filter" (solution/project)
function DefaultConfig()
location "Build"
language "C++"
configuration "Debug"
defines { "DEBUG", "_DEBUG" }
objdir "Build/obj"
flags { "Symbols" }
configuration "Release"
defines { "RELEASE" }
objdir "Build/obj"
flags { "Optimize" }
configuration "*" -- to reset configuration filter
end
function CompilerSpecificFlags()
configuration { "vs*"}
defines {
"_CRT_SECURE_NO_DEPRECATE",
"_CRT_NONSTDC_NO_DEPRECATE"
}
configuration {"gmake"}
buildoptions { "-v -std=c++0x" }
configuration "*" -- to reset configuration filter
end
function CompilerSpecificPostBuildEvent()
configuration {"xcode*" }
postbuildcommands {"$TARGET_BUILD_DIR/$TARGET_NAME"}
configuration {"gmake"}
postbuildcommands { "$(TARGET)" }
configuration {"codeblocks" }
postbuildcommands { "$(TARGET_OUTPUT_FILE)"}
configuration { "vs*"}
postbuildcommands { "\"$(TargetPath)\"" }
configuration "*" -- to reset configuration filter
end
----------------------------------------------------------------------------------------------------------------
-- A solution contains projects, and defines the available configurations
local sln=solution "hiberlite"
location "Build"
sln.absbasedir=path.getabsolute(sln.basedir)
configurations { "Debug", "Release" }
platforms { "native","x32", "x64" }
libdirs { }
includedirs {
[[./include]],
[[./sqlite-amalgamation]],
[[./Catch/single_include]]
}
vpaths {
["Headers"] = {"**.h","**.hpp"},
["Sources"] = {"**.c", "**.cpp"},
}
----------------------------------------------------------------------------------------------------------------
local hiberlite=project "hiberlite"
location "Build"
kind "StaticLib"
DefaultConfig()
CompilerSpecificFlags()
files {
"./include/*.h",
"./include/*.hpp",
"./src/*.cpp",
}
----------------------------------------------------------------------------------------------------------------
local sqlite=project "sqlite"
kind "StaticLib"
DefaultConfig()
files {
"./sqlite-amalgamation/*.h",
"./sqlite-amalgamation/*.c",
}
----------------------------------------------------------------------------------------------------------------
local make_console_project=function(name,input_files,post_build_event)
project(name)
kind "ConsoleApp"
DefaultConfig()
CompilerSpecificFlags()
if type(post_build_event)=="function" then
post_build_event()
end
language "C++"
files ( input_files )
links (deps)
configuration {"gmake"}
local deps = {
"hiberlite",
"sqlite"
}
links (merge_tables( Settings.gcc_link, deps ))
configuration "*"
end
----------------------------------------------------------------------------------------------------------------
make_console_project("sample",{ "./sample.cpp" },CompilerSpecificPostBuildEvent)
make_console_project("catch_test",{ "./catch_tests.cpp" },CompilerSpecificPostBuildEvent)
make_console_project("hiberlite_test",{ "./tests.cpp" },CompilerSpecificPostBuildEvent)