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