[imgui-sfml] update to 2.1 (#8004)

This commit is contained in:
kiwixz 2019-09-10 22:52:21 +02:00 committed by Phil Christensen
parent 15d747662c
commit 95a336e049
7 changed files with 81 additions and 87 deletions

View File

@ -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

View File

@ -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

View File

@ -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) { \

View File

@ -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

View File

@ -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)

View File

@ -1,71 +0,0 @@
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)
+ # 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)
# 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
+ # ${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
\ No newline at end of file

10
ports/imgui-sfml/usage Normal file
View File

@ -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
)