Skip to content

Commit

Permalink
[imgui] Split bindings to multiple features (microsoft#12329)
Browse files Browse the repository at this point in the history
* [imgui] Split bindings to multiple features

See microsoft#12250.

I tested all the features on x86-windows, x64-windows, x64-windows-static and x64-linux triplets. Everything build fine except:
- dx12-binding on x86-windows. There's an issue opened about it here : ocornut/imgui#2406
- allegro5-binding on x64-linux, because the current allegro5 port fails to build on this platform.

Contrary to the previous port which simply copied the sources to a specific folder, bindings are now compiled with their dependencies. The only exception is Marmelade, because there's no port available for it yet.

Unfortunately, I can't test the OSX and metal bindings. If someone using this platform could test it, it would be very much appreciated. :)

* [imgui] Move port files to the correct folder

* Update ports/imgui/CONTROL

Co-authored-by: Rémy Tassoux <[email protected]>
Co-authored-by: Jack·Boos·Yu <[email protected]>
  • Loading branch information
3 people authored Jul 15, 2020
1 parent e59e5a4 commit 0b78ddc
Show file tree
Hide file tree
Showing 3 changed files with 236 additions and 27 deletions.
176 changes: 154 additions & 22 deletions ports/imgui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,102 @@ target_sources(
${CMAKE_CURRENT_SOURCE_DIR}/misc/cpp/imgui_stdlib.cpp
)

if(IMGUI_FREETYPE)
find_package(Freetype REQUIRED)
if(IMGUI_BUILD_ALLEGRO5_BINDING)
find_path(ALLEGRO5_INCLUDE_DIRS allegro5/allegro.h)
target_include_directories(${PROJECT_NAME} PRIVATE ${ALLEGRO5_INCLUDE_DIRS})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_allegro5.cpp)
endif()

if(IMGUI_BUILD_DX9_BINDING)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx9.cpp)
endif()

if(IMGUI_BUILD_DX10_BINDING)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx10.cpp)
endif()

if(IMGUI_BUILD_DX11_BINDING)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx11.cpp)
endif()

if(IMGUI_BUILD_DX12_BINDING)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx12.cpp)
endif()

if(IMGUI_BUILD_GLFW_BINDING)
find_package(glfw3 REQUIRED)
get_target_property(GLFW3_INCLUDE_DIRS glfw INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(${PROJECT_NAME} PRIVATE ${GLFW3_INCLUDE_DIRS})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_glfw.cpp)
endif()

if(IMGUI_BUILD_GLUT_BINDING)
find_path(GLUT_INCLUDE_DIRS GL/freeglut.h)
target_include_directories(${PROJECT_NAME} PRIVATE ${GLUT_INCLUDE_DIRS})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_glut.cpp)
endif()

if(IMGUI_BUILD_METAL_BINDING)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_metal.mm)
endif()

if(IMGUI_BUILD_OPENGL2_BINDING)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl2.cpp)
endif()

if(IMGUI_BUILD_OPENGL3_GLEW_BINDING)
find_package(glew REQUIRED)
target_include_directories(${PROJECT_NAME} PRIVATE ${GLEW_INCLUDE_DIRS})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl3.cpp)
endif()

if(IMGUI_BUILD_OPENGL3_GLAD_BINDING)
find_package(glad REQUIRED)
get_target_property(GLAD_INCLUDE_DIRS glad::glad INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(${PROJECT_NAME} PRIVATE ${GLAD_INCLUDE_DIRS})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl3.cpp)
endif()

if(IMGUI_BUILD_OPENGL3_GL3W_BINDING)
find_package(gl3w REQUIRED)
get_target_property(GL3W_INCLUDE_DIRS unofficial::gl3w::gl3w INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(${PROJECT_NAME} PRIVATE ${GL3W_INCLUDE_DIRS})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl3.cpp)
endif()

if(IMGUI_BUILD_OPENGL3_GLBINDING_BINDING)
find_package(glbinding REQUIRED)
get_target_property(GLBINDING_INCLUDE_DIRS glbinding::glbinding INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(${PROJECT_NAME} PRIVATE ${GLBINDING_INCLUDE_DIRS})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl3.cpp)
endif()

