xmake.lua 1.5 KB

12345678910111213141516171819202122232425262728293031323334
  1. package("libpeconv")
  2. set_homepage("https://hasherezade.github.io/libpeconv")
  3. set_description("A library to load, manipulate, dump PE files. See also: https://github.com/hasherezade/libpeconv_tpl")
  4. add_urls("https://github.com/hasherezade/libpeconv.git")
  5. add_versions("2023.05.31", "709a9b40fa6420c6cd7aa1145b0ff1a154858358")
  6. add_deps("cmake")
  7. if is_plat("windows", "mingw") then
  8. add_syslinks("kernel32", "ntdll")
  9. end
  10. on_install("windows", "mingw", function (package)
  11. local configs = {"-DPECONV_BUILD_TESTING=OFF"}
  12. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  13. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  14. io.replace("libpeconv/CMakeLists.txt", "/MT", "", {plain = true})
  15. io.replace("CMakeLists.txt", "add_subdirectory ( run_pe )", "", {plain = true})
  16. io.replace("CMakeLists.txt", "add_dependencies ( run_pe libpeconv )", "", {plain = true})
  17. import("package.tools.cmake").install(package, configs)
  18. end)
  19. on_test(function (package)
  20. assert(package:check_cxxsnippets({test = [[
  21. void test() {
  22. size_t size = 0;
  23. BYTE* my_pe = peconv::load_pe_executable(NULL, size);
  24. if (my_pe) {
  25. peconv::set_main_module_in_peb((HMODULE)my_pe);
  26. }
  27. }
  28. ]]}, {includes = {"peconv.h"}}))
  29. end)