From f90f50e10e18ab3bdbe1f3d96dd9c9739f85ee45 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Thu, 19 Sep 2024 15:37:17 +0300 Subject: [PATCH] ogre: unvendor imgui --- recipes/ogre/1.x/CMakeLists.txt | 6 ++++++ recipes/ogre/1.x/conanfile.py | 19 +++++++++++++------ 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/recipes/ogre/1.x/CMakeLists.txt b/recipes/ogre/1.x/CMakeLists.txt index 780adf8f2b697..bbf97e40eb77a 100644 --- a/recipes/ogre/1.x/CMakeLists.txt +++ b/recipes/ogre/1.x/CMakeLists.txt @@ -39,6 +39,12 @@ endif() add_subdirectory(src) +if(TARGET OgreOverlay AND OGRE_BUILD_COMPONENT_OVERLAY_IMGUI) + find_package(imgui REQUIRED CONFIG) + target_sources(OgreOverlay PRIVATE ${CONAN_IMGUI_SRC}/misc/freetype/imgui_freetype.cpp) + target_include_directories(OgreOverlay PRIVATE ${CONAN_IMGUI_SRC}/misc/freetype) + target_link_libraries(OgreOverlay PUBLIC imgui::imgui) +endif() if(TARGET Codec_FreeImage) target_link_libraries(Codec_FreeImage PUBLIC freeimage::freeimage) endif() diff --git a/recipes/ogre/1.x/conanfile.py b/recipes/ogre/1.x/conanfile.py index 63baee1c438ca..79003e07faf5a 100644 --- a/recipes/ogre/1.x/conanfile.py +++ b/recipes/ogre/1.x/conanfile.py @@ -262,10 +262,9 @@ def requirements(self): self.requires("bullet3/3.25") if self.options.build_component_overlay: self.requires("freetype/2.13.2") - # TODO: unvendor imgui - # if self.options.build_component_overlay_imgui: - # # Used in Overlay/OgreImGuiOverlay.h public heder - # self.requires("imgui/1.91.0", transitive_headers=True, transitive_libs=True) + if self.options.build_component_overlay_imgui: + # Used in Overlay/OgreImGuiOverlay.h public heder + self.requires("imgui/1.91.0", transitive_headers=True, transitive_libs=True) if self.options.build_plugin_assimp: self.requires("assimp/5.4.2") if self.options.build_plugin_exrcodec: @@ -407,6 +406,8 @@ def generate(self): tc.variables["OGRE_PLUGINS_PATH"] = self._to_cmake_path(self._plugins_dir) tc.variables["OGRE_MEDIA_PATH"] = self._to_cmake_path(self._media_dir) tc.variables["OGRE_CFG_INSTALL_PATH"] = self._to_cmake_path(self._config_dir) + if self.options.get_safe("build_component_overlay_imgui"): + tc.variables["CONAN_IMGUI_SRC"] = os.path.join(self.dependencies["imgui"].package_folder, "res") tc.generate() deps = CMakeDeps(self) @@ -433,6 +434,12 @@ def _patch_sources(self): rmdir(self, os.path.join(self.source_folder, "PlugIns", "STBICodec", "src", "stbi")) replace_in_file(self, os.path.join(self.source_folder, "PlugIns", "STBICodec", "src", "OgreSTBICodec.cpp"), '#include "stbi/', '#include "') + # Unvendor imgui in Overlay + # https://github.com/OGRECave/ogre/blob/v14.2.6/Components/Overlay/CMakeLists.txt#L21-L43 + replace_in_file(self, os.path.join(self.source_folder, "Components", "Overlay", "CMakeLists.txt"), + "if(OGRE_BUILD_COMPONENT_OVERLAY_IMGUI)", "if(0)") + replace_in_file(self, os.path.join(self.source_folder, "Components", "Overlay", "CMakeLists.txt"), + "list(REMOVE_ITEM SOURCE_FILES", "# list(REMOVE_ITEM SOURCE_FILES") def build(self): self._patch_sources() @@ -583,8 +590,8 @@ def _add_plugin_component(comp, *, requires=None): _add_core_component("MeshLodGenerator") if self.options.build_component_overlay: _add_core_component("Overlay", requires=["freetype::freetype"]) - # if self.options.get_safe("build_component_overlay_imgui"): - # self.cpp_info.components["Overlay"].requires.append("imgui::imgui") + if self.options.get_safe("build_component_overlay_imgui"): + self.cpp_info.components["Overlay"].requires.append("imgui::imgui") if self.options.build_component_paging: _add_core_component("Paging") if self.options.build_component_property: