Skip to content

Commit

Permalink
Re-apply 5f54aca
Browse files Browse the repository at this point in the history
  • Loading branch information
tigerw committed Apr 11, 2021
1 parent 9972ba6 commit 935fe91
Show file tree
Hide file tree
Showing 34 changed files with 74 additions and 75 deletions.
143 changes: 74 additions & 69 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,70 +1,9 @@
cmake_minimum_required (VERSION 3.13)
project (lua)

set(LIBSOURCES
src/lapi.c
src/lauxlib.c
src/lbaselib.c
src/lcode.c
src/ldblib.c
src/ldebug.c
src/ldo.c
src/ldump.c
src/lfunc.c
src/lgc.c
src/linit.c
src/liolib.c
src/llex.c
src/lmathlib.c
src/lmem.c
src/loadlib.c
src/lobject.c
src/lopcodes.c
src/loslib.c
src/lparser.c
src/lstate.c
src/lstring.c
src/lstrlib.c
src/ltable.c
src/ltablib.c
src/ltm.c
src/lundump.c
src/lvm.c
src/lzio.c
src/print.c
)

set(LIBHEADERS
src/lapi.h
src/lauxlib.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/lua.h
src/luaconf.h
src/lualib.h
src/lundump.h
src/lvm.h
src/lzio.h
)



# Lua needs to be linked dynamically on Windows and statically on *nix, so that LuaRocks work:
if (WIN32)
add_library(lualib SHARED ${LIBSOURCES} ${LIBHEADERS})
add_library(lualib SHARED)

target_compile_definitions(lualib PUBLIC LUA_BUILD_AS_DLL)

Expand All @@ -88,6 +27,7 @@ if (WIN32)
RUNTIME_OUTPUT_DIRECTORY_DEBUGPROFILE ${CMAKE_BINARY_DIR}/Server
RUNTIME_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_BINARY_DIR}/Server
)

set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/Server)

if (MSVC)
Expand All @@ -104,13 +44,76 @@ if (WIN32)
# 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 ${LIBSOURCES} ${LIBHEADERS})
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

# Tell the compiler to use C++ when compiling the library,
# so that Lua uses C++ exceptions instead of setjmp / longjmp (GH #3678):
SET_SOURCE_FILES_PROPERTIES(${SOURCE} PROPERTIES LANGUAGE CXX)
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)
Expand All @@ -121,13 +124,14 @@ 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.c)
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
Expand All @@ -146,6 +150,7 @@ if (NOT(CMAKE_CROSSCOMPILING))
RUNTIME_OUTPUT_DIRECTORY_DEBUGPROFILE ${CMAKE_BINARY_DIR}/Server
RUNTIME_OUTPUT_DIRECTORY_RELEASEPROFILE ${CMAKE_BINARY_DIR}/Server
)

if (MSVC)
set_target_properties(
lua
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 0 additions & 6 deletions src/lua.hpp

This file was deleted.

File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 935fe91

Please sign in to comment.