Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[lua] Fix library type and usage #24436

Merged
merged 13 commits into from
May 13, 2022
29 changes: 20 additions & 9 deletions ports/lua/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,6 @@ src/lopcodes.c src/loslib.c src/lparser.c src/lstate.c src/lstring.c src/lstrlib
src/ltable.c src/ltablib.c src/ltm.c src/lundump.c src/lutf8lib.c src/lvm.c src/lzio.c
)

IF (COMPILE_AS_CPP)
SET_SOURCE_FILES_PROPERTIES(${SRC_LIBLUA} src/lua.c src/luac.c PROPERTIES LANGUAGE CXX)
ELSE ()
SET (CMAKE_C_STANDARD 99)
ENDIF ()

# append headers to sources to make them show up in MSVC GUI
LIST(APPEND SRC_LIBLUA ${HDR_LIBLUA})

Expand All @@ -51,7 +45,9 @@ IF (UNIX)
ENDIF ()

#DLL
SET (CMAKE_C_STANDARD 99)
ADD_LIBRARY ( lua ${SRC_LIBLUA} )
TARGET_INCLUDE_DIRECTORIES(lua PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src> PUBLIC $<INSTALL_INTERFACE:include>)
SET_PROPERTY (TARGET lua PROPERTY POSITION_INDEPENDENT_CODE ON)

IF (BUILD_SHARED_LIBS AND WIN32)
Expand Down Expand Up @@ -80,8 +76,12 @@ INSTALL ( TARGETS lua
install(EXPORT unofficial-lua-config DESTINATION share/unofficial-lua)

IF (COMPILE_AS_CPP)
ADD_LIBRARY ( lua-cpp ${SRC_LIBLUA} )
file(COPY ${SRC_LIBLUA} DESTINATION ${CMAKE_BINARY_DIR}/luacpp)
file(GLOB SRC_LIBLUA_CXX ${CMAKE_BINARY_DIR}/luacpp/*.c)
JackBoosY marked this conversation as resolved.
Show resolved Hide resolved
SET_SOURCE_FILES_PROPERTIES(${SRC_LIBLUA_CXX} src/lua.c src/luac.c PROPERTIES LANGUAGE CXX)
JackBoosY marked this conversation as resolved.
Show resolved Hide resolved
ADD_LIBRARY ( lua-cpp ${SRC_LIBLUA_CXX} )
SET_TARGET_PROPERTIES(lua-cpp PROPERTIES OUTPUT_NAME "lua-c++")
TARGET_INCLUDE_DIRECTORIES(lua-cpp PRIVATE $<BUILD_INTERFACE:${CMAKE_CURRENT_LIST_DIR}/src> PUBLIC $<INSTALL_INTERFACE:include>)
IF (BUILD_SHARED_LIBS AND WIN32)
TARGET_COMPILE_DEFINITIONS (lua-cpp PUBLIC -DLUA_BUILD_AS_DLL )
ENDIF ()
Expand All @@ -108,9 +108,20 @@ IF (COMPILE_AS_CPP)
ENDIF()

IF (INSTALL_TOOLS)
ADD_EXECUTABLE ( luac src/luac.c ${SRC_LIBLUA} ) # compiler uses non-exported APIs, so must include sources directly.
if (COMPILE_AS_CPP)
JackBoosY marked this conversation as resolved.
Show resolved Hide resolved
ADD_EXECUTABLE ( luac src/luac.c ${SRC_LIBLUA_CXX} ) # compiler uses non-exported APIs, so must include sources directly.
TARGET_INCLUDE_DIRECTORIES(luac PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src)
else()
ADD_EXECUTABLE ( luac src/luac.c ${SRC_LIBLUA} ) # compiler uses non-exported APIs, so must include sources directly.
endif()
ADD_EXECUTABLE ( luai src/lua.c ) # interpreter
TARGET_LINK_LIBRARIES ( luai lua )
if (COMPILE_AS_CPP)
TARGET_LINK_LIBRARIES ( luac PRIVATE lua-cpp )
TARGET_LINK_LIBRARIES ( luai PRIVATE lua-cpp )
else()
TARGET_LINK_LIBRARIES ( luac PRIVATE lua )
TARGET_LINK_LIBRARIES ( luai PRIVATE lua )
endif()
SET_TARGET_PROPERTIES ( luai PROPERTIES OUTPUT_NAME lua PDB_NAME luai )
IF (UNIX)
IF (CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
Expand Down
3 changes: 2 additions & 1 deletion ports/lua/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"name": "lua",
"version": "5.4.4",
"port-version": 1,
"port-version": 2,
"description": "A powerful, fast, lightweight, embeddable scripting language",
"homepage": "https://www.lua.org",
"license": null,
"dependencies": [
{
"name": "vcpkg-cmake",
Expand Down
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -4294,7 +4294,7 @@
},
"lua": {
"baseline": "5.4.4",
"port-version": 1
"port-version": 2
},
"luabridge": {
"baseline": "2.6",
Expand Down
5 changes: 5 additions & 0 deletions versions/l-/lua.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "9a98d45112d4746697642715c65bcbbff2d16ae7",
"version": "5.4.4",
"port-version": 2
},
{
"git-tree": "26701e6e610ff6eaee198ca1aaa0b9125e4b2d6f",
"version": "5.4.4",
Expand Down