forked from GPUOpen-LibrariesAndSDKs/RadeonRays_SDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
premake5.lua
213 lines (172 loc) · 4.47 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
function fileExists(name)
local f=io.open(name,"r")
if f~=nil then io.close(f) return true else return false end
end
newoption {
trigger = "embed_kernels",
description = "Embed CL kernels into binary module"
}
newoption {
trigger = "allow_cpu_devices",
description = "Allows CPU Devices"
}
newoption {
trigger = "use_opencl",
description = "Use OpenCL for GPU hit testing"
}
newoption {
trigger = "use_embree",
description = "Use Intel(R) Embree for CPU hit testing"
}
newoption {
trigger = "use_vulkan",
description = "Use vulkan for GPU hit testing"
}
newoption {
trigger = "no_tests",
description = "Don't add any unit tests and remove any test functionality from the library"
}
newoption {
trigger = "static_library",
description = "Create static libraries rather than dynamic"
}
newoption {
trigger = "shared_calc",
description = "Link Calc(compute abstraction layer) dynamically"
}
newoption {
trigger = "enable_raymask",
description = "Enable ray masking in intersection kernels"
}
newoption {
trigger = "tutorials",
description = "Add tutorials projects"
}
newoption {
trigger = "safe_math",
description = "use safe math"
}
if not _OPTIONS["use_opencl"] and not _OPTIONS["use_vulkan"] and not _OPTIONS["use_embree"] then
_OPTIONS["use_opencl"] = 1
end
if _OPTIONS["shared_calc"] and _OPTIONS["use_vulkan"] then
print ">>Error: shared_calc option is not yet supported for Vulkan backend"
return -1
end
if _OPTIONS["shared_calc"] then
print ">> Building Calc as a shared library"
end
if _OPTIONS["use_embree"] then
print ">> Embree backend enabled"
end
function build(config)
if os.is("windows") then
buildcmd="devenv RadeonRays.sln /build \"" .. config .. "|x64\""
else
config=config .. "_x64"
buildcmd="make config=" .. config
end
return os.execute(buildcmd)
end
solution "RadeonRays"
configurations { "Debug", "Release" }
platforms {"x64"}
language "C++"
flags { "NoMinimalRebuild", "EnableSSE", "EnableSSE2" }
if( _OPTIONS["static_library"]) then
defines{ "RR_STATIC_LIBRARY=1" }
print ">> Building Radeon Rays as a static library";
end
if _OPTIONS["use_opencl"] then
print ">> OpenCL backend enabled"
-- find and add path to Opencl headers
dofile ("./OpenCLSearch.lua" )
end
-- define common includes
includedirs { ".","./3rdParty/include" }
if not _OPTIONS["no_tests"] then
defines{"PRORAY_UNITTEST=1"}
end
-- perform OS specific initializations
local targetName;
if os.is("macosx") then
targetName = "osx"
end
if os.is("windows") then
targetName = "win"
defines{ "WIN32" }
buildoptions { "/MP" } --multiprocessor build
defines {"_CRT_SECURE_NO_WARNINGS"}
elseif os.is("linux") then
buildoptions {"-fvisibility=hidden"}
end
if _OPTIONS["use_opencl"] then
defines{"USE_OPENCL=1"}
end
if _OPTIONS["use_vulkan"] then
print ">> Vulkan backend enabled"
defines{"USE_VULKAN=1"}
vulkanPath = ""
vulkanSDKPath = os.getenv( "VK_SDK_PATH" );
if vulkanSDKPath == nil then
vulkanSDKPath = os.getenv( "VULKAN_SDK" );
end
if vulkanSDKPath ~= nil then
if os.is("linux") then
vulkanPath = vulkanSDKPath .. "/include"
else
vulkanPath = vulkanSDKPath .. "/Include"
end
end
includedirs { "./Anvil",
"./Anvil/deps",
"./Anvil/include",
"./Anvil_premake",
vulkanPath }
end
--make configuration specific definitions
configuration "Debug"
defines { "_DEBUG" }
flags { "Symbols" }
configuration "Release"
defines { "NDEBUG" }
flags { "Optimize" }
configuration {"x64", "Debug"}
targetsuffix "64D"
configuration {"x32", "Debug"}
targetsuffix "D"
configuration {"x64", "Release"}
targetsuffix "64"
configuration {} -- back to all configurations
if _OPTIONS["use_vulkan"] then
if fileExists("./Anvil_premake/anvil.lua") then
dofile("./Anvil_premake/anvil.lua")
end
end
if _OPTIONS["safe_math"] then
defines { "USE_SAFE_MATH" }
end
if fileExists("./RadeonRays/RadeonRays.lua") then
dofile("./RadeonRays/RadeonRays.lua")
end
if fileExists("./Calc/Calc.lua") then
dofile("./Calc/Calc.lua")
end
if _OPTIONS["use_opencl"] then
if fileExists("./CLW/CLW.lua") then
dofile("./CLW/CLW.lua")
end
end
if not _OPTIONS["no_tests"] then
if fileExists("./Gtest/gtest.lua") then
dofile("./Gtest/gtest.lua")
end
if fileExists("./UnitTest/UnitTest.lua") then
dofile("./UnitTest/UnitTest.lua")
end
end
if _OPTIONS["tutorials"] then
if fileExists("./Tutorials/Tutorials.lua") then
dofile("./Tutorials/Tutorials.lua")
end
end