From e17e20aaa9501e81e7dc3a9bd40265c73416d392 Mon Sep 17 00:00:00 2001 From: Romain BOULLARD Date: Tue, 14 Apr 2026 23:39:11 +0200 Subject: [PATCH] imgui --- .gitea/workflows/ci.yml | 2 + imgui/all/CMakeLists.txt | 74 ++++++++++ imgui/all/conandata.yml | 94 +++++++++++++ imgui/all/conanfile.py | 127 ++++++++++++++++++ ...-0001-static-linking-bugfix-backport.patch | 15 +++ ...-0001-static-linking-bugfix-backport.patch | 15 +++ imgui/all/test_package/CMakeLists.txt | 20 +++ imgui/all/test_package/conanfile.py | 35 +++++ imgui/all/test_package/my_imgui_config.h | 11 ++ imgui/all/test_package/test_package.cpp | 33 +++++ imgui/config.yml | 29 ++++ 11 files changed, 455 insertions(+) create mode 100644 imgui/all/CMakeLists.txt create mode 100644 imgui/all/conandata.yml create mode 100644 imgui/all/conanfile.py create mode 100644 imgui/all/patches/1.92.4-0001-static-linking-bugfix-backport.patch create mode 100644 imgui/all/patches/1.92.4-docking-0001-static-linking-bugfix-backport.patch create mode 100644 imgui/all/test_package/CMakeLists.txt create mode 100644 imgui/all/test_package/conanfile.py create mode 100644 imgui/all/test_package/my_imgui_config.h create mode 100644 imgui/all/test_package/test_package.cpp create mode 100644 imgui/config.yml diff --git a/.gitea/workflows/ci.yml b/.gitea/workflows/ci.yml index 99f9df2..0da8a9e 100644 --- a/.gitea/workflows/ci.yml +++ b/.gitea/workflows/ci.yml @@ -39,6 +39,8 @@ jobs: { name: "rapidhash", version: "3.0", location: "all" }, { name: "cli11", version: "2.6.1", location: "all" }, { name: "assimp", version: "6.0.4", location: "5.x" }, + + { name: "imgui", version: "1.92.6-docking", location: "all" }, ] name: "Package ${{matrix.package.name }}/${{ matrix.package.version }}" steps: diff --git a/imgui/all/CMakeLists.txt b/imgui/all/CMakeLists.txt new file mode 100644 index 0000000..3ff4d57 --- /dev/null +++ b/imgui/all/CMakeLists.txt @@ -0,0 +1,74 @@ +cmake_minimum_required(VERSION 3.9) +project(imgui LANGUAGES CXX) + +set(MISC_DIR ${IMGUI_SRC_DIR}/misc) +set(EXTRA_FONTS_DIR ${MISC_DIR}/fonts) +set(IMGUI_EXPORT_HEADERS imgui_export_headers.h) + +file(GLOB SOURCE_FILES ${IMGUI_SRC_DIR}/*.cpp) +file(GLOB HEADER_FILES ${IMGUI_SRC_DIR}/*.h) + +if(IMGUI_ENABLE_TEST_ENGINE) + message(STATUS "Building ImGui with test engine") + file(GLOB TEST_ENGINE_FILES ${IMGUI_TEST_ENGINE_DIR}/imgui_test_engine/*.cpp) + list(APPEND SOURCE_FILES ${TEST_ENGINE_FILES}) + file(GLOB TEST_ENGINE_HEADER_FILES ${IMGUI_TEST_ENGINE_DIR}/imgui_test_engine/*.h) + list(APPEND HEADER_FILES ${TEST_ENGINE_HEADER_FILES}) +else() + message(STATUS "Building ImGui without test engine") +endif() + +file(GLOB EXTRA_FONTS_FILES ${EXTRA_FONTS_DIR}/*.ttf) +if (MSVC) + file(GLOB EXTRA_NATVIS_FILES ${MISC_DIR}/natvis/*.natvis) +endif() + +set(BINARY_TO_COMPRESSED_BIN binary_to_compressed_c) + +add_executable(${BINARY_TO_COMPRESSED_BIN} ${EXTRA_FONTS_DIR}/binary_to_compressed_c.cpp) +target_compile_features(${BINARY_TO_COMPRESSED_BIN} PRIVATE cxx_std_11) + +add_library(${PROJECT_NAME} ${SOURCE_FILES}) + +if(IMGUI_WITH_SDL3_BINDING) + target_sources(${PROJECT_NAME} PRIVATE ${IMGUI_SRC_DIR}/backends/imgui_impl_sdl3.cpp) + list(APPEND HEADER_FILES ${IMGUI_SRC_DIR}/backends/imgui_impl_sdl3.h) + find_package(SDL3 REQUIRED CONFIG) + target_link_libraries(${PROJECT_NAME} PUBLIC SDL3::SDL3) +endif() + +set_target_properties(${PROJECT_NAME} PROPERTIES + CXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON +) +include(GenerateExportHeader) +generate_export_header(${PROJECT_NAME} + EXPORT_MACRO_NAME IMGUI_API + EXPORT_FILE_NAME ${IMGUI_EXPORT_HEADERS} +) +target_include_directories(${PROJECT_NAME} PUBLIC + $ + $ + $ +) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) + +include(GNUInstallDirs) + +install(TARGETS ${PROJECT_NAME} + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}) +install(TARGETS ${BINARY_TO_COMPRESSED_BIN} + DESTINATION ${CMAKE_INSTALL_BINDIR}) +install(FILES ${HEADER_FILES} ${CMAKE_CURRENT_BINARY_DIR}/${IMGUI_EXPORT_HEADERS} + DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} + PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +install(FILES ${EXTRA_FONTS_FILES} + DESTINATION ${CMAKE_INSTALL_PREFIX}/res/fonts + PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +if (MSVC) + install(FILES ${EXTRA_NATVIS_FILES} + DESTINATION ${CMAKE_INSTALL_PREFIX}/res/natvis + PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) +endif() diff --git a/imgui/all/conandata.yml b/imgui/all/conandata.yml new file mode 100644 index 0000000..c246a4d --- /dev/null +++ b/imgui/all/conandata.yml @@ -0,0 +1,94 @@ +# this package's recipe relies on version suffixes to handle imgui's docking branch. +# Suffix: -docking for docking branch sources +sources: + "1.92.6": + core: + url: "https://github.com/ocornut/imgui/archive/v1.92.6.tar.gz" + sha256: "5b17c01f69545bde732b14936d89ce0f508adb83e8b56fa82448371845172bc3" + testengine: + url: "https://github.com/ocornut/imgui_test_engine/archive/v1.92.6.tar.gz" + sha256: "5374ec2318933f9fc663d924529ea80e5fa40866e82fafc3872ae94a16fdbc7f" + "1.92.6-docking": + core: + url: "https://github.com/ocornut/imgui/archive/v1.92.6-docking.tar.gz" + sha256: "5e84cdaa6a6041586a0d11a3071b749734a0439d66fdbdad37ae5b27e37d396c" + testengine: + url: "https://github.com/ocornut/imgui_test_engine/archive/v1.92.6.tar.gz" + sha256: "5374ec2318933f9fc663d924529ea80e5fa40866e82fafc3872ae94a16fdbc7f" + "1.92.2b": + core: + url: "https://github.com/ocornut/imgui/archive/v1.92.2b.tar.gz" + sha256: "da3d453cce74e0fb3d67f8d798a2a8d04fcaf0b33ce0e0131d0695dfc4f64191" + testengine: + url: "https://github.com/ocornut/imgui_test_engine/archive/v1.92.2.tar.gz" + sha256: "5914327269b2dd9ad66bead3be8577f99f5f572d196bbe4028f6812cf0356adb" + "1.92.2b-docking": + core: + url: "https://github.com/ocornut/imgui/archive/v1.92.2b-docking.tar.gz" + sha256: "f6ad86e6f938fdda4d5e362b9a9b39158963dd3257fdc9902efc148c0c0c39f9" + testengine: + url: "https://github.com/ocornut/imgui_test_engine/archive/v1.92.2.tar.gz" + sha256: "5914327269b2dd9ad66bead3be8577f99f5f572d196bbe4028f6812cf0356adb" + "1.91.8": + core: + url: "https://github.com/ocornut/imgui/archive/v1.91.8.tar.gz" + sha256: "db3a2e02bfd6c269adf0968950573053d002f40bdfb9ef2e4a90bce804b0f286" + testengine: + url: "https://github.com/ocornut/imgui_test_engine/archive/v1.91.8.tar.gz" + sha256: "bdfc31cb819bd6e4df2d5da0316edf92b1011d1c4046293aafd9ae14106570e2" + "1.91.8-docking": + core: + url: "https://github.com/ocornut/imgui/archive/v1.91.8-docking.tar.gz" + sha256: "55f5e65abea635f2a8bfa9a92cd966448a363a262cf6dead7cc662fb0ab37612" + testengine: + url: "https://github.com/ocornut/imgui_test_engine/archive/v1.91.8.tar.gz" + sha256: "bdfc31cb819bd6e4df2d5da0316edf92b1011d1c4046293aafd9ae14106570e2" + "1.90.9": + core: + url: "https://github.com/ocornut/imgui/archive/v1.90.9.tar.gz" + sha256: "04943919721e874ac75a2f45e6eb6c0224395034667bf508923388afda5a50bf" + "1.90.9-docking": + core: + url: "https://github.com/ocornut/imgui/archive/v1.90.9-docking.tar.gz" + sha256: "48e7e4e4f154ad98d0946126a84e2375f849f6a67792129a805817dd60a34330" + "1.90.5": + core: + url: "https://github.com/ocornut/imgui/archive/v1.90.5.tar.gz" + sha256: "e94b48dba7311c85ba8e3e6fe7c734d76a0eed21b2b42c5180fd5706d1562241" + testengine: + url: "https://github.com/ocornut/imgui_test_engine/archive/v1.90.5.tar.gz" + sha256: "79339246d8c919c5926df0a7bee99be585ebaf67cdaba89a0ac314b1f7846f92" + "1.90.5-docking": + core: + url: "https://github.com/ocornut/imgui/archive/v1.90.5-docking.tar.gz" + sha256: "8a5e1e594d6c8552e46e4c1ba8dd9deb51262067f04937904babc04384533ccc" + testengine: + url: "https://github.com/ocornut/imgui_test_engine/archive/v1.90.5.tar.gz" + sha256: "79339246d8c919c5926df0a7bee99be585ebaf67cdaba89a0ac314b1f7846f92" + "1.88": + core: + url: "https://github.com/ocornut/imgui/archive/v1.88.tar.gz" + sha256: "9f14c788aee15b777051e48f868c5d4d959bd679fc5050e3d2a29de80d8fd32e" + "1.87": + core: + url: "https://github.com/ocornut/imgui/archive/v1.87.tar.gz" + sha256: "b54ceb35bda38766e36b87c25edf7a1cd8fd2cb8c485b245aedca6fb85645a20" + "1.86": + core: + url: "https://github.com/ocornut/imgui/archive/v1.86.tar.gz" + sha256: "6ba6ae8425a19bc52c5e067702c48b70e4403cd339cba02073a462730a63e825" + "1.85": + core: + url: "https://github.com/ocornut/imgui/archive/v1.85.tar.gz" + sha256: "7ed49d1f4573004fa725a70642aaddd3e06bb57fcfe1c1a49ac6574a3e895a77" +patches: + "1.92.4": + - patch_file: "patches/1.92.4-0001-static-linking-bugfix-backport.patch" + patch_description: "Add missing export for a function needed by the backends" + patch_source: "https://github.com/ocornut/imgui/pull/9016" + patch_type: "backport" + "1.92.4-docking": + - patch_file: "patches/1.92.4-docking-0001-static-linking-bugfix-backport.patch" + patch_description: "Add missing export for a function needed by the backends" + patch_source: "https://github.com/ocornut/imgui/pull/9016" + patch_type: "backport" diff --git a/imgui/all/conanfile.py b/imgui/all/conanfile.py new file mode 100644 index 0000000..f1da700 --- /dev/null +++ b/imgui/all/conanfile.py @@ -0,0 +1,127 @@ +import os + +from conan import ConanFile +from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout, CMakeDeps +from conan.tools.files import apply_conandata_patches, copy, export_conandata_patches, get, replace_in_file +from conan.tools.scm import Version + +required_conan_version = ">=1.53.0" + + +class IMGUIConan(ConanFile): + name = "imgui" + description = "Bloat-free Immediate Mode Graphical User interface for C++ with minimal dependencies" + license = "MIT" + url = "https://github.com/conan-io/conan-center-index" + homepage = "https://github.com/ocornut/imgui" + topics = ("gui", "graphical", "bloat-free") + package_type = "library" + + settings = "os", "arch", "compiler", "build_type" + options = { + "shared": [True, False], + "fPIC": [True, False], + "enable_test_engine": [True, False], + "with_sdl3_binding": [True, False], + } + default_options = { + "shared": False, + "fPIC": True, + "enable_test_engine": False, + "with_sdl3_binding": False, + } + + def requirements(self): + if self.options.get_safe("with_sdl3_binding"): + self.requires("sdl/[>3 <4]", transitive_headers=True) + + def export_sources(self): + copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + export_conandata_patches(self) + + def config_options(self): + if self.settings.os == "Windows": + del self.options.fPIC + if "testengine" not in self.conan_data["sources"][self.version]: + self.output.warning("No test engine found for this version, removing test engine option") + del self.options.enable_test_engine + + # sdl3 bindings were introduced with 1.89.3 + # 1.91.8 is the oldest version that supports the latest sdl headers + if Version(self.version) < "1.91.8": + del self.options.with_sdl3_binding + + def configure(self): + if self.options.shared: + self.options.rm_safe("fPIC") + + def layout(self): + cmake_layout(self, src_folder="src") + + def source(self): + get(self, **self.conan_data["sources"][self.version]["core"], strip_root=True) + if "testengine" in self.conan_data["sources"][self.version]: + get(self, **self.conan_data["sources"][self.version]["testengine"], strip_root=True, destination="test_engine") + self._patch_sources() + + def generate(self): + tc = CMakeToolchain(self) + tc.variables["IMGUI_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.variables["IMGUI_WITH_SDL3_BINDING"] = self.options.get_safe("with_sdl3_binding", False) + # test engine is not available for all versions + if self.options.get_safe("enable_test_engine"): + tc.preprocessor_definitions["IMGUI_ENABLE_TEST_ENGINE"] = "1" + tc.preprocessor_definitions["IMGUI_TEST_ENGINE_ENABLE_COROUTINE_STDTHREAD_IMPL"] = "1" + tc.variables["IMGUI_ENABLE_TEST_ENGINE"] = "ON" + tc.variables["IMGUI_TEST_ENGINE_DIR"] = os.path.join(self.source_folder, "test_engine").replace("\\", "/") + tc.generate() + + deps = CMakeDeps(self) + deps.generate() + + def _patch_sources(self): + apply_conandata_patches(self) + + # Ensure we take into account export_headers + replace_in_file(self, + os.path.join(self.source_folder, "imgui.h"), + "#ifdef IMGUI_USER_CONFIG", + "#include \"imgui_export_headers.h\"\n\n#ifdef IMGUI_USER_CONFIG" + ) + + def build(self): + cmake = CMake(self) + cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.build() + + def package(self): + copy(self, pattern="LICENSE.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) + backends_folder = os.path.join(self.source_folder, "backends") + copy(self, pattern="imgui_impl_*", + dst=os.path.join(self.package_folder, "res", "bindings"), + src=backends_folder) + copy(self, pattern="imgui*.cpp", + dst=os.path.join(self.package_folder, "res", "src"), + src=os.path.join(self.source_folder)) + copy(self, pattern="*.*", + dst=os.path.join(self.package_folder, "res", "misc", "cpp"), + src=os.path.join(self.source_folder, "misc", "cpp")) + copy(self, pattern="*.*", + dst=os.path.join(self.package_folder, "res", "misc", "freetype"), + src=os.path.join(self.source_folder, "misc", "freetype")) + cmake = CMake(self) + cmake.install() + + def package_info(self): + _is_docking_branch = "docking" in str(self.version) + self.conf_info.define("user.imgui:with_docking", _is_docking_branch) + self.cpp_info.libs = ["imgui"] + if self.settings.os == "Linux": + self.cpp_info.system_libs.append("m") + if self.settings.os == "Windows": + self.cpp_info.system_libs.append("imm32") + self.cpp_info.srcdirs = [os.path.join("res", "bindings")] + + bin_path = os.path.join(self.package_folder, "bin") + self.output.info("Appending PATH env var with : {}".format(bin_path)) + self.env_info.PATH.append(bin_path) diff --git a/imgui/all/patches/1.92.4-0001-static-linking-bugfix-backport.patch b/imgui/all/patches/1.92.4-0001-static-linking-bugfix-backport.patch new file mode 100644 index 0000000..7da3242 --- /dev/null +++ b/imgui/all/patches/1.92.4-0001-static-linking-bugfix-backport.patch @@ -0,0 +1,15 @@ +diff --git imgui.h imgui.h +index 0a216b76..baeda39b 100644 +--- imgui.h ++++ imgui.h +@@ -3978,8 +3978,8 @@ struct ImGuiPlatformIO + // Functions + //------------------------------------------------------------------ + +- void ClearPlatformHandlers(); // Clear all Platform_XXX fields. Typically called on Platform Backend shutdown. +- void ClearRendererHandlers(); // Clear all Renderer_XXX fields. Typically called on Renderer Backend shutdown. ++ IMGUI_API void ClearPlatformHandlers(); // Clear all Platform_XXX fields. Typically called on Platform Backend shutdown. ++ IMGUI_API void ClearRendererHandlers(); // Clear all Renderer_XXX fields. Typically called on Renderer Backend shutdown. + }; + + // (Optional) Support for IME (Input Method Editor) via the platform_io.Platform_SetImeDataFn() function. Handler is called during EndFrame(). diff --git a/imgui/all/patches/1.92.4-docking-0001-static-linking-bugfix-backport.patch b/imgui/all/patches/1.92.4-docking-0001-static-linking-bugfix-backport.patch new file mode 100644 index 0000000..e8df467 --- /dev/null +++ b/imgui/all/patches/1.92.4-docking-0001-static-linking-bugfix-backport.patch @@ -0,0 +1,15 @@ +diff --git imgui.h imgui.h +index d0f071d2..8328e9a3 100644 +--- imgui.h ++++ imgui.h +@@ -4235,8 +4235,8 @@ struct ImGuiPlatformIO + // Functions + //------------------------------------------------------------------ + +- void ClearPlatformHandlers(); // Clear all Platform_XXX fields. Typically called on Platform Backend shutdown. +- void ClearRendererHandlers(); // Clear all Renderer_XXX fields. Typically called on Renderer Backend shutdown. ++ IMGUI_API void ClearPlatformHandlers(); // Clear all Platform_XXX fields. Typically called on Platform Backend shutdown. ++ IMGUI_API void ClearRendererHandlers(); // Clear all Renderer_XXX fields. Typically called on Renderer Backend shutdown. + }; + + // (Optional) This is required when enabling multi-viewport. Represent the bounds of each connected monitor/display and their DPI. diff --git a/imgui/all/test_package/CMakeLists.txt b/imgui/all/test_package/CMakeLists.txt new file mode 100644 index 0000000..588bf94 --- /dev/null +++ b/imgui/all/test_package/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.15) +project(test_package LANGUAGES CXX) + +find_package(imgui REQUIRED CONFIG) + +add_executable(${PROJECT_NAME} test_package.cpp) +target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui) + +option(DOCKING "Test docking" OFF) + +if (DOCKING) + target_compile_definitions(${PROJECT_NAME} PRIVATE -DDOCKING) +endif() + +if(ENABLE_TEST_ENGINE) + target_compile_definitions(${PROJECT_NAME} PRIVATE -DENABLE_TEST_ENGINE) +endif() + +target_compile_definitions(${PROJECT_NAME} PUBLIC "IMGUI_USER_CONFIG=\"${CMAKE_CURRENT_SOURCE_DIR}/my_imgui_config.h\"") +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) diff --git a/imgui/all/test_package/conanfile.py b/imgui/all/test_package/conanfile.py new file mode 100644 index 0000000..6fedd6a --- /dev/null +++ b/imgui/all/test_package/conanfile.py @@ -0,0 +1,35 @@ +from conan import ConanFile +from conan.tools.build import can_run +from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain +import os +import re + + +class TestPackageConan(ConanFile): + settings = "os", "arch", "compiler", "build_type" + generators = "CMakeDeps", "VirtualRunEnv" + test_type = "explicit" + + def requirements(self): + self.requires(self.tested_reference_str) + + def layout(self): + cmake_layout(self) + + def generate(self): + with_docking = self.dependencies[self.tested_reference_str].conf_info.get("user.imgui:with_docking", False) + with_test_engine = self.dependencies[self.tested_reference_str].options.get_safe("enable_test_engine", False) + tc = CMakeToolchain(self) + tc.variables["DOCKING"] = with_docking + tc.variables["ENABLE_TEST_ENGINE"] = with_test_engine + tc.generate() + + def build(self): + cmake = CMake(self) + cmake.configure() + cmake.build() + + def test(self): + if can_run(self): + bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + self.run(bin_path, env="conanrun") diff --git a/imgui/all/test_package/my_imgui_config.h b/imgui/all/test_package/my_imgui_config.h new file mode 100644 index 0000000..69f4176 --- /dev/null +++ b/imgui/all/test_package/my_imgui_config.h @@ -0,0 +1,11 @@ +#pragma once + +#include + + +namespace ImGui +{ + void MyFunction(const char* name) { + printf(" ImGui::MyFunction(%s)\n", name); + } +} diff --git a/imgui/all/test_package/test_package.cpp b/imgui/all/test_package/test_package.cpp new file mode 100644 index 0000000..71df5a4 --- /dev/null +++ b/imgui/all/test_package/test_package.cpp @@ -0,0 +1,33 @@ +#include +#ifdef DOCKING + #include +#endif +#ifdef ENABLE_TEST_ENGINE +#include +#endif + +#include + +int main(int, char**) +{ + printf("IMGUI VERSION: %s\n", IMGUI_VERSION); + ImGui::CreateContext(); +#ifdef DOCKING + printf(" with docking\n"); +#endif + +#ifdef ENABLE_TEST_ENGINE + printf(" with test engine\n"); + ImGuiTestEngine *engine = ImGuiTestEngine_CreateContext(); + if (engine == NULL) { + printf(" Failed to create test engine context\n"); + return -1; + } + ImGui::DestroyContext(); + ImGuiTestEngine_DestroyContext(engine); +#else + ImGui::DestroyContext(); +#endif + + return 0; +} diff --git a/imgui/config.yml b/imgui/config.yml new file mode 100644 index 0000000..27e816d --- /dev/null +++ b/imgui/config.yml @@ -0,0 +1,29 @@ +versions: + "1.92.6": + folder: all + "1.92.6-docking": + folder: all + "1.92.2b": + folder: all + "1.92.2b-docking": + folder: all + "1.91.8": + folder: all + "1.91.8-docking": + folder: all + "1.90.9": + folder: all + "1.90.9-docking": + folder: all + "1.90.5": + folder: all + "1.90.5-docking": + folder: all + "1.88": + folder: all + "1.87": + folder: all + "1.86": + folder: all + "1.85": + folder: all