From 420b40199fcec30671dbe890cf18c1d7b0f1b583 Mon Sep 17 00:00:00 2001 From: "Stephen E. Baker" Date: Tue, 28 May 2024 21:02:45 -0400 Subject: [PATCH 1/2] [lpeg] Add cmake Config files Second of two ports for #38340 --- ports/lpeg/CMakeLists.txt | 28 +++++++++++++++++++++- ports/lpeg/portfile.cmake | 5 ++++ ports/lpeg/unofficial-lpeg-config.cmake.in | 5 ++++ ports/lpeg/usage | 13 ++++++++++ ports/lpeg/vcpkg.json | 6 +++++ 5 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 ports/lpeg/unofficial-lpeg-config.cmake.in create mode 100644 ports/lpeg/usage diff --git a/ports/lpeg/CMakeLists.txt b/ports/lpeg/CMakeLists.txt index e3ef2bf540b6ae..b35118b62e9804 100644 --- a/ports/lpeg/CMakeLists.txt +++ b/ports/lpeg/CMakeLists.txt @@ -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) @@ -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}") diff --git a/ports/lpeg/portfile.cmake b/ports/lpeg/portfile.cmake index 40b38be2c6ca7c..d9d513ae095c21 100644 --- a/ports/lpeg/portfile.cmake +++ b/ports/lpeg/portfile.cmake @@ -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) diff --git a/ports/lpeg/unofficial-lpeg-config.cmake.in b/ports/lpeg/unofficial-lpeg-config.cmake.in new file mode 100644 index 00000000000000..fcf6683bf5bbe1 --- /dev/null +++ b/ports/lpeg/unofficial-lpeg-config.cmake.in @@ -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) diff --git a/ports/lpeg/usage b/ports/lpeg/usage new file mode 100644 index 00000000000000..19ef17b04f26aa --- /dev/null +++ b/ports/lpeg/usage @@ -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} + $) + + install(FILES ${UNOFFICIAL_LPEG_LUA_FILES} DESTINATION my_lua_path) diff --git a/ports/lpeg/vcpkg.json b/ports/lpeg/vcpkg.json index e750e87a52f55c..905e19293b902c 100644 --- a/ports/lpeg/vcpkg.json +++ b/ports/lpeg/vcpkg.json @@ -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 } ] } From d3af8ff6f790be9084b3c3ee6f34554fba77ff94 Mon Sep 17 00:00:00 2001 From: "Stephen E. Baker" Date: Fri, 31 May 2024 21:26:03 -0400 Subject: [PATCH 2/2] Update version db --- versions/baseline.json | 2 +- versions/l-/lpeg.json | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/versions/baseline.json b/versions/baseline.json index db1427902644ee..a78d344c1fdce4 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -5438,7 +5438,7 @@ }, "lpeg": { "baseline": "1.1.0", - "port-version": 0 + "port-version": 1 }, "ltla-aarand": { "baseline": "2023-03-19", diff --git a/versions/l-/lpeg.json b/versions/l-/lpeg.json index 617853a15d18a2..495f9b4d71e770 100644 --- a/versions/l-/lpeg.json +++ b/versions/l-/lpeg.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "933131ff56540fca7bbfb7a4ccd5fbf2612d4b0c", + "version": "1.1.0", + "port-version": 1 + }, { "git-tree": "a1832dfc0fc6e11738a1653cdf7a65ccde8903ba", "version": "1.1.0",