Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[imgui-sfml] initial port #8004

Merged
merged 4 commits into from
Sep 10, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 50 additions & 0 deletions ports/imgui-sfml/0001-fix_find_package.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 53500fd..cb98701 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -35,34 +35,14 @@ if (IMGUI_SFML_FIND_SFML)
if (NOT BUILD_SHARED_LIBS)
set(SFML_STATIC_LIBRARIES ON)
endif()
- find_package(SFML 2.5 COMPONENTS graphics system window)
+ find_package(SFML COMPONENTS graphics system window)

if(NOT SFML_FOUND)
message(FATAL_ERROR "SFML 2 directory not found. Set SFML_DIR to directory where SFML was built (or one which ccontains SFMLConfig.cmake)")
endif()
endif()

-# ImGui does not provide native support for CMakeLists, workaround for now to have
-# users specify IMGUI_DIR. Waiting for this PR to get merged...
-# https://github.com/ocornut/imgui/pull/1713
-if(NOT IMGUI_DIR)
- set(IMGUI_DIR "" CACHE PATH "imgui top-level directory")
- message(FATAL_ERROR "ImGui directory not found. Set IMGUI_DIR to imgui's top-level path (containing 'imgui.h' and other files).\n")
-endif()
-
-# This uses FindImGui.cmake provided in ImGui-SFML repo for now
-find_package(ImGui 1.68 REQUIRED)
-
-# these headers will be installed alongside ImGui-SFML
-set(IMGUI_PUBLIC_HEADERS
- ${IMGUI_INCLUDE_DIR}/imconfig.h
- ${IMGUI_INCLUDE_DIR}/imgui.h
- ${IMGUI_INCLUDE_DIR}/imgui_internal.h # not actually public, but users might need it
- ${IMGUI_INCLUDE_DIR}/imstb_rectpack.h
- ${IMGUI_INCLUDE_DIR}/imstb_textedit.h
- ${IMGUI_INCLUDE_DIR}/imstb_truetype.h
- ${IMGUI_INCLUDE_DIR}/misc/cpp/imgui_stdlib.h
-)
+find_package(imgui CONFIG REQUIRED)

# CMake 3.11 and later prefer to choose GLVND, but we choose legacy OpenGL just because it's safer
# (unless the OpenGL_GL_PREFERENCE was explicitly set)
@@ -82,7 +62,7 @@ add_library(ImGui-SFML
add_library(ImGui-SFML::ImGui-SFML ALIAS ImGui-SFML)

target_link_libraries(ImGui-SFML
- PUBLIC
+ imgui::imgui
sfml-graphics
sfml-system
sfml-window
11 changes: 11 additions & 0 deletions ports/imgui-sfml/0002-fix_imgui_config.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
diff --git a/imconfig-SFML.h b/imconfig-SFML.h
index f66ba20..0f43ce6 100644
--- a/imconfig-SFML.h
+++ b/imconfig-SFML.h
@@ -28,5 +28,3 @@
static_cast<sf::Uint8>(z * 255.f), \
static_cast<sf::Uint8>(w * 255.f)); \
}
-
-#define ImTextureID unsigned int
\ No newline at end of file
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ index 0f43ce6..1fce2c1 100644
--- a/imconfig-SFML.h
+++ b/imconfig-SFML.h
@@ -19,7 +19,7 @@

#define IM_VEC4_CLASS_EXTRA \
ImVec4(const sf::Color & c) \
- : ImVec4(c.r / 255.f, c.g / 255.f, c.b / 255.f, c.a / 255.f) { \
Expand Down
4 changes: 2 additions & 2 deletions ports/imgui-sfml/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: imgui-sfml
Version: 2.0.2
Version: 2.1
Homepage: https://github.com/eliasdaler/imgui-sfml
Description: Library which allows you to use ImGui with SFML
Description: ImGui binding for use with SFML
Build-Depends: sfml, imgui
20 changes: 7 additions & 13 deletions ports/imgui-sfml/portfile.cmake
Original file line number Diff line number Diff line change
@@ -1,30 +1,24 @@
include(vcpkg_common_functions)

# Compile as static lib since vcpkg's imgui is compiled as static lib
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)

vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO eliasdaler/imgui-sfml
REF v2.0.2
SHA512 44099e162c0e712ec9147452189649801a6463396830e117c7a0a4483d0526e94554498bfa41e9cd418d26286b5d1a28dd1c2d305c30d1eb266922767e53ab48
REF v2.1
SHA512 134c49e9c57bc4d3882d99a52ec87f74c11d2f3134501c79b20bce4612f315f2e3f33a521597b387ca8f91942cf2b82ec9f4a8b1672a700e7233a9758897b6d0
HEAD_REF master
PATCHES
static-build-with-vcpkg-imgui.patch
remove-delegating-ctor.patch
0001-fix_find_package.patch
0002-fix_imgui_config.patch
0003-fix_osx.patch
)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
)

vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/ImGui-SFML)
vcpkg_copy_pdbs()

# Debug include directory not needed
vcpkg_fixup_cmake_targets(CONFIG_PATH lib/cmake/ImGui-SFML)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)

# License
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/imgui-sfml RENAME copyright)
configure_file(${SOURCE_PATH}/LICENSE ${CURRENT_PACKAGES_DIR}/share/imgui-sfml/copyright COPYONLY)
71 changes: 0 additions & 71 deletions ports/imgui-sfml/static-build-with-vcpkg-imgui.patch

This file was deleted.

10 changes: 10 additions & 0 deletions ports/imgui-sfml/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
The package imgui-sfml provides CMake targets:

find_package(imgui CONFIG REQUIRED)
find_package(SFML CONFIG REQUIRED COMPONENTS graphics system window)
find_package(ImGui-SFML CONFIG REQUIRED)
target_link_libraries(main PRIVATE
imgui::imgui
sfml-graphics sfml-system sfml-window
ImGui-SFML::ImGui-SFML
)