Skip to content

Commit

Permalink
[luafilesystem] Add cmake files for find_package
Browse files Browse the repository at this point in the history
Addresses microsoft#38340 for luafilesystem
  • Loading branch information
TheCycoONE committed Apr 30, 2024
1 parent bd5a4e7 commit 49696f3
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 18 deletions.
60 changes: 43 additions & 17 deletions ports/luafilesystem/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,17 +1,43 @@
cmake_minimum_required(VERSION 3.0)
project(luafilesystem)

find_path(LUA_INCLUDE_DIR lua.h PATH_SUFFIXES lua)
find_library(LUA_LIBRARY lua)
set(LFS_INCLUDES ${LUA_INCLUDE_DIR})
set(LFS_LIBRARIES ${LUA_LIBRARY})

add_library( lfs src/lfs.h src/lfs.c src/lfs.def)

target_include_directories(lfs PRIVATE ${LFS_INCLUDES})
target_link_libraries(lfs PRIVATE ${LFS_LIBRARIES})

install(TARGETS lfs
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
cmake_minimum_required(VERSION 3.11)
project(luafilesystem)

find_path(LUA_INCLUDE_DIR lua.h PATH_SUFFIXES lua)
find_library(LUA_LIBRARY lua)
set(LFS_INCLUDES ${LUA_INCLUDE_DIR})
set(LFS_LIBRARIES ${LUA_LIBRARY})

add_library(lfs src/lfs.h src/lfs.c src/lfs.def)

target_include_directories(lfs PRIVATE ${LFS_INCLUDES})
target_link_libraries(lfs PRIVATE ${LFS_LIBRARIES})

install(TARGETS lfs
EXPORT "unofficial-lfs-targets"
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)

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/${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 "${LFS_VERSION}"
COMPATIBILITY SameMajorVersion
)

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

install(
EXPORT "unofficial-lfs-targets"
NAMESPACE "unofficial::${PROJECT_NAME}::"
DESTINATION "share/${PROJECT_NAME}")
9 changes: 9 additions & 0 deletions ports/luafilesystem/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,22 @@ vcpkg_from_github(
)

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

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

vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_cmake_config_fixup()

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

# Handle copyright
file(INSTALL "${SOURCE_PATH}/LICENSE" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
Expand Down
5 changes: 5 additions & 0 deletions ports/luafilesystem/unofficial-luafilesystem-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-lfs-targets.cmake")

check_required_components(luafilesystem)
6 changes: 5 additions & 1 deletion ports/luafilesystem/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "luafilesystem",
"version": "1.8.0",
"port-version": 5,
"port-version": 6,
"description": "LuaFileSystem is a Lua library developed to complement the set of functions related to file systems offered by the standard Lua distribution.",
"homepage": "https://github.com/keplerproject/luafilesystem",
"supports": "!uwp",
Expand All @@ -10,6 +10,10 @@
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}

0 comments on commit 49696f3

Please sign in to comment.