xmake.lua 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. option("openmp", {default = false})
  2. option("regex", {default = false})
  3. option("rand", {default = false})
  4. add_rules("mode.debug", "mode.release")
  5. if has_config("openmp") then
  6. add_requires("openmp")
  7. add_packages("openmp")
  8. end
  9. if has_config("regex") then
  10. add_defines("USE_GKREGEX", {public = true})
  11. end
  12. if has_config("rand") then
  13. add_defines("USE_GKRAND")
  14. end
  15. includes("@builtin/check")
  16. configvar_check_cincludes("HAVE_EXECINFO_H", "execinfo.h")
  17. configvar_check_cfuncs("HAVE_GETLINE", "getline")
  18. target("gklib")
  19. set_kind("$(kind)")
  20. add_files("*.c")
  21. add_headerfiles("*.h")
  22. add_includedirs(".")
  23. add_vectorexts("all")
  24. if is_plat("windows") then
  25. add_files("win32/*.c")
  26. add_headerfiles("(win32/adapt.h)")
  27. add_defines("_CRT_SECURE_NO_DEPRECATE", "USE_GKREGEX", "__thread=__declspec(thread)", {public = true})
  28. if is_kind("shared") then
  29. add_rules("utils.symbols.export_all")
  30. end
  31. elseif is_plat("mingw") then
  32. add_defines("USE_GKREGEX")
  33. elseif is_plat("linux") then
  34. add_syslinks("m")
  35. add_defines("_FILE_OFFSET_BITS=64")
  36. elseif is_plat("bsd") then
  37. add_syslinks("m")
  38. end
  39. on_config(function (target)
  40. if not target:check_csnippets({test = "extern __thread int x;"}) then
  41. target:add("defines", "__thread")
  42. end
  43. end)