Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/torch/threads-ffi.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRonan Collobert <locronan@fb.com>2017-04-19 08:31:03 +0300
committerRonan Collobert <locronan@fb.com>2017-04-19 08:31:03 +0300
commitac9cf106d55f3c2441064d79162b1cb9a8b29189 (patch)
treec31a187bb5460695f0be2dbbc770df805ce1bc8b
parentd371549d4532a77beb935e20540d2ecbb72d0a8f (diff)
luaL_setfuncs detection more robust
-rw-r--r--CMakeLists.txt14
-rw-r--r--lib/init.c2
-rw-r--r--rocks/threads-scm-1.rockspec2
3 files changed, 16 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1e39a8e..c90fc76 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -20,6 +20,20 @@ set(luasrc
safe.lua
)
+set(CMAKE_REQUIRED_INCLUDES ${LUA_INCDIR})
+include(CheckCSourceCompiles)
+check_c_source_compiles("
+#include <lauxlib.h>
+int main()
+{
+ long i = sizeof(&luaL_setfuncs);
+ return 0;
+}
+" HAS_LUAL_SETFUNCS)
+if(HAS_LUAL_SETFUNCS)
+ add_definitions(-DHAS_LUAL_SETFUNCS)
+endif()
+
ADD_LIBRARY(threadsmain MODULE lib/thread-main.c)
IF(APPLE)
SET_TARGET_PROPERTIES(threadsmain PROPERTIES
diff --git a/lib/init.c b/lib/init.c
index 021f38c..be88263 100644
--- a/lib/init.c
+++ b/lib/init.c
@@ -1,7 +1,7 @@
#include <lua.h>
#include <lauxlib.h>
-#if LUA_VERSION_NUM == 501
+#ifndef HAS_LUAL_SETFUNCS
static void luaL_setfuncs(lua_State *L, const luaL_Reg *l, int nup)
{
luaL_checkstack(L, nup+1, "too many upvalues");
diff --git a/rocks/threads-scm-1.rockspec b/rocks/threads-scm-1.rockspec
index 9765d4a..294ff62 100644
--- a/rocks/threads-scm-1.rockspec
+++ b/rocks/threads-scm-1.rockspec
@@ -23,7 +23,7 @@ dependencies = {
build = {
type = "command",
build_command = [[
-cmake -E make_directory build && cd build && cmake .. -DLUALIB=$(LUALIB) -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)" && $(MAKE)
+cmake -E make_directory build && cd build && cmake .. -DLUALIB=$(LUALIB) -DLUA_INCDIR=$(LUA_INCDIR) -DCMAKE_BUILD_TYPE=Release -DCMAKE_PREFIX_PATH="$(LUA_BINDIR)/.." -DCMAKE_INSTALL_PREFIX="$(PREFIX)" && $(MAKE)
]],
platforms = {
windows = {