xmake.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. add_rules("mode.debug", "mode.release")
  2. add_requires("cjson")
  3. add_requires("fmt")
  4. target("sql-parser")
  5. add_rules("lex", "yacc")
  6. add_rules("c++")
  7. set_kind("binary")
  8. add_files("src/*.l", "src/*.y")
  9. add_packages("cjson")
  10. target_end()
  11. target("sql-checker")
  12. set_languages("c++20")
  13. set_kind("binary")
  14. add_files("src/*.cpp")
  15. add_includedirs("src")
  16. add_packages("fmt")
  17. target_end()
  18. --
  19. -- If you want to known more usage about xmake, please see https://xmake.io
  20. --
  21. -- ## FAQ
  22. --
  23. -- You can enter the project directory firstly before building project.
  24. --
  25. -- $ cd projectdir
  26. --
  27. -- 1. How to build project?
  28. --
  29. -- $ xmake
  30. --
  31. -- 2. How to configure project?
  32. --
  33. -- $ xmake f -p [macosx|linux|iphoneos ..] -a [x86_64|i386|arm64 ..] -m [debug|release]
  34. --
  35. -- 3. Where is the build output directory?
  36. --
  37. -- The default output directory is `./build` and you can configure the output directory.
  38. --
  39. -- $ xmake f -o outputdir
  40. -- $ xmake
  41. --
  42. -- 4. How to run and debug target after building project?
  43. --
  44. -- $ xmake run [targetname]
  45. -- $ xmake run -d [targetname]
  46. --
  47. -- 5. How to install target to the system directory or other output directory?
  48. --
  49. -- $ xmake install
  50. -- $ xmake install -o installdir
  51. --
  52. -- 6. Add some frequently-used compilation flags in xmake.lua
  53. --
  54. -- @code
  55. -- -- add debug and release modes
  56. -- add_rules("mode.debug", "mode.release")
  57. --
  58. -- -- add macro defination
  59. -- add_defines("NDEBUG", "_GNU_SOURCE=1")
  60. --
  61. -- -- set warning all as error
  62. -- set_warnings("all", "error")
  63. --
  64. -- -- set language: c99, c++11
  65. -- set_languages("c99", "c++11")
  66. --
  67. -- -- set optimization: none, faster, fastest, smallest
  68. -- set_optimize("fastest")
  69. --
  70. -- -- add include search directories
  71. -- add_includedirs("/usr/include", "/usr/local/include")
  72. --
  73. -- -- add link libraries and search directories
  74. -- add_links("tbox")
  75. -- add_linkdirs("/usr/local/lib", "/usr/lib")
  76. --
  77. -- -- add system link libraries
  78. -- add_syslinks("z", "pthread")
  79. --
  80. -- -- add compilation and link flags
  81. -- add_cxflags("-stdnolib", "-fno-strict-aliasing")
  82. -- add_ldflags("-L/usr/local/lib", "-lpthread", {force = true})
  83. --
  84. -- @endcode
  85. --