aboutsummaryrefslogtreecommitdiff
path: root/premake5.lua
diff options
context:
space:
mode:
authorhachem <im@hachem.wtf>2026-09-22 06:57:16 +0200
committerhachem <im@hachem.wtf>2026-09-22 06:57:16 +0200
commitd7c1ced08d5d78fcb239550404db4e67d4357a19 (patch)
tree9c0e218b096d138075cbf6a48e2562d33a8f94ed /premake5.lua
parent270eda6f558c972ec86ad0580f1d3d18afc83a94 (diff)
fix: windows supportHEADmain
Diffstat (limited to 'premake5.lua')
-rw-r--r--premake5.lua77
1 files changed, 54 insertions, 23 deletions
diff --git a/premake5.lua b/premake5.lua
index 27a11e2..88cf22a 100644
--- a/premake5.lua
+++ b/premake5.lua
@@ -1,5 +1,12 @@
output_dir = "%{cfg.buildcfg}-%{cfg.system}"
+-- the LunarG installer sets this on windows. without it the vulkan backend is
+-- left out of the build (DONUT_NO_VULKAN) and the app runs opengl only.
+vulkan_sdk = os.getenv("VULKAN_SDK")
+if os.target() == "windows" and not vulkan_sdk then
+ print("VULKAN_SDK is not set: building without the Vulkan backend (OpenGL only)")
+end
+
include_dir = {
glm = "ext/glm",
glfw = "ext/glfw/include",
@@ -38,19 +45,21 @@ function setup_c_target()
runtime "Debug"
symbols "On"
- filter { "system:macosx or system:linux" }
- buildoptions {
- "-g",
- "-fno-omit-frame-pointer",
- "-fsanitize=address,undefined",
- }
+ -- premake filters don't nest: this one has to name debug again, or the
+ -- sanitizers end up in every config
+ filter { "configurations:debug", "system:macosx or system:linux" }
+ buildoptions {
+ "-g",
+ "-fno-omit-frame-pointer",
+ "-fsanitize=address,undefined",
+ }
- linkoptions {
- "-fsanitize=address,undefined",
- }
- filter {}
+ linkoptions {
+ "-fsanitize=address,undefined",
+ }
+ filter {}
- filter { "configurations:release", "configurations:dist" }
+ filter "configurations:release or dist"
runtime "Release"
optimize "Speed"
filter {}
@@ -78,19 +87,21 @@ function setup_cpp_target()
runtime "Debug"
symbols "On"
- filter { "system:macosx or system:linux" }
- buildoptions {
- "-g",
- "-fno-omit-frame-pointer",
- "-fsanitize=address,undefined",
- }
+ -- premake filters don't nest: this one has to name debug again, or the
+ -- sanitizers end up in every config
+ filter { "configurations:debug", "system:macosx or system:linux" }
+ buildoptions {
+ "-g",
+ "-fno-omit-frame-pointer",
+ "-fsanitize=address,undefined",
+ }
- linkoptions {
- "-fsanitize=address,undefined",
- }
- filter {}
+ linkoptions {
+ "-fsanitize=address,undefined",
+ }
+ filter {}
- filter { "configurations:release", "configurations:dist" }
+ filter "configurations:release or dist"
runtime "Release"
optimize "Speed"
filter {}
@@ -335,6 +346,10 @@ project "imgui"
externalincludedirs "/opt/homebrew/include"
filter "system:windows"
systemversion "latest"
+ if vulkan_sdk then
+ files "ext/imgui/backends/imgui_impl_vulkan.cpp"
+ externalincludedirs (vulkan_sdk .. "/Include")
+ end
filter {}
project "imguizmo"
@@ -387,6 +402,7 @@ project "donut"
}
includedirs "src"
+ debugdir "%{wks.location}" -- every asset path is relative to the repo root
externalincludedirs {
"%{include_dir.glm}",
@@ -413,7 +429,22 @@ project "donut"
filter "system:windows"
systemversion "latest"
- links "opengl32.lib"
+ defines "NOMINMAX" -- glad drags in windows.h, whose min/max macros eat std::min/std::max
+ usestandardpreprocessor "On" -- msvc only knows __VA_OPT__ (log.h) with its conforming preprocessor
+ conformancemode "On"
+ buildoptions "/utf-8"
+ links "opengl32"
+ if vulkan_sdk then
+ externalincludedirs (vulkan_sdk .. "/Include")
+ libdirs (vulkan_sdk .. "/Lib")
+ -- delay-loaded, so a box without a Vulkan driver still starts (on OpenGL)
+ -- instead of the loader refusing to run the exe at all
+ links { "vulkan-1", "delayimp" }
+ linkoptions "/DELAYLOAD:vulkan-1.dll"
+ else
+ defines "DONUT_NO_VULKAN"
+ removefiles "src/platform/vulkan/**"
+ end
filter "system:macosx"
files "src/**.mm"