if(IMGUI_BUILD_OSX_BINDING)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_osx.mm)
endif()

if(IMGUI_BUILD_SDL2_BINDING)
find_package(SDL2 CONFIG REQUIRED)
find_path(SDL2_INCLUDE_DIRS SDL2/SDL.h)
target_include_directories(${PROJECT_NAME} PRIVATE ${SDL2_INCLUDE_DIRS} ${SDL2_INCLUDE_DIRS}/SDL2)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_sdl.cpp)
endif()

target_include_directories(
${PROJECT_NAME}
PRIVATE
${FREETYPE_INCLUDE_DIRS}
)
if(IMGUI_BUILD_VULKAN_BINDING)
find_package(Vulkan REQUIRED)
get_target_property(VULKAN_INCLUDE_DIRS Vulkan::Vulkan INTERFACE_INCLUDE_DIRECTORIES)
target_include_directories(${PROJECT_NAME} PRIVATE ${VULKAN_INCLUDE_DIRS})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_vulkan.cpp)
endif()

target_sources(
${PROJECT_NAME}
PRIVATE
${CMAKE_CURRENT_SOURCE_DIR}/misc/freetype/imgui_freetype.cpp
)
if(IMGUI_BUILD_WIN32_BINDING)
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_win32.cpp)
endif()

if(IMGUI_FREETYPE)
find_package(Freetype REQUIRED)
target_include_directories(${PROJECT_NAME} PRIVATE ${FREETYPE_INCLUDE_DIRS})
target_sources(${PROJECT_NAME} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/misc/freetype/imgui_freetype.cpp)
endif()

install(
Expand All @@ -56,19 +138,69 @@ if(NOT IMGUI_SKIP_HEADERS)
DESTINATION include
)

if(IMGUI_COPY_BINDINGS)
file(GLOB IMGUI_BINDINGS ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_* )
install(
FILES ${IMGUI_BINDINGS}
DESTINATION include/bindings
)
if(IMGUI_BUILD_ALLEGRO5_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_allegro5.h DESTINATION include)
endif()

if(IMGUI_BUILD_DX9_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx9.h DESTINATION include)
endif()

if(IMGUI_BUILD_DX10_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx10.h DESTINATION include)
endif()

if(IMGUI_BUILD_DX11_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx11.h DESTINATION include)
endif()

if(IMGUI_BUILD_DX12_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_dx12.h DESTINATION include)
endif()

if(IMGUI_BUILD_GLFW_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_glfw.h DESTINATION include)
endif()

if(IMGUI_BUILD_GLUT_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_glut.h DESTINATION include)
endif()

if(IMGUI_COPY_MARMALADE_BINDING)
file(GLOB MARMALADE_BINDING_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_marmalade.*)
install(FILES ${MARMALADE_BINDING_SRCS} DESTINATION include/bindings)
endif()

if(IMGUI_BUILD_METAL_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_metal.h DESTINATION include)
endif()

if(IMGUI_BUILD_OPENGL2_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl2.h DESTINATION include)
endif()

if(IMGUI_BUILD_OPENGL3_GLEW_BINDING OR IMGUI_BUILD_OPENGL3_GLAD_BINDING OR IMGUI_BUILD_OPENGL3_GL3W_BINDING OR IMGUI_BUILD_OPENGL3_GLBINDING_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_opengl3.h DESTINATION include)
endif()

if(IMGUI_BUILD_OSX_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_osx.h DESTINATION include)
endif()

if(IMGUI_BUILD_SDL2_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_sdl.h DESTINATION include)
endif()

if(IMGUI_BUILD_VULKAN_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_vulkan.h DESTINATION include)
endif()

if(IMGUI_BUILD_WIN32_BINDING)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/examples/imgui_impl_win32.h DESTINATION include)
endif()

if(IMGUI_FREETYPE)
install(FILES
${CMAKE_CURRENT_SOURCE_DIR}/misc/freetype/imgui_freetype.h
DESTINATION include
)
install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/misc/freetype/imgui_freetype.h DESTINATION include)
endif()
endif()

