aboutsummaryrefslogtreecommitdiff
path: root/third-party/cmake/BuildLuarocks.cmake
diff options
context:
space:
mode:
Diffstat (limited to 'third-party/cmake/BuildLuarocks.cmake')
-rw-r--r--third-party/cmake/BuildLuarocks.cmake26
1 files changed, 22 insertions, 4 deletions
diff --git a/third-party/cmake/BuildLuarocks.cmake b/third-party/cmake/BuildLuarocks.cmake
index 7551c52ecc..4b1b94a46b 100644
--- a/third-party/cmake/BuildLuarocks.cmake
+++ b/third-party/cmake/BuildLuarocks.cmake
@@ -52,13 +52,17 @@ if(NOT MSVC)
set(LUAROCKS_BUILDARGS CC=${HOSTDEPS_C_COMPILER} LD=${HOSTDEPS_C_COMPILER})
endif()
+# Lua version, used with rocks directories.
+# Defaults to 5.1 for bundled LuaJIT/Lua.
+set(LUA_VERSION "5.1")
+
if(UNIX OR (MINGW AND CMAKE_CROSSCOMPILING))
if(USE_BUNDLED_LUAJIT)
list(APPEND LUAROCKS_OPTS
--with-lua=${HOSTDEPS_INSTALL_DIR}
--with-lua-include=${HOSTDEPS_INSTALL_DIR}/include/luajit-2.1
- --lua-suffix=jit)
+ --with-lua-interpreter=luajit)
elseif(USE_BUNDLED_LUA)
list(APPEND LUAROCKS_OPTS
--with-lua=${HOSTDEPS_INSTALL_DIR})
@@ -66,9 +70,23 @@ if(UNIX OR (MINGW AND CMAKE_CROSSCOMPILING))
find_package(LuaJit)
if(LUAJIT_FOUND)
list(APPEND LUAROCKS_OPTS
- --lua-version=5.1
--with-lua-include=${LUAJIT_INCLUDE_DIRS}
- --lua-suffix=jit)
+ --with-lua-interpreter=luajit)
+ endif()
+
+ # Get LUA_VERSION used with rocks output.
+ if(LUAJIT_FOUND)
+ set(LUA_EXE "luajit")
+ else()
+ set(LUA_EXE "lua")
+ endif()
+ execute_process(
+ COMMAND ${LUA_EXE} -e "print(string.sub(_VERSION, 5))"
+ OUTPUT_VARIABLE LUA_VERSION
+ ERROR_VARIABLE ERR
+ RESULT_VARIABLE RES)
+ if(NOT RES EQUAL 0)
+ message(FATAL_ERROR "Could not get LUA_VERSION with ${LUA_EXE}: ${ERR}")
endif()
endif()
@@ -111,7 +129,7 @@ if(USE_BUNDLED_LUAJIT)
elseif(USE_BUNDLED_LUA)
add_dependencies(luarocks lua)
endif()
-set(ROCKS_DIR ${HOSTDEPS_LIB_DIR}/luarocks/rocks)
+set(ROCKS_DIR ${HOSTDEPS_LIB_DIR}/luarocks/rocks-${LUA_VERSION})
# mpack
add_custom_command(OUTPUT ${ROCKS_DIR}/mpack