xmake.lua 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. package("freerdp")
  2. set_homepage("http://www.freerdp.com")
  3. set_description("FreeRDP is a free remote desktop protocol library and clients ")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/FreeRDP/FreeRDP/releases/download/$(version)/freerdp-$(version).tar.gz",
  6. "https://github.com/FreeRDP/FreeRDP.git")
  7. add_versions("3.18.0", "70e89fdc92e3c2a429a7e61015ffd55bda4f6fefd76bb2978a91134d94869462")
  8. add_versions("3.17.2", "c42c712ad879bf06607b78b8c3fad98e08c82f73f4e0bc1693552900041e692a")
  9. add_versions("3.16.0", "385af54245560493698730b688b5e6e5d56d5c7ecf2fa7c1d7cedfde8a4ba456")
  10. add_versions("3.15.0", "e8cd58decef4c970faea2fbea675970eea60e440ebe8033c54889acb83787371")
  11. add_configs("client", {description = "Build client", default = false, type = "boolean"})
  12. add_configs("client_channels", {description = "Build virtual channel plugins", default = false, type = "boolean"})
  13. add_configs("server", {description = "Build server", default = false, type = "boolean"})
  14. add_configs("server_channels", {description = "Build virtual channel plugins", default = false, type = "boolean"})
  15. add_configs("rdtk", {description = "Build rdtk toolkit", default = false, type = "boolean"})
  16. add_configs("shadow", {description = "Compile with shadow server", default = false, type = "boolean"})
  17. add_configs("proxy", {description = "Compile with proxy server", default = false, type = "boolean"})
  18. add_configs("platform_server", {description = "Compile with platform server", default = false, type = "boolean"})
  19. add_configs("x11", {description = "Build X11 client/server", default = false, type = "boolean"})
  20. add_configs("wayland", {description = "Build with wayland", default = false, type = "boolean"})
  21. add_configs("fuse", {description = "Build clipboard with FUSE file copy support", default = false, type = "boolean"})
  22. add_configs("json", {description = "Build with any JSON support", default = nil, type = "string", values = {"cjson", "json-c"}})
  23. add_configs("uriparser", {description = "use uriparser library to handle URIs", default = false, type = "boolean"})
  24. add_configs("ffmpeg", {description = "Enable FFMPEG for audio/video encoding/decoding", default = false, type = "boolean"})
  25. add_configs("cairo", {description = "Use CAIRO image library for screen resizing", default = false, type = "boolean"})
  26. add_configs("swscale", {description = "Use SWScale image library for screen resizing", default = false, type = "boolean"})
  27. add_configs("openh264", {description = "Build openh264", default = false, type = "boolean"})
  28. add_configs("krb5", {description = "Compile support for kerberos authentication.", default = false, type = "boolean"})
  29. -- Try resolve emmintrin.h:740:1: error: inlining failed in call to 'always_inline' '_mm_storeu_si128': target specific option mismatch
  30. add_configs("simd", {description = "Build with simd", default = not is_plat("wasm") and not (is_arch("i386") and is_plat("mingw") and is_subhost("macosx")), type = "boolean"})
  31. -- winpr
  32. add_configs("unicode_builtin", {description = "Build builtin unicode", default = true, type = "boolean"})
  33. add_configs("timezone_icu", {description = "Use ICU for improved timezone mapping", default = false, type = "boolean"})
  34. add_configs("winpr_tools", {description = "Build WinPR helper binaries", default = false, type = "boolean"})
  35. if is_plat("windows", "mingw") then
  36. add_configs("winmm", {description = "Use Windows Multimedia", default = true, type = "boolean"})
  37. end
  38. if is_plat("linux", "bsd") then
  39. add_syslinks("pthread")
  40. elseif is_plat("windows", "mingw") then
  41. add_syslinks("rpcrt4", "ncrypt", "shell32", "ole32", "dbghelp", "shlwapi", "ntdll")
  42. if is_plat("mingw") then
  43. add_syslinks("uuid")
  44. end
  45. elseif is_plat("macosx") then
  46. add_frameworks("CoreFoundation", "Carbon")
  47. end
  48. add_deps("cmake")
  49. add_deps("zlib", "openssl3")
  50. add_includedirs("include", "include/freerdp3", "include/winpr3")
  51. add_links("freerdp-server3", "freerdp-server-proxy3", "freerdp-client3", "freerdp3", "rdtk0", "winpr3")
  52. on_load(function (package)
  53. if package:config("shadow") or package:config("proxy") or package:config("platform_server") then
  54. package:config_set("server", true)
  55. end
  56. if package:config("proxy") then
  57. package:config_set("client", true)
  58. end
  59. local configs_map_to_deps = {
  60. client = "libusb",
  61. wayland = "wayland",
  62. fuse = "libfuse",
  63. json = package:config("json"),
  64. uriparser = "uriparser",
  65. cairo = "cairo",
  66. openh264 = "openh264",
  67. ffmpeg = "ffmpeg",
  68. swscale = "ffmpeg",
  69. krb5 = "krb5",
  70. }
  71. for config, dep in pairs(configs_map_to_deps) do
  72. if package:config(config) then
  73. package:add("deps", dep)
  74. end
  75. end
  76. if package:config("x11") or package:config("shadow") then
  77. package:add("deps", "libx11", "libxext", "libxcursor")
  78. end
  79. if not package:config("unicode_builtin") or package:config("timezone_icu") then
  80. package:add("deps", "icu4c")
  81. end
  82. if package:dep("libusb") then
  83. if is_subhost("windows") then
  84. package:add("deps", "pkgconf")
  85. else
  86. package:add("deps", "pkg-config")
  87. end
  88. end
  89. -- https://github.com/libfuse/libfuse/issues/383
  90. if package:config("fuse") then
  91. package:add("deps", "libfuse", {configs = {shared = true}})
  92. end
  93. if package:is_plat("windows", "mingw") and not package:config("shared") then
  94. package:add("defines", "FREERDP_EXPORTS")
  95. end
  96. if package:config("winmm") and package:is_plat("windows", "mingw") then
  97. package:add("syslinks", "winmm")
  98. end
  99. end)
  100. on_install("!bsd and !iphoneos", function (package)
  101. if package:is_plat("mingw") then
  102. io.replace("winpr/include/winpr/wtypes.h", "typedef ssize_t SSIZE_T;", "#ifndef _SSIZE_T_DEFINED\ntypedef ssize_t SSIZE_T;\n#endif", {plain = true})
  103. end
  104. io.replace("CMakeLists.txt", "include(${CMAKE_CPACK_INCLUDE_FILE})", "", {plain = true})
  105. io.replace("cmake/MSVCRuntime.cmake", "if(BUILD_SHARED_LIBS)", "if(0)", {plain = true})
  106. if package:config("fuse") then
  107. io.replace("client/common/CMakeLists.txt", "pkg_check_modules(FUSE3 REQUIRED fuse3)", "pkg_check_modules(FUSE3 REQUIRED IMPORTED_TARGET fuse3)", {plain = true})
  108. io.replace("client/common/CMakeLists.txt", "${FUSE3_LIBRARIES}", "PkgConfig::FUSE3", {plain = true})
  109. end
  110. local libusb = package:dep("libusb")
  111. if libusb and not libusb:is_system() and not libusb:config("shared") and package:is_plat("linux", "cross") then
  112. io.replace("cmake/Findlibusb-1.0.cmake", "set(LIBUSB_1_LIBRARIES ${LIBUSB_1_LIBRARY})",
  113. [[find_package(PkgConfig)
  114. pkg_check_modules(PC_LIBUDEV QUIET libudev)
  115. find_library(UDEV_LIBRARY NAMES udev PATHS ${PC_LIBUDEV_LIBRARY_DIRS} ${PC_LIBUDEV_LIBDIR} PATH_SUFFIXES lib)
  116. set(LIBUSB_1_LIBRARIES ${LIBUSB_1_LIBRARY} ${UDEV_LIBRARY})]], {plain = true})
  117. end
  118. local configs = {
  119. "-DWITH_SAMPLE=OFF",
  120. "-DWITH_MANPAGES=OFF",
  121. "-DBUILD_TESTING=OFF",
  122. "-DWITH_CCACHE=OFF",
  123. "-DWITH_CLANG_FORMAT=OFF",
  124. "-DCMAKE_INTERPROCEDURAL_OPTIMIZATION=OFF",
  125. -- build bundle winpr
  126. "-DFREERDP_UNIFIED_BUILD=ON",
  127. "-DWITH_CUPS=OFF",
  128. }
  129. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  130. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  131. local dep = package:config("json")
  132. table.insert(configs, "-DWITH_JSON_DISABLED=" .. (dep and "OFF" or "ON"))
  133. table.insert(configs, "-DWITH_CJSON_REQUIRED=" .. (dep == "cjson" and "ON" or "OFF"))
  134. table.insert(configs, "-DWITH_JSONC_REQUIRED=" .. (dep == "json-c" and "ON" or "OFF"))
  135. if package:is_plat("mingw") then
  136. -- winpr/libwinpr/utils/unwind/debug.c require dlfcn.h, try `dlfcn-win32`?
  137. table.insert(configs, "-DUSE_UNWIND=OFF")
  138. -- fatal error: bits/libc-header-start.h: No such file or directory
  139. table.insert(configs, "-DWITH_SMARTCARD_EMULATE=OFF")
  140. end
  141. table.insert(configs, "-DWITH_CLIENT_COMMON=" .. (package:config("client") and "ON" or "OFF"))
  142. for name, enabled in table.orderpairs(package:configs()) do
  143. if not package:extraconf("configs", name, "builtin") then
  144. table.insert(configs, format("-DWITH_%s=%s", name:upper(), (enabled and "ON" or "OFF")))
  145. end
  146. end
  147. local opt = {}
  148. if package:is_plat("mingw") and package:has_tool("cc", "gcc") then
  149. opt.cxflags = "-Wno-error=incompatible-pointer-types"
  150. end
  151. if package:dep("libx11") then
  152. opt.packagedeps = {"libx11", "xorgproto", "libxext", "libxcursor"}
  153. end
  154. if package:dep("ffmpeg") and not package:has_tool("ld", "link") then
  155. -- https://stackoverflow.com/questions/44379426/building-shared-library-with-ffmpeg-results-in-relocation-error
  156. opt.ldflags = "-Wl,-Bsymbolic"
  157. opt.shflags = "-Wl,-Bsymbolic"
  158. end
  159. import("package.tools.cmake").install(package, configs, opt)
  160. end)
  161. on_test(function (package)
  162. assert(package:has_cfuncs("winpr_get_version", {includes = "winpr/winpr.h"}))
  163. assert(package:has_cfuncs("freerdp_get_version", {includes = "freerdp/freerdp.h"}))
  164. end)