xmake.lua 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. package("raw_pdb")
  2. set_homepage("https://github.com/MolecularMatters/raw_pdb")
  3. set_description("A C++11 library for reading Microsoft Program DataBase PDB files")
  4. set_license("BSD-2-Clause")
  5. add_urls("https://github.com/MolecularMatters/raw_pdb.git")
  6. add_versions("2024.08.27", "3d6ca630f7527716fd3345cbfc5e043c67bfd2a1")
  7. add_versions("2022.10.17", "e6f9d2104025ad152d68517b3f4c31cc7c2334a4")
  8. add_deps("cmake")
  9. on_install("!macosx and !iphoneos", function (package)
  10. local configs = {"-DRAWPDB_BUILD_EXAMPLES=OFF"}
  11. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  12. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  13. if package:is_plat("windows") and package:config("shared") then
  14. table.insert(configs, "-DCMAKE_WINDOWS_EXPORT_ALL_SYMBOLS=ON")
  15. end
  16. if package:gitref() or package:version():ge("2024.08.27") then
  17. io.replace("src/CMakeLists.txt", "if (UNIX)", "if(1)", {plain = true})
  18. import("package.tools.cmake").install(package, configs)
  19. if is_host("windows") then
  20. os.trycp("raw_pdb.natvis", package:installdir("include/natvis"))
  21. end
  22. else
  23. io.replace("src/CMakeLists.txt", "add_subdirectory(Examples)", "", {plain = true})
  24. import("package.tools.cmake").build(package, configs)
  25. os.cp("src/*.h", package:installdir("include"))
  26. os.cp("src/Foundation/*.h", package:installdir("include/Foundation"))
  27. os.trycp("**.a", package:installdir("lib"))
  28. os.trycp("**.so", package:installdir("lib"))
  29. os.trycp("**.dylib", package:installdir("lib"))
  30. os.trycp("**.dll", package:installdir("bin"))
  31. os.trycp("**.lib", package:installdir("lib"))
  32. if package:config("shared") then
  33. os.trycp("**.pdb", package:installdir("bin"))
  34. else
  35. os.trycp("**.pdb", package:installdir("lib"))
  36. end
  37. end
  38. end)
  39. on_test(function (package)
  40. if package:gitref() or package:version():ge("2024.08.27") then
  41. assert(package:has_cxxfuncs("PDB::ValidateFile(0, 0)", {includes = {"cstddef", "raw_pdb/PDB.h"}}))
  42. else
  43. assert(package:has_cxxfuncs("PDB::ValidateFile(0)", {includes = "PDB.h"}))
  44. end
  45. end)