lua.cmake /size: 2890 b    last modification: 2025-02-21 11:03
1set(lua_sources
2
3    source/luacore/lua55/src/lapi.c
4    source/luacore/lua55/src/lauxlib.c
5    source/luacore/lua55/src/lbaselib.c
6    source/luacore/lua55/src/lcode.c
7    source/luacore/lua55/src/lcorolib.c
8    source/luacore/lua55/src/lctype.c
9    source/luacore/lua55/src/ldblib.c
10    source/luacore/lua55/src/ldebug.c
11    source/luacore/lua55/src/ldo.c
12    source/luacore/lua55/src/ldump.c
13    source/luacore/lua55/src/lfunc.c
14    source/luacore/lua55/src/lgc.c
15    source/luacore/lua55/src/linit.c
16    source/luacore/lua55/src/liolib.c
17    source/luacore/lua55/src/llex.c
18    source/luacore/lua55/src/lmathlib.c
19    source/luacore/lua55/src/lmem.c
20    source/luacore/lua55/src/loadlib.c
21    source/luacore/lua55/src/lobject.c
22    source/luacore/lua55/src/lopcodes.c
23    source/luacore/lua55/src/loslib.c
24    source/luacore/lua55/src/lparser.c
25    source/luacore/lua55/src/lstate.c
26    source/luacore/lua55/src/lstring.c
27    source/luacore/lua55/src/lstrlib.c
28    source/luacore/lua55/src/ltable.c
29    source/luacore/lua55/src/ltablib.c
30    source/luacore/lua55/src/ltm.c
31    source/luacore/lua55/src/lua.c
32    source/luacore/lua55/src/lundump.c
33    source/luacore/lua55/src/lutf8lib.c
34    source/luacore/lua55/src/lvm.c
35    source/luacore/lua55/src/lzio.c
36
37    source/luacore/luapeg/lptree.c
38    source/luacore/luapeg/lpvm.c
39    source/luacore/luapeg/lpprint.c
40    source/luacore/luapeg/lpcap.c
41    source/luacore/luapeg/lpcset.c
42    source/luacore/luapeg/lpcode.c
43
44)
45
46add_library(lua STATIC ${lua_sources})
47
48set_property(TARGET lua PROPERTY C_STANDARD 99)
49
50target_include_directories(lua PRIVATE
51    source/luacore/lua55/src
52    source/luacore/luapeg
53)
54
55# luajit: 8000, lua 5.3: 1000000 or 15000
56
57target_compile_definitions(lua PUBLIC
58    # This one should also be set in the lua namespace!
59  # LUAI_HASHLIMIT=6 # obsolete
60  # LUAI_MAXSHORTLEN=48
61    LUAI_MAXCSTACK=6000
62    LUA_UCID # permits utf8
63  # LUA_USE_JUMPTABLE=0
64    LPEG_DEBUG
65  # LUA_NOCVTS2N
66    LUA_NOBUILTIN # disable likely usage
67  # LUAI_ASSERT
68  # LUA_STRFTIMEOPTIONS="aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%"
69  # MINSTRTABSIZE=65536
70    NDEBUG=0
71)
72
73if (UNIX)
74    target_compile_definitions(lua PUBLIC
75        LUA_USE_POSIX
76        LUA_USE_DLOPEN
77    )
78endif (UNIX)
79
80if (NOT MSVC)
81    target_compile_options(lua PRIVATE
82        -Wno-cast-align
83        -Wno-cast-qual
84    )
85endif (NOT MSVC)
86
87# if (CMAKE_HOST_APPLE)
88#     target_compile_definitions(lua PUBLIC
89#         TARGET_OS_IOS=0
90#         TARGET_OS_WATCH=0
91#         TARGET_OS_TV=0
92#     )
93# endif (CMAKE_HOST_APPLE)
94
95# this seems to be ok for mingw default
96#
97# todo: what is the right way to increase the stack (mingw)
98
99# target_compile_options(lua PRIVATE -DLUAI_MAXCSTACK=65536 -Wl,--stack,16777216)
100
101# When one want to use shared libraries:
102
103if (DEFINED LMT_PERMIT_LUA_LIBRARIES)
104    set_property(TARGET lua PROPERTY POSITION_INDEPENDENT_CODE ON)
105endif () 
106