xmake.lua 2.0 KB

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