xmake.lua 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. package("wxwidgets")
  2. set_homepage("https://www.wxwidgets.org/")
  3. set_description("Cross-Platform C++ GUI Library")
  4. if is_plat("windows") then
  5. if is_arch("x64") then
  6. add_urls("https://github.com/wxWidgets/wxWidgets/releases/download/v$(version)/wxMSW-$(version)_vc14x_x64_Dev.7z")
  7. add_versions("3.2.0", "02b7227916b98324f73ae9bed0f1cf27ae3157b4e3a3ded40ee8c0d570f0fd10")
  8. add_resources("3.2.0", "releaseDLL",
  9. "https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.0/wxMSW-3.2.0_vc14x_x64_ReleaseDLL.7z",
  10. "81d6512843a715fd4ba03b227a473701c90fae42406b88f0cc7ca022ec47dc51")
  11. add_versions("3.2.2", "b5d36e3ac9e01dc1a024344a0a28f9b99bdba75bafa119e1a626d8cc6fdef63d")
  12. add_resources("3.2.2", "releaseDLL",
  13. "https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.2/wxMSW-3.2.2_vc14x_x64_ReleaseDLL.7z",
  14. "34e11c8d493e4f2856441942a88296864243db320e3f9057633d50b89a4f2848")
  15. add_versions("3.2.3", "b8a6be72378d9947e303d7075a58c9bbc161d5debd25a187b654373b4d204873")
  16. add_resources("3.2.3", "releaseDLL",
  17. "https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.3/wxMSW-3.2.3_vc14x_x64_ReleaseDLL.7z",
  18. "ee0fde533b7ac8eac6ec112da2e3a488675aa8c1dda483eb8a9a2d4f8e5bb734")
  19. add_versions("3.2.4", "b8be152f08031aed2bfeffd17d8409209c38667859094b319818e08f7a4ad065")
  20. add_resources("3.2.4", "releaseDLL",
  21. "https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.4/wxMSW-3.2.4_vc14x_x64_ReleaseDLL.7z",
  22. "0f9108e64f98978580fee2d4b3a53451ab4333e4b47dde45b82e7867d0bbfc2c")
  23. else
  24. add_urls("https://github.com/wxWidgets/wxWidgets/releases/download/v$(version)/wxMSW-$(version)_vc14x_Dev.7z")
  25. add_versions("3.2.0", "0cd2387edcf1f26924d59efcc3ea4c8a00783ee01bf396756dabdd7967e4b37b")
  26. add_resources("3.2.0", "releaseDLL",
  27. "https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.0/wxMSW-3.2.0_vc14x_ReleaseDLL.7z",
  28. "b168c9225f17168c7ece551c499d043bffc121d32408edf1905648482002110b")
  29. add_versions("3.2.2", "7150112bece62f4eccd68d3b0eba11b5a1da0f773e864bdecb9840ce76160847")
  30. add_resources("3.2.2", "releaseDLL",
  31. "https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.2/wxMSW-3.2.2_vc14x_ReleaseDLL.7z",
  32. "1a8d387fae963d2242b0fc628699d34bb6141751fb05dec8fa9c0e2784833426")
  33. add_versions("3.2.3", "8961f24abb16362a542140912f3c6cb75b8f95111816311ecf5b00ea1e0c55f3")
  34. add_resources("3.2.3", "releaseDLL",
  35. "https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.3/wxMSW-3.2.3_vc14x_ReleaseDLL.7z",
  36. "b1b22d43509c2e1fe427d038210076dcb1d9953e5fef09ffa04e49f49c78a9a7")
  37. add_versions("3.2.4", "efa6bf76d42373e7930af18a176e5e52fbdd43f5da41b9bf6cd3b347d820f8b7")
  38. add_resources("3.2.4", "releaseDLL",
  39. "https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.4/wxMSW-3.2.4_vc14x_ReleaseDLL.7z",
  40. "240308cb9ffb718ab2f1298238c6e6aea7708cb16aca5801a03bffee6f9ef673")
  41. end
  42. add_resources("3.2.0", "headers",
  43. "https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.0/wxWidgets-3.2.0-headers.7z",
  44. "bd847e20050c52d127f4afe9b00ffe29d87c2f907749bd6bc732c0db05bce4b1")
  45. add_resources("3.2.2", "headers",
  46. "https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.2/wxWidgets-3.2.2-headers.7z",
  47. "affad097f2c274f796bf08494c1624d999d75727e73959bce5a3d366aeebc721")
  48. add_resources("3.2.3", "headers",
  49. "https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.3/wxWidgets-3.2.3-headers.7z",
  50. "a610f1a044b93f4d8d5439c67fc42b3feb168d854bc4725aa2b5ff4569d89a06")
  51. add_resources("3.2.4", "headers",
  52. "https://github.com/wxWidgets/wxWidgets/releases/download/v3.2.4/wxWidgets-3.2.4-headers.7z",
  53. "b8c4fd1a62c104c65089a088670d80e827b3893b7425c1cab8d7e49879797326")
  54. add_configs("shared", {description = "Build shared library.", default = true, type = "boolean", readonly = true})
  55. add_configs("vs_runtime", {description = "Set vs compiler runtime.", default = "MD", readonly = true})
  56. add_configs("debug", {description = "Enable debug symbols.", default = false, type = "boolean", readonly = true})
  57. else
  58. add_urls("https://github.com/wxWidgets/wxWidgets/releases/download/v$(version)/wxWidgets-$(version).tar.bz2",
  59. "https://github.com/wxWidgets/wxWidgets.git")
  60. add_versions("3.2.0", "356e9b55f1ae3d58ae1fed61478e9b754d46b820913e3bfbc971c50377c1903a")
  61. add_versions("3.2.2", "8edf18672b7bc0996ee6b7caa2bee017a9be604aad1ee471e243df7471f5db5d")
  62. add_versions("3.2.3", "c170ab67c7e167387162276aea84e055ee58424486404bba692c401730d1a67a")
  63. add_versions("3.2.4", "0640e1ab716db5af2ecb7389dbef6138d7679261fbff730d23845ba838ca133e")
  64. add_versions("3.2.5", "0ad86a3ad3e2e519b6a705248fc9226e3a09bbf069c6c692a02acf7c2d1c6b51")
  65. add_deps("cmake")
  66. add_deps("libjpeg", "libpng", "nanosvg", "expat", "zlib", "pango", "glib")
  67. if is_plat("linux") then
  68. add_deps("opengl", "at-spi2-core")
  69. add_patches("<=3.2.5", "patches/3.2.5/add_libdir.patch", "9a9fe4d745b4b6b09998ec7a93642d69761a8779d203fbb42a3df8c3d62adeb0")
  70. end
  71. end
  72. if is_plat("macosx") then
  73. add_defines("__WXOSX_COCOA__", "__WXMAC__", "__WXOSX__", "__WXMAC_XCODE__")
  74. add_frameworks("AudioToolbox", "WebKit", "CoreFoundation", "Security", "Carbon", "Cocoa", "IOKit", "QuartzCore")
  75. add_syslinks("iconv")
  76. elseif is_plat("linux") then
  77. add_defines("__WXGTK3__", "__WXGTK__")
  78. add_syslinks("pthread", "m", "dl")
  79. add_syslinks("X11", "Xext", "Xtst", "xkbcommon")
  80. add_links(
  81. "pango-1.0", "pangoxft-1.0", "pangocairo-1.0", "pangoft2-1.0"
  82. )
  83. elseif is_plat("windows") then
  84. add_defines("WXUSINGDLL", "__WXMSW__", "wxSUFFIX=u", "wxMSVC_VERSION=14x")
  85. add_links(
  86. "wxbase32u", "wxbase32u_net", "wxbase32u_xml", "wxexpat",
  87. "wxjpeg", "wxmsw32u_adv", "wxmsw32u_aui", "wxmsw32u_core", "wxmsw32u_gl",
  88. "wxmsw32u_html", "wxmsw32u_media", "wxmsw32u_propgrid", "wxmsw32u_qa", "wxmsw32u_ribbon",
  89. "wxmsw32u_richtext", "wxmsw32u_stc", "wxmsw32u_webview", "wxmsw32u_xrc",
  90. "wxpng", "wxregexu", "wxscintilla", "wxtiff", "wxzlib"
  91. )
  92. end
  93. on_load(function (package)
  94. if package:is_plat("macosx", "linux") then
  95. local version = package:version()
  96. local suffix = version:major() .. "." .. version:minor()
  97. local static = package:config("shared") and "" or "-static"
  98. if package:is_plat("macosx") then
  99. package:add("includedirs", path.join("lib", "wx", "include", "osx_cocoa-unicode" .. static .. "-" .. suffix))
  100. elseif package:is_plat("linux") then
  101. package:add("includedirs", path.join("lib", "wx", "include", "gtk3-unicode" .. static .. "-" .. suffix))
  102. end
  103. package:add("includedirs", path.join("include", "wx-" .. suffix))
  104. if package:debug() then
  105. package:add("defines", "wxDEBUG_LEVEL=2")
  106. end
  107. if package:config("shared") then
  108. package:add("defines", "WXUSINGDLL")
  109. package:add("deps", "libtiff", {configs = {shared = true}})
  110. package:add("deps", "gdk-pixbuf", {configs = {shared = true}})
  111. else
  112. package:add("deps", "libtiff")
  113. package:add("deps", "gdk-pixbuf")
  114. end
  115. if is_plat("linux") then
  116. if package:config("shared") then
  117. package:add("deps", "gtk3", {configs = {shared = true}})
  118. else
  119. package:add("deps", "gtk3")
  120. end
  121. end
  122. end
  123. end)
  124. on_install("windows", function (package)
  125. local dlldir = package:is_arch("x64") and "vc14x_x64_dll" or "vc14x_dll"
  126. os.cp(path.join("lib", dlldir, "*.lib"), package:installdir("lib"))
  127. os.cp(path.join(package:resourcedir("releaseDLL"),"lib", dlldir, "*.dll"), package:installdir("bin"))
  128. os.cp(path.join("lib", dlldir, "mswu", "wx"), package:installdir("lib", dlldir, "mswu"))
  129. os.cp(path.join(package:resourcedir("headers"), "include"), package:installdir())
  130. os.cp(path.join(package:resourcedir("headers"), "include", "msvc", "wx", "setup.h"), package:installdir("include/wx"))
  131. io.replace(path.join(package:installdir("include"), "wx", "setup.h"), "../../../lib/", "../../lib/", {plain = true})
  132. end)
  133. on_install("macosx", "linux", function (package)
  134. -- Notify the user about issues caused by the CMake version.
  135. local cmake = package:dep("cmake")
  136. local cmake_fetch = cmake:fetch()
  137. local major, minor, patch = cmake_fetch.version:match("^(%d+)%.(%d+)%.(%d+)$")
  138. local cmake_version = tonumber(major.. minor.. patch)
  139. if cmake_version > 3280 then
  140. wprint("\ncmake may not find Cmath detail in https://github.com/prusa3d/PrusaSlicer/issues/12169\n")
  141. end
  142. io.replace("build/cmake/modules/FindGTK3.cmake", "FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK3 DEFAULT_MSG GTK3_INCLUDE_DIRS GTK3_LIBRARIES VERSION_OK)",
  143. [[FIND_PACKAGE_HANDLE_STANDARD_ARGS(GTK3 DEFAULT_MSG GTK3_INCLUDE_DIRS GTK3_LIBRARY_DIRS GTK3_LIBRARIES VERSION_OK)]], {plain = true})
  144. local configs = {"-DwxBUILD_TESTS=OFF",
  145. "-DwxBUILD_SAMPLES=OFF",
  146. "-DwxBUILD_DEMOS=OFF",
  147. "-DwxBUILD_PRECOMP=OFF",
  148. "-DwxBUILD_BENCHMARKS=OFF",
  149. "-DwxUSE_REGEX=sys",
  150. "-DwxUSE_ZLIB=sys",
  151. "-DwxUSE_EXPAT=sys",
  152. "-DwxUSE_LIBJPEG=sys",
  153. "-DwxUSE_LIBPNG=sys",
  154. "-DwxUSE_NANOSVG=sys",
  155. "-DwxUSE_LIBTIFF=builtin"}
  156. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  157. if package:debug() then
  158. table.insert(configs, "-DwxBUILD_DEBUG_LEVEL=2")
  159. end
  160. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  161. import("package.tools.cmake").install(package, configs)
  162. local version = package:version()
  163. local subdir = "wx-" .. version:major() .. "." .. version:minor()
  164. local setupdir = package:is_plat("macosx") and "osx" or "gtk"
  165. os.cp(path.join(package:installdir("include", subdir, "wx", setupdir, "setup.h")),
  166. path.join(package:installdir("include", subdir, "wx")))
  167. local lib_suffix = version:major() .. "." .. version:minor()
  168. if package:is_plat("linux") then
  169. package:add("links", "wx_gtk3u_xrc-" .. lib_suffix, "wx_gtk3u_html-" .. lib_suffix, "wx_gtk3u_qa-" .. lib_suffix, "wx_gtk3u_core-" .. lib_suffix, "wx_baseu_xml-" .. lib_suffix, "wx_baseu_net-" .. lib_suffix, "wx_baseu-" .. lib_suffix)
  170. end
  171. end)
  172. on_test(function (package)
  173. assert(package:check_cxxsnippets({test = [[
  174. #include <wx/wxprec.h>
  175. #ifndef WX_PRECOMP
  176. #include <wx/wx.h>
  177. #endif
  178. #include "wx/app.h"
  179. #include "wx/cmdline.h"
  180. void test() {
  181. wxApp::CheckBuildOptions(WX_BUILD_OPTIONS_SIGNATURE, "program");
  182. wxInitializer initializer;
  183. if (!initializer) {
  184. fprintf(stderr, "Failed to initialize the wxWidgets library, aborting.");
  185. }
  186. }
  187. ]]}, {configs = {languages = "c++14"}}))
  188. end)