Subject: [PATCH v2 2/9] gnu: Add qtimgui.

From: Simon South <[email-masked]>
Date: Fri, 27 Jan 2023 15:34:27 -0500

* gnu/packages/qt.scm (qtimgui): New variable.
---
 gnu/packages/qt.scm | 63 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

diff --git a/gnu/packages/qt.scm b/gnu/packages/qt.scm
index 14fc73ef28..d513794484 100644
--- a/gnu/packages/qt.scm
+++ b/gnu/packages/qt.scm
@@ -26,6 +26,7 @@
 ;;; Copyright © 2022 Foo Chuan Wei <[email-masked]>
 ;;; Copyright © 2022 Zhu Zihao <[email-masked]>
 ;;; Copyright © 2022 Petr Hodina <[email-masked]>
+;;; Copyright © 2023 Simon South <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -114,6 +115,7 @@ (define-module (gnu packages qt)
   #:use-module (gnu packages sqlite)
   #:use-module (gnu packages telephony)
   #:use-module (gnu packages tls)
+  #:use-module (gnu packages toolkits)
   #:use-module (gnu packages valgrind)
   #:use-module (gnu packages video)
   #:use-module (gnu packages vulkan)
@@ -3550,6 +3552,67 @@ (define-public python-pyqt+qscintilla
     (description
      "This package contains the union of PyQt and the Qscintilla extension.")))
 
+(define-public qtimgui
+  (let ((commit "48d64a715b75dee24e398f7e5b0942c2ca329334")
+        (revision "0"))
+    (package
+      (name "qtimgui")
+      (version (git-version "0.0" revision commit))
+      (source (origin
+                (method git-fetch)
+                (uri (git-reference
+                      (url "https://github.com/seanchas116/qtimgui")
+                      (commit commit)))
+                (file-name (git-file-name name version))
+                (sha256
+                 (base32
+                  "0x71j8m15w003ak0d7q346rlwyvklkda9l0dwbxfx6kny3gsl11k"))))
+      (build-system cmake-build-system)
+      (arguments
+       (list
+        #:configure-flags #~(list "-DQTIMGUI_BUILD_IMGUI=OFF"
+                                  "-DQTIMGUI_BUILD_IMPLOT=OFF")
+        #:phases
+        #~(modify-phases %standard-phases
+            (add-after 'unpack 'patch-source
+              (lambda* (#:key inputs #:allow-other-keys)
+                (substitute* "CMakeLists.txt"
+                  ;; Disable building the examples.
+                  (("^add_subdirectory\\(examples\\)") ""))
+                (substitute* "src/CMakeLists.txt"
+                  ;; Build shared libraries, not static.
+                  (("STATIC") "SHARED")
+                  ;; Compile with the system imgui headers.
+                  (("^(target_include_directories.*)\\)" _ prefix)
+                   (string-append prefix
+                                  " "
+                                  (search-input-directory inputs
+                                                          "include/imgui")
+                                  ")")))))
+            (replace 'install
+              ;; No install target provided; manually copy the header and
+              ;; library files to the output.
+              (lambda* (#:key source #:allow-other-keys)
+                (for-each
+                 (lambda (file-name)
+                   (install-file (string-append source "/src/" file-name)
+                                 (string-append #$output "/include/qtimgui")))
+                 '("ImGuiRenderer.h" "QtImGui.h"))
+                (for-each
+                 (lambda (file-name)
+                   (install-file (string-append "src/" file-name)
+                                 (string-append #$output "/lib")))
+                 '("libqt_imgui_quick.so" "libqt_imgui_widgets.so")))))
+        #:tests? #f))                   ; no test suite
+      (inputs
+       (list imgui-1.86 implot qtbase-5 qtdeclarative-5))
+      (home-page "https://github.com/seanchas116/qtimgui")
+      (synopsis "Qt backend for the ImGui GUI library")
+      (description "QtImGui allows the ImGui C++ GUI library to be used by Qt
+applications within subclasses of @code{QOpenGLWidget} and
+@code{QOpenGLWindow}.")
+      (license license:expat))))
+
 (define-public qtkeychain
   (package
     (name "qtkeychain")
-- 
2.38.1