From aee83e6564f016b128ecda65d77cfceb82368a92 Mon Sep 17 00:00:00 2001 From: Andre Weissflog Date: Tue, 10 Sep 2024 16:58:18 +0200 Subject: [PATCH 1/2] update build.zig to make cimgui build work with an unmodified cimgui --- build.zig | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build.zig b/build.zig index e566f8b..7a439ef 100644 --- a/build.zig +++ b/build.zig @@ -848,9 +848,12 @@ const libImGuiOptions = struct { }; fn buildImgui(b: *Build, options: libImGuiOptions) !*CompileStep { const imgui_cpp = b.dependency("imgui", .{}); - const imgui_cpp_dir = imgui_cpp.path(""); const cimgui = b.dependency("cimgui", .{}); - const cimgui_dir = cimgui.path(""); + + // create file tree for cimgui and imgui + const wf = b.addNamedWriteFiles("cimgui"); + const cimgui_dir = wf.addCopyDirectory(cimgui.path(""), "", .{}); + const imgui_cpp_dir = wf.addCopyDirectory(imgui_cpp.path(""), "imgui", .{}); const libimgui = b.addStaticLibrary(.{ .name = "cimgui", From 2f604a90cbe8795065876ea832808f11f67ac11a Mon Sep 17 00:00:00 2001 From: Andre Weissflog Date: Tue, 10 Sep 2024 17:10:46 +0200 Subject: [PATCH 2/2] let libimgui depend on cimgui file copy step --- build.zig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/build.zig b/build.zig index 7a439ef..481edc9 100644 --- a/build.zig +++ b/build.zig @@ -860,6 +860,10 @@ fn buildImgui(b: *Build, options: libImGuiOptions) !*CompileStep { .target = options.target, .optimize = options.optimize, }); + + // libimgui compilation depends on file tree + libimgui.step.dependOn(&wf.step); + if (libimgui.linkage == .static) libimgui.pie = true else if (libimgui.linkage == .static)