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

[lpeg] Add cmake Config file #39001

Merged
merged 2 commits into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
28 changes: 27 additions & 1 deletion ports/lpeg/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.0)
cmake_minimum_required(VERSION 3.11)
project(lpeg)

find_path(LUA_INCLUDE_DIR lua.h PATH_SUFFIXES lua)
Expand All @@ -19,7 +19,33 @@ target_include_directories(lpeg PRIVATE ${LPEG_INCLUDES})
target_link_libraries(lpeg PRIVATE ${LPEG_LIBRARIES})

install(TARGETS lpeg
EXPORT unofficial-lpeg-targets
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install(FILES re.lua DESTINATION share/lua)

include(CMakePackageConfigHelpers)

configure_package_config_file(
"${CMAKE_CURRENT_SOURCE_DIR}/unofficial-${PROJECT_NAME}-config.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/unofficial-${PROJECT_NAME}-config.cmake"
INSTALL_DESTINATION "share/unofficial-${PROJECT_NAME}"
)

set(VERSION_FILE_PATH "${CMAKE_CURRENT_BINARY_DIR}/unofficial-${PROJECT_NAME}-config-version.cmake")
write_basic_package_version_file(
"${VERSION_FILE_PATH}"
VERSION "${LPEG_VERSION}"
COMPATIBILITY SameMajorVersion
)

install(
FILES "${CMAKE_CURRENT_BINARY_DIR}/unofficial-${PROJECT_NAME}-config.cmake"
DESTINATION "share/unofficial-${PROJECT_NAME}"
)

install(
EXPORT "unofficial-${PROJECT_NAME}-targets"
NAMESPACE "unofficial::${PROJECT_NAME}::"
DESTINATION "share/unofficial-${PROJECT_NAME}")
5 changes: 5 additions & 0 deletions ports/lpeg/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,23 @@ vcpkg_extract_source_archive(

file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/lpeg.def" DESTINATION "${SOURCE_PATH}")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/unofficial-lpeg-config.cmake.in" DESTINATION "${SOURCE_PATH}")

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
"-DLPEG_VERSION=${VERSION}"
)

vcpkg_cmake_install()
vcpkg_cmake_config_fixup(PACKAGE_NAME "unofficial-lpeg")

# Remove debug share
file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")

# Handle copyright
file(INSTALL "${SOURCE_PATH}/lpeg.html" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")

# Allow empty include directory
set(VCPKG_POLICY_EMPTY_INCLUDE_FOLDER enabled)
5 changes: 5 additions & 0 deletions ports/lpeg/unofficial-lpeg-config.cmake.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
@PACKAGE_INIT@

include("${CMAKE_CURRENT_LIST_DIR}/unofficial-lpeg-targets.cmake")
set(UNOFFICIAL_LPEG_LUA_FILES "${PACKAGE_PREFIX_DIR}/share/lua/re.lua")
check_required_components(lpeg)
13 changes: 13 additions & 0 deletions ports/lpeg/usage
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
lpeg provides CMake targets:

find_package(unofficial-lpeg CONFIG REQUIRED)
target_link_libraries(main PRIVATE unofficial::lpeg::lpeg)

UNOFFICIAL_LPEG_LUA_FILES will be set to the path of re.lua

add_custom_command(TARGET main POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy
${UNOFFICIAL_LPEG_LUA_FILES}
$<TARGET_FILE_DIR:main>)

install(FILES ${UNOFFICIAL_LPEG_LUA_FILES} DESTINATION my_lua_path)
6 changes: 6 additions & 0 deletions ports/lpeg/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
{
"name": "lpeg",
"version": "1.1.0",
"port-version": 1,
"description": "LPeg is a pattern-matching library for Lua, based on Parsing Expression Grammars (PEGs).",
"homepage": "https://www.inf.puc-rio.br/~roberto/lpeg",
"license": "MIT",
"dependencies": [
"lua",
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
2 changes: 1 addition & 1 deletion versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -5438,7 +5438,7 @@
},
"lpeg": {
"baseline": "1.1.0",
"port-version": 0
"port-version": 1
},
"ltla-aarand": {
"baseline": "2023-03-19",
Expand Down
5 changes: 5 additions & 0 deletions versions/l-/lpeg.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "933131ff56540fca7bbfb7a4ccd5fbf2612d4b0c",
"version": "1.1.0",
"port-version": 1
},
{
"git-tree": "a1832dfc0fc6e11738a1653cdf7a65ccde8903ba",
"version": "1.1.0",
Expand Down