From 3b053a8c5b06a0890cfc839dc453bf055032291f Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Fri, 30 Aug 2024 22:39:58 +0300 Subject: [PATCH 01/23] imgui: make backends available as optional components --- recipes/imgui/all/CMakeLists.txt | 231 +++++++++++--- recipes/imgui/all/conanfile.py | 290 +++++++++++++++--- recipes/imgui/all/test_package/CMakeLists.txt | 10 +- recipes/imgui/all/test_package/conanfile.py | 29 +- .../imgui/all/test_package/test_package.cpp | 118 ++++++- 5 files changed, 577 insertions(+), 101 deletions(-) diff --git a/recipes/imgui/all/CMakeLists.txt b/recipes/imgui/all/CMakeLists.txt index 0626bf7008e52..66f632cde1f22 100644 --- a/recipes/imgui/all/CMakeLists.txt +++ b/recipes/imgui/all/CMakeLists.txt @@ -1,56 +1,201 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.15) project(imgui LANGUAGES CXX) -set(MISC_DIR ${IMGUI_SRC_DIR}/misc) -set(EXTRA_FONTS_DIR ${MISC_DIR}/fonts) +add_library(imgui + imgui.cpp + imgui_demo.cpp + imgui_draw.cpp + imgui_tables.cpp + imgui_widgets.cpp + misc/cpp/imgui_stdlib.cpp +) +set_target_properties(imgui PROPERTIES + CXX_VISIBILITY_PRESET hidden + OBJCXX_VISIBILITY_PRESET hidden + VISIBILITY_INLINES_HIDDEN ON +) +target_include_directories(imgui PUBLIC ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) +target_compile_features(imgui PRIVATE cxx_std_11) + set(IMGUI_EXPORT_HEADERS imgui_export_headers.h) +include(GenerateExportHeader) +generate_export_header(imgui + EXPORT_MACRO_NAME IMGUI_API + EXPORT_FILE_NAME ${IMGUI_EXPORT_HEADERS} +) -file(GLOB SOURCE_FILES ${IMGUI_SRC_DIR}/*.cpp) -file(GLOB HEADER_FILES ${IMGUI_SRC_DIR}/*.h) +if(IMGUI_IMPL_ALLEGRO5) + find_package(Allegro CONFIG REQUIRED) + add_library(imgui-allegro5 backends/imgui_impl_allegro5.cpp) + target_link_libraries(imgui-allegro5 PRIVATE Allegro::allegro Allegro::allegro_ttf Allegro::allegro_font Allegro::allegro_main) + install(FILES backends/imgui_impl_allegro5.h DESTINATION include) + list(APPEND IMGUI_COMPONENTS imgui-allegro5) +endif() -file(GLOB EXTRA_FONTS_FILES ${EXTRA_FONTS_DIR}/*.ttf) -if (MSVC) - file(GLOB EXTRA_NATVIS_FILES ${MISC_DIR}/natvis/*.natvis) +if(IMGUI_IMPL_ANDROID) + add_library(imgui-android backends/imgui_impl_android.cpp) + install(FILES backends/imgui_impl_android.h DESTINATION include) + target_link_libraries(imgui-android PRIVATE android log EGL GLESv3) + list(APPEND IMGUI_COMPONENTS imgui-android) endif() -set(BINARY_TO_COMPRESSED_BIN binary_to_compressed_c) +if(IMGUI_IMPL_DX9) + add_library(imgui-dx9 backends/imgui_impl_dx9.cpp) + target_link_libraries(imgui-dx9 PRIVATE d3d9) + install(FILES backends/imgui_impl_dx9.h DESTINATION include) + list(APPEND IMGUI_COMPONENTS imgui-dx9) +endif() -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) +if(IMGUI_IMPL_DX10) + add_library(imgui-dx10 backends/imgui_impl_dx10.cpp) + target_link_libraries(imgui-dx9 PRIVATE d3d10) + install(FILES backends/imgui_impl_dx10.h DESTINATION include) + list(APPEND IMGUI_COMPONENTS imgui-dx10) +endif() -add_library(${PROJECT_NAME} ${SOURCE_FILES}) -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} +if(IMGUI_IMPL_DX11) + add_library(imgui-dx11 backends/imgui_impl_dx11.cpp) + target_link_libraries(imgui-dx11 PRIVATE d3d11) + install(FILES backends/imgui_impl_dx11.h DESTINATION include) + list(APPEND IMGUI_COMPONENTS imgui-dx11) +endif() + +if(IMGUI_IMPL_DX12) + add_library(imgui-dx12 backends/imgui_impl_dx12.cpp) + target_link_libraries(imgui-dx12 PRIVATE d3d12) + install(FILES backends/imgui_impl_dx12.h DESTINATION include) + list(APPEND IMGUI_COMPONENTS imgui-dx12) +endif() + +if(IMGUI_IMPL_GLFW) + add_library(imgui-glfw backends/imgui_impl_glfw.cpp) + if(NOT EMSCRIPTEN) + find_package(glfw3 CONFIG REQUIRED) + target_link_libraries(imgui-glfw PRIVATE glfw) + endif() + install(FILES backends/imgui_impl_glfw.h DESTINATION include) + list(APPEND IMGUI_COMPONENTS imgui-glfw) +endif() + +if(IMGUI_IMPL_GLUT) + add_library(imgui-glut backends/imgui_impl_glut.cpp) + if(NOT EMSCRIPTEN) + find_package(GLUT REQUIRED) + target_link_libraries(imgui-glut PRIVATE GLUT::GLUT) + endif() + install(FILES backends/imgui_impl_glut.h DESTINATION include) + list(APPEND IMGUI_COMPONENTS imgui-glut) +endif() + +if(IMGUI_IMPL_METAL) + enable_language(OBJCXX) + add_library(imgui-metal backends/imgui_impl_metal.mm) + set_source_files_properties(backends/imgui_impl_metal.mm PROPERTIES COMPILE_FLAGS -fobjc-weak) + target_link_libraries(imgui-metal PRIVATE "-framework Metal" "-framework Cocoa" "-framework QuartzCore") + install(FILES backends/imgui_impl_metal.h DESTINATION include) + list(APPEND IMGUI_COMPONENTS imgui-metal) +endif() + +if(IMGUI_IMPL_OPENGL2) + find_package(OpenGL REQUIRED) + add_library(imgui-opengl2 backends/imgui_impl_opengl2.cpp) + target_link_libraries(imgui-opengl2 PRIVATE OpenGL::GL) + install(FILES backends/imgui_impl_opengl2.h DESTINATION include) + list(APPEND IMGUI_COMPONENTS imgui-opengl2) +endif() + +if(IMGUI_IMPL_OPENGL3) + find_package(OpenGL REQUIRED) + add_library(imgui-opengl3 backends/imgui_impl_opengl3.cpp) + target_link_libraries(imgui-opengl3 PRIVATE OpenGL::GL) + install(FILES backends/imgui_impl_opengl3.h DESTINATION include) + install(FILES backends/imgui_impl_opengl3_loader.h DESTINATION include) + list(APPEND IMGUI_COMPONENTS imgui-opengl3) +endif() + +if(IMGUI_IMPL_OSX) + enable_language(OBJCXX) + add_library(imgui-osx backends/imgui_impl_osx.mm) + target_link_libraries(imgui-osx INTERFACE "-framework Cocoa" "-framework AppKit") + install(FILES backends/imgui_impl_osx.h DESTINATION include) + list(APPEND IMGUI_COMPONENTS imgui-osx) +endif() + +if(IMGUI_IMPL_SDL2) + find_package(SDL2 CONFIG REQUIRED) + add_library(imgui-sdl2 backends/imgui_impl_sdl2.cpp) + target_link_libraries(imgui-sdl2 PRIVATE SDL2::SDL2) + install(FILES backends/imgui_impl_sdl2.h DESTINATION include) + list(APPEND IMGUI_COMPONENTS imgui-sdl2) +endif() + +if(IMGUI_IMPL_SDLRENDERER2) + find_package(SDL2 CONFIG REQUIRED) + add_library(imgui-sdlrenderer2 backends/imgui_impl_sdlrenderer2.cpp) + target_link_libraries(imgui-sdlrenderer2 PRIVATE SDL2::SDL2) + install(FILES backends/imgui_impl_sdlrenderer2.h DESTINATION include) + list(APPEND IMGUI_COMPONENTS imgui-sdlrenderer2) +endif() + +if(IMGUI_IMPL_VULKAN) + find_package(Vulkan REQUIRED) + add_library(imgui-vulkan backends/imgui_impl_vulkan.cpp) + target_link_libraries(imgui-vulkan PRIVATE Vulkan::Vulkan) + install(FILES backends/imgui_impl_vulkan.h DESTINATION include) + list(APPEND IMGUI_COMPONENTS imgui-vulkan) +endif() + +if(IMGUI_IMPL_WIN32) + add_library(imgui-win32 backends/imgui_impl_win32.cpp) + target_link_libraries(imgui-win32 PRIVATE dwmapi xinput) + install(FILES backends/imgui_impl_win32.h DESTINATION include) + list(APPEND IMGUI_COMPONENTS imgui-win32) +endif() + +if(IMGUI_FREETYPE) + find_package(freetype CONFIG REQUIRED) + add_library(imgui-freetype PRIVATE misc/freetype/imgui_freetype.cpp) + target_link_libraries(imgui-freetype PRIVATE freetype) + install(FILES misc/freetype/imgui_freetype.h DESTINATION include) + if(IMGUI_FREETYPE_LUNASVG) + find_package(lunasvg CONFIG REQUIRED) + target_link_libraries(imgui-freetype PRIVATE lunasvg::lunasvg) + endif() + list(APPEND IMGUI_COMPONENTS imgui-freetype) +endif() + +foreach(component ${IMGUI_COMPONENTS}) + target_link_libraries(${component} PUBLIC imgui) +endforeach() + +if(IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS) + target_link_libraries(imgui PRIVATE "-framework ApplicationServices") +endif() + +if(IMGUI_IMPL_TOOLS) + add_executable(binary_to_compressed_c misc/fonts/binary_to_compressed_c.cpp) + target_compile_features(binary_to_compressed_c PRIVATE cxx_std_11) + install(TARGETS binary_to_compressed_c DESTINATION bin) +endif() + +install(TARGETS imgui ${IMGUI_COMPONENTS} + ARCHIVE DESTINATION lib + LIBRARY DESTINATION lib + RUNTIME DESTINATION bin ) -target_include_directories(${PROJECT_NAME} PUBLIC - $ - $ - $ + +file(GLOB IMGUI_HEADERS *.h) +install(FILES + misc/cpp/imgui_stdlib.h + ${IMGUI_HEADERS} + ${PROJECT_BINARY_DIR}/${IMGUI_EXPORT_HEADERS} + DESTINATION include ) -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) + +file(GLOB EXTRA_FONTS_FILES misc/fonts/*.ttf) +install(FILES ${EXTRA_FONTS_FILES} DESTINATION res/fonts) + if (MSVC) - install(FILES ${EXTRA_NATVIS_FILES} - DESTINATION ${CMAKE_INSTALL_PREFIX}/res/natvis - PERMISSIONS OWNER_WRITE OWNER_READ GROUP_READ WORLD_READ) + file(GLOB EXTRA_NATVIS_FILES misc/natvis/*.natvis) + install(FILES ${EXTRA_NATVIS_FILES} DESTINATION res/natvis) endif() diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index ffe8b2248047c..5505517483f0a 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -1,104 +1,302 @@ -from conan import ConanFile -from conan.tools.files import get, copy, replace_in_file -from conan.tools.scm import Version -from conan.tools.cmake import CMake, CMakeToolchain, cmake_layout import os import re +from pathlib import Path + +from conan import ConanFile +from conan.errors import ConanException +from conan.tools.apple import is_apple_os +from conan.tools.build import check_min_cppstd +from conan.tools.cmake import CMake, CMakeDeps, CMakeToolchain, cmake_layout +from conan.tools.files import copy, get, replace_in_file +from conan.tools.scm import Version required_conan_version = ">=1.53.0" -class IMGUIConan(ConanFile): +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" + package_type = "library" settings = "os", "arch", "compiler", "build_type" options = { "shared": [True, False], "fPIC": [True, False], + # Backends + # See https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md + "build_backends": [True, False], + # "backend_allegro5": [True, False], + "backend_android": [True, False], + "backend_dx9": [True, False], + "backend_dx10": [True, False], + "backend_dx11": [True, False], + "backend_dx12": [True, False], + "backend_glfw": [True, False], + "backend_glut": [True, False], + "backend_metal": [True, False], + "backend_opengl2": [True, False], + "backend_opengl3": [True, False], + "backend_osx": [True, False], + "backend_sdl2": [True, False], + "backend_sdlrenderer2": [True, False], + # "backend_sdlrenderer3": [True, False], + "backend_vulkan": [True, False], + "backend_win32": [True, False], + # "backend_wgpu": [True, False], + # Other options + # See https://github.com/ocornut/imgui/blob/master/imconfig.h for details + "enable_freetype": [True, False], + "enable_freetype_lunasvg": [True, False], + "enable_osx_clipboard": [True, False], + "enable_demo_windows": [True, False], + "enable_debug_tools": [True, False], + "use_bgra_packed_color": [True, False], + "use_wchar32": [True, False], + "build_programs": [True, False], } default_options = { "shared": False, "fPIC": True, + # Backends + "build_backends": True, + "backend_android": True, + "backend_dx9": False, + "backend_dx10": False, + "backend_dx11": False, + "backend_dx12": False, + "backend_glfw": True, + "backend_glut": True, + "backend_metal": True, + "backend_opengl2": True, + "backend_opengl3": True, + "backend_osx": True, + "backend_sdl2": True, + "backend_sdlrenderer2": True, + "backend_vulkan": True, + "backend_win32": True, + # Other options + "enable_freetype": False, + "enable_freetype_lunasvg": False, + "enable_osx_clipboard": True, + "enable_demo_windows": True, + "enable_debug_tools": True, + "use_bgra_packed_color": False, + "use_wchar32": False, + "build_programs": True, } def export_sources(self): - copy(self, "CMakeLists.txt", self.recipe_folder, self.export_sources_folder) + copy(self, "CMakeLists.txt", self.recipe_folder, os.path.join(self.export_sources_folder, "src")) def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if self.settings.os != "Android": + del self.options.backend_android + if self.settings.os != "Windows": + del self.options.backend_dx9 + del self.options.backend_dx10 + del self.options.backend_dx11 + del self.options.backend_dx12 + del self.options.backend_win32 + if not is_apple_os(self): + del self.options.backend_metal + del self.options.backend_osx + del self.options.enable_osx_clipboard def configure(self): if self.options.shared: self.options.rm_safe("fPIC") + if not self.options.build_backends: + self.options.rm_safe("backend_allegro5") + self.options.rm_safe("backend_android") + self.options.rm_safe("backend_dx9") + self.options.rm_safe("backend_dx10") + self.options.rm_safe("backend_dx11") + self.options.rm_safe("backend_dx12") + self.options.rm_safe("backend_glfw") + self.options.rm_safe("backend_glut") + self.options.rm_safe("backend_metal") + self.options.rm_safe("backend_opengl2") + self.options.rm_safe("backend_opengl3") + self.options.rm_safe("backend_osx") + self.options.rm_safe("backend_sdl2") + self.options.rm_safe("backend_sdlrenderer2") + self.options.rm_safe("backend_sdlrenderer3") + self.options.rm_safe("backend_vulkan") + self.options.rm_safe("backend_win32") + self.options.rm_safe("backend_wgpu") + if not self.options.enable_freetype: + del self.options.enable_freetype_lunasvg def layout(self): cmake_layout(self, src_folder="src") + def requirements(self): + # if self.options.get_safe("backend_allegro5"): + # self.requi`res("allegro5/0") + if self.options.get_safe("backend_opengl2") or self.options.get_safe("backend_opengl3"): + self.requires("opengl/system") + if self.options.get_safe("backend_glut") and self.settings.os != "Emscripten": + self.requires("freeglut/3.4.0") + if self.options.get_safe("backend_sdl2") or self.options.get_safe("backend_sdlrenderer2"): + self.requires("sdl/2.30.6") + # elif self.options.get_safe("backend_sdlrenderer3"): + # self.requires("sdl/3.x") + if self.options.get_safe("backend_vulkan"): + self.requires("vulkan-loader/1.3.290.0") + if self.options.get_safe("backend_glfw") and self.settings.os != "Emscripten": + self.requires("glfw/3.4") + # if self.options.get_safe("backend_wgpu"): + # self.requires("dawn/cci.20240726") + if self.options.enable_freetype: + self.requires("freetype/2.13.2") + if self.options.enable_freetype_lunasvg: + self.requires("lunasvg/2.4.0") + + def validate(self): + if self.settings.compiler.cppstd: + check_min_cppstd(self, 11) + def source(self): get(self, **self.conan_data["sources"][self.version], strip_root=True) def generate(self): tc = CMakeToolchain(self) - tc.variables["IMGUI_SRC_DIR"] = self.source_folder.replace("\\", "/") + tc.cache_variables["IMGUI_IMPL_ALLEGRO5"] = self.options.get_safe("backend_allegro5", False) + tc.cache_variables["IMGUI_IMPL_ANDROID"] = self.options.get_safe("backend_android", False) + tc.cache_variables["IMGUI_IMPL_DX9"] = self.options.get_safe("backend_dx9", False) + tc.cache_variables["IMGUI_IMPL_DX10"] = self.options.get_safe("backend_dx10", False) + tc.cache_variables["IMGUI_IMPL_DX11"] = self.options.get_safe("backend_dx11", False) + tc.cache_variables["IMGUI_IMPL_DX12"] = self.options.get_safe("backend_dx12", False) + tc.cache_variables["IMGUI_IMPL_GLFW"] = self.options.get_safe("backend_glfw", False) + tc.cache_variables["IMGUI_IMPL_GLUT"] = self.options.get_safe("backend_glut", False) + tc.cache_variables["IMGUI_IMPL_METAL"] = self.options.get_safe("backend_metal", False) + tc.cache_variables["IMGUI_IMPL_OPENGL2"] = self.options.get_safe("backend_opengl2", False) + tc.cache_variables["IMGUI_IMPL_OPENGL3"] = self.options.get_safe("backend_opengl3", False) + tc.cache_variables["IMGUI_IMPL_OSX"] = self.options.get_safe("backend_osx", False) + tc.cache_variables["IMGUI_IMPL_SDL2"] = self.options.get_safe("backend_sdl2", False) + tc.cache_variables["IMGUI_IMPL_SDLRENDERER2"] = self.options.get_safe("backend_sdlrenderer2", False) + tc.cache_variables["IMGUI_IMPL_SDLRENDERER3"] = self.options.get_safe("backend_sdlrenderer3", False) + tc.cache_variables["IMGUI_IMPL_VULKAN"] = self.options.get_safe("backend_vulkan", False) + tc.cache_variables["IMGUI_IMPL_WIN32"] = self.options.get_safe("backend_win32", False) + tc.cache_variables["IMGUI_IMPL_WGPU"] = self.options.get_safe("backend_wgpu", False) + tc.cache_variables["IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS"] = self.options.get_safe("enable_osx_clipboard", False) + tc.cache_variables["IMGUI_FREETYPE"] = self.options.enable_freetype + tc.cache_variables["IMGUI_FREETYPE_LUNASVG"] = self.options.get_safe("enable_freetype_lunasvg", False) + tc.cache_variables["IMGUI_BUILD_PROGRAMS"] = self.options.build_programs tc.generate() + deps = CMakeDeps(self) + deps.generate() + + def _configure_header(self): + defines = {} + defines["IMGUI_ENABLE_FREETYPE"] = self.options.enable_freetype + defines["IMGUI_ENABLE_FREETYPE_LUNASVG"] = self.options.get_safe("enable_freetype_lunasvg") + defines["IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS"] = self.options.get_safe("enable_osx_clipboard") + # Build default IME handler on MinGW as well, not just MSVC. Only disabled there due to a lack of autolinking support. + defines["IMGUI_ENABLE_WIN32_DEFAULT_IME_FUNCTIONS"] = True + defines["IMGUI_USE_BGRA_PACKED_COLOR"] = self.options.use_bgra_packed_color + defines["IMGUI_USE_WCHAR32"] = self.options.use_wchar32 + defines["IMGUI_DISABLE_DEMO_WINDOWS"] = not self.options.enable_demo_windows + defines["IMGUI_DISABLE_DEBUG_TOOLS"] = not self.options.enable_debug_tools + + imconfig_path = Path(self.source_folder, "imconfig.h") + content = imconfig_path.read_text("utf8") + for define, value in defines.items(): + if value: + content, n = re.subn(rf"// *#define +{define}\b", f"#define {define}", content) + if n != 1: + raise ConanException(f"Failed to set {define} in imconfig.h") + imconfig_path.write_text(content, "utf8") + def _patch_sources(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" - ) + 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): + self._configure_header() self._patch_sources() cmake = CMake(self) - cmake.configure(build_script_folder=os.path.join(self.source_folder, os.pardir)) + cmake.configure() cmake.build() - def _match_docking_branch(self): - return re.match(r'cci\.\d{8}\+(?P\d+\.\d+(?:\.\d+))\.docking', str(self.version)) - def package(self): - copy(self, pattern="LICENSE.txt", dst=os.path.join(self.package_folder, "licenses"), src=self.source_folder) - m = self._match_docking_branch() - version = Version(m.group('version')) if m else Version(self.version) - backends_folder = os.path.join( - self.source_folder, - "backends" if version >= "1.80" else "examples" - ) - 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")) + copy(self, "LICENSE.txt", self.source_folder, os.path.join(self.package_folder, "licenses")) cmake = CMake(self) cmake.install() + # Package ImGui sources for users that need more fine-grained control + version = Version(self.version.replace("-docking", "")) + backends_folder = os.path.join(self.source_folder, "backends" if version >= "1.80" else "examples") + res_folder = os.path.join(self.package_folder, "res") + copy(self, "imgui_impl_*", backends_folder, os.path.join(res_folder, "bindings")) + copy(self, "imgui*.cpp", self.source_folder, os.path.join(res_folder, "src")) + copy(self, "*", os.path.join(self.source_folder, "misc", "cpp"), os.path.join(res_folder, "misc", "cpp")) + copy(self, "*", os.path.join(self.source_folder, "misc", "freetype"), os.path.join(res_folder, "misc", "freetype")) + def package_info(self): - self.conf_info.define("user.imgui:with_docking", bool(self._match_docking_branch())) + # Unofficial aggregate target. Prefer the individual targets instead. + self.cpp_info.set_property("cmake_target_name", "imgui::imgui_all") - 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")] + self.cpp_info.components["core"].set_property("cmake_target_name", "imgui::imgui") + self.cpp_info.components["core"].set_property("pkg_config_name", "imgui") + self.cpp_info.components["core"].libs = ["imgui"] + self.cpp_info.components["core"].srcdirs = [os.path.join("res", "bindings")] + if self.settings.os in ["Linux", "FreeBSD"]: + self.cpp_info.components["core"].system_libs.append("m") + elif self.settings.os == "Windows": + self.cpp_info.components["core"].system_libs.append("imm32") + elif is_apple_os(self): + if self.options.enable_osx_clipboard: + self.cpp_info.components["core"].frameworks.append("ApplicationServices") + + if self.options.enable_freetype: + self.cpp_info.components["freetype"].libs = ["imgui-freetype"] + self.cpp_info.components["freetype"].requires.append("freetype::freetype") + if self.options.enable_freetype_lunasvg: + self.cpp_info.components["freetype"].requires.append("lunasvg::lunasvg") + + def _add_binding(name, requires=None, system_libs=None, frameworks=None): + if self.options.get_safe(f"backend_{name}"): + self.cpp_info.components[name].libs = [f"imgui-{name}"] + self.cpp_info.components[name].requires = ["core"] + self.cpp_info.components[name].requires = requires or [] + self.cpp_info.components[name].system_libs = system_libs or [] + self.cpp_info.components[name].frameworks = frameworks or [] + + # _add_binding("allegro5", requires=[ + # "allegro::allegro", + # "allegro::allegro_ttf", + # "allegro::allegro_font", + # "allegro::allegro_main", + # ]) + _add_binding("android", system_libs=["android", "log", "EGL", "GLESv3"]) + _add_binding("dx9", system_libs=["d3d9"]) + _add_binding("dx10", system_libs=["d3d10"]) + _add_binding("dx11", system_libs=["d3d11"]) + _add_binding("dx12", system_libs=["d3d12"]) + _add_binding("glfw", requires=["glfw::glfw"] if self.settings.os != "Emscripten" else []) + _add_binding("glut", requires=["freeglut::freeglut"] if self.settings.os != "Emscripten" else []) + _add_binding("metal", frameworks=["Metal", "Cocoa", "QuartzCore"]) + _add_binding("opengl2", requires=["opengl::opengl"]) + _add_binding("opengl3", requires=["opengl::opengl"]) + _add_binding("osx", frameworks=["Cocoa", "AppKit"]) + _add_binding("sdl2", requires=["sdl::sdl"]) + _add_binding("sdlrenderer2", requires=["sdl::sdl"]) + # _add_binding("sdlrenderer3", requires=["sdl::sdl"]) + _add_binding("vulkan", requires=["vulkan-loader::vulkan-loader"]) + _add_binding("win32", system_libs=["dwmapi", "xinput"]) + # _add_binding("wgpu", requires=["dawn::dawn"]) + + self.conf_info.define("user.imgui:with_docking", "-docking" in self.version) - 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) + if self.options.build_programs: + self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/imgui/all/test_package/CMakeLists.txt b/recipes/imgui/all/test_package/CMakeLists.txt index e5abc72962c86..d1d70c69f2634 100644 --- a/recipes/imgui/all/test_package/CMakeLists.txt +++ b/recipes/imgui/all/test_package/CMakeLists.txt @@ -4,13 +4,7 @@ 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() - +# Using the aggregate target for easier testing. +target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui_all) 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/recipes/imgui/all/test_package/conanfile.py b/recipes/imgui/all/test_package/conanfile.py index b97c0a2e4d75c..75c7df8e6198c 100644 --- a/recipes/imgui/all/test_package/conanfile.py +++ b/recipes/imgui/all/test_package/conanfile.py @@ -16,10 +16,37 @@ def requirements(self): def layout(self): cmake_layout(self) + @property + def _backends(self): + return [ + "allegro5", + "android", + "dx9", + "dx10", + "dx11", + "dx12", + "glfw", + "glut", + "metal", + "opengl2", + "opengl3", + "osx", + "sdl2", + "sdlrenderer2", + "sdlrenderer3", + "vulkan", + "win32", + "wgpu", + ] + def generate(self): with_docking = self.dependencies[self.tested_reference_str].conf_info.get("user.imgui:with_docking", False) tc = CMakeToolchain(self) - tc.variables["DOCKING"] = with_docking + if with_docking: + tc.preprocessor_definitions["DOCKING"] = "" + for backend in self._backends: + if str(self.dependencies[self.tested_reference_str].options.get_safe(f"backend_{backend}", False)) == "True": + tc.preprocessor_definitions[f"IMGUI_IMPL_{backend.upper()}"] = "" tc.generate() def build(self): diff --git a/recipes/imgui/all/test_package/test_package.cpp b/recipes/imgui/all/test_package/test_package.cpp index 37c38430fa7a8..37a6bce806623 100644 --- a/recipes/imgui/all/test_package/test_package.cpp +++ b/recipes/imgui/all/test_package/test_package.cpp @@ -1,12 +1,124 @@ #include + #ifdef DOCKING #include #endif -#include +#ifdef IMGUI_IMPL_ALLEGRO5 + #include +#endif +#ifdef IMGUI_IMPL_ANDROID + #include +#endif +#ifdef IMGUI_IMPL_DX9 + #include +#endif +#ifdef IMGUI_IMPL_DX10 + #include +#endif +#ifdef IMGUI_IMPL_DX11 + #include +#endif +#ifdef IMGUI_IMPL_DX12 + #include +#endif +#ifdef IMGUI_IMPL_GLFW + #include +#endif +#ifdef IMGUI_IMPL_GLUT + #include +#endif +#ifdef IMGUI_IMPL_METAL + #include +#endif +#ifdef IMGUI_IMPL_OPENGL2 + #include +#endif +#ifdef IMGUI_IMPL_OPENGL3 + #include +#endif +#ifdef IMGUI_IMPL_OSX + #include +#endif +#ifdef IMGUI_IMPL_SDL2 + #include +#endif +#ifdef IMGUI_IMPL_SDLRENDERER2 + #include +#endif +#ifdef IMGUI_IMPL_SDLRENDERER3 + #include +#endif +#ifdef IMGUI_IMPL_VULKAN + #include +#endif +#ifdef IMGUI_IMPL_WIN32 + #include +#endif +#ifdef IMGUI_IMPL_WGPU + #include +#endif + +#include + +void test_backends() { +#ifdef IMGUI_IMPL_ALLEGRO5 + ImGui_ImplAllegro5_Shutdown(); +#endif +#ifdef IMGUI_IMPL_ANDROID + ImGui_ImplAndroid_Shutdown(); +#endif +#ifdef IMGUI_IMPL_DX9 + ImGui_ImplDX9_Shutdown(); +#endif +#ifdef IMGUI_IMPL_DX10 + ImGui_ImplDX10_Shutdown(); +#endif +#ifdef IMGUI_IMPL_DX11 + ImGui_ImplDX11_Shutdown(); +#endif +#ifdef IMGUI_IMPL_DX12 + ImGui_ImplDX12_Shutdown(); +#endif +#ifdef IMGUI_IMPL_GLFW + ImGui_ImplGlfw_Shutdown(); +#endif +#ifdef IMGUI_IMPL_GLUT + ImGui_ImplGLUT_Shutdown(); +#endif +#ifdef IMGUI_IMPL_METAL + ImGui_ImplMetal_Shutdown(); +#endif +#ifdef IMGUI_IMPL_OPENGL2 + ImGui_ImplOpenGL2_Shutdown(); +#endif +#ifdef IMGUI_IMPL_OPENGL3 + ImGui_ImplOpenGL3_Shutdown(); +#endif +#ifdef IMGUI_IMPL_OSX + ImGui_ImplOSX_Shutdown(); +#endif +#ifdef IMGUI_IMPL_SDL2 + ImGui_ImplSDL2_Shutdown(); +#endif +#ifdef IMGUI_IMPL_SDLRENDERER2 + ImGui_ImplSDLRenderer2_Shutdown(); +#endif +#ifdef IMGUI_IMPL_SDLRENDERER3 + ImGui_ImplSDLRenderer3_Shutdown(); +#endif +#ifdef IMGUI_IMPL_VULKAN + ImGui_ImplVulkan_Shutdown(); +#endif +#ifdef IMGUI_IMPL_WIN32 + ImGui_ImplWin32_Shutdown(); +#endif +#ifdef IMGUI_IMPL_WGPU + ImGui_ImplWGPU_Shutdown(); +#endif +} -int main(int, char**) -{ +int main() { printf("IMGUI VERSION: %s\n", IMGUI_VERSION); ImGui::CreateContext(); #ifdef DOCKING From 27bdbd08ec452ec3f9ba2f59cfe63ed74a1504b4 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 23 Sep 2024 09:14:24 +0300 Subject: [PATCH 02/23] imgui: disable glut backend due missing binaries and being considered legacy --- recipes/imgui/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index 5505517483f0a..e256c05e9d8b0 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -69,7 +69,7 @@ class ImguiConan(ConanFile): "backend_dx11": False, "backend_dx12": False, "backend_glfw": True, - "backend_glut": True, + "backend_glut": False, "backend_metal": True, "backend_opengl2": True, "backend_opengl3": True, From a2c92f964cd50d1495c25e94211b28fec6a9abf2 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 23 Sep 2024 09:34:32 +0300 Subject: [PATCH 03/23] imgui: add transitive vulkan-headers --- recipes/imgui/all/conanfile.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index e256c05e9d8b0..c4a2fd000808b 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -148,6 +148,7 @@ def requirements(self): # elif self.options.get_safe("backend_sdlrenderer3"): # self.requires("sdl/3.x") if self.options.get_safe("backend_vulkan"): + self.requires("vulkan-headers/1.3.290.0", transitive_headers=True) self.requires("vulkan-loader/1.3.290.0") if self.options.get_safe("backend_glfw") and self.settings.os != "Emscripten": self.requires("glfw/3.4") @@ -292,7 +293,7 @@ def _add_binding(name, requires=None, system_libs=None, frameworks=None): _add_binding("sdl2", requires=["sdl::sdl"]) _add_binding("sdlrenderer2", requires=["sdl::sdl"]) # _add_binding("sdlrenderer3", requires=["sdl::sdl"]) - _add_binding("vulkan", requires=["vulkan-loader::vulkan-loader"]) + _add_binding("vulkan", requires=["vulkan-headers::vulkan-headers", "vulkan-loader::vulkan-loader"]) _add_binding("win32", system_libs=["dwmapi", "xinput"]) # _add_binding("wgpu", requires=["dawn::dawn"]) From 3b715bc9f518b1ad53cf24fe1334416df06a173e Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 23 Sep 2024 10:09:15 +0300 Subject: [PATCH 04/23] imgui: sdl2 backend is not available in old versions --- recipes/imgui/all/conanfile.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index c4a2fd000808b..bd0b5019f93fb 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -107,6 +107,9 @@ def config_options(self): del self.options.backend_metal del self.options.backend_osx del self.options.enable_osx_clipboard + if Version(self.version) < "1.89.6": + del self.options.backend_sdl2 + del self.options.backend_sdlrenderer2 def configure(self): if self.options.shared: From 5584c834deb76273fc14bf8186a7b3d70915d91f Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 23 Sep 2024 10:13:22 +0300 Subject: [PATCH 05/23] imgui: bump sdl --- recipes/imgui/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index bd0b5019f93fb..85c26646f63b6 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -147,7 +147,7 @@ def requirements(self): if self.options.get_safe("backend_glut") and self.settings.os != "Emscripten": self.requires("freeglut/3.4.0") if self.options.get_safe("backend_sdl2") or self.options.get_safe("backend_sdlrenderer2"): - self.requires("sdl/2.30.6") + self.requires("sdl/2.30.7") # elif self.options.get_safe("backend_sdlrenderer3"): # self.requires("sdl/3.x") if self.options.get_safe("backend_vulkan"): From f68daa9846a927d90b89c65af715bc189e9f7c66 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 23 Sep 2024 11:03:50 +0300 Subject: [PATCH 06/23] imgui: move Objective-C++ backends to a separate test --- recipes/imgui/all/test_package/CMakeLists.txt | 11 +++++-- recipes/imgui/all/test_package/conanfile.py | 8 +++-- .../imgui/all/test_package/test_package.cpp | 12 ------- .../imgui/all/test_package/test_package.mm | 33 +++++++++++++++++++ 4 files changed, 48 insertions(+), 16 deletions(-) create mode 100644 recipes/imgui/all/test_package/test_package.mm diff --git a/recipes/imgui/all/test_package/CMakeLists.txt b/recipes/imgui/all/test_package/CMakeLists.txt index d1d70c69f2634..d252145610b31 100644 --- a/recipes/imgui/all/test_package/CMakeLists.txt +++ b/recipes/imgui/all/test_package/CMakeLists.txt @@ -1,10 +1,17 @@ -cmake_minimum_required(VERSION 3.8) +cmake_minimum_required(VERSION 3.15) project(test_package LANGUAGES CXX) find_package(imgui REQUIRED CONFIG) +add_compile_definitions("IMGUI_USER_CONFIG=\"${CMAKE_CURRENT_SOURCE_DIR}/my_imgui_config.h\"") add_executable(${PROJECT_NAME} test_package.cpp) # Using the aggregate target for easier testing. target_link_libraries(${PROJECT_NAME} PRIVATE imgui::imgui_all) -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) + +if(APPLE) + enable_language(OBJCXX) + add_executable(${PROJECT_NAME}_objcxx test_package.mm) + target_link_libraries(${PROJECT_NAME}_objcxx PRIVATE imgui::imgui_all) + target_compile_features(${PROJECT_NAME}_objcxx PRIVATE cxx_std_11) +endif() diff --git a/recipes/imgui/all/test_package/conanfile.py b/recipes/imgui/all/test_package/conanfile.py index 75c7df8e6198c..c450d7c3758a8 100644 --- a/recipes/imgui/all/test_package/conanfile.py +++ b/recipes/imgui/all/test_package/conanfile.py @@ -1,8 +1,8 @@ from conan import ConanFile +from conan.tools.apple import is_apple_os from conan.tools.build import can_run from conan.tools.cmake import cmake_layout, CMake, CMakeToolchain import os -import re class TestPackageConan(ConanFile): @@ -56,5 +56,9 @@ def build(self): def test(self): if can_run(self): - bin_path = os.path.join(self.cpp.build.bindirs[0], "test_package") + bin_path = os.path.join(self.cpp.build.bindir, "test_package") self.run(bin_path, env="conanrun") + + if is_apple_os(self): + bin_path = os.path.join(self.cpp.build.bindir, "test_package_objcxx") + self.run(bin_path, env="conanrun") diff --git a/recipes/imgui/all/test_package/test_package.cpp b/recipes/imgui/all/test_package/test_package.cpp index 37a6bce806623..26d62cfba7375 100644 --- a/recipes/imgui/all/test_package/test_package.cpp +++ b/recipes/imgui/all/test_package/test_package.cpp @@ -28,18 +28,12 @@ #ifdef IMGUI_IMPL_GLUT #include #endif -#ifdef IMGUI_IMPL_METAL - #include -#endif #ifdef IMGUI_IMPL_OPENGL2 #include #endif #ifdef IMGUI_IMPL_OPENGL3 #include #endif -#ifdef IMGUI_IMPL_OSX - #include -#endif #ifdef IMGUI_IMPL_SDL2 #include #endif @@ -86,18 +80,12 @@ void test_backends() { #ifdef IMGUI_IMPL_GLUT ImGui_ImplGLUT_Shutdown(); #endif -#ifdef IMGUI_IMPL_METAL - ImGui_ImplMetal_Shutdown(); -#endif #ifdef IMGUI_IMPL_OPENGL2 ImGui_ImplOpenGL2_Shutdown(); #endif #ifdef IMGUI_IMPL_OPENGL3 ImGui_ImplOpenGL3_Shutdown(); #endif -#ifdef IMGUI_IMPL_OSX - ImGui_ImplOSX_Shutdown(); -#endif #ifdef IMGUI_IMPL_SDL2 ImGui_ImplSDL2_Shutdown(); #endif diff --git a/recipes/imgui/all/test_package/test_package.mm b/recipes/imgui/all/test_package/test_package.mm new file mode 100644 index 0000000000000..56feca5cbfd6c --- /dev/null +++ b/recipes/imgui/all/test_package/test_package.mm @@ -0,0 +1,33 @@ +#include + +#ifdef DOCKING + #include +#endif + +#ifdef IMGUI_IMPL_OSX + #include +#endif +#ifdef IMGUI_IMPL_METAL + #include +#endif + +#include + +void test_backends() { +#ifdef IMGUI_IMPL_OSX + ImGui_ImplOSX_Shutdown(); +#endif +#ifdef IMGUI_IMPL_METAL + ImGui_ImplMetal_Shutdown(); +#endif +} + +int main() { + printf("IMGUI VERSION: %s\n", IMGUI_VERSION); + ImGui::CreateContext(); +#ifdef DOCKING + printf(" with docking\n"); +#endif + ImGui::DestroyContext(); + return 0; +} From 293df93c922d13e43db01b9b370c40d66961ebf1 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 23 Sep 2024 11:39:38 +0300 Subject: [PATCH 07/23] imgui: ensure cxx_std_11 is set --- recipes/imgui/all/CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/recipes/imgui/all/CMakeLists.txt b/recipes/imgui/all/CMakeLists.txt index 66f632cde1f22..99e397da336fc 100644 --- a/recipes/imgui/all/CMakeLists.txt +++ b/recipes/imgui/all/CMakeLists.txt @@ -1,6 +1,10 @@ cmake_minimum_required(VERSION 3.15) project(imgui LANGUAGES CXX) +if(NOT DEFINED CMAKE_CXX_STANDARD) + set(CMAKE_CXX_STANDARD 11) +endif() + add_library(imgui imgui.cpp imgui_demo.cpp @@ -15,7 +19,6 @@ set_target_properties(imgui PROPERTIES VISIBILITY_INLINES_HIDDEN ON ) target_include_directories(imgui PUBLIC ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) -target_compile_features(imgui PRIVATE cxx_std_11) set(IMGUI_EXPORT_HEADERS imgui_export_headers.h) include(GenerateExportHeader) @@ -174,7 +177,6 @@ endif() if(IMGUI_IMPL_TOOLS) add_executable(binary_to_compressed_c misc/fonts/binary_to_compressed_c.cpp) - target_compile_features(binary_to_compressed_c PRIVATE cxx_std_11) install(TARGETS binary_to_compressed_c DESTINATION bin) endif() From 989430c2c8aca86802d9317b84862c02ace1ebc1 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 23 Sep 2024 12:32:54 +0300 Subject: [PATCH 08/23] imgui: fix required macOS frameworks --- recipes/imgui/all/CMakeLists.txt | 14 ++++++++++++-- recipes/imgui/all/conanfile.py | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/recipes/imgui/all/CMakeLists.txt b/recipes/imgui/all/CMakeLists.txt index 99e397da336fc..3260fecf1925b 100644 --- a/recipes/imgui/all/CMakeLists.txt +++ b/recipes/imgui/all/CMakeLists.txt @@ -94,7 +94,11 @@ if(IMGUI_IMPL_METAL) enable_language(OBJCXX) add_library(imgui-metal backends/imgui_impl_metal.mm) set_source_files_properties(backends/imgui_impl_metal.mm PROPERTIES COMPILE_FLAGS -fobjc-weak) - target_link_libraries(imgui-metal PRIVATE "-framework Metal" "-framework Cocoa" "-framework QuartzCore") + target_link_libraries(imgui-metal PRIVATE + "-framework Foundation" + "-framework Metal" + "-framework QuartzCore" + ) install(FILES backends/imgui_impl_metal.h DESTINATION include) list(APPEND IMGUI_COMPONENTS imgui-metal) endif() @@ -119,7 +123,13 @@ endif() if(IMGUI_IMPL_OSX) enable_language(OBJCXX) add_library(imgui-osx backends/imgui_impl_osx.mm) - target_link_libraries(imgui-osx INTERFACE "-framework Cocoa" "-framework AppKit") + target_link_libraries(imgui-osx PRIVATE + "-framework AppKit" + "-framework Carbon" + "-framework Cocoa" + "-framework Foundation" + "-framework GameController" + ) install(FILES backends/imgui_impl_osx.h DESTINATION include) list(APPEND IMGUI_COMPONENTS imgui-osx) endif() diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index 85c26646f63b6..96feb2b1bdbcb 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -289,10 +289,10 @@ def _add_binding(name, requires=None, system_libs=None, frameworks=None): _add_binding("dx12", system_libs=["d3d12"]) _add_binding("glfw", requires=["glfw::glfw"] if self.settings.os != "Emscripten" else []) _add_binding("glut", requires=["freeglut::freeglut"] if self.settings.os != "Emscripten" else []) - _add_binding("metal", frameworks=["Metal", "Cocoa", "QuartzCore"]) + _add_binding("metal", frameworks=["Foundation", "Metal", "QuartzCore"]) _add_binding("opengl2", requires=["opengl::opengl"]) _add_binding("opengl3", requires=["opengl::opengl"]) - _add_binding("osx", frameworks=["Cocoa", "AppKit"]) + _add_binding("osx", frameworks=["AppKit", "Carbon", "Cocoa", "Foundation", "GameController"]) _add_binding("sdl2", requires=["sdl::sdl"]) _add_binding("sdlrenderer2", requires=["sdl::sdl"]) # _add_binding("sdlrenderer3", requires=["sdl::sdl"]) From 4f1fac69339caf12ba90e8c9ce72e585391123d5 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 23 Sep 2024 12:33:21 +0300 Subject: [PATCH 09/23] imgui: add enable_metal_cpp option --- recipes/imgui/all/conanfile.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index 96feb2b1bdbcb..a9c062d508266 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -51,6 +51,7 @@ class ImguiConan(ConanFile): # See https://github.com/ocornut/imgui/blob/master/imconfig.h for details "enable_freetype": [True, False], "enable_freetype_lunasvg": [True, False], + "enable_metal_cpp": [True, False], "enable_osx_clipboard": [True, False], "enable_demo_windows": [True, False], "enable_debug_tools": [True, False], @@ -81,6 +82,7 @@ class ImguiConan(ConanFile): # Other options "enable_freetype": False, "enable_freetype_lunasvg": False, + "enable_metal_cpp": False, "enable_osx_clipboard": True, "enable_demo_windows": True, "enable_debug_tools": True, @@ -106,10 +108,13 @@ def config_options(self): if not is_apple_os(self): del self.options.backend_metal del self.options.backend_osx + del self.options.enable_metal_cpp del self.options.enable_osx_clipboard if Version(self.version) < "1.89.6": del self.options.backend_sdl2 del self.options.backend_sdlrenderer2 + if Version(self.version) < "1.87": + self.options.rm_safe("enable_metal_cpp") def configure(self): if self.options.shared: @@ -217,6 +222,10 @@ def _configure_header(self): content, n = re.subn(rf"// *#define +{define}\b", f"#define {define}", content) if n != 1: raise ConanException(f"Failed to set {define} in imconfig.h") + # Not listed in imconfig.h, but supported by the OSX and Metal backends + if self.options.get_safe("enable_metal_cpp"): + content += "\n#define IMGUI_IMPL_METAL_CPP\n" + content += "#define IMGUI_IMPL_METAL_CPP_EXTENSIONS\n" imconfig_path.write_text(content, "utf8") def _patch_sources(self): From 4163b7008a7994ed69f87f78c08f91a1a3444bbb Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 23 Sep 2024 16:42:48 +0300 Subject: [PATCH 10/23] imgui: rename export header --- recipes/imgui/all/CMakeLists.txt | 6 +++--- recipes/imgui/all/conanfile.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/recipes/imgui/all/CMakeLists.txt b/recipes/imgui/all/CMakeLists.txt index 3260fecf1925b..cf962aeacd9cd 100644 --- a/recipes/imgui/all/CMakeLists.txt +++ b/recipes/imgui/all/CMakeLists.txt @@ -20,11 +20,11 @@ set_target_properties(imgui PROPERTIES ) target_include_directories(imgui PUBLIC ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) -set(IMGUI_EXPORT_HEADERS imgui_export_headers.h) +set(IMGUI_EXPORT_HEADER imgui_export.h) include(GenerateExportHeader) generate_export_header(imgui EXPORT_MACRO_NAME IMGUI_API - EXPORT_FILE_NAME ${IMGUI_EXPORT_HEADERS} + EXPORT_FILE_NAME ${IMGUI_EXPORT_HEADER} ) if(IMGUI_IMPL_ALLEGRO5) @@ -200,7 +200,7 @@ file(GLOB IMGUI_HEADERS *.h) install(FILES misc/cpp/imgui_stdlib.h ${IMGUI_HEADERS} - ${PROJECT_BINARY_DIR}/${IMGUI_EXPORT_HEADERS} + ${PROJECT_BINARY_DIR}/${IMGUI_EXPORT_HEADER} DESTINATION include ) diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index a9c062d508266..9fd9f00bc5d01 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -229,10 +229,10 @@ def _configure_header(self): imconfig_path.write_text(content, "utf8") def _patch_sources(self): - # Ensure we take into account export_headers + # Ensure the generated imgui_export.h is always included 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') + '#include "imconfig.h"', + '#include "imconfig.h"\n\n#include "imgui_export.h"') def build(self): self._configure_header() From 5055e379177162154f7b4796b1aa4dcdc8bb84f1 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 24 Sep 2024 07:52:48 +0300 Subject: [PATCH 11/23] imgui: fix MSVC shared build --- recipes/imgui/all/CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/recipes/imgui/all/CMakeLists.txt b/recipes/imgui/all/CMakeLists.txt index cf962aeacd9cd..5531776693561 100644 --- a/recipes/imgui/all/CMakeLists.txt +++ b/recipes/imgui/all/CMakeLists.txt @@ -26,6 +26,8 @@ generate_export_header(imgui EXPORT_MACRO_NAME IMGUI_API EXPORT_FILE_NAME ${IMGUI_EXPORT_HEADER} ) +# Enable __declspec(dllexport) in backend libs as well +add_compile_definitions(imgui_EXPORTS) if(IMGUI_IMPL_ALLEGRO5) find_package(Allegro CONFIG REQUIRED) From cb5e64b7bcab5c79ff268c63e064dbc6470a4afb Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 24 Sep 2024 07:58:27 +0300 Subject: [PATCH 12/23] imgui: freetype support cannot be built separately --- recipes/imgui/all/CMakeLists.txt | 7 +++---- recipes/imgui/all/conanfile.py | 8 +++----- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/recipes/imgui/all/CMakeLists.txt b/recipes/imgui/all/CMakeLists.txt index 5531776693561..95248b8205967 100644 --- a/recipes/imgui/all/CMakeLists.txt +++ b/recipes/imgui/all/CMakeLists.txt @@ -169,14 +169,13 @@ endif() if(IMGUI_FREETYPE) find_package(freetype CONFIG REQUIRED) - add_library(imgui-freetype PRIVATE misc/freetype/imgui_freetype.cpp) - target_link_libraries(imgui-freetype PRIVATE freetype) + target_sources(imgui PRIVATE misc/freetype/imgui_freetype.cpp) + target_link_libraries(imgui PRIVATE freetype) install(FILES misc/freetype/imgui_freetype.h DESTINATION include) if(IMGUI_FREETYPE_LUNASVG) find_package(lunasvg CONFIG REQUIRED) - target_link_libraries(imgui-freetype PRIVATE lunasvg::lunasvg) + target_link_libraries(imgui PRIVATE lunasvg::lunasvg) endif() - list(APPEND IMGUI_COMPONENTS imgui-freetype) endif() foreach(component ${IMGUI_COMPONENTS}) diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index 9fd9f00bc5d01..41d191e3f5231 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -80,7 +80,7 @@ class ImguiConan(ConanFile): "backend_vulkan": True, "backend_win32": True, # Other options - "enable_freetype": False, + "enable_freetype": True, "enable_freetype_lunasvg": False, "enable_metal_cpp": False, "enable_osx_clipboard": True, @@ -270,12 +270,10 @@ def package_info(self): elif is_apple_os(self): if self.options.enable_osx_clipboard: self.cpp_info.components["core"].frameworks.append("ApplicationServices") - if self.options.enable_freetype: - self.cpp_info.components["freetype"].libs = ["imgui-freetype"] - self.cpp_info.components["freetype"].requires.append("freetype::freetype") + self.cpp_info.components["core"].requires.append("freetype::freetype") if self.options.enable_freetype_lunasvg: - self.cpp_info.components["freetype"].requires.append("lunasvg::lunasvg") + self.cpp_info.components["core"].requires.append("lunasvg::lunasvg") def _add_binding(name, requires=None, system_libs=None, frameworks=None): if self.options.get_safe(f"backend_{name}"): From bd5139b7d3b1790e83428ea270523ad762fd4bbd Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 24 Sep 2024 07:58:55 +0300 Subject: [PATCH 13/23] imgui: enable DirectX 9 and 10, Metal C++ bindings --- recipes/imgui/all/conanfile.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index 41d191e3f5231..3bbb764ad32fd 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -65,8 +65,8 @@ class ImguiConan(ConanFile): # Backends "build_backends": True, "backend_android": True, - "backend_dx9": False, - "backend_dx10": False, + "backend_dx9": True, + "backend_dx10": True, "backend_dx11": False, "backend_dx12": False, "backend_glfw": True, @@ -82,7 +82,7 @@ class ImguiConan(ConanFile): # Other options "enable_freetype": True, "enable_freetype_lunasvg": False, - "enable_metal_cpp": False, + "enable_metal_cpp": True, "enable_osx_clipboard": True, "enable_demo_windows": True, "enable_debug_tools": True, From 823aa9f2de2cb9b6b8535b9109e152c1fdf29e95 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 24 Sep 2024 08:00:22 +0300 Subject: [PATCH 14/23] imgui: tidy CMakeLists.txt --- recipes/imgui/all/CMakeLists.txt | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/recipes/imgui/all/CMakeLists.txt b/recipes/imgui/all/CMakeLists.txt index 95248b8205967..c4f4c9ace4c4f 100644 --- a/recipes/imgui/all/CMakeLists.txt +++ b/recipes/imgui/all/CMakeLists.txt @@ -13,13 +13,13 @@ add_library(imgui imgui_widgets.cpp misc/cpp/imgui_stdlib.cpp ) +target_include_directories(imgui PUBLIC ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) + set_target_properties(imgui PROPERTIES CXX_VISIBILITY_PRESET hidden OBJCXX_VISIBILITY_PRESET hidden VISIBILITY_INLINES_HIDDEN ON ) -target_include_directories(imgui PUBLIC ${CMAKE_SOURCE_DIR} ${CMAKE_BINARY_DIR}) - set(IMGUI_EXPORT_HEADER imgui_export.h) include(GenerateExportHeader) generate_export_header(imgui @@ -29,6 +29,21 @@ generate_export_header(imgui # Enable __declspec(dllexport) in backend libs as well add_compile_definitions(imgui_EXPORTS) +if(IMGUI_FREETYPE) + find_package(freetype CONFIG REQUIRED) + target_sources(imgui PRIVATE misc/freetype/imgui_freetype.cpp) + target_link_libraries(imgui PRIVATE freetype) + install(FILES misc/freetype/imgui_freetype.h DESTINATION include) + if(IMGUI_FREETYPE_LUNASVG) + find_package(lunasvg CONFIG REQUIRED) + target_link_libraries(imgui PRIVATE lunasvg::lunasvg) + endif() +endif() + +if(IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS) + target_link_libraries(imgui PRIVATE "-framework ApplicationServices") +endif() + if(IMGUI_IMPL_ALLEGRO5) find_package(Allegro CONFIG REQUIRED) add_library(imgui-allegro5 backends/imgui_impl_allegro5.cpp) @@ -167,25 +182,10 @@ if(IMGUI_IMPL_WIN32) list(APPEND IMGUI_COMPONENTS imgui-win32) endif() -if(IMGUI_FREETYPE) - find_package(freetype CONFIG REQUIRED) - target_sources(imgui PRIVATE misc/freetype/imgui_freetype.cpp) - target_link_libraries(imgui PRIVATE freetype) - install(FILES misc/freetype/imgui_freetype.h DESTINATION include) - if(IMGUI_FREETYPE_LUNASVG) - find_package(lunasvg CONFIG REQUIRED) - target_link_libraries(imgui PRIVATE lunasvg::lunasvg) - endif() -endif() - foreach(component ${IMGUI_COMPONENTS}) target_link_libraries(${component} PUBLIC imgui) endforeach() -if(IMGUI_ENABLE_OSX_DEFAULT_CLIPBOARD_FUNCTIONS) - target_link_libraries(imgui PRIVATE "-framework ApplicationServices") -endif() - if(IMGUI_IMPL_TOOLS) add_executable(binary_to_compressed_c misc/fonts/binary_to_compressed_c.cpp) install(TARGETS binary_to_compressed_c DESTINATION bin) From 75e557b02922acc37d87dd2170aa72467ebd3c8a Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 24 Sep 2024 09:59:47 +0300 Subject: [PATCH 15/23] imgui: bump lunasvg --- recipes/imgui/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index 3bbb764ad32fd..a95509b07c5a9 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -165,7 +165,7 @@ def requirements(self): if self.options.enable_freetype: self.requires("freetype/2.13.2") if self.options.enable_freetype_lunasvg: - self.requires("lunasvg/2.4.0") + self.requires("lunasvg/2.4.1") def validate(self): if self.settings.compiler.cppstd: From bb1c3057469f87d23bd10df87b7df94c0b724acf Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 24 Sep 2024 09:35:16 +0300 Subject: [PATCH 16/23] imgui: temporarily enable lunasvg as well --- recipes/imgui/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index a95509b07c5a9..ec34e90da0838 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -81,7 +81,7 @@ class ImguiConan(ConanFile): "backend_win32": True, # Other options "enable_freetype": True, - "enable_freetype_lunasvg": False, + "enable_freetype_lunasvg": True, "enable_metal_cpp": True, "enable_osx_clipboard": True, "enable_demo_windows": True, From be4be74026736a00fa260aba934a98b632559eec Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 24 Sep 2024 10:22:48 +0300 Subject: [PATCH 17/23] imgui: lunasvg is not available for all versions --- recipes/imgui/all/conanfile.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index ec34e90da0838..98be1a620dd03 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -110,6 +110,8 @@ def config_options(self): del self.options.backend_osx del self.options.enable_metal_cpp del self.options.enable_osx_clipboard + if Version(self.version) < "1.89.8": + del self.options.enable_freetype_lunasvg if Version(self.version) < "1.89.6": del self.options.backend_sdl2 del self.options.backend_sdlrenderer2 @@ -139,7 +141,7 @@ def configure(self): self.options.rm_safe("backend_win32") self.options.rm_safe("backend_wgpu") if not self.options.enable_freetype: - del self.options.enable_freetype_lunasvg + self.options.rm_safe("enable_freetype_lunasvg") def layout(self): cmake_layout(self, src_folder="src") @@ -164,7 +166,7 @@ def requirements(self): # self.requires("dawn/cci.20240726") if self.options.enable_freetype: self.requires("freetype/2.13.2") - if self.options.enable_freetype_lunasvg: + if self.options.get_safe("enable_freetype_lunasvg"): self.requires("lunasvg/2.4.1") def validate(self): @@ -272,7 +274,7 @@ def package_info(self): self.cpp_info.components["core"].frameworks.append("ApplicationServices") if self.options.enable_freetype: self.cpp_info.components["core"].requires.append("freetype::freetype") - if self.options.enable_freetype_lunasvg: + if self.options.get_safe("enable_freetype_lunasvg"): self.cpp_info.components["core"].requires.append("lunasvg::lunasvg") def _add_binding(name, requires=None, system_libs=None, frameworks=None): From 169547586365ba5b6a29467c70406400417e67f4 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 24 Sep 2024 11:24:34 +0300 Subject: [PATCH 18/23] imgui: lunasvg in 1.89.x is buggy https://github.com/ocornut/imgui/commit/701a047ac0759c12350f682f8308b4ecbec4be68 --- recipes/imgui/all/conanfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index 98be1a620dd03..81005301a2a4e 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -110,7 +110,7 @@ def config_options(self): del self.options.backend_osx del self.options.enable_metal_cpp del self.options.enable_osx_clipboard - if Version(self.version) < "1.89.8": + if Version(self.version) < "1.90": del self.options.enable_freetype_lunasvg if Version(self.version) < "1.89.6": del self.options.backend_sdl2 From 9f6b90e80266ccba12b8c6343ac7f2ec7eb7e270 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 24 Sep 2024 12:45:36 +0300 Subject: [PATCH 19/23] imgui: add metal-cpp dependency --- recipes/imgui/all/CMakeLists.txt | 8 ++++++++ recipes/imgui/all/conanfile.py | 15 +++++++++++++-- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/recipes/imgui/all/CMakeLists.txt b/recipes/imgui/all/CMakeLists.txt index c4f4c9ace4c4f..16c2740fbe0ca 100644 --- a/recipes/imgui/all/CMakeLists.txt +++ b/recipes/imgui/all/CMakeLists.txt @@ -117,6 +117,10 @@ if(IMGUI_IMPL_METAL) "-framework QuartzCore" ) install(FILES backends/imgui_impl_metal.h DESTINATION include) + if(IMGUI_IMPL_METAL_CPP) + find_package(metal-cpp CONFIG REQUIRED) + target_link_libraries(imgui-metal PRIVATE metal-cpp::metal-cpp) + endif() list(APPEND IMGUI_COMPONENTS imgui-metal) endif() @@ -148,6 +152,10 @@ if(IMGUI_IMPL_OSX) "-framework GameController" ) install(FILES backends/imgui_impl_osx.h DESTINATION include) + if(IMGUI_IMPL_METAL_CPP_EXTENSIONS) + find_package(metal-cpp CONFIG REQUIRED) + target_link_libraries(imgui-osx PRIVATE metal-cpp::metal-cpp) + endif() list(APPEND IMGUI_COMPONENTS imgui-osx) endif() diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index 81005301a2a4e..f690e168482f0 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -142,6 +142,10 @@ def configure(self): self.options.rm_safe("backend_wgpu") if not self.options.enable_freetype: self.options.rm_safe("enable_freetype_lunasvg") + if not self.options.get_safe("backend_osx"): + self.options.rm_safe("enable_osx_clipboard") + if not self.options.get_safe("backend_osx") and not self.options.get_safe("backend_metal"): + self.options.rm_safe("enable_metal_cpp") def layout(self): cmake_layout(self, src_folder="src") @@ -168,6 +172,8 @@ def requirements(self): self.requires("freetype/2.13.2") if self.options.get_safe("enable_freetype_lunasvg"): self.requires("lunasvg/2.4.1") + if self.options.get_safe("enable_metal_cpp"): + self.requires("metal-cpp/14.2", transitive_headers=bool(self.options.get_safe("backend_metal"))) def validate(self): if self.settings.compiler.cppstd: @@ -200,6 +206,8 @@ def generate(self): tc.cache_variables["IMGUI_FREETYPE"] = self.options.enable_freetype tc.cache_variables["IMGUI_FREETYPE_LUNASVG"] = self.options.get_safe("enable_freetype_lunasvg", False) tc.cache_variables["IMGUI_BUILD_PROGRAMS"] = self.options.build_programs + tc.cache_variables["IMGUI_IMPL_METAL_CPP"] = self.options.get_safe("enable_metal_cpp", False) + tc.cache_variables["IMGUI_IMPL_METAL_CPP_EXTENSIONS"] = self.options.get_safe("enable_metal_cpp", False) tc.generate() deps = CMakeDeps(self) @@ -285,6 +293,9 @@ def _add_binding(name, requires=None, system_libs=None, frameworks=None): self.cpp_info.components[name].system_libs = system_libs or [] self.cpp_info.components[name].frameworks = frameworks or [] + def _metal_cpp(): + return ["metal-cpp::metal-cpp"] if self.options.get_safe("enable_metal_cpp") else [] + # _add_binding("allegro5", requires=[ # "allegro::allegro", # "allegro::allegro_ttf", @@ -298,10 +309,10 @@ def _add_binding(name, requires=None, system_libs=None, frameworks=None): _add_binding("dx12", system_libs=["d3d12"]) _add_binding("glfw", requires=["glfw::glfw"] if self.settings.os != "Emscripten" else []) _add_binding("glut", requires=["freeglut::freeglut"] if self.settings.os != "Emscripten" else []) - _add_binding("metal", frameworks=["Foundation", "Metal", "QuartzCore"]) + _add_binding("metal", frameworks=["Foundation", "Metal", "QuartzCore"], requires=_metal_cpp()) _add_binding("opengl2", requires=["opengl::opengl"]) _add_binding("opengl3", requires=["opengl::opengl"]) - _add_binding("osx", frameworks=["AppKit", "Carbon", "Cocoa", "Foundation", "GameController"]) + _add_binding("osx", frameworks=["AppKit", "Carbon", "Cocoa", "Foundation", "GameController"], requires=_metal_cpp()) _add_binding("sdl2", requires=["sdl::sdl"]) _add_binding("sdlrenderer2", requires=["sdl::sdl"]) # _add_binding("sdlrenderer3", requires=["sdl::sdl"]) From 9a7c2397da400064bf4cffeeb79bd58c831eac39 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 24 Sep 2024 14:16:35 +0300 Subject: [PATCH 20/23] imgui: disable heavier SDL2 and Vulkan backends, disable freetype by default --- recipes/imgui/all/conanfile.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index f690e168482f0..d20f87bc56f56 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -75,20 +75,20 @@ class ImguiConan(ConanFile): "backend_opengl2": True, "backend_opengl3": True, "backend_osx": True, - "backend_sdl2": True, - "backend_sdlrenderer2": True, - "backend_vulkan": True, + "backend_sdl2": False, + "backend_sdlrenderer2": False, + "backend_vulkan": False, "backend_win32": True, # Other options - "enable_freetype": True, - "enable_freetype_lunasvg": True, + "enable_freetype": False, + "enable_freetype_lunasvg": False, "enable_metal_cpp": True, "enable_osx_clipboard": True, - "enable_demo_windows": True, - "enable_debug_tools": True, + "enable_demo_windows": False, + "enable_debug_tools": False, "use_bgra_packed_color": False, "use_wchar32": False, - "build_programs": True, + "build_programs": False, } def export_sources(self): From 2b349e6adb18b2e97f86dfd761c468feb8c48a82 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 24 Sep 2024 14:39:50 +0300 Subject: [PATCH 21/23] imgui: fix different config param name in old version --- recipes/imgui/all/conanfile.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index d20f87bc56f56..344933c44b722 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -84,8 +84,8 @@ class ImguiConan(ConanFile): "enable_freetype_lunasvg": False, "enable_metal_cpp": True, "enable_osx_clipboard": True, - "enable_demo_windows": False, - "enable_debug_tools": False, + "enable_demo_windows": True, + "enable_debug_tools": True, "use_bgra_packed_color": False, "use_wchar32": False, "build_programs": False, @@ -223,7 +223,10 @@ def _configure_header(self): defines["IMGUI_USE_BGRA_PACKED_COLOR"] = self.options.use_bgra_packed_color defines["IMGUI_USE_WCHAR32"] = self.options.use_wchar32 defines["IMGUI_DISABLE_DEMO_WINDOWS"] = not self.options.enable_demo_windows - defines["IMGUI_DISABLE_DEBUG_TOOLS"] = not self.options.enable_debug_tools + if Version(self.version) >= "1.88": + defines["IMGUI_DISABLE_DEBUG_TOOLS"] = not self.options.enable_debug_tools + else: + defines["IMGUI_DISABLE_METRICS_WINDOW"] = not self.options.enable_debug_tools imconfig_path = Path(self.source_folder, "imconfig.h") content = imconfig_path.read_text("utf8") From feaa8a52befc581987a2461320819f29e3de3124 Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Mon, 21 Oct 2024 08:42:57 +0300 Subject: [PATCH 22/23] imgui: convert -docking versions into a recipe option instead The source() method is meant for configuration-independent source downloads, so I moved it into build() instead, as recommended by the Conan docs. I kept support for the old -docking versions, but their use should be discontinued after this change. --- recipes/imgui/all/conandata.yml | 126 ++++++++++++++++++-------------- recipes/imgui/all/conanfile.py | 22 +++++- recipes/imgui/config.yml | 3 +- 3 files changed, 94 insertions(+), 57 deletions(-) diff --git a/recipes/imgui/all/conandata.yml b/recipes/imgui/all/conandata.yml index c3fd237c5414c..d695a3c337db5 100644 --- a/recipes/imgui/all/conandata.yml +++ b/recipes/imgui/all/conandata.yml @@ -1,67 +1,87 @@ sources: + "1.91.4": + regular: + url: "https://github.com/ocornut/imgui/archive/v1.91.4.tar.gz" + sha256: "a455c28d987c78ddf56aab98ce0ff0fda791a23a2ec88ade46dd106b837f0923" + docking: + url: "https://github.com/ocornut/imgui/archive/v1.91.4-docking.tar.gz" + sha256: "7405bdaf304b77d6d03e6d17d1f31ca3586fa0c65a466fa1dd71b6ca6a222023" "1.91.3": - url: "https://github.com/ocornut/imgui/archive/v1.91.3.tar.gz" - sha256: "29949d7b300c30565fbcd66398100235b63aa373acfee0b76853a7aeacd1be28" - "1.91.3-docking": - url: "https://github.com/ocornut/imgui/archive/v1.91.3-docking.tar.gz" - sha256: "d462ccd0ca10cb412f8946c09ebd4cd0f62ca5def544dec5b3ce293c59f089fb" + regular: + url: "https://github.com/ocornut/imgui/archive/v1.91.3.tar.gz" + sha256: "29949d7b300c30565fbcd66398100235b63aa373acfee0b76853a7aeacd1be28" + docking: + url: "https://github.com/ocornut/imgui/archive/v1.91.3-docking.tar.gz" + sha256: "d462ccd0ca10cb412f8946c09ebd4cd0f62ca5def544dec5b3ce293c59f089fb" "1.91.2": - url: "https://github.com/ocornut/imgui/archive/v1.91.2.tar.gz" - sha256: "a3c4fd857a0a48f6edad3e25de68fa1e96d2437f1665039714d1de9ad579b8d0" - "1.91.2-docking": - url: "https://github.com/ocornut/imgui/archive/v1.91.2-docking.tar.gz" - sha256: "bd6e9e6dc0451060152cea2a610256969c77a360659f4bd3836d6d4c9267229b" + regular: + url: "https://github.com/ocornut/imgui/archive/v1.91.2.tar.gz" + sha256: "a3c4fd857a0a48f6edad3e25de68fa1e96d2437f1665039714d1de9ad579b8d0" + docking: + url: "https://github.com/ocornut/imgui/archive/v1.91.2-docking.tar.gz" + sha256: "bd6e9e6dc0451060152cea2a610256969c77a360659f4bd3836d6d4c9267229b" "1.91.0": - url: "https://github.com/ocornut/imgui/archive/v1.91.0.tar.gz" - sha256: "6e62c87252e6b3725ba478a1c04dc604aa0aaeec78fedcf4011f1e52548f4cc9" - "1.91.0-docking": - url: "https://github.com/ocornut/imgui/archive/v1.91.0-docking.tar.gz" - sha256: "b08a569eedcf2bf25e763e034754fdbe37dfcb035072310781c92fa6e6504bf7" + regular: + url: "https://github.com/ocornut/imgui/archive/v1.91.0.tar.gz" + sha256: "6e62c87252e6b3725ba478a1c04dc604aa0aaeec78fedcf4011f1e52548f4cc9" + docking: + url: "https://github.com/ocornut/imgui/archive/v1.91.0-docking.tar.gz" + sha256: "b08a569eedcf2bf25e763e034754fdbe37dfcb035072310781c92fa6e6504bf7" "1.90.9": - url: "https://github.com/ocornut/imgui/archive/v1.90.9.tar.gz" - sha256: "04943919721e874ac75a2f45e6eb6c0224395034667bf508923388afda5a50bf" - "1.90.9-docking": - url: "https://github.com/ocornut/imgui/archive/v1.90.9-docking.tar.gz" - sha256: "48e7e4e4f154ad98d0946126a84e2375f849f6a67792129a805817dd60a34330" + regular: + url: "https://github.com/ocornut/imgui/archive/v1.90.9.tar.gz" + sha256: "04943919721e874ac75a2f45e6eb6c0224395034667bf508923388afda5a50bf" + docking: + url: "https://github.com/ocornut/imgui/archive/v1.90.9-docking.tar.gz" + sha256: "48e7e4e4f154ad98d0946126a84e2375f849f6a67792129a805817dd60a34330" "1.90.8": - url: "https://github.com/ocornut/imgui/archive/v1.90.8.tar.gz" - sha256: "f606b4fb406aa0f8dad36d4a9dd3d6f0fd39f5f0693e7468abc02d545fb505ae" - "1.90.8-docking": - url: "https://github.com/ocornut/imgui/archive/v1.90.8-docking.tar.gz" - sha256: "51845ed8b8e81490288c3c8165173d47e9bcf92f7d999aea800635f95587b9e7" + regular: + url: "https://github.com/ocornut/imgui/archive/v1.90.8.tar.gz" + sha256: "f606b4fb406aa0f8dad36d4a9dd3d6f0fd39f5f0693e7468abc02d545fb505ae" + docking: + url: "https://github.com/ocornut/imgui/archive/v1.90.8-docking.tar.gz" + sha256: "51845ed8b8e81490288c3c8165173d47e9bcf92f7d999aea800635f95587b9e7" "1.90.7": - url: "https://github.com/ocornut/imgui/archive/v1.90.7.tar.gz" - sha256: "872574217643d4ad7e9e6df420bb8d9e0d468fb90641c2bf50fd61745e05de99" - "1.90.7-docking": - url: "https://github.com/ocornut/imgui/archive/v1.90.7-docking.tar.gz" - sha256: "582a9061a508b82b0ff6504aa17af6bb449bca9edf0a0f0f33bf729252cd3194" + regular: + url: "https://github.com/ocornut/imgui/archive/v1.90.7.tar.gz" + sha256: "872574217643d4ad7e9e6df420bb8d9e0d468fb90641c2bf50fd61745e05de99" + docking: + url: "https://github.com/ocornut/imgui/archive/v1.90.7-docking.tar.gz" + sha256: "582a9061a508b82b0ff6504aa17af6bb449bca9edf0a0f0f33bf729252cd3194" "1.90.6": - url: "https://github.com/ocornut/imgui/archive/v1.90.6.tar.gz" - sha256: "70b4b05ac0938e82b4d5b8d59480d3e2ca63ca570dfb88c55023831f387237ad" - "1.90.6-docking": - url: "https://github.com/ocornut/imgui/archive/v1.90.6-docking.tar.gz" - sha256: "fc7f81d009ef718917aee0ac3ea1c74c8a5cfc8016049ad153b4d91d302b8aef" + regular: + url: "https://github.com/ocornut/imgui/archive/v1.90.6.tar.gz" + sha256: "70b4b05ac0938e82b4d5b8d59480d3e2ca63ca570dfb88c55023831f387237ad" + docking: + url: "https://github.com/ocornut/imgui/archive/v1.90.6-docking.tar.gz" + sha256: "fc7f81d009ef718917aee0ac3ea1c74c8a5cfc8016049ad153b4d91d302b8aef" "1.90.5": - url: "https://github.com/ocornut/imgui/archive/v1.90.5.tar.gz" - sha256: "e94b48dba7311c85ba8e3e6fe7c734d76a0eed21b2b42c5180fd5706d1562241" - "1.90.5-docking": - url: "https://github.com/ocornut/imgui/archive/v1.90.5-docking.tar.gz" - sha256: "8a5e1e594d6c8552e46e4c1ba8dd9deb51262067f04937904babc04384533ccc" + regular: + url: "https://github.com/ocornut/imgui/archive/v1.90.5.tar.gz" + sha256: "e94b48dba7311c85ba8e3e6fe7c734d76a0eed21b2b42c5180fd5706d1562241" + docking: + url: "https://github.com/ocornut/imgui/archive/v1.90.5-docking.tar.gz" + sha256: "8a5e1e594d6c8552e46e4c1ba8dd9deb51262067f04937904babc04384533ccc" "1.89.9": - url: "https://github.com/ocornut/imgui/archive/v1.89.9.tar.gz" - sha256: "1acc27a778b71d859878121a3f7b287cd81c29d720893d2b2bf74455bf9d52d6" - "1.89.9-docking": - url: "https://github.com/ocornut/imgui/archive/v1.89.9-docking.tar.gz" - sha256: "2481489ce9091239b3cab8a330d0409ffdd9ee607ad1f3fe3a0b0b751c27a8eb" + regular: + url: "https://github.com/ocornut/imgui/archive/v1.89.9.tar.gz" + sha256: "1acc27a778b71d859878121a3f7b287cd81c29d720893d2b2bf74455bf9d52d6" + docking: + url: "https://github.com/ocornut/imgui/archive/v1.89.9-docking.tar.gz" + sha256: "2481489ce9091239b3cab8a330d0409ffdd9ee607ad1f3fe3a0b0b751c27a8eb" "1.88": - url: "https://github.com/ocornut/imgui/archive/v1.88.tar.gz" - sha256: "9f14c788aee15b777051e48f868c5d4d959bd679fc5050e3d2a29de80d8fd32e" + regular: + url: "https://github.com/ocornut/imgui/archive/v1.88.tar.gz" + sha256: "9f14c788aee15b777051e48f868c5d4d959bd679fc5050e3d2a29de80d8fd32e" "1.87": - url: "https://github.com/ocornut/imgui/archive/v1.87.tar.gz" - sha256: "b54ceb35bda38766e36b87c25edf7a1cd8fd2cb8c485b245aedca6fb85645a20" + regular: + url: "https://github.com/ocornut/imgui/archive/v1.87.tar.gz" + sha256: "b54ceb35bda38766e36b87c25edf7a1cd8fd2cb8c485b245aedca6fb85645a20" "1.86": - url: "https://github.com/ocornut/imgui/archive/v1.86.tar.gz" - sha256: "6ba6ae8425a19bc52c5e067702c48b70e4403cd339cba02073a462730a63e825" + regular: + url: "https://github.com/ocornut/imgui/archive/v1.86.tar.gz" + sha256: "6ba6ae8425a19bc52c5e067702c48b70e4403cd339cba02073a462730a63e825" "1.85": - url: "https://github.com/ocornut/imgui/archive/v1.85.tar.gz" - sha256: "7ed49d1f4573004fa725a70642aaddd3e06bb57fcfe1c1a49ac6574a3e895a77" + regular: + url: "https://github.com/ocornut/imgui/archive/v1.85.tar.gz" + sha256: "7ed49d1f4573004fa725a70642aaddd3e06bb57fcfe1c1a49ac6574a3e895a77" diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index 344933c44b722..a7bf79fe42c66 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -26,6 +26,7 @@ class ImguiConan(ConanFile): options = { "shared": [True, False], "fPIC": [True, False], + "docking": [True, False], # Backends # See https://github.com/ocornut/imgui/blob/master/docs/BACKENDS.md "build_backends": [True, False], @@ -62,6 +63,7 @@ class ImguiConan(ConanFile): default_options = { "shared": False, "fPIC": True, + "docking": False, # Backends "build_backends": True, "backend_android": True, @@ -97,6 +99,9 @@ def export_sources(self): def config_options(self): if self.settings.os == "Windows": del self.options.fPIC + if self.version.endswith("-docking"): + # Support the old -docking versions for backwards compatibility + self.options.docking = True if self.settings.os != "Android": del self.options.backend_android if self.settings.os != "Windows": @@ -152,7 +157,7 @@ def layout(self): def requirements(self): # if self.options.get_safe("backend_allegro5"): - # self.requi`res("allegro5/0") + # self.requires("allegro5/0") if self.options.get_safe("backend_opengl2") or self.options.get_safe("backend_opengl3"): self.requires("opengl/system") if self.options.get_safe("backend_glut") and self.settings.os != "Emscripten": @@ -178,9 +183,14 @@ def requirements(self): def validate(self): if self.settings.compiler.cppstd: check_min_cppstd(self, 11) + if Version(self.version) < "1.89" and self.options.docking: + raise ConanException("Docking support requires version 1.89 or newer.") + if self.version.endswith("-docking"): + self.output.warning("The -docking versions of imgui are deprecated. Use -o imgui/*:docking=True instead.") def source(self): - get(self, **self.conan_data["sources"][self.version], strip_root=True) + # Handled in build() instead to support self.options.docking. + pass def generate(self): tc = CMakeToolchain(self) @@ -213,6 +223,11 @@ def generate(self): deps = CMakeDeps(self) deps.generate() + def _source(self): + version = self.version.replace("-docking", "") + kind = "docking" if self.options.docking else "regular" + get(self, **self.conan_data["sources"][version][kind], destination=self.source_folder, strip_root=True) + def _configure_header(self): defines = {} defines["IMGUI_ENABLE_FREETYPE"] = self.options.enable_freetype @@ -248,6 +263,7 @@ def _patch_sources(self): '#include "imconfig.h"\n\n#include "imgui_export.h"') def build(self): + self._source() self._configure_header() self._patch_sources() cmake = CMake(self) @@ -323,7 +339,7 @@ def _metal_cpp(): _add_binding("win32", system_libs=["dwmapi", "xinput"]) # _add_binding("wgpu", requires=["dawn::dawn"]) - self.conf_info.define("user.imgui:with_docking", "-docking" in self.version) + self.conf_info.define("user.imgui:with_docking", bool(self.options.docking)) if self.options.build_programs: self.env_info.PATH.append(os.path.join(self.package_folder, "bin")) diff --git a/recipes/imgui/config.yml b/recipes/imgui/config.yml index 3b5152c257e44..b646e187b543e 100644 --- a/recipes/imgui/config.yml +++ b/recipes/imgui/config.yml @@ -1,4 +1,6 @@ versions: + "1.91.4": + folder: all "1.91.3": folder: all "1.91.3-docking": @@ -43,4 +45,3 @@ versions: folder: all "1.85": folder: all - From c13dbf658511deddc2cd81533c09057518889c1e Mon Sep 17 00:00:00 2001 From: Martin Valgur Date: Tue, 5 Nov 2024 22:56:08 +0200 Subject: [PATCH 23/23] imgui: drop Conan 1.x support --- recipes/imgui/all/conanfile.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/recipes/imgui/all/conanfile.py b/recipes/imgui/all/conanfile.py index a7bf79fe42c66..499ea0bce0756 100644 --- a/recipes/imgui/all/conanfile.py +++ b/recipes/imgui/all/conanfile.py @@ -10,7 +10,7 @@ from conan.tools.files import copy, get, replace_in_file from conan.tools.scm import Version -required_conan_version = ">=1.53.0" +required_conan_version = ">=2.0.9" class ImguiConan(ConanFile): @@ -181,8 +181,7 @@ def requirements(self): self.requires("metal-cpp/14.2", transitive_headers=bool(self.options.get_safe("backend_metal"))) def validate(self): - if self.settings.compiler.cppstd: - check_min_cppstd(self, 11) + check_min_cppstd(self, 11) if Version(self.version) < "1.89" and self.options.docking: raise ConanException("Docking support requires version 1.89 or newer.") if self.version.endswith("-docking"): @@ -340,6 +339,3 @@ def _metal_cpp(): # _add_binding("wgpu", requires=["dawn::dawn"]) self.conf_info.define("user.imgui:with_docking", bool(self.options.docking)) - - if self.options.build_programs: - self.env_info.PATH.append(os.path.join(self.package_folder, "bin"))