2020-06-30 12:52:34 +00:00
|
|
|
set(LUA_LIB_SRCS
|
2020-06-30 13:29:24 +00:00
|
|
|
"src/lapi.c"
|
|
|
|
"src/lcode.c"
|
|
|
|
"src/lctype.c"
|
|
|
|
"src/ldebug.c"
|
|
|
|
"src/ldo.c"
|
|
|
|
"src/ldump.c"
|
|
|
|
"src/lfunc.c"
|
|
|
|
"src/lgc.c"
|
|
|
|
"src/llex.c"
|
|
|
|
"src/lmem.c"
|
|
|
|
"src/lobject.c"
|
|
|
|
"src/lopcodes.c"
|
|
|
|
"src/lparser.c"
|
|
|
|
"src/lstate.c"
|
|
|
|
"src/lstring.c"
|
|
|
|
"src/ltable.c"
|
|
|
|
"src/ltm.c"
|
|
|
|
"src/lundump.c"
|
|
|
|
"src/lvm.c"
|
|
|
|
"src/lzio.c"
|
|
|
|
"src/lauxlib.c"
|
|
|
|
"src/lbaselib.c"
|
|
|
|
"src/lcorolib.c"
|
|
|
|
"src/ldblib.c"
|
|
|
|
"src/liolib.c"
|
|
|
|
"src/lmathlib.c"
|
|
|
|
"src/loadlib.c"
|
|
|
|
"src/loslib.c"
|
|
|
|
"src/lstrlib.c"
|
|
|
|
"src/ltablib.c"
|
|
|
|
"src/lutf8lib.c"
|
|
|
|
"src/linit.c"
|
2020-06-30 12:52:34 +00:00
|
|
|
)
|
2021-01-12 01:13:09 +00:00
|
|
|
|
2021-04-25 18:39:29 +00:00
|
|
|
if(LUA_BUILD_AS_CXX)
|
2021-04-26 15:37:51 +00:00
|
|
|
set_source_files_properties(${LUA_LIB_SRCS} "src/lua.c" "src/luac.c" PROPERTIES LANGUAGE CXX )
|
2021-04-25 18:39:29 +00:00
|
|
|
endif()
|
|
|
|
|
2020-06-30 12:52:34 +00:00
|
|
|
add_library(lua_static STATIC ${LUA_LIB_SRCS})
|
2020-06-30 13:29:24 +00:00
|
|
|
set_target_properties(lua_static PROPERTIES OUTPUT_NAME "lua")
|
|
|
|
target_include_directories(lua_static PUBLIC "include")
|
|
|
|
if(UNIX)
|
2021-01-12 14:06:42 +00:00
|
|
|
set(LUA_DEFINITIONS)
|
2021-01-12 01:13:09 +00:00
|
|
|
|
2021-01-16 14:53:29 +00:00
|
|
|
if(NOT EMSCRIPTEN)
|
|
|
|
find_library(LIBM m)
|
|
|
|
#TODO: Redo this with find_package
|
|
|
|
if(NOT LIBM)
|
2021-03-10 20:46:07 +00:00
|
|
|
message(FATAL_ERROR "libm not found and is required by lua")
|
2021-01-16 14:53:29 +00:00
|
|
|
endif()
|
|
|
|
target_link_libraries(lua_static INTERFACE ${LIBM})
|
2021-01-12 01:13:09 +00:00
|
|
|
|
2021-01-16 14:53:29 +00:00
|
|
|
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()
|
2020-06-30 13:29:24 +00:00
|
|
|
endif()
|
2021-01-16 14:53:29 +00:00
|
|
|
|
2021-01-12 14:06:42 +00:00
|
|
|
target_compile_definitions(lua_static
|
|
|
|
PUBLIC ${LUA_DEFINITIONS}
|
|
|
|
)
|
|
|
|
target_compile_options(lua_static
|
|
|
|
PRIVATE "-Wall" "-Wextra"
|
|
|
|
)
|
2020-06-30 12:52:34 +00:00
|
|
|
endif()
|
|
|
|
|
|
|
|
if(LUA_BUILD_BINARY)
|
2020-06-30 13:29:24 +00:00
|
|
|
include(CheckIncludeFile)
|
|
|
|
CHECK_INCLUDE_FILE("readline/readline.h" HAVE_READLINE_READLINE_H)
|
|
|
|
|
|
|
|
|
|
|
|
add_executable(lua "src/lua.c")
|
2020-06-30 12:52:34 +00:00
|
|
|
target_link_libraries(lua PUBLIC lua_static)
|
|
|
|
set_target_properties(lua PROPERTIES
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}
|
|
|
|
)
|
2020-06-30 13:29:24 +00:00
|
|
|
if (HAVE_READLINE_READLINE_H)
|
|
|
|
target_compile_definitions(lua PUBLIC "LUA_USE_READLINE")
|
|
|
|
target_link_libraries(lua PUBLIC readline)
|
|
|
|
endif()
|
2020-06-30 12:52:34 +00:00
|
|
|
endif()
|
|
|
|
if(LUA_BUILD_COMPILER)
|
2020-06-30 13:29:24 +00:00
|
|
|
add_executable(luac "src/luac.c")
|
2020-06-30 12:52:34 +00:00
|
|
|
target_link_libraries(luac PUBLIC lua_static)
|
|
|
|
set_target_properties(luac PROPERTIES
|
|
|
|
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}
|
|
|
|
)
|
|
|
|
endif()
|