xmake.lua 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. package("tesseract")
  2. set_homepage("https://tesseract-ocr.github.io/")
  3. set_description("Tesseract Open Source OCR Engine")
  4. set_license("Apache-2.0")
  5. add_urls("https://github.com/tesseract-ocr/tesseract/archive/$(version).tar.gz",
  6. "https://github.com/tesseract-ocr/tesseract.git")
  7. add_versions("4.1.1", "2a66ff0d8595bff8f04032165e6c936389b1e5727c3ce5a27b3e059d218db1cb")
  8. add_versions("4.1.3", "83dc56b544be938983f528c777e4e1d906205b0f6dc0110afc223f2cc1cec6d3")
  9. add_versions("5.0.1", "b5b0e561650ed67feb1e9de38d4746121d302ae4c876c95b99b8b6f9f89d5c58")
  10. add_versions("5.2.0", "eba4deb2f92a3f89a6623812074af8c53b772079525b3c263aa70bbf7b748b3c")
  11. add_configs("training", {description = "Build training tools.", default = false, type = "boolean"})
  12. add_configs("libarchive", {description = "Enable build with libarchive.", default = false, type = "boolean"})
  13. add_configs("libcurl", {description = "Enable build with libcurl.", default = false, type = "boolean"})
  14. add_configs("opencl", {description = "Enable experimental OpenCL support.", default = false, type = "boolean"})
  15. add_deps("cmake")
  16. add_deps("leptonica")
  17. on_load("windows", "macosx", "linux", function (package)
  18. if package:config("training") then
  19. package:add("deps", "icu4c")
  20. end
  21. if package:config("libarchive") then
  22. package:add("deps", "libarchive")
  23. end
  24. if package:config("libcurl") then
  25. package:add("deps", "libcurl")
  26. end
  27. if package:config("opencl") then
  28. package:add("deps", "opencl")
  29. end
  30. if package:config("shared") then
  31. package:add("defines", "TESS_IMPORTS")
  32. end
  33. end)
  34. on_install("windows|x86", "windows|x64", "macosx", "linux", function (package)
  35. io.replace("CMakeLists.txt", "find_package(PkgConfig)", "", {plain = true})
  36. io.replace("src/training/CMakeLists.txt", "find_package(PkgConfig)", "", {plain = true})
  37. local configs = {"-DSW_BUILD=OFF", "-DBUILD_TESTS=OFF", "-DUSE_SYSTEM_ICU=ON"}
  38. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:debug() and "Debug" or "Release"))
  39. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  40. if package:is_plat("windows") then
  41. table.insert(configs, "-DWIN32_MT_BUILD=" .. (package:config("vs_runtime"):startswith("MT") and "ON" or "OFF"))
  42. end
  43. table.insert(configs, "-DBUILD_TRAINING_TOOLS=" .. (package:config("training") and "ON" or "OFF"))
  44. table.insert(configs, "-DDISABLE_ARCHIVE=" .. (package:config("libarchive") and "OFF" or "ON"))
  45. table.insert(configs, "-DDISABLE_CURL=" .. (package:config("libcurl") and "OFF" or "ON"))
  46. table.insert(configs, "-DENABLE_OPENCL=" .. (package:config("opencl") and "ON" or "OFF"))
  47. import("package.tools.cmake").install(package, configs)
  48. package:addenv("PATH", "bin")
  49. end)
  50. on_test(function (package)
  51. os.vrun("tesseract --version")
  52. assert(package:has_cxxtypes("tesseract::TessBaseAPI", {configs = {languages = "c++11"}, includes = "tesseract/baseapi.h"}))
  53. end)