improve imgui-sfml (#2199)

* improve imgui-sfml

* add links

* fix shared
pull/2200/head
ruki 2 years ago committed by GitHub
parent c5acba7a75
commit 2eeb5070f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 14
      packages/i/imgui-sfml/patches/v2.5/macosx.patch
  2. 64
      packages/i/imgui-sfml/xmake.lua

@ -1,14 +0,0 @@
diff --git a/CMakeLists.txt b/CMakeLists.txt
index fad29a6..2a9e512 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -164,6 +164,9 @@ set_target_properties(ImGui-SFML PROPERTIES
PUBLIC_HEADER "${IMGUI_SFML_PUBLIC_HEADERS}"
)
+# Set minimum required standard
+target_compile_features(ImGui-SFML PUBLIC cxx_std_11)
+
if(IMGUI_SFML_BUILD_EXAMPLES)
add_subdirectory(examples)
endif()

@ -7,50 +7,60 @@ package("imgui-sfml")
"https://github.com/eliasdaler/imgui-sfml.git")
add_versions("v2.5", "3775c9303f656297f2392e91ffae2021e874ee319b4139c60076d6f757ede109")
add_patches("v2.5", path.join(os.scriptdir(), "patches", "v2.5", "macosx.patch"), "1bb74614926dd34034e34a4052794e0b13caa861a780f813ad8a082aac74588f")
add_deps("cmake")
add_deps("imgui", {system = false, private = true})
add_deps("imgui 1.80")
add_deps("opengl", {optional = true})
if is_plat("windows", "mingw") then
add_syslinks("imm32")
end
add_links("ImGui-SFML")
on_load(function(package)
if package:is_plat("linux") and package:config("shared") then
package:add("deps", "sfml", {configs = {shared = true}})
else
package:add("deps", "sfml")
end
if package:is_plat("windows", "mingw") and package:config("shared") then
package:add("defines", "IMGUI_SFML_SHARED_LIB=1")
end
end)
on_install("macosx", "linux", "windows", "mingw", function (package)
import("lib.detect.find_path")
local configs = {"-DIMGUI_SFML_FIND_SFML=OFF"}
table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
local imgui_sourcedir = package:dep("imgui"):cachedir()
if imgui_sourcedir then
local imguidir = find_path("imgui.h", path.join(imgui_sourcedir, "*")) or find_path("imgui.h", path.join(imgui_sourcedir, "source", "*"))
if imguidir then
table.insert(configs, "-DIMGUI_DIR=" .. imguidir)
io.writefile("xmake.lua", [[
add_rules("mode.release", "mode.debug")
add_requires("imgui 1.80")
if is_plat("linux") and is_kind("shared") then
add_requires("sfml", {configs = {shared = true}})
else
add_requires("sfml")
end
end
-- fix sfml links
if package:is_plat("windows", "linux") then
local sfml = package:dep("sfml"):fetch()
if sfml.links then
for _, name in ipairs({"sfml-graphics", "sfml-system", "sfml-window"}) do
for _, link in ipairs(sfml.links) do
if link:find(name, 1, true) then
io.replace("CMakeLists.txt", name, link, {plain = true})
break
end
add_requires("opengl", {optional = true})
target("ImGui-SFML")
set_kind("$(kind)")
add_files("imgui-SFML.cpp")
add_headerfiles("*.h")
add_includedirs(".")
add_packages("imgui", "sfml", "opengl")
set_languages("c++11")
add_defines("IMGUI_USER_CONFIG=\"imconfig-SFML.h\"")
if is_plat("windows", "mingw") then
add_syslinks("imm32")
if is_kind("shared") then
add_defines("IMGUI_SFML_SHARED_LIB=1", "IMGUI_SFML_EXPORTS")
end
end
end
end
if package:is_plat("mingw") then
io.replace("cmake/FindImGui.cmake", "NO_DEFAULT_PATH", "NO_DEFAULT_PATH NO_CMAKE_FIND_ROOT_PATH")
add_rules("utils.install.pkgconfig_importfiles")
add_rules("utils.install.cmake_importfiles")
]])
local configs = {}
if package:config("shared") then
configs.kind = "shared"
end
import("package.tools.cmake").install(package, configs, {packagedeps = "sfml"})
import("package.tools.xmake").install(package, configs)
end)
on_test(function (package)

Loading…
Cancel
Save