xmake.lua 1.9 KB

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