Expand Down
66 changes: 63 additions & 3 deletions ports/imgui/CONTROL
Original file line number Diff line number Diff line change
@@ -1,11 +1,71 @@
Source: imgui
Version: 1.77
Port-Version: 1
Homepage: https://github.com/ocornut/imgui
Description: Bloat-free Immediate Mode Graphical User interface for C++ with minimal dependencies.

Feature: bindings
Description: make available bindings header and source files for supported implementations
Build-Depends: glfw3, freeglut, opengl, sdl2, allegro5
Feature: allegro5-binding
Description: Make available Allegro5 binding
Build-Depends: allegro5

Feature: dx9-binding
Description: Make available DirectX9 binding

Feature: dx10-binding
Description: Make available DirectX10 binding

Feature: dx11-binding
Description: Make available DirectX11 binding

Feature: dx12-binding
Description: Make available DirectX12 binding

Feature: glfw-binding
Description: Make available GLFW binding
Build-Depends: glfw3

Feature: glut-binding
Description: Make available Glut binding
Build-Depends: freeglut

Feature: marmalade-binding
Description: Make available Marmalade binding

Feature: metal-binding
Description: Make available Metal binding

Feature: opengl2-binding
Description: Make available OpenGL (legacy) binding

Feature: opengl3-glew-binding
Description: Make available OpenGL3/ES/ES2 (modern) binding with GLEW
Build-Depends: glew

Feature: opengl3-glad-binding
Description: Make available OpenGL3/ES/ES2 (modern) binding with glad
Build-Depends: glad

Feature: opengl3-gl3w-binding
Description: Make available OpenGL3/ES/ES2 (modern) binding with gl3w
Build-Depends: gl3w

Feature: opengl3-glbinding-binding
Description: Make available OpenGL3/ES/ES2 (modern) binding glbinding
Build-Depends: glbinding

Feature: osx-binding
Description: Make available OSX binding

Feature: sdl2-binding
Description: Make available SDL2 binding
Build-Depends: sdl2

Feature: vulkan-binding
Description: Make available Vulkan binding
Build-Depends: vulkan

Feature: win32-binding
Description: Make available Win32 binding

Feature: freetype
Description: Build font atlases using FreeType instead of stb_truetype
Expand Down
21 changes: 19 additions & 2 deletions ports/imgui/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,25 @@ vcpkg_from_github(
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
bindings IMGUI_COPY_BINDINGS # should only be copied once, at most
freetype IMGUI_FREETYPE
allegro5-binding IMGUI_BUILD_ALLEGRO5_BINDING
dx9-binding IMGUI_BUILD_DX9_BINDING
dx10-binding IMGUI_BUILD_DX10_BINDING
dx11-binding IMGUI_BUILD_DX11_BINDING
dx12-binding IMGUI_BUILD_DX12_BINDING
glfw-binding IMGUI_BUILD_GLFW_BINDING
glut-binding IMGUI_BUILD_GLUT_BINDING
marmalade-binding IMGUI_COPY_MARMALADE_BINDING
metal-binding IMGUI_BUILD_METAL_BINDING
opengl2-binding IMGUI_BUILD_OPENGL2_BINDING
opengl3-glew-binding IMGUI_BUILD_OPENGL3_GLEW_BINDING
opengl3-glad-binding IMGUI_BUILD_OPENGL3_GLAD_BINDING
opengl3-gl3w-binding IMGUI_BUILD_OPENGL3_GL3W_BINDING
opengl3-glbinding-binding IMGUI_BUILD_OPENGL3_GLBINDING_BINDING
osx-binding IMGUI_BUILD_OSX_BINDING
sdl2-binding IMGUI_BUILD_SDL2_BINDING
vulkan-binding IMGUI_BUILD_VULKAN_BINDING
win32-binding IMGUI_BUILD_WIN32_BINDING
freetype IMGUI_FREETYPE
)

vcpkg_configure_cmake(
Expand Down

0 comments on commit 0b78ddc

Please sign in to comment.