vcpkg/ports/lua/portfile.cmake
Jack·Boos·Yu 32d25e6b85
[lua] Fix library type and usage (#24436)
* [lua] Fix library type and usage

* version

* Use c code in executables

* version

* Apply suggestion

* version

* Add an extra CMakeLists.txt to avoid scope pollution of SET_SOURCE_FILES_PROPERTIES

* version

* Apply suggestions

* version

* Various nitpicks:

* Use "supports" on features rather than if tests plus message FATAL_ERROR
* Deduplicate ENABLE_LUA_CPP and COMPILE_AS_CPP
* Add quotes.
* Use file(INSTALL rather than configure_file(COPYONLY)

Co-authored-by: Billy Robert O'Neal III <bion@microsoft.com>
2022-05-13 15:02:20 -07:00

55 lines
1.9 KiB
CMake

vcpkg_download_distfile(ARCHIVE
URLS "https://www.lua.org/ftp/lua-5.4.4.tar.gz"
FILENAME "lua-5.4.4.tar.gz"
SHA512 af0c35d5ba00fecbb2dd617bd7b825edf7418a16a73076e04f2a0df58cdbf098dc3ff4402e974afd789eb5d86d2e12ec6df9c84b99b23656ea694a85f83bcd21
)
vcpkg_extract_source_archive_ex(
OUT_SOURCE_PATH SOURCE_PATH
ARCHIVE "${ARCHIVE}"
PATCHES
vs2015-impl-c99.patch
fix-ios-system.patch
)
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/CMakeLists-cpp.txt" DESTINATION "${SOURCE_PATH}/cpp" RENAME "CMakeLists.txt")
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
FEATURES
cpp COMPILE_AS_CPP # Also used in cmake wrapper
tools INSTALL_TOOLS
)
vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS
${FEATURE_OPTIONS}
OPTIONS_DEBUG
-DSKIP_INSTALL_HEADERS=ON
)
vcpkg_cmake_install()
vcpkg_copy_pdbs()
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-lua CONFIG_PATH share/unofficial-lua)
if("cpp" IN_LIST FEATURES)
vcpkg_cmake_config_fixup(PACKAGE_NAME unofficial-lua-cpp CONFIG_PATH "share/unofficial-lua-cpp")
endif()
if ("tools" IN_LIST FEATURES)
vcpkg_copy_tools(TOOL_NAMES lua luac SEARCH_DIR "${CURRENT_PACKAGES_DIR}/tools/${PORT}")
endif()
if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic)
if(VCPKG_TARGET_IS_WINDOWS)
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/include/luaconf.h" "defined(LUA_BUILD_AS_DLL)" "1")
endif()
endif()
# 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}")
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/COPYRIGHT" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)