summaryrefslogtreecommitdiff
path: root/source/luametatex/cmake/lua.cmake
blob: a31f1c8b03587c75ffa5597a0b92447b48bfab44 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
set(lua_sources

    source/luacore/lua54/src/lapi.c
    source/luacore/lua54/src/lauxlib.c
    source/luacore/lua54/src/lbaselib.c
    source/luacore/lua54/src/lcode.c
    source/luacore/lua54/src/lcorolib.c
    source/luacore/lua54/src/lctype.c
    source/luacore/lua54/src/ldblib.c
    source/luacore/lua54/src/ldebug.c
    source/luacore/lua54/src/ldo.c
    source/luacore/lua54/src/ldump.c
    source/luacore/lua54/src/lfunc.c
    source/luacore/lua54/src/lgc.c
    source/luacore/lua54/src/linit.c
    source/luacore/lua54/src/liolib.c
    source/luacore/lua54/src/llex.c
    source/luacore/lua54/src/lmathlib.c
    source/luacore/lua54/src/lmem.c
    source/luacore/lua54/src/loadlib.c
    source/luacore/lua54/src/lobject.c
    source/luacore/lua54/src/lopcodes.c
    source/luacore/lua54/src/loslib.c
    source/luacore/lua54/src/lparser.c
    source/luacore/lua54/src/lstate.c
    source/luacore/lua54/src/lstring.c
    source/luacore/lua54/src/lstrlib.c
    source/luacore/lua54/src/ltable.c
    source/luacore/lua54/src/ltablib.c
    source/luacore/lua54/src/ltm.c
    source/luacore/lua54/src/lua.c
    source/luacore/lua54/src/lundump.c
    source/luacore/lua54/src/lutf8lib.c
    source/luacore/lua54/src/lvm.c
    source/luacore/lua54/src/lzio.c

    source/luacore/luapeg/lptree.c
    source/luacore/luapeg/lpvm.c
    source/luacore/luapeg/lpprint.c
    source/luacore/luapeg/lpcap.c
    source/luacore/luapeg/lpcode.c

)

add_library(lua STATIC ${lua_sources})

set_property(TARGET lua PROPERTY C_STANDARD 99)

target_include_directories(lua PRIVATE
    source/luacore/lua54/src
    source/luacore/luapeg
)

# luajit: 8000, lua 5.3: 1000000 or 15000

target_compile_definitions(lua PUBLIC
    # This one should also be set in the lua namespace!
  # LUAI_HASHLIMIT=6 # obsolete
  # LUAI_MAXSHORTLEN=48
    LUAI_MAXCSTACK=6000
    LUA_UCID
  # LUA_USE_JUMPTABLE=0
    LPEG_DEBUG
  # LUA_NOCVTS2N
  # LUA_NOBUILTIN # disable likely usage
  # LUAI_ASSERT
  # LUA_STRFTIMEOPTIONS="aAbBcCdDeFgGhHIjmMnprRStTuUVwWxXyYzZ%" 
  # MINSTRTABSIZE=65536
)

if (UNIX)
    target_compile_definitions(lua PUBLIC
        LUA_USE_POSIX
        LUA_USE_DLOPEN
    )
endif (UNIX)

if (NOT MSVC)
    target_compile_options(lua PRIVATE
        -Wno-cast-align
        -Wno-cast-qual
    )
endif (NOT MSVC)

# if (CMAKE_HOST_APPLE)
#     target_compile_definitions(lua PUBLIC
#         TARGET_OS_IOS=0
#         TARGET_OS_WATCH=0
#         TARGET_OS_TV=0
#     )
# endif (CMAKE_HOST_APPLE)

# this seems to be ok for mingw default
#
# todo: what is the right way to increase the stack (mingw)

# target_compile_options(lua PRIVATE -DLUAI_MAXCSTACK=65536 -Wl,--stack,16777216)