diff --git a/ports/lua/CMakeLists.txt b/ports/lua/CMakeLists.txt index 3fa62fe2cf..01a1d5a128 100644 --- a/ports/lua/CMakeLists.txt +++ b/ports/lua/CMakeLists.txt @@ -9,9 +9,6 @@ PROJECT ( lua ) -IF( NOT WIN32 ) - message( FATAL_ERROR "Written for window only" ) -ENDIF() CMAKE_MINIMUM_REQUIRED(VERSION 2.8) @@ -33,21 +30,45 @@ src/ltable.c src/ltablib.c src/ltm.c src/lundump.c src/lutf8lib.c src/lvm.c src/ 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 () # append headers to sources to make them show up in MSVC GUI LIST(APPEND SRC_LIBLUA ${HDR_LIBLUA}) -# remove warnings -ADD_DEFINITIONS (-D_CRT_SECURE_NO_WARNINGS ) +IF (WIN32) + # remove warnings + ADD_DEFINITIONS (-D_CRT_SECURE_NO_WARNINGS ) +ENDIF () + +IF (UNIX) + ADD_DEFINITIONS (-DLUA_USE_POSIX) + FIND_LIBRARY (LIB_MATH NAMES m) + IF (LIB_MATH) + LINK_LIBRARIES (${LIB_MATH}) + ENDIF () +ENDIF () #DLL ADD_LIBRARY ( lua ${SRC_LIBLUA} ) -IF (BUILD_SHARED_LIBS) +IF (BUILD_SHARED_LIBS AND WIN32) TARGET_COMPILE_DEFINITIONS (lua PUBLIC -DLUA_BUILD_AS_DLL ) ENDIF () +IF (UNIX) + IF (APPLE) + TARGET_COMPILE_DEFINITIONS (lua PUBLIC -DLUA_USE_DLOPEN) + ELSE () + FIND_LIBRARY (LIB_DLOPEN NAMES dl) + IF (LIB_DLOPEN) + TARGET_COMPILE_DEFINITIONS (lua PUBLIC -DLUA_USE_DLOPEN) + TARGET_LINK_LIBRARIES (lua ${LIB_DLOPEN}) + ENDIF () + ENDIF () +ENDIF () + INSTALL ( TARGETS lua RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin LIBRARY DESTINATION ${CMAKE_INSTALL_PREFIX}/lib @@ -59,6 +80,21 @@ IF (NOT DEFINED SKIP_INSTALL_TOOLS) ADD_EXECUTABLE ( luai src/lua.c ) # interpreter TARGET_LINK_LIBRARIES ( luai lua ) SET_TARGET_PROPERTIES ( luai PROPERTIES OUTPUT_NAME lua PDB_NAME luai ) + IF (UNIX) + IF (CMAKE_SYSTEM_NAME STREQUAL FreeBSD) + SET (_LIB_READLINE_NAME edit) + ELSE () + SET (_LIB_READLINE_NAME readline) + ENDIF () + FIND_LIBRARY (LIB_READLINE NAMES ${_LIB_READLINE_NAME}) + IF (LIB_READLINE) + TARGET_COMPILE_DEFINITIONS (luai PUBLIC -DLUA_USE_READLINE) + TARGET_LINK_LIBRARIES(luai ${LIB_READLINE}) + IF (_LIB_READLINE_NAME STREQUAL edit) + TARGET_INCLUDE_DIRECTORIES (luai PUBLIC /usr/include/edit) + ENDIF () + ENDIF () + ENDIF () INSTALL ( TARGETS luai luac RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/tools/lua ) ENDIF () diff --git a/ports/lua/CONTROL b/ports/lua/CONTROL index 836ae345a0..23f31a1fd7 100644 --- a/ports/lua/CONTROL +++ b/ports/lua/CONTROL @@ -1,3 +1,3 @@ Source: lua -Version: 5.3.4-4 +Version: 5.3.5-1 Description: a powerful, fast, lightweight, embeddable scripting language diff --git a/ports/lua/portfile.cmake b/ports/lua/portfile.cmake index a1dcbd379d..e3c972ac41 100644 --- a/ports/lua/portfile.cmake +++ b/ports/lua/portfile.cmake @@ -7,13 +7,16 @@ # include(vcpkg_common_functions) -set(SOURCE_PATH ${CURRENT_BUILDTREES_DIR}/src/lua-5.3.4) vcpkg_download_distfile(ARCHIVE - URLS "http://www.lua.org/ftp/lua-5.3.4.tar.gz" - FILENAME "lua-5.3.4.tar.gz" - SHA512 739e31f82e6a60fa99910c2005e991b3a1e21339af52847f653cb190b30842054d189ca116ffcfdf9b36e07888c9ce5642b1dd2988cc7eff9f8789f9a2e34997 + URLS "https://www.lua.org/ftp/lua-5.3.5.tar.gz" + FILENAME "lua-5.3.5.tar.gz" + SHA512 4f9516acc4659dfd0a9e911bfa00c0788f0ad9348e5724fe8fb17aac59e9c0060a64378f82be86f8534e49c6c013e7488ad17321bafcc787831d3d67406bd0f4 +) +vcpkg_extract_source_archive_ex( + OUT_SOURCE_PATH SOURCE_PATH + ARCHIVE ${ARCHIVE} + PATCHES vs2015-impl-c99.patch ) -vcpkg_extract_source_archive(${ARCHIVE}) file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH}) @@ -30,13 +33,15 @@ vcpkg_configure_cmake( vcpkg_install_cmake() if(VCPKG_LIBRARY_LINKAGE STREQUAL dynamic) - file(READ ${CURRENT_PACKAGES_DIR}/include/luaconf.h LUA_CONF_H) - string(REPLACE "defined(LUA_BUILD_AS_DLL)" "1" LUA_CONF_H "${LUA_CONF_H}") - file(WRITE ${CURRENT_PACKAGES_DIR}/include/luaconf.h "${LUA_CONF_H}") + if(NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL WindowsStore) + file(READ ${CURRENT_PACKAGES_DIR}/include/luaconf.h LUA_CONF_H) + string(REPLACE "defined(LUA_BUILD_AS_DLL)" "1" LUA_CONF_H "${LUA_CONF_H}") + file(WRITE ${CURRENT_PACKAGES_DIR}/include/luaconf.h "${LUA_CONF_H}") + endif() endif() vcpkg_copy_tool_dependencies(${CURRENT_PACKAGES_DIR}/tools/lua) # Handle copyright -file(COPY ${CMAKE_CURRENT_LIST_DIR}/COPYRIGHT DESTINATION ${CURRENT_PACKAGES_DIR}/share/lua) +file(COPY ${CMAKE_CURRENT_LIST_DIR}/COPYRIGHT DESTINATION ${CURRENT_PACKAGES_DIR}/share/lua/copyright) vcpkg_copy_pdbs() diff --git a/ports/lua/vs2015-impl-c99.patch b/ports/lua/vs2015-impl-c99.patch new file mode 100644 index 0000000000..e281e83cf6 --- /dev/null +++ b/ports/lua/vs2015-impl-c99.patch @@ -0,0 +1,11 @@ +--- a/src/luaconf.h ++++ b/src/luaconf.h +@@ -54,7 +54,7 @@ + + #if defined(LUA_USE_WINDOWS) + #define LUA_DL_DLL /* enable support for DLL */ +-#define LUA_USE_C89 /* broadly, Windows is C89 */ ++//#define LUA_USE_C89 /* broadly, Windows is C89 */ + #endif + +