Updated everything to 5.4.0

This commit is contained in:
Walter Schell 2020-06-30 09:29:24 -04:00
parent 85f515a9f0
commit b524fe6513
6 changed files with 51 additions and 37 deletions

View File

@ -1,6 +1,8 @@
cmake_minimum_required(VERSION 3.1) cmake_minimum_required(VERSION 3.1)
project(lua LANGUAGES C VERSION 5.4.0) project(lua LANGUAGES C VERSION 5.4.0)
option(LUA_SUPPORT_DL "Support dynamic loading of compiled modules" OFF)
if(${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME}) if(${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME})
set(TOP_LEVEL TRUE) set(TOP_LEVEL TRUE)
else() else()

View File

@ -1,49 +1,53 @@
set(LUA_LIB_SRCS set(LUA_LIB_SRCS
${CMAKE_CURRENT_SOURCE_DIR}/src/lapi.c "src/lapi.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/lcode.c "src/lcode.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/lctype.c "src/lctype.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/ldebug.c "src/ldebug.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/ldo.c "src/ldo.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/ldump.c "src/ldump.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/lfunc.c "src/lfunc.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/lgc.c "src/lgc.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/llex.c "src/llex.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/lmem.c "src/lmem.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/lobject.c "src/lobject.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/lopcodes.c "src/lopcodes.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/lparser.c "src/lparser.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/lstate.c "src/lstate.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/lstring.c "src/lstring.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/ltable.c "src/ltable.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/ltm.c "src/ltm.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/lundump.c "src/lundump.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/lvm.c "src/lvm.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/lzio.c "src/lzio.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/lauxlib.c "src/lauxlib.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/lbaselib.c "src/lbaselib.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/lcorolib.c "src/lcorolib.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/ldblib.c "src/ldblib.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/liolib.c "src/liolib.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/lmathlib.c "src/lmathlib.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/loadlib.c "src/loadlib.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/loslib.c "src/loslib.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/lstrlib.c "src/lstrlib.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/ltablib.c "src/ltablib.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/lutf8lib.c "src/lutf8lib.c"
${CMAKE_CURRENT_SOURCE_DIR}/src/linit.c "src/linit.c"
) )
set(LUA_LIB_INCLUDE ${CMAKE_CURRENT_SOURCE_DIR}/src)
#TODO: Redo this with find_package #TODO: Redo this with find_package
find_library(LIBM m) find_library(LIBM m)
if(NOT LIBM) if(NOT LIBM)
message(FATAL_ERROR "libm not found and requred by lua") message(FATAL_ERROR "libm not found and requred by lua")
endif() endif()
add_library(lua_static STATIC ${LUA_LIB_SRCS}) add_library(lua_static STATIC ${LUA_LIB_SRCS})
set_target_properties(lua_static PROPERTIES OUTPUT_NAME "lua")
target_link_libraries(lua_static INTERFACE ${LIBM}) target_link_libraries(lua_static INTERFACE ${LIBM})
target_include_directories(lua_static PUBLIC ${LUA_LIB_INCLUDE}) target_include_directories(lua_static PUBLIC "include")
set(LUA_DEFINITIONS) set(LUA_DEFINITIONS)
if(NOT EMSCRIPTEN) if(UNIX)
list(APPEND LUA_DEFINITIONS LUA_USE_POSIX) list(APPEND LUA_DEFINITIONS LUA_USE_POSIX)
if(LUA_SUPPORT_DL)
target_compile_definitions(lua_static PRIVATE "LUA_USE_DLOPEN")
target_link_libraries(lua_static INTERFACE dl)
endif()
endif() endif()
target_compile_definitions(lua_static target_compile_definitions(lua_static
PUBLIC ${LUA_DEFINITIONS} PUBLIC ${LUA_DEFINITIONS}
@ -53,14 +57,22 @@ target_compile_options(lua_static
) )
if(LUA_BUILD_BINARY) if(LUA_BUILD_BINARY)
add_executable(lua ${CMAKE_CURRENT_SOURCE_DIR}/src/lua.c) include(CheckIncludeFile)
CHECK_INCLUDE_FILE("readline/readline.h" HAVE_READLINE_READLINE_H)
add_executable(lua "src/lua.c")
target_link_libraries(lua PUBLIC lua_static) target_link_libraries(lua PUBLIC lua_static)
set_target_properties(lua PROPERTIES set_target_properties(lua PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}
) )
if (HAVE_READLINE_READLINE_H)
target_compile_definitions(lua PUBLIC "LUA_USE_READLINE")
target_link_libraries(lua PUBLIC readline)
endif()
endif() endif()
if(LUA_BUILD_COMPILER) if(LUA_BUILD_COMPILER)
add_executable(luac ${CMAKE_CURRENT_SOURCE_DIR}/src/luac.c) add_executable(luac "src/luac.c")
target_link_libraries(luac PUBLIC lua_static) target_link_libraries(luac PUBLIC lua_static)
set_target_properties(luac PROPERTIES set_target_properties(luac PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}