-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
153 lines (134 loc) · 4.84 KB
/
CMakeLists.txt
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
cmake_minimum_required (VERSION 3.13)
project (lua)
# Lua needs to be linked dynamically on Windows and statically on *nix, so that LuaRocks work:
if (WIN32)
add_library(lualib SHARED)
target_compile_definitions(lualib PUBLIC LUA_BUILD_AS_DLL)
set(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Server)
# Output the DLL into the Server subfolder, so that Cuberite can find it:
SET_TARGET_PROPERTIES(lualib PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Server
ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/Server
ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/Server
ARCHIVE_OUTPUT_DIRECTORY_DEBUGPROFILE ${CMAKE_BINARY_DIR}/Server
ARCHIVE_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_BINARY_DIR}/Server
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Server
LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/Server
LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/Server
LIBRARY_OUTPUT_DIRECTORY_DEBUGPROFILE ${CMAKE_BINARY_DIR}/Server
LIBRARY_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_BINARY_DIR}/Server
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Server
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/Server
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/Server
RUNTIME_OUTPUT_DIRECTORY_DEBUGPROFILE ${CMAKE_BINARY_DIR}/Server
RUNTIME_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_BINARY_DIR}/Server
)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Server)
set_target_properties(lualib PROPERTIES OUTPUT_NAME "lua51" PREFIX "")
# NOTE: The DLL for each configuration is stored at the same place, thus overwriting each other.
# This is known, however such behavior is needed for LuaRocks - they always load "lua5.1.dll" or "lua51.dll"
# We make it work by compiling to "lua51.dll" and providing a proxy-DLL "lua5.1.dll"
# See http://lua-users.org/wiki/LuaProxyDllFour for details
else()
add_library(lualib STATIC)
endif()
# All .c files were renamed to .cpp so the compiler uses C++ when compiling the library,
# so that Lua uses C++ exceptions instead of setjmp / longjmp (GH #3678). Don't use set_source_files_properties
# with LANGUAGE option because clang emits a deprecation warning.
target_sources(
lualib PRIVATE
src/lapi.cpp
src/lauxlib.cpp
src/lbaselib.cpp
src/lcode.cpp
src/ldblib.cpp
src/ldebug.cpp
src/ldo.cpp
src/ldump.cpp
src/lfunc.cpp
src/lgc.cpp
src/linit.cpp
src/liolib.cpp
src/llex.cpp
src/lmathlib.cpp
src/lmem.cpp
src/loadlib.cpp
src/lobject.cpp
src/lopcodes.cpp
src/loslib.cpp
src/lparser.cpp
src/lstate.cpp
src/lstring.cpp
src/lstrlib.cpp
src/ltable.cpp
src/ltablib.cpp
src/ltm.cpp
src/lundump.cpp
src/lvm.cpp
src/lzio.cpp
src/print.cpp
src/lapi.h
src/lcode.h
src/ldebug.h
src/ldo.h
src/lfunc.h
src/lgc.h
src/llex.h
src/llimits.h
src/lmem.h
src/lobject.h
src/lopcodes.h
src/lparser.h
src/lstate.h
src/lstring.h
src/ltable.h
src/ltm.h
src/luaconf.h
src/lundump.h
src/lvm.h
src/lzio.h
)
target_sources(
lualib PUBLIC
src/lauxlib.h
src/lua.h
src/lualib.h
)
# Tell Lua what dynamic loader to use (for LuaRocks):
if (UNIX)
add_definitions(-DLUA_USE_DLOPEN)
target_link_libraries(lualib m ${CMAKE_DL_LIBS})
endif()
# Let Lua use additional checks on its C API. This is only compiled into Debug builds:
target_compile_definitions(lualib PRIVATE LUA_USE_APICHECK)
# Lua files themselves don't need this include, but Cuberite does, so INTERFACE:
target_include_directories(lualib INTERFACE "${CMAKE_CURRENT_LIST_DIR}/src")
# If not crosscompiling, build a local Lua:
if (NOT CMAKE_CROSSCOMPILING)
add_executable(lua src/lua.cpp)
target_link_libraries(lua lualib)
# Output the EXE into the Server subfolder, so that it can find lua51.dll:
SET_TARGET_PROPERTIES(lua PROPERTIES
ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Server
ARCHIVE_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/Server
ARCHIVE_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/Server
ARCHIVE_OUTPUT_DIRECTORY_DEBUGPROFILE ${CMAKE_BINARY_DIR}/Server
ARCHIVE_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_BINARY_DIR}/Server
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Server
LIBRARY_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/Server
LIBRARY_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/Server
LIBRARY_OUTPUT_DIRECTORY_DEBUGPROFILE ${CMAKE_BINARY_DIR}/Server
LIBRARY_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_BINARY_DIR}/Server
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/Server
RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/Server
RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/Server
RUNTIME_OUTPUT_DIRECTORY_DEBUGPROFILE ${CMAKE_BINARY_DIR}/Server
RUNTIME_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_BINARY_DIR}/Server
)
if (MSVC)
set_target_properties(
lua
PROPERTIES FOLDER Support
)
endif()
endif()