Add hello_imgui port (#36501)

With suggestions from code review by @dgoyt (thanks a lot for the attentive review :-)
Co-authored-by: Kai Pastor <dg0yt@darc.de>
This commit is contained in:
Pascal Thomet 2024-02-08 07:28:33 +01:00 committed by GitHub
parent fe9f0b22b3
commit a938bfa9d6
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 277 additions and 0 deletions

View File

@ -0,0 +1,126 @@
vcpkg_check_linkage(ONLY_STATIC_LIBRARY) # this mirrors ImGui's portfile behavior
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO pthom/hello_imgui
REF b9bdca77cb58bd879228f34a9bcf1f1c2e6b96bd
SHA512 2044fb34bdd64377335e46802f8546ccc30077e84f122c895b820bef0d692f62e1c5bc175cf8003c518db2bc0f1e07ed94bf1ccdc4a4720b7c0e0812c192bf7f
HEAD_REF master
)
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
"opengl3-binding" HELLOIMGUI_HAS_OPENGL3
"metal-binding" HELLOIMGUI_HAS_METAL
"experimental-vulkan-binding" HELLOIMGUI_HAS_VULKAN
"experimental-dx11-binding" HELLOIMGUI_HAS_DIRECTX11
"experimental-dx12-binding" HELLOIMGUI_HAS_DIRECTX12
"glfw-binding" HELLOIMGUI_USE_GLFW3
"sdl2-binding" HELLOIMGUI_USE_SDL2
"freetype-lunasvg" HELLOIMGUI_USE_FREETYPE # When hello_imgui is built with freetype, it will also build with lunasvg
)
if (NOT HELLOIMGUI_HAS_OPENGL3
AND NOT HELLOIMGUI_HAS_METAL
AND NOT HELLOIMGUI_HAS_VULKAN
AND NOT HELLOIMGUI_HAS_DIRECTX11
AND NOT HELLOIMGUI_HAS_DIRECTX12)
set(no_rendering_backend ON)
endif()
if (NOT HELLOIMGUI_USE_GLFW3 AND NOT HELLOIMGUI_USE_SDL2)
set(no_platform_backend ON)
endif()
set(platform_options "")
if(WIN32)
# Standard win32 options (these are the defaults for HelloImGui)
# we could add a vcpkg feature for this, but it would have to be platform specific
list(APPEND platform_options
-DHELLOIMGUI_WIN32_NO_CONSOLE=ON
-DHELLOIMGUI_WIN32_AUTO_WINMAIN=ON
)
endif()
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# Standard macOS options (these are the defaults for HelloImGui)
# we could add a vcpkg feature for this, but it would have to be platform specific
list(APPEND platform_options
-DHELLOIMGUI_MACOS_NO_BUNDLE=OFF
)
endif()
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
-DHELLOIMGUI_BUILD_DEMOS=OFF
-DHELLOIMGUI_BUILD_DOCS=OFF
-DHELLOIMGUI_BUILD_TESTS=OFF
# vcpkg does not support ImGui Test Engine, so we cannot enable it
-DHELLOIMGUI_WITH_TEST_ENGINE=OFF
-DHELLOIMGUI_USE_IMGUI_CMAKE_PACKAGE=ON
-DHELLO_IMGUI_IMGUI_SHARED=OFF
-DHELLOIMGUI_BUILD_IMGUI=OFF
${platform_options}
# Rendering backends
-DHELLOIMGUI_HAS_OPENGL3=${HELLOIMGUI_HAS_OPENGL3}
-DHELLOIMGUI_HAS_METAL=${HELLOIMGUI_HAS_METAL}
-DHELLOIMGUI_HAS_VULKAN=${HELLOIMGUI_HAS_VULKAN}
-DHELLOIMGUI_HAS_DIRECTX11=${HELLOIMGUI_HAS_DIRECTX11}
-DHELLOIMGUI_HAS_DIRECTX12=${HELLOIMGUI_HAS_DIRECTX12}
# Platform backends
-DHELLOIMGUI_USE_GLFW3=${HELLOIMGUI_USE_GLFW3}
-DHELLOIMGUI_USE_SDL2=${HELLOIMGUI_USE_SDL2}
)
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/hello_imgui PACKAGE_NAME "hello-imgui") # should be active once himgui produces a config
file(REMOVE_RECURSE
"${CURRENT_PACKAGES_DIR}/debug/include"
"${CURRENT_PACKAGES_DIR}/debug/share"
"${CURRENT_PACKAGES_DIR}/share/hello-imgui/hello_imgui_cmake/ios-cmake"
)
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
if (no_rendering_backend OR no_platform_backend)
message(STATUS "
########################################################################
!!!! WARNING !!!!!
!!!! Installed hello-imgui without a viable backend !!!!!
########################################################################
When installing hello-imgui, you should specify:
- At least one (or more) rendering backend (OpenGL3, Metal, Vulkan, DirectX11, DirectX12)
Make your choice according to your needs and your target platforms, between:
opengl3-binding # This is the recommended choice, especially for beginners
metal-binding # Apple only, advanced users only
experimental-vulkan-binding # Advanced users only
experimental-dx11-binding # Windows only, still experimental
experimental-dx12-binding # Windows only, advanced users only, still experimental
- At least one (or more) platform backend (SDL2, Glfw3):
Make your choice according to your needs and your target platforms, between:
glfw-binding
sdl-binding
For example, you could use:
vcpkg install \"hello-imgui[opengl3-binding,glfw-binding]\"
########################################################################
!!!! WARNING !!!!!
!!!! Installed hello-imgui without a viable backend !!!!!
########################################################################
")
endif()

17
ports/hello-imgui/usage Normal file
View File

@ -0,0 +1,17 @@
hello_imgui provides CMake targets and hello_imgui_add_app:
Usage with `hello_imgui_add_app` (recommended)
set(CMAKE_CXX_STANDARD 17)
find_package(hello-imgui CONFIG REQUIRED)
hello_imgui_add_app(test test.cpp) # see example below
Usage with `target_link_libraries`
set(CMAKE_CXX_STANDARD 17)
find_package(hello-imgui CONFIG REQUIRED)
# Note the subtle difference between the package name and the target name: hello-imgui vs hello_imgui!
target_link_libraries(main PRIVATE hello-imgui::hello_imgui)
# this mode will ignore all of hello_imgui cmake tooling, and will not deploy the assets
Example test.cpp:
#include "hello_imgui/hello_imgui.h"
int main() { HelloImGui::Run([](){ ImGui::Text("Hello, world!"); ImGui::ShowDemoWindow(); }); }

View File

@ -0,0 +1,121 @@
{
"name": "hello-imgui",
"version": "1.4.2",
"description": "Hello ImGui: unleash your creativity in app development and prototyping",
"homepage": "https://pthom.github.io/hello_imgui/",
"license": "MIT",
"dependencies": [
{
"name": "imgui",
"features": [
"docking-experimental"
]
},
"stb",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
],
"features": {
"experimental-dx11-binding": {
"description": "Use DirectX11 renderer backend (Windows only, experimental)",
"dependencies": [
{
"name": "imgui",
"features": [
"dx11-binding"
]
}
]
},
"experimental-dx12-binding": {
"description": "Use DirectX12 renderer backend (Windows only, experimental)",
"dependencies": [
{
"name": "imgui",
"features": [
"dx12-binding"
]
}
]
},
"experimental-vulkan-binding": {
"description": "Use Vulkan renderer backend (Windows/Linux/macOS, experimental)",
"dependencies": [
{
"name": "imgui",
"features": [
"vulkan-binding"
]
}
]
},
"freetype-lunasvg": {
"description": "Improve font rendering and use colored fonts with freetype and lunasvg",
"dependencies": [
{
"name": "imgui",
"features": [
"freetype",
"freetype-lunasvg"
]
}
]
},
"glfw-binding": {
"description": "Use GLFW platform backend (default)",
"dependencies": [
{
"name": "imgui",
"features": [
"glfw-binding"
]
}
]
},
"metal-binding": {
"description": "Use Metal renderer backend (macOS/iOS only)",
"dependencies": [
{
"name": "imgui",
"features": [
"metal-binding"
]
}
]
},
"opengl3-binding": {
"description": "Use OpenGL3/ES2 renderer backend (default)",
"dependencies": [
{
"name": "glad",
"features": [
"gl-api-43"
]
},
{
"name": "imgui",
"features": [
"opengl3-binding"
]
}
]
},
"sdl2-binding": {
"description": "Use SDL2 platform backend",
"dependencies": [
{
"name": "imgui",
"features": [
"sdl2-binding"
]
}
]
}
}
}

View File

@ -3332,6 +3332,10 @@
"baseline": "15",
"port-version": 0
},
"hello-imgui": {
"baseline": "1.4.2",
"port-version": 0
},
"hexl": {
"baseline": "1.2.4",
"port-version": 0

View File

@ -0,0 +1,9 @@
{
"versions": [
{
"git-tree": "5ecf61526918746249b229e66d820f4da98e0c5a",
"version": "1.4.2",
"port-version": 0
}
]
}