xmake.lua 2.3 KB

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