xmake.lua 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. package("dlib")
  2. set_homepage("https://dlib.net")
  3. set_description("A toolkit for making real world machine learning and data analysis applications in C++")
  4. set_license("Boost")
  5. add_urls("https://github.com/davisking/dlib/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/davisking/dlib.git")
  7. add_versions("v19.24.6", "22513c353ec9c153300c394050c96ca9d088e02966ac0f639e989e50318c82d6")
  8. add_versions("v19.24.5", "01cab8fb880cf4d1cb9c84cb74c6ce291a78c69f443dced5aa2a88fb20bdc3bd")
  9. add_versions("v19.24.4", "d881911d68972d11563bb9db692b8fcea0ac1b3fd2e3f03fa0b94fde6c739e43")
  10. add_versions("v19.22", "5f44b67f762691b92f3e41dcf9c95dd0f4525b59cacb478094e511fdacb5c096")
  11. add_configs("png", {description = "Enable png", default = false, type = "boolean"})
  12. add_configs("jpg", {description = "Enable jpg", default = false, type = "boolean"})
  13. add_configs("gif", {description = "Enable gif", default = false, type = "boolean"})
  14. add_configs("sqlite3", {description = "Enable sqlite3", default = false, type = "boolean"})
  15. add_configs("blas", {description = "Enable blas", default = false, type = "boolean"})
  16. add_configs("mkl", {description = "Enable mkl", default = false, type = "boolean"})
  17. add_configs("jxl", {description = "Enable jpeg xl", default = false, type = "boolean"})
  18. add_configs("ffmpeg", {description = "Enable ffmpeg", default = false, type = "boolean"})
  19. add_configs("webp", {description = "Enable webp", default = false, type = "boolean"})
  20. add_configs("simd", {description = "SIMD acceleration architecture.", type = "string", values = {"sse2", "sse4", "avx", "neon"}})
  21. if is_plat("linux", "bsd") then
  22. add_syslinks("pthread")
  23. end
  24. add_deps("cmake")
  25. on_load(function (package)
  26. if package:config("png") then
  27. package:add("deps", "libpng")
  28. end
  29. if package:config("png") then
  30. package:add("deps", "libjpeg")
  31. end
  32. if package:config("gif") then
  33. package:add("deps", "giflib")
  34. end
  35. if package:config("sqlite3") then
  36. package:add("deps", "sqlite3")
  37. end
  38. if package:config("blas") then
  39. package:add("deps", "openblas")
  40. end
  41. if package:config("mkl") then
  42. package:add("deps", "mkl")
  43. end
  44. if package:config("jxl") then
  45. package:add("deps", "libjxl")
  46. end
  47. if package:config("ffmpeg") then
  48. package:add("deps", "ffmpeg")
  49. end
  50. if package:version():ge("19.24") and package:config("webp") then
  51. package:add("deps", "libwebp")
  52. end
  53. end)
  54. on_install(function (package)
  55. local configs = {
  56. "-DDLIB_IN_PROJECT_BUILD=OFF",
  57. "-DDLIB_ISO_CPP_ONLY=OFF",
  58. "-DDLIB_NO_GUI_SUPPORT=ON"
  59. }
  60. if package:is_plat("windows") then
  61. if package:is_debug() then
  62. table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''")
  63. end
  64. if package:config("shared") then
  65. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  66. io.replace("dlib/CMakeLists.txt", [[message(FATAL_ERROR "Building dlib as a standalone dll is not supported when using Visual Studio. You are highly encouraged to use static linking instead. See https://github.com/davisking/dlib/issues/1483 for a discussion.")]], "", {plain = true})
  67. end
  68. end
  69. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  70. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  71. table.insert(configs, "-DDLIB_PNG_SUPPORT=" .. (package:config("png") and "ON" or "OFF"))
  72. table.insert(configs, "-DDLIB_JPEG_SUPPORT=" .. (package:config("jpg") and "ON" or "OFF"))
  73. table.insert(configs, "-DDLIB_GIF_SUPPORT=" .. (package:config("jpg") and "ON" or "OFF"))
  74. table.insert(configs, "-DDLIB_LINK_WITH_SQLITE3=" .. (package:config("sqlite3") and "ON" or "OFF"))
  75. table.insert(configs, "-DDLIB_USE_BLAS=" .. (package:config("blas") and "ON" or "OFF"))
  76. table.insert(configs, "-DDLIB_USE_MKL_FFT=" .. (package:config("mkl") and "ON" or "OFF"))
  77. table.insert(configs, "-DDLIB_JXL_SUPPORT=" .. (package:config("jxl") and "ON" or "OFF"))
  78. table.insert(configs, "-DDLIB_USE_FFMPEG=" .. (package:config("ffmpeg") and "ON" or "OFF"))
  79. table.insert(configs, "-DDLIB_WEBP_SUPPORT=" .. (package:config("webp") and "ON" or "OFF"))
  80. local simd = package:config("simd")
  81. table.insert(configs, "-DUSE_NEON_INSTRUCTIONS=" .. ((simd == "neon") and "ON" or "OFF"))
  82. table.insert(configs, "-DUSE_SSE2_INSTRUCTIONS=" .. ((simd == "sse2") and "ON" or "OFF"))
  83. table.insert(configs, "-DUSE_SSE4_INSTRUCTIONS=" .. ((simd == "sse4") and "ON" or "OFF"))
  84. table.insert(configs, "-DUSE_AVX_INSTRUCTIONS=" .. ((simd == "avx") and "ON" or "OFF"))
  85. if simd == "sse4" then
  86. package:add("defines", "DLIB_HAVE_SSE2", "DLIB_HAVE_SSE3", "DLIB_HAVE_SSE41")
  87. end
  88. import("package.tools.cmake").install(package, configs)
  89. end)
  90. on_test(function (package)
  91. assert(package:has_cxxtypes("dlib::command_line_parser", {
  92. includes = "dlib/cmd_line_parser.h", configs = {languages = "c++14"}}))
  93. end)