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] Export cmake targets, rewrite CMakeLists and delete usage #15921

Merged
merged 12 commits into from
Aug 12, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 31 additions & 3 deletions ports/lua/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,6 @@ ENDIF ()
#DLL
ADD_LIBRARY ( lua ${SRC_LIBLUA} )
SET_PROPERTY (TARGET lua PROPERTY POSITION_INDEPENDENT_CODE ON)
IF (COMPILE_AS_CPP)
SET_TARGET_PROPERTIES(lua PROPERTIES OUTPUT_NAME "lua-c++")
ENDIF()

IF (BUILD_SHARED_LIBS AND WIN32)
TARGET_COMPILE_DEFINITIONS (lua PUBLIC -DLUA_BUILD_AS_DLL )
Expand All @@ -74,11 +71,42 @@ IF (UNIX)
ENDIF ()

INSTALL ( TARGETS lua
EXPORT unofficial-lua-config
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
)

install(EXPORT unofficial-lua-config DESTINATION share/unofficial-lua)

IF (COMPILE_AS_CPP)
ADD_LIBRARY ( lua-cpp ${SRC_LIBLUA} )
SET_TARGET_PROPERTIES(lua-cpp PROPERTIES OUTPUT_NAME "lua-c++")
IF (BUILD_SHARED_LIBS AND WIN32)
TARGET_COMPILE_DEFINITIONS (lua-cpp PUBLIC -DLUA_BUILD_AS_DLL )
ENDIF ()
IF (UNIX)
IF (APPLE)
TARGET_COMPILE_DEFINITIONS (lua-cpp PUBLIC -DLUA_USE_DLOPEN)
ELSE ()
FIND_LIBRARY (LIB_DLOPEN NAMES dl)
IF (LIB_DLOPEN)
TARGET_COMPILE_DEFINITIONS (lua-cpp PUBLIC -DLUA_USE_DLOPEN)
TARGET_LINK_LIBRARIES (lua-cpp ${LIB_DLOPEN})
ENDIF ()
ENDIF ()
ENDIF ()

INSTALL ( TARGETS lua-cpp
EXPORT unofficial-lua-cpp-config
RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin
LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib
)

install(EXPORT unofficial-lua-cpp-config DESTINATION share/unofficial-lua-cpp)
ENDIF()

IF (NOT DEFINED SKIP_INSTALL_TOOLS)
ADD_EXECUTABLE ( luac src/luac.c ${SRC_LIBLUA} ) # compiler uses non-exported APIs, so must include sources directly.
ADD_EXECUTABLE ( luai src/lua.c ) # interpreter
Expand Down
1 change: 1 addition & 0 deletions ports/lua/CONTROL
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
Source: lua
Version: 5.4.1
Port-Version: 1
Homepage: https://www.lua.org
Description: a powerful, fast, lightweight, embeddable scripting language

Expand Down
23 changes: 9 additions & 14 deletions ports/lua/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,32 +11,28 @@ vcpkg_extract_source_archive_ex(

file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})

vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
cpp COMPILE_AS_CPP
)

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DCOMPILE_AS_CPP=OFF
${FEATURE_OPTIONS}
OPTIONS_DEBUG
-DSKIP_INSTALL_HEADERS=ON
-DSKIP_INSTALL_TOOLS=ON
)

vcpkg_install_cmake()

vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-lua TARGET_PATH share/unofficial-lua)

set(ENABLE_LUA_CPP 0)
if("cpp" IN_LIST FEATURES)
set(ENABLE_LUA_CPP 1)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DCOMPILE_AS_CPP=ON
OPTIONS_DEBUG
-DSKIP_INSTALL_HEADERS=ON
-DSKIP_INSTALL_TOOLS=ON
)

vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-lua-cpp TARGET_PATH share/unofficial-lua-cpp)
endif()

vcpkg_copy_pdbs()
Expand All @@ -51,9 +47,8 @@ if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
endif()
endif()

# Handle post-build CMake instructions
# Suitable for old version
configure_file(${CMAKE_CURRENT_LIST_DIR}/vcpkg-cmake-wrapper.cmake.in ${CURRENT_PACKAGES_DIR}/share/${PORT}/vcpkg-cmake-wrapper.cmake @ONLY)
file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT})

# Handle copyright
file(INSTALL ${CMAKE_CURRENT_LIST_DIR}/COPYRIGHT DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
9 changes: 0 additions & 9 deletions ports/lua/usage

This file was deleted.

17 changes: 14 additions & 3 deletions ports/lua/vcpkg-cmake-wrapper.cmake.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,17 @@
_find_package(${ARGS})
set(REQUIRES )
foreach(ARG ${ARGS})
if (ARG STREQUAL "REQUIRED")
set(REQUIRES "REQUIRED")
break()
endif()
endforeach()

_find_package(unofficial-lua CONFIG ${REQUIRES})

set(LUA_LIBRARIES lua)
set(LUA_FOUND 1)

if (@ENABLE_LUA_CPP@)
find_library(lua_cpp NAMES lua-c++ liblua-c++ REQUIRED)
set(LUA_LIBRARIES ${LUA_LIBRARIES} ${lua_cpp})
_find_package(unofficial-lua-cpp CONFIG ${REQUIRES})
list(APPEND LUA_LIBRARIES lua-cpp)
endif()
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -3566,7 +3566,7 @@
},
"lua": {
"baseline": "5.4.1",
"port-version": 0
"port-version": 1
},
"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": "3d8976d794f971e0f58f73803a0ae3da14c2f2a5",
"version-string": "5.4.1",
"port-version": 1
},
{
"git-tree": "3bf3ea5ddf8760d12d37e7a2e95cb3db3cc51b7f",
"version-string": "5.4.1",
Expand Down