Skip to content

Commit

Permalink
imgui: add metal-cpp dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Sep 24, 2024
1 parent 1695475 commit 9f6b90e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
8 changes: 8 additions & 0 deletions recipes/imgui/all/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down
15 changes: 13 additions & 2 deletions recipes/imgui/all/conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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:
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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",
Expand All @@ -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"])
Expand Down

0 comments on commit 9f6b90e

Please sign in to comment.