xmake.lua 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. option("enable_bindings_cxx", {default = true, showmenu = true, description = "Enable C++ bindings"})
  2. option("enable_tools", {default = true, showmenu = true, description = "Enable tools"})
  3. target("gpiod")
  4. set_kind("$(kind)")
  5. set_languages("cxx11")
  6. add_headerfiles("include/(gpiod.h)")
  7. add_headerfiles("lib/uapi/*.h")
  8. add_files("lib/*.c")
  9. add_includedirs("include", {public = true})
  10. before_build(function (target)
  11. local configure = io.readfile("configure.ac")
  12. local version = configure:match("AC_INIT%(%[libgpiod%], %[?([0-9%.]+)%]?%)")
  13. target:add("defines", "GPIOD_VERSION_STR=\"" .. version .. "\"")
  14. end)
  15. if has_config("enable_bindings_cxx") then
  16. target("gpiodcxx")
  17. set_kind("$(kind)")
  18. set_languages("cxx17")
  19. add_headerfiles("include/(gpiod.h)")
  20. add_headerfiles("lib/uapi/*.h")
  21. add_files("lib/*.c")
  22. add_includedirs("include")
  23. add_headerfiles("bindings/cxx/(gpiod.hpp)")
  24. add_headerfiles("bindings/cxx/(gpiodcxx/**.hpp)")
  25. add_files("bindings/cxx/*.cpp")
  26. add_includedirs("bindings/cxx", {public = true})
  27. before_build(function (target)
  28. local configure = io.readfile("configure.ac")
  29. local version = configure:match("AC_INIT%(%[libgpiod%], %[?([0-9%.]+)%]?%)")
  30. target:add("defines", "GPIOD_VERSION_STR=\"" .. version .. "\"")
  31. end)
  32. end
  33. if has_config("enable_tools") then
  34. for _, tool_file in ipairs(os.files("tools/*.c")) do
  35. local name = path.basename(tool_file)
  36. if name ~= "tools-common" then
  37. target(name)
  38. set_kind("binary")
  39. set_languages("cxx11")
  40. add_files("tools/" .. name .. ".c")
  41. add_headerfiles("tools/tools-common.h")
  42. add_files("tools/tools-common.c")
  43. add_defines("program_invocation_short_name=\"" .. name .. "\"")
  44. add_defines("program_invocation_name=\"" .. name .. "\"")
  45. add_deps("gpiod")
  46. end
  47. end
  48. end