xmake.lua 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package("openxlsx")
  2. set_homepage("https://github.com/troldal/OpenXLSX")
  3. set_description("A C++ library for reading, writing, creating and modifying Microsoft Excel® (.xlsx) files.")
  4. set_license("BSD-3-Clause")
  5. set_urls("https://github.com/troldal/OpenXLSX.git")
  6. add_versions("2024.10.17", "d618e1de159cfb4fb3bf97934319fe8b7bed350e")
  7. add_configs("compact_mode", {description = "Build library in compact mode (slower, but uses less memory)", default = false, type = "boolean"})
  8. add_deps("cmake")
  9. add_includedirs("include", "include/OpenXLSX/headers")
  10. on_install(function (package)
  11. if package:is_plat("windows") and not package:config("shared") then
  12. package:add("defines", "OPENXLSX_STATIC_DEFINE")
  13. end
  14. if not package:config("lto") then
  15. io.replace("CMakeLists.txt", "set_property(TARGET OpenXLSX PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)", "", {plain = true})
  16. end
  17. if package:is_plat("mingw") then
  18. io.replace("OpenXLSX/sources/XLDocument.cpp", "# define stat _stat", "", {plain = true})
  19. end
  20. local configs = {
  21. "-DOPENXLSX_CREATE_DOCS=OFF",
  22. "-DOPENXLSX_BUILD_SAMPLES=OFF",
  23. "-DOPENXLSX_BUILD_TESTS=OFF",
  24. "-DOPENXLSX_BUILD_BENCHMARKS=OFF",
  25. }
  26. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  27. table.insert(configs, "-DOPENXLSX_LIBRARY_TYPE=" .. (package:config("shared") and "SHARED" or "STATIC"))
  28. table.insert(configs, "-DOPENXLSX_COMPACT_MODE=" .. (package:config("compact_mode") and "ON" or "OFF"))
  29. if package:is_plat("windows") then
  30. table.insert(configs, "-DCMAKE_COMPILE_PDB_OUTPUT_DIRECTORY=''")
  31. end
  32. import("package.tools.cmake").install(package, configs)
  33. os.vcp("OpenXLSX/external", package:installdir("include"))
  34. if package:is_plat("windows") and package:is_debug() then
  35. local dir = package:installdir(package:config("shared") and "bin" or "lib")
  36. os.trycp(path.join(package:buildir(), "**.pdb"), dir)
  37. end
  38. end)
  39. on_test(function (package)
  40. assert(package:check_cxxsnippets({test = [[
  41. void test() {
  42. OpenXLSX::XLDocument doc;
  43. doc.close();
  44. }
  45. ]]}, {configs = {languages = "c++17"}, includes = "OpenXLSX/OpenXLSX.hpp"}))
  46. end)