From fd1365bff2c087f978d959b7325ada947a3c0b3a Mon Sep 17 00:00:00 2001 From: Tri Tran Date: Thu, 25 Jul 2019 16:16:59 -0500 Subject: [PATCH 1/5] [imgui-sfml] Add new package ImGui-SFML * Static build only to match with `imgui`. --- ports/imgui-sfml/CONTROL | 5 + ports/imgui-sfml/portfile.cmake | 29 ++++++ .../static-build-with-vcpkg-imgui.patch | 99 +++++++++++++++++++ 3 files changed, 133 insertions(+) create mode 100644 ports/imgui-sfml/CONTROL create mode 100644 ports/imgui-sfml/portfile.cmake create mode 100644 ports/imgui-sfml/static-build-with-vcpkg-imgui.patch diff --git a/ports/imgui-sfml/CONTROL b/ports/imgui-sfml/CONTROL new file mode 100644 index 00000000000000..f72f50db82f863 --- /dev/null +++ b/ports/imgui-sfml/CONTROL @@ -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 diff --git a/ports/imgui-sfml/portfile.cmake b/ports/imgui-sfml/portfile.cmake new file mode 100644 index 00000000000000..96896c530ef6ad --- /dev/null +++ b/ports/imgui-sfml/portfile.cmake @@ -0,0 +1,29 @@ +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 +) + +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) diff --git a/ports/imgui-sfml/static-build-with-vcpkg-imgui.patch b/ports/imgui-sfml/static-build-with-vcpkg-imgui.patch new file mode 100644 index 00000000000000..d6f92db9aec088 --- /dev/null +++ b/ports/imgui-sfml/static-build-with-vcpkg-imgui.patch @@ -0,0 +1,99 @@ +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(z * 255.f), \ + static_cast(w * 255.f)); \ + } +- +-#define ImTextureID unsigned int +\ No newline at end of file +diff --git a/imgui-SFML_export.h b/imgui-SFML_export.h +index cf5e4c9..3cb0fe6 100644 +--- a/imgui-SFML_export.h ++++ b/imgui-SFML_export.h +@@ -5,21 +5,16 @@ + #if _WIN32 + #ifdef IMGUI_SFML_EXPORTS + #define IMGUI_SFML_API __declspec(dllexport) +- #define IMGUI_API __declspec(dllexport) + #else + #define IMGUI_SFML_API __declspec(dllimport) +- #define IMGUI_API __declspec(dllexport) + #endif + #elif __GNUC__ >= 4 + #define IMGUI_SFML_API __attribute__ ((visibility("default"))) +- #define IMGUI_API __attribute__ ((visibility("default"))) + #else + #define IMGUI_SFML_API +- #define IMGUI_API + #endif + #else + #define IMGUI_SFML_API +- #define IMGUI_API + #endif + + #endif +\ No newline at end of file + From 03daa62388ac4d318d0118a2b19522f5e1a7707e Mon Sep 17 00:00:00 2001 From: Tri Tran Date: Thu, 25 Jul 2019 16:35:42 -0500 Subject: [PATCH 2/5] [imgui-sfml] Fix case-sensitive imgui package name --- .../static-build-with-vcpkg-imgui.patch | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ports/imgui-sfml/static-build-with-vcpkg-imgui.patch b/ports/imgui-sfml/static-build-with-vcpkg-imgui.patch index d6f92db9aec088..cad88bbb35b231 100644 --- a/ports/imgui-sfml/static-build-with-vcpkg-imgui.patch +++ b/ports/imgui-sfml/static-build-with-vcpkg-imgui.patch @@ -4,11 +4,11 @@ index 015a030..33d6894 100644 +++ 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() @@ -23,11 +23,11 @@ index 015a030..33d6894 100644 + # 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) - ++find_package(imgui REQUIRED) + # these headers will be installed alongside ImGui-SFML -set(IMGUI_PUBLIC_HEADERS - ${IMGUI_INCLUDE_DIR}/imconfig.h @@ -47,11 +47,11 @@ index 015a030..33d6894 100644 + # ${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 @@ -93,7 +93,7 @@ index cf5e4c9..3cb0fe6 100644 #define IMGUI_SFML_API - #define IMGUI_API #endif - + #endif \ No newline at end of file From f3ddb654fe307de91dc438a3331736a773437063 Mon Sep 17 00:00:00 2001 From: Tri Tran Date: Thu, 25 Jul 2019 16:54:53 -0500 Subject: [PATCH 3/5] [imgui-sfml] Require C++11 --- ports/imgui-sfml/portfile.cmake | 1 + ports/imgui-sfml/require-c++11.patch | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 ports/imgui-sfml/require-c++11.patch diff --git a/ports/imgui-sfml/portfile.cmake b/ports/imgui-sfml/portfile.cmake index 96896c530ef6ad..5f0b3e65030b20 100644 --- a/ports/imgui-sfml/portfile.cmake +++ b/ports/imgui-sfml/portfile.cmake @@ -11,6 +11,7 @@ vcpkg_from_github( HEAD_REF master PATCHES static-build-with-vcpkg-imgui.patch + require-c++11.patch ) vcpkg_configure_cmake( diff --git a/ports/imgui-sfml/require-c++11.patch b/ports/imgui-sfml/require-c++11.patch new file mode 100644 index 00000000000000..79db1b5a67efe2 --- /dev/null +++ b/ports/imgui-sfml/require-c++11.patch @@ -0,0 +1,14 @@ +diff --git a/CMakeLists.txt b/CMakeLists.txt +index ad59f9c..e03b4d3 100644 +--- a/CMakeLists.txt ++++ b/CMakeLists.txt +@@ -5,6 +5,9 @@ project(imgui_sfml + VERSION 2.0 + ) + ++set(CMAKE_CXX_STANDARD 11) ++set(CMAKE_CXX_STANDARD_REQUIRED ON) ++ + # In CMake 3.13+ this policy enables you to define normal variables with option names as if you defined + # these options. Useful for add_subdirectory(ImGui-SFML) + if(POLICY CMP0077) From 0c257bb7625c635bb03d0b2628d93760f2796785 Mon Sep 17 00:00:00 2001 From: Tri Tran Date: Thu, 25 Jul 2019 19:28:38 -0500 Subject: [PATCH 4/5] [imgui-sfml] Include IMGUI_API define --- .../static-build-with-vcpkg-imgui.patch | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/ports/imgui-sfml/static-build-with-vcpkg-imgui.patch b/ports/imgui-sfml/static-build-with-vcpkg-imgui.patch index cad88bbb35b231..0432a5c26cd3dd 100644 --- a/ports/imgui-sfml/static-build-with-vcpkg-imgui.patch +++ b/ports/imgui-sfml/static-build-with-vcpkg-imgui.patch @@ -69,31 +69,3 @@ index f66ba20..0f43ce6 100644 - -#define ImTextureID unsigned int \ No newline at end of file -diff --git a/imgui-SFML_export.h b/imgui-SFML_export.h -index cf5e4c9..3cb0fe6 100644 ---- a/imgui-SFML_export.h -+++ b/imgui-SFML_export.h -@@ -5,21 +5,16 @@ - #if _WIN32 - #ifdef IMGUI_SFML_EXPORTS - #define IMGUI_SFML_API __declspec(dllexport) -- #define IMGUI_API __declspec(dllexport) - #else - #define IMGUI_SFML_API __declspec(dllimport) -- #define IMGUI_API __declspec(dllexport) - #endif - #elif __GNUC__ >= 4 - #define IMGUI_SFML_API __attribute__ ((visibility("default"))) -- #define IMGUI_API __attribute__ ((visibility("default"))) - #else - #define IMGUI_SFML_API -- #define IMGUI_API - #endif - #else - #define IMGUI_SFML_API -- #define IMGUI_API - #endif - - #endif -\ No newline at end of file - From 8e865192a4377a0d1d3a33faeac1afdd7fa6bfa4 Mon Sep 17 00:00:00 2001 From: Tri Tran Date: Thu, 8 Aug 2019 08:30:59 -0500 Subject: [PATCH 5/5] [imgui-sfml] Remove delegating ctor - C++11 is not required --- ports/imgui-sfml/portfile.cmake | 2 +- ports/imgui-sfml/remove-delegating-ctor.patch | 13 +++++++++++++ ports/imgui-sfml/require-c++11.patch | 14 -------------- 3 files changed, 14 insertions(+), 15 deletions(-) create mode 100644 ports/imgui-sfml/remove-delegating-ctor.patch delete mode 100644 ports/imgui-sfml/require-c++11.patch diff --git a/ports/imgui-sfml/portfile.cmake b/ports/imgui-sfml/portfile.cmake index 5f0b3e65030b20..4cc33edb9c1518 100644 --- a/ports/imgui-sfml/portfile.cmake +++ b/ports/imgui-sfml/portfile.cmake @@ -11,7 +11,7 @@ vcpkg_from_github( HEAD_REF master PATCHES static-build-with-vcpkg-imgui.patch - require-c++11.patch + remove-delegating-ctor.patch ) vcpkg_configure_cmake( diff --git a/ports/imgui-sfml/remove-delegating-ctor.patch b/ports/imgui-sfml/remove-delegating-ctor.patch new file mode 100644 index 00000000000000..a0442fc13ea52d --- /dev/null +++ b/ports/imgui-sfml/remove-delegating-ctor.patch @@ -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( \ diff --git a/ports/imgui-sfml/require-c++11.patch b/ports/imgui-sfml/require-c++11.patch deleted file mode 100644 index 79db1b5a67efe2..00000000000000 --- a/ports/imgui-sfml/require-c++11.patch +++ /dev/null @@ -1,14 +0,0 @@ -diff --git a/CMakeLists.txt b/CMakeLists.txt -index ad59f9c..e03b4d3 100644 ---- a/CMakeLists.txt -+++ b/CMakeLists.txt -@@ -5,6 +5,9 @@ project(imgui_sfml - VERSION 2.0 - ) - -+set(CMAKE_CXX_STANDARD 11) -+set(CMAKE_CXX_STANDARD_REQUIRED ON) -+ - # In CMake 3.13+ this policy enables you to define normal variables with option names as if you defined - # these options. Useful for add_subdirectory(ImGui-SFML) - if(POLICY CMP0077)