@@ -35,6 +35,34 @@ function loadrequire(module, linkToRepository)
35
35
end
36
36
end
37
37
38
+ function addCUDAToProject (sourceDir , objDir )
39
+ buildcustomizations " BuildCustomizations/CUDA 12.2"
40
+ -- CUDA specific properties
41
+
42
+ cudaIntDir (objDir )
43
+ cudaFiles
44
+ {
45
+ sourceDir .. " /**.cu"
46
+ }
47
+
48
+ cudaFastMath " On"
49
+ cudaRelocatableCode " On"
50
+ cudaMaxRegCount " 32"
51
+
52
+ -- Let's compile for all supported architectures (and also in parallel with -t0)
53
+ cudaCompilerOptions { " -gencode=arch=compute_52,code=sm_52" , " -gencode=arch=compute_75,code=sm_75" ,
54
+ " -gencode=arch=compute_80,code=sm_80" ,
55
+ " -gencode=arch=compute_86,code=sm_86" , " -t0" , " -Wreorder" , " -Werror=reorder" , " -err-no" , " -Xcompiler=/wd4505" }
56
+
57
+ filter " configurations:debug"
58
+ cudaLinkerOptions { " -g" , " -Xcompiler=/wd4100" }
59
+ filter {}
60
+
61
+ filter " configurations:release"
62
+ cudaFastMath " On"
63
+ filter {}
64
+ end
65
+
38
66
local root = " ./"
39
67
local pathTarget = " ../InteropUnityCUDA/Assets/Runtime/Plugin"
40
68
local pathSampleProject = " SampleBasic"
@@ -98,7 +126,8 @@ local rootProject = pathPluginInterop
98
126
location (rootProject )
99
127
language " C++"
100
128
targetdir (pathTarget , " SampleBasic" )
101
- objdir (rootProject .. " /temp/" )
129
+ local tempDir = rootProject .. " /temp/"
130
+ objdir (tempDir )
102
131
kind " SharedLib"
103
132
104
133
local SourceDir = rootProject .. " /src/" ;
@@ -142,31 +171,9 @@ links { "GL", nameUtilitiesLib }
142
171
filter {}
143
172
144
173
145
- -- Add necessary build customization using standard Premake5
146
- -- This assumes you have installed Visual Studio integration for CUDA
147
- -- Here we have it set to 11.4
148
- buildcustomizations " BuildCustomizations/CUDA 12.2"
149
- -- cudaPath "/usr/local/cuda" -- Only affects linux, because the windows builds get CUDA from the VS extension
150
-
151
- -- CUDA specific properties
152
- cudaFiles { SourceDir .. " **.cu" }
153
- cudaMaxRegCount " 32"
154
-
155
- -- Let's compile for all supported architectures (and also in parallel with -t0)
156
- cudaCompilerOptions { " -arch=sm_52" , " -gencode=arch=compute_52,code=sm_52" , " -gencode=arch=compute_60,code=sm_60" ,
157
- " -gencode=arch=compute_61,code=sm_61" , " -gencode=arch=compute_70,code=sm_70" ,
158
- " -gencode=arch=compute_75,code=sm_75" , " -gencode=arch=compute_80,code=sm_80" ,
159
- " -gencode=arch=compute_86,code=sm_86" , " -gencode=arch=compute_86,code=compute_86" , " -t0" }
160
-
161
- -- On Windows, the link to cudart is done by the CUDA extension, but on Linux, this must be done manually
162
- if os .target () == " linux" then
163
- linkoptions { " -L/usr/local/cuda/lib64 -lcudart" }
164
- end
165
-
166
- filter " configurations:release"
167
- cudaFastMath " On" -- enable fast math for release
168
- filter " "
169
-
174
+ sourceDirAbsolute = path .getabsolute (SourceDir )
175
+ objDirAbsolute = path .getabsolute (tempDir )
176
+ addCUDAToProject (sourceDirAbsolute , objDirAbsolute )
170
177
171
178
172
179
@@ -179,7 +186,8 @@ local rootProject = root .. locationProject
179
186
location (rootProject )
180
187
language " C++"
181
188
targetdir (pathTarget )
182
- objdir (rootProject .. " /temp/" )
189
+ local tempDir = rootProject .. " /temp/"
190
+ objdir (tempDir )
183
191
kind " SharedLib"
184
192
185
193
local SourceDir = rootProject .. " /src/" ;
@@ -262,7 +270,8 @@ location(rootProject)
262
270
kind " SharedLib"
263
271
language " C++"
264
272
targetdir (pathTarget )
265
- objdir (rootProject .. " /temp/" .. locationProject )
273
+ local tempDir = rootProject .. " /temp/"
274
+ objdir (tempDir )
266
275
267
276
local SourceDir = rootProject .. " /src/" ;
268
277
local IncludeDir = pathUtilitiesInclude ;
@@ -287,24 +296,6 @@ flags {}
287
296
defines { " UTILITIES_SHARED" , " UTILITIES_SHARED_EXPORTS" }
288
297
symbols " On"
289
298
290
- -- Add necessary build customization using standard Premake5
291
- -- This assumes you have installed Visual Studio integration for CUDA
292
- -- Here we have it set to 11.4
293
- buildcustomizations " BuildCustomizations/CUDA 12.2"
294
- -- cudaPath "/usr/local/cuda" -- Only affects linux, because the windows builds get CUDA from the VS extension
295
-
296
- cudaMaxRegCount " 32"
297
- -- Let's compile for all supported architectures (and also in parallel with -t0)
298
- cudaCompilerOptions { " -arch=sm_52" , " -gencode=arch=compute_52,code=sm_52" , " -gencode=arch=compute_60,code=sm_60" ,
299
- " -gencode=arch=compute_61,code=sm_61" , " -gencode=arch=compute_70,code=sm_70" ,
300
- " -gencode=arch=compute_75,code=sm_75" , " -gencode=arch=compute_80,code=sm_80" ,
301
- " -gencode=arch=compute_86,code=sm_86" , " -gencode=arch=compute_86,code=compute_86" , " -t0" }
302
-
303
- -- On Windows, the link to cudart is done by the CUDA extension, but on Linux, this must be done manually
304
- if os .target () == " linux" then
305
- linkoptions { " -L/usr/local/cuda/lib64 -lcudart" }
306
- end
307
-
308
- filter " configurations:release"
309
- cudaFastMath " On" -- enable fast math for release
310
- filter " "
299
+ sourceDirAbsolute = path .getabsolute (SourceDir )
300
+ objDirAbsolute = path .getabsolute (tempDir )
301
+ addCUDAToProject (sourceDirAbsolute , objDirAbsolute )
0 commit comments