-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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] Add new package ImGui-SFML #7429
Changes from all commits
fd1365b
03daa62
f3ddb65
0c257bb
8e86519
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Source: imgui-sfml | ||
Version: 2.0.2 | ||
Homepage: https://github.com/eliasdaler/imgui-sfml | ||
Description: Library which allows you to use ImGui with SFML | ||
Build-Depends: sfml, imgui |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
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 | ||
HEAD_REF master | ||
PATCHES | ||
static-build-with-vcpkg-imgui.patch | ||
remove-delegating-ctor.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 | ||
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include) | ||
|
||
# License | ||
file(INSTALL ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/imgui-sfml RENAME copyright) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/imconfig-SFML.h b/imconfig-SFML.h | ||
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) { \ | ||
+ : x(c.r / 255.f), y(c.g / 255.f), z(c.b / 255.f), w(c.a / 255.f) { \ | ||
} \ | ||
operator sf::Color() const { \ | ||
return sf::Color( \ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
diff --git a/CMakeLists.txt b/CMakeLists.txt | ||
index 015a030..33d6894 100644 | ||
--- a/CMakeLists.txt | ||
+++ b/CMakeLists.txt | ||
@@ -29,7 +29,7 @@ set(IMGUI_SFML_CONFIG_NAME "imconfig-SFML.h" CACHE STRING "Name of a custom user | ||
set(IMGUI_SFML_CONFIG_INSTALL_DIR "" CACHE PATH "Path where user's config header will be installed") | ||
|
||
# For FindImGui.cmake | ||
-list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") | ||
+# list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") | ||
|
||
if (IMGUI_SFML_FIND_SFML) | ||
find_package(SFML 2.5 COMPONENTS graphics system window) | ||
@@ -42,24 +42,24 @@ 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_ROOT to imgui's top-level path (containing 'imgui.h' and other files).\n") | ||
-endif() | ||
+# if(NOT IMGUI_DIR) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does vcpkg set if(NOT ${IMGUI_NAME}_DIR)
...
endif() There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. vcpkg There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess checking for version could be disabled in some cases... I'll thunk about it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I could make vcpkg's imgui to export Maybe you should include an exact verison of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ImGui is mostly stable in the part that ImGui-SFML uses. ImGui's widgets functions/interfaces can change, but that will break client's ImGui code, not ImGui-SFML's code. |
||
+ # set(IMGUI_DIR "" CACHE PATH "imgui top-level directory") | ||
+ # message(FATAL_ERROR "ImGui directory not found. Set IMGUI_ROOT 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) | ||
+find_package(imgui REQUIRED) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like |
||
|
||
# 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 | ||
-) | ||
+# set(IMGUI_PUBLIC_HEADERS | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not sure if this is needed for patch - yes, it won't be used, but patch should be as minimal as possible, in my opinion. |
||
+ # ${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 | ||
+# ) | ||
|
||
# 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) | ||
@@ -80,6 +80,7 @@ add_library(ImGui-SFML::ImGui-SFML ALIAS ImGui-SFML) | ||
|
||
target_link_libraries(ImGui-SFML | ||
PUBLIC | ||
+ imgui::imgui | ||
sfml-graphics | ||
sfml-system | ||
sfml-window | ||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this line needed? ImTextureID should really be "unsigned int" for ImGui-SFML, not "void*" There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It creates a linkage error with static build of vcpkg's imgui. C++ name mangling magic treats imgui static compiled Maybe include your own version of imgui in imgui-sfml, just need a few files... There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see. Well, I hope that doesn't break something. Also yeah, it looks like using external 'imgui' package with imgui-sfml is kinda painful... I've thought about adding ImGui as git submodule for ImGui-SFML here: SFML/imgui-sfml#81 ... and maybe it'll make the whole process easier if you don't depend on ImGui's vckpg package. |
||
\ No newline at end of file |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is necessary.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just want to use 1 line of vcpkg's
find_package(imgui REQUIRED)
andtarget_link_libraries(... imgui::imgui)
to include imgui library, so I disable all of your FindImgui cmake as they are not needed (I guess)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I should put a check for osx triplet and enable C++11 for osx build only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, FindImGui.cmake is not needed, if you use vcpkg's find module, but it won't really change anything, so I think to make patch smaller, this line should not be changed with it.
Also I might put some other useful CMake things in imgui-sfml's "cmake" directory, so this might break some other things.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imgui-sfml needs these sources
while vcpkg's imgui CMakeLists.txt has these compiled
set(IMGUI_SOURCES imgui.cpp imgui_demo.cpp imgui_draw.cpp imgui_widgets.cpp )
The only file that is missing is
misc/cpp/imgui_stdlib.cpp
, which it states that it needs C++11: https://github.com/ocornut/imgui/blob/d057550209d794461744a91c812bf8e9e264f32f/misc/cpp/imgui_stdlib.h#L5There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And since vcpkg has those sources already compiled, you won't find these .cpp files, which FindImGui.cmake will create a cmake config error so I don't use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imgui_stdlib functions don't need C++11 to compile, but they're not guaranteed to work. That's an imporant difference.
As for the sources vs linking to target - yeah. Again, ImGui-SFML needs to add some flags which will allow you to either build ImGui along with ImGui-SFML or link to it in some other way.