Skip to content

Commit 5e732f0

Browse files
author
david.algis
committed
♻️ refactor premake
1 parent d7a3751 commit 5e732f0

File tree

1 file changed

+40
-19
lines changed

1 file changed

+40
-19
lines changed

Plugin/premake5.lua

Lines changed: 40 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -50,18 +50,18 @@ workspace "PluginInteropUnity"
5050
-- [ PluginGLInteropCUDA ] --
5151
-------------------------------
5252
project "PluginInteropUnityCUDA"
53-
local ROOT_PROJECT = pathPluginInterop
54-
location (ROOT_PROJECT)
53+
local rootProject = pathPluginInterop
54+
location (rootProject)
5555
language "C++"
5656
targetdir (pathTarget, "SampleBasic")
57-
objdir (ROOT_PROJECT .. "/temp/")
57+
objdir (rootProject .. "/temp/")
5858
kind "SharedLib"
5959

60-
local SourceDir = ROOT_PROJECT .. "/src/";
60+
local SourceDir = rootProject .. "/src/";
6161
local IncludeSubDir = pathPluginInteropIncludeSubdir;
6262
local IncludeDir = pathPluginInteropInclude;
63-
local ThirdPartyGLDir = ROOT_PROJECT .. "/thirdParty/gl3w/include/";
64-
local SourceThirdPartyGLDir = ROOT_PROJECT .. "/thirdParty/gl3w/src/";
63+
local ThirdPartyGLDir = rootProject .. "/thirdParty/gl3w/include/";
64+
local SourceThirdPartyGLDir = rootProject .. "/thirdParty/gl3w/src/";
6565

6666
dependson {"Utilities"}
6767
files
@@ -135,19 +135,19 @@ project "PluginInteropUnityCUDA"
135135
-- [ SampleBasic ] --
136136
-------------------------------
137137
project "SampleBasic"
138-
local LOCATION_PROJECT = pathSampleProject
139-
local ROOT_PROJECT = root .. LOCATION_PROJECT
140-
location (ROOT_PROJECT)
138+
local locationProject = pathSampleProject
139+
local rootProject = root .. locationProject
140+
location (rootProject)
141141
language "C++"
142142
targetdir (pathTarget)
143-
objdir (ROOT_PROJECT .. "/temp/")
143+
objdir (rootProject .. "/temp/")
144144
kind "SharedLib"
145145

146-
local SourceDir = ROOT_PROJECT .. "/src/";
147-
local IncludeSubDir = ROOT_PROJECT .. "/include/**";
148-
local IncludeDir = ROOT_PROJECT .. "/include/";
149-
local ThirdPartyGLDir = ROOT_PROJECT .. "/thirdParty/gl3w/include/";
150-
local SourceThirdPartyGLDir = ROOT_PROJECT .. "/thirdParty/gl3w/src/";
146+
local SourceDir = rootProject .. "/src/";
147+
local IncludeSubDir = rootProject .. "/include/**";
148+
local IncludeDir = rootProject .. "/include/";
149+
local ThirdPartyGLDir = rootProject .. "/thirdParty/gl3w/include/";
150+
local SourceThirdPartyGLDir = rootProject .. "/thirdParty/gl3w/src/";
151151
dependson{"PluginInteropUnityCUDA"}
152152
files
153153
{
@@ -220,14 +220,14 @@ project "SampleBasic"
220220
-- [ Utilities ] --
221221
-------------------------------
222222
project "Utilities"
223-
local ROOT_PROJECT = pathUtilities
224-
location (ROOT_PROJECT)
223+
local rootProject = pathUtilities
224+
location (rootProject)
225225
kind "SharedLib"
226226
language "C++"
227227
targetdir (pathTarget)
228-
objdir (ROOT_PROJECT .. "/temp/".. LOCATION_PROJECT)
228+
objdir (rootProject .. "/temp/".. locationProject)
229229

230-
local SourceDir = ROOT_PROJECT .. "/src/";
230+
local SourceDir = rootProject .. "/src/";
231231
local IncludeDir = pathUtilitiesInclude;
232232

233233
-- what files the visual studio project/makefile/etc should know about
@@ -249,5 +249,26 @@ project "Utilities"
249249

250250
defines {"UTILITIES_SHARED", "UTILITIES_SHARED_EXPORTS"} symbols "On"
251251

252+
-- Add necessary build customization using standard Premake5
253+
-- This assumes you have installed Visual Studio integration for CUDA
254+
-- Here we have it set to 11.4
255+
buildcustomizations "BuildCustomizations/CUDA 11.7"
256+
cudaPath "/usr/local/cuda" -- Only affects linux, because the windows builds get CUDA from the VS extension
257+
258+
cudaMaxRegCount "32"
259+
-- Let's compile for all supported architectures (and also in parallel with -t0)
260+
cudaCompilerOptions {"-arch=sm_52", "-gencode=arch=compute_52,code=sm_52", "-gencode=arch=compute_60,code=sm_60",
261+
"-gencode=arch=compute_61,code=sm_61", "-gencode=arch=compute_70,code=sm_70",
262+
"-gencode=arch=compute_75,code=sm_75", "-gencode=arch=compute_80,code=sm_80",
263+
"-gencode=arch=compute_86,code=sm_86", "-gencode=arch=compute_86,code=compute_86", "-t0"}
264+
265+
-- On Windows, the link to cudart is done by the CUDA extension, but on Linux, this must be done manually
266+
if os.target() == "linux" then
267+
linkoptions {"-L/usr/local/cuda/lib64 -lcudart"}
268+
end
269+
270+
filter "configurations:release"
271+
cudaFastMath "On" -- enable fast math for release
272+
filter ""
252273

253274

0 commit comments

Comments
 (0)