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 } ] }