Subject: [bug#74075] [PATCH v2 4/5] gnu: ogre: Add support for Wayland, Vulkan and Bullet.

From: Maxim Cournoyer <[email-masked]>
Date: Tue, 29 Oct 2024 10:40:07 +0900

* gnu/packages/patches/ogre-glslang.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
* gnu/packages/graphics.scm (ogre): Apply patch.
[configure-flags]: Add -DOGRE_BUILD_RENDERSYSTEM_VULKAN=ON.
[native-inputs]: Add vulkan-headers.
[inputs]: Add bullet, glslang, spirv-tools and wayland.

Change-Id: I77f8964f36facd40f48a80006cfaa0a17c7971e5
---

(no changes since v1)

 gnu/local.mk                            |  1 +
 gnu/packages/graphics.scm               | 11 ++++++--
 gnu/packages/patches/ogre-glslang.patch | 36 +++++++++++++++++++++++++
 3 files changed, 46 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/patches/ogre-glslang.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index c432685775..ac53887aa3 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1836,6 +1836,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/ocaml-4.07-dynamically-allocate-signal-stack.patch	\
   %D%/packages/patches/ocaml-4.09-dynamically-allocate-signal-stack.patch	\
   %D%/packages/patches/ocaml-4.09-multiple-definitions.patch	\
+  %D%/packages/patches/ogre-glslang.patch			\
   %D%/packages/patches/omake-fix-non-determinism.patch	\
   %D%/packages/patches/oneko-remove-nonfree-characters.patch	\
   %D%/packages/patches/onionshare-cli-async-mode.patch		\
diff --git a/gnu/packages/graphics.scm b/gnu/packages/graphics.scm
index 7659bec27d..bde89b487b 100644
--- a/gnu/packages/graphics.scm
+++ b/gnu/packages/graphics.scm
@@ -1185,7 +1185,8 @@ (define-public ogre
              (commit (string-append "v" version))))
        (file-name (git-file-name name version))
        (sha256
-        (base32 "0l5rlxk2jiz8sb5w4bd8xvyzrmwnas27sxzkar7xc5azs1x2vgxf"))))
+        (base32 "0l5rlxk2jiz8sb5w4bd8xvyzrmwnas27sxzkar7xc5azs1x2vgxf"))
+       (patches (search-patches "ogre-glslang.patch"))))
     (build-system cmake-build-system)
     (arguments
      (list
@@ -1218,6 +1219,7 @@ (define-public ogre
           (list (string-append "-DCMAKE_INSTALL_RPATH=" runpath)
                 "-DIMGUI_DIR=../imgui-source"
                 "-DOGRE_BUILD_DEPENDENCIES=OFF"
+                "-DOGRE_BUILD_RENDERSYSTEM_VULKAN=ON"
                 "-DOGRE_BUILD_TESTS=TRUE"
                 "-DOGRE_INSTALL_DOCS=TRUE"
                 "-DOGRE_INSTALL_SAMPLES=TRUE"
@@ -1228,16 +1230,21 @@ (define-public ogre
        ("googletest" ,googletest)
        ("pkg-config" ,pkg-config)
        ("python" ,python)
+       ("vulkan-headers" ,vulkan-headers)
        ("xorg-server-for-tests" ,xorg-server-for-tests)))
     (inputs
-     (list freeimage
+     (list bullet
+           freeimage
            freetype
+           glslang
            libxaw
            libxrandr
            libxt
            mesa
            pugixml
            sdl2
+           spirv-tools
+           wayland
            zlib))
     (synopsis "Scene-oriented, flexible 3D engine written in C++")
     (description
diff --git a/gnu/packages/patches/ogre-glslang.patch b/gnu/packages/patches/ogre-glslang.patch
new file mode 100644
index 0000000000..a0711f8ead
--- /dev/null
+++ b/gnu/packages/patches/ogre-glslang.patch
@@ -0,0 +1,36 @@
+From ab1a39e0610c737993ef605559d9b7998a975666 Mon Sep 17 00:00:00 2001
+From: Maxim Cournoyer <[email-masked]>
+Date: Tue, 29 Oct 2024 09:52:48 +0900
+Subject: [PATCH] build/glslang: Fix build when OSDependent library is missing.
+
+The OSDependent glslang library is only available when it is built as
+a static library, not a shared one; look for the library but do not
+fail the  build when it doesn't exist.
+
+Fixes: <https://github.com/OGRECave/ogre/issues/3248>
+---
+ PlugIns/GLSLang/CMakeLists.txt | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/PlugIns/GLSLang/CMakeLists.txt b/PlugIns/GLSLang/CMakeLists.txt
+index bfe03d9b8..7de816939 100644
+--- a/PlugIns/GLSLang/CMakeLists.txt
++++ b/PlugIns/GLSLang/CMakeLists.txt
+@@ -19,7 +19,11 @@ elseif(DEFINED ENV{VULKAN_SDK})
+     target_link_directories(Plugin_GLSLangProgramManager PUBLIC $ENV{VULKAN_SDK}/lib)
+     target_link_libraries(Plugin_GLSLangProgramManager PUBLIC OgreMain shaderc_combined)
+ else()
+-  set(GLSLANG_LIBS glslang OSDependent SPIRV SPIRV-Tools-opt SPIRV-Tools)
++  set(GLSLANG_LIBS glslang SPIRV SPIRV-Tools-opt SPIRV-Tools)
++  find_library(GLSLANG_OSDependent OSDependent)
++  if(GLSLANG_OGLCompiler)
++    set(GLSLANG_LIBS ${GLSLANG_LIBS} ${GLSLANG_OSDependent})
++  endif()
+   find_library(GLSLANG_HLSL HLSL)
+   if(GLSLANG_HLSL)
+     set(GLSLANG_LIBS ${GLSLANG_LIBS} ${GLSLANG_HLSL})
+
+base-commit: edb3d26fa6fa2a40498e80db03e2c0e17c51d46d
+-- 
+2.46.0
+
-- 
2.46.0