diff --git a/ports/lua/CMakeLists-cpp.txt b/ports/lua/CMakeLists-cpp.txt new file mode 100644 index 00000000000000..88e128ffff9222 --- /dev/null +++ b/ports/lua/CMakeLists-cpp.txt @@ -0,0 +1,28 @@ +SET(SRC_LIBLUACPP ${SRC_LIBLUA}) +ADD_LIBRARY ( lua-cpp ${SRC_LIBLUACPP} ${HDR_LIBLUACPP} ) +SET_TARGET_PROPERTIES(lua-cpp PROPERTIES OUTPUT_NAME "lua-c++") +SET_SOURCE_FILES_PROPERTIES(${SRC_LIBLUACPP} PROPERTIES LANGUAGE CXX) +TARGET_INCLUDE_DIRECTORIES(lua-cpp PRIVATE $ PUBLIC $) +IF (BUILD_SHARED_LIBS AND WIN32) + TARGET_COMPILE_DEFINITIONS (lua-cpp PUBLIC -DLUA_BUILD_AS_DLL ) +ENDIF () +IF (UNIX) + IF (APPLE) + TARGET_COMPILE_DEFINITIONS (lua-cpp PUBLIC -DLUA_USE_DLOPEN) + ELSE () + FIND_LIBRARY (LIB_DLOPEN NAMES dl) + IF (LIB_DLOPEN) + TARGET_COMPILE_DEFINITIONS (lua-cpp PUBLIC -DLUA_USE_DLOPEN) + TARGET_LINK_LIBRARIES (lua-cpp ${LIB_DLOPEN}) + ENDIF () + ENDIF () +ENDIF () + +INSTALL ( TARGETS lua-cpp + EXPORT unofficial-lua-cpp-config + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib +) + +INSTALL(EXPORT unofficial-lua-cpp-config DESTINATION share/unofficial-lua-cpp) diff --git a/ports/lua/CMakeLists.txt b/ports/lua/CMakeLists.txt index 8e93eb1ab7c6a4..ac52d7e8052570 100644 --- a/ports/lua/CMakeLists.txt +++ b/ports/lua/CMakeLists.txt @@ -10,32 +10,16 @@ PROJECT ( lua ) -CMAKE_MINIMUM_REQUIRED(VERSION 2.8) - -SET (HDR_LIBLUA -src/lapi.h src/lauxlib.h src/lcode.h src/lctype.h src/ldebug.h src/ldo.h src/lfunc.h -src/lgc.h src/llex.h src/llimits.h src/lmem.h src/lobject.h src/lopcodes.h src/lparser.h -src/lstate.h src/lstring.h src/ltable.h src/ltm.h src/lua.h src/luaconf.h src/lualib.h -src/lundump.h src/lvm.h src/lzio.h -) +CMAKE_MINIMUM_REQUIRED(VERSION 3.18) # Build Libraries -SET (SRC_LIBLUA -src/lapi.c src/lauxlib.c src/lbaselib.c src/lcode.c src/lcorolib.c -src/lctype.c src/ldblib.c src/ldebug.c src/ldo.c src/ldump.c src/lfunc.c src/lgc.c -src/linit.c src/liolib.c src/llex.c src/lmathlib.c src/lmem.c src/loadlib.c src/lobject.c -src/lopcodes.c src/loslib.c src/lparser.c src/lstate.c src/lstring.c src/lstrlib.c -src/ltable.c src/ltablib.c src/ltm.c src/lundump.c src/lutf8lib.c src/lvm.c src/lzio.c -) - -IF (COMPILE_AS_CPP) - SET_SOURCE_FILES_PROPERTIES(${SRC_LIBLUA} src/lua.c src/luac.c PROPERTIES LANGUAGE CXX) -ELSE () - SET (CMAKE_C_STANDARD 99) -ENDIF () +FILE(GLOB HDR_LIBLUA "${CMAKE_SOURCE_DIR}/src/*.h") +# For luac.c +LIST(REMOVE_ITEM HDR_LIBLUA "${CMAKE_SOURCE_DIR}/src/lopnames.h") -# append headers to sources to make them show up in MSVC GUI -LIST(APPEND SRC_LIBLUA ${HDR_LIBLUA}) +FILE(GLOB SRC_LIBLUA "${CMAKE_SOURCE_DIR}/src/*.c") +# Executables luac and luai +LIST(REMOVE_ITEM SRC_LIBLUA "${CMAKE_SOURCE_DIR}/src/luac.c" "${CMAKE_SOURCE_DIR}/src/lua.c") IF (WIN32) # remove warnings @@ -50,9 +34,13 @@ IF (UNIX) ENDIF () ENDIF () -#DLL -ADD_LIBRARY ( lua ${SRC_LIBLUA} ) +# C library +SET (CMAKE_C_STANDARD 99) +SET(SRC_LIBLUAC ${SRC_LIBLUA}) +ADD_LIBRARY ( lua ${SRC_LIBLUAC} ${HDR_LIBLUA} ) +TARGET_INCLUDE_DIRECTORIES(lua PRIVATE $ PUBLIC $) SET_PROPERTY (TARGET lua PROPERTY POSITION_INDEPENDENT_CODE ON) +SET_SOURCE_FILES_PROPERTIES(${SRC_LIBLUAC} PROPERTIES LANGUAGE C) IF (BUILD_SHARED_LIBS AND WIN32) TARGET_COMPILE_DEFINITIONS (lua PUBLIC -DLUA_BUILD_AS_DLL ) @@ -72,45 +60,25 @@ ENDIF () INSTALL ( TARGETS lua EXPORT unofficial-lua-config - RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin - LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib - ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib + RUNTIME DESTINATION bin + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib ) install(EXPORT unofficial-lua-config DESTINATION share/unofficial-lua) +# CXX library IF (COMPILE_AS_CPP) - ADD_LIBRARY ( lua-cpp ${SRC_LIBLUA} ) - SET_TARGET_PROPERTIES(lua-cpp PROPERTIES OUTPUT_NAME "lua-c++") - IF (BUILD_SHARED_LIBS AND WIN32) - TARGET_COMPILE_DEFINITIONS (lua-cpp PUBLIC -DLUA_BUILD_AS_DLL ) - ENDIF () - IF (UNIX) - IF (APPLE) - TARGET_COMPILE_DEFINITIONS (lua-cpp PUBLIC -DLUA_USE_DLOPEN) - ELSE () - FIND_LIBRARY (LIB_DLOPEN NAMES dl) - IF (LIB_DLOPEN) - TARGET_COMPILE_DEFINITIONS (lua-cpp PUBLIC -DLUA_USE_DLOPEN) - TARGET_LINK_LIBRARIES (lua-cpp ${LIB_DLOPEN}) - ENDIF () - ENDIF () - ENDIF () - - INSTALL ( TARGETS lua-cpp - EXPORT unofficial-lua-cpp-config - RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin - LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib - ARCHIVE DESTINATION ${CMAKE_INSTALL_PREFIX}/lib - ) - - install(EXPORT unofficial-lua-cpp-config DESTINATION share/unofficial-lua-cpp) + ADD_SUBDIRECTORY(cpp) ENDIF() IF (INSTALL_TOOLS) - ADD_EXECUTABLE ( luac src/luac.c ${SRC_LIBLUA} ) # compiler uses non-exported APIs, so must include sources directly. - ADD_EXECUTABLE ( luai src/lua.c ) # interpreter - TARGET_LINK_LIBRARIES ( luai lua ) + # compiler uses non-exported APIs, so must include sources directly. + ADD_EXECUTABLE ( luac ${CMAKE_SOURCE_DIR}/src/luac.c ${SRC_LIBLUA} ${CMAKE_SOURCE_DIR}/src/lopnames.h ) + ADD_EXECUTABLE ( luai ${CMAKE_SOURCE_DIR}/src/lua.c ) # interpreter + + TARGET_INCLUDE_DIRECTORIES(luac PRIVATE ${CMAKE_CURRENT_LIST_DIR}/src) + TARGET_LINK_LIBRARIES ( luai PRIVATE lua ) SET_TARGET_PROPERTIES ( luai PROPERTIES OUTPUT_NAME lua PDB_NAME luai ) IF (UNIX) IF (CMAKE_SYSTEM_NAME STREQUAL FreeBSD) @@ -127,7 +95,7 @@ IF (INSTALL_TOOLS) ENDIF () ENDIF () ENDIF () - INSTALL ( TARGETS luai luac RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/tools/lua ) + INSTALL ( TARGETS luai luac RUNTIME DESTINATION tools/lua ) ENDIF () IF (NOT SKIP_INSTALL_HEADERS) diff --git a/ports/lua/portfile.cmake b/ports/lua/portfile.cmake index 0a034611ab35b7..e607a6f61f5dc0 100644 --- a/ports/lua/portfile.cmake +++ b/ports/lua/portfile.cmake @@ -5,31 +5,20 @@ vcpkg_download_distfile(ARCHIVE ) vcpkg_extract_source_archive_ex( OUT_SOURCE_PATH SOURCE_PATH - ARCHIVE ${ARCHIVE} + ARCHIVE "${ARCHIVE}" PATCHES vs2015-impl-c99.patch fix-ios-system.patch ) file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") - -# Used in cmake wrapper -set(ENABLE_LUA_CPP 0) -if ("cpp" IN_LIST FEATURES) - if (VCPKG_TARGET_IS_UWP) - message(FATAL_ERROR "Feature cpp does not support uwp.") - endif() - set(ENABLE_LUA_CPP 1) -endif() +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 + cpp COMPILE_AS_CPP # Also used in cmake wrapper tools INSTALL_TOOLS ) -if(VCPKG_TARGET_IS_IOS AND "tools" IN_LIST FEATURES) - message(FATAL_ERROR "lua[tools] is not supported for iOS platform build") -endif() vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" @@ -62,5 +51,4 @@ endif() 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}") -# Handle copyright file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/COPYRIGHT" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright) diff --git a/ports/lua/vcpkg-cmake-wrapper.cmake.in b/ports/lua/vcpkg-cmake-wrapper.cmake.in index 74973eca35126b..eec21fdb365eef 100644 --- a/ports/lua/vcpkg-cmake-wrapper.cmake.in +++ b/ports/lua/vcpkg-cmake-wrapper.cmake.in @@ -7,7 +7,7 @@ endforeach() _find_package(unofficial-lua CONFIG ${REQUIRES}) -if (@ENABLE_LUA_CPP@) +if (@COMPILE_AS_CPP@) _find_package(unofficial-lua-cpp CONFIG ${REQUIRES}) endif() diff --git a/ports/lua/vcpkg.json b/ports/lua/vcpkg.json index 2017af76562172..d7c7d2d57c71ef 100644 --- a/ports/lua/vcpkg.json +++ b/ports/lua/vcpkg.json @@ -1,9 +1,10 @@ { "name": "lua", "version": "5.4.4", - "port-version": 1, + "port-version": 2, "description": "A powerful, fast, lightweight, embeddable scripting language", "homepage": "https://www.lua.org", + "license": null, "dependencies": [ { "name": "vcpkg-cmake", @@ -16,10 +17,12 @@ ], "features": { "cpp": { - "description": "Builds Lua for C++ linkage" + "description": "Builds Lua for C++ linkage", + "supports": "!uwp" }, "tools": { - "description": "Builds Lua compiler and interpreter" + "description": "Builds Lua compiler and interpreter", + "supports": "!ios" } } } diff --git a/versions/baseline.json b/versions/baseline.json index 37dfe4cff9c2fc..e9669eafe78eda 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -4302,7 +4302,7 @@ }, "lua": { "baseline": "5.4.4", - "port-version": 1 + "port-version": 2 }, "luabridge": { "baseline": "2.6", diff --git a/versions/l-/lua.json b/versions/l-/lua.json index 9ee6c7e2580ede..5fb64a0a474ecc 100644 --- a/versions/l-/lua.json +++ b/versions/l-/lua.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "1443185b76c2f6e0e74c425ed0b3176e98a5fb01", + "version": "5.4.4", + "port-version": 2 + }, { "git-tree": "26701e6e610ff6eaee198ca1aaa0b9125e4b2d6f", "version": "5.4.4",