xmake.lua 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. package("easy_profiler")
  2. set_homepage("https://github.com/yse/easy_profiler")
  3. set_description("Lightweight profiler library for c++")
  4. set_license("MIT")
  5. add_urls("https://github.com/yse/easy_profiler/archive/refs/tags/$(version).tar.gz",
  6. "https://github.com/yse/easy_profiler.git")
  7. add_versions("v2.1.0", "fabf95d59ede9da4873aebd52ef8a762fa8578dcdbcc6d7cdd811b5a7c3367ad")
  8. if is_plat("linux", "bsd") then
  9. add_syslinks("pthread")
  10. elseif is_plat("windows", "mingw") then
  11. add_syslinks("ws2_32", "psapi")
  12. end
  13. add_deps("cmake")
  14. on_load(function (package)
  15. if not package:config("shared") then
  16. package:add("defines", "EASY_PROFILER_STATIC=1")
  17. end
  18. end)
  19. on_install("!bsd and !wasm", function (package)
  20. io.replace("easy_profiler_core/CMakeLists.txt", "/WX", "", {plain = true})
  21. io.replace("easy_profiler_core/CMakeLists.txt", "include(InstallRequiredSystemLibraries)", "", {plain = true})
  22. local configs = {
  23. "-DCMAKE_POLICY_DEFAULT_CMP0057=NEW",
  24. "-DEASY_PROFILER_NO_GUI=ON",
  25. }
  26. table.insert(configs, "-DCMAKE_BUILD_TYPE=" .. (package:is_debug() and "Debug" or "Release"))
  27. table.insert(configs, "-DBUILD_SHARED_LIBS=" .. (package:config("shared") and "ON" or "OFF"))
  28. import("package.tools.cmake").install(package, configs)
  29. end)
  30. on_test(function (package)
  31. assert(package:check_cxxsnippets({test = [[
  32. void test() {
  33. EASY_FUNCTION();
  34. }
  35. ]]}, {configs = {languages = "c++17"}, includes = {"easy/profiler.h"}}))
  36. end)