xmake.lua 2.5 KB

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