Fix broken cross-compiling

master
Sfan5 2014-02-16 08:07:57 +01:00
parent c163859057
commit 4585fba98b
1 changed files with 30 additions and 25 deletions

View File

@ -217,34 +217,39 @@ endif (NOT DISABLE_LUAJIT)
set(USE_LUAJIT 0) set(USE_LUAJIT 0)
if(LUA_LIBRARY AND LUA_INCLUDE_DIR) if(LUA_LIBRARY AND LUA_INCLUDE_DIR)
message (STATUS "LuaJIT found, checking for broken versions...") message (STATUS "LuaJIT found, checking for broken versions...")
set(BACKUP_REQUIRED_INCS CMAKE_REQUIRED_INCLUDES) if(CMAKE_CROSSCOMPILING)
set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES} ${LUA_INCLUDE_DIR}") message(WARNING "Cross-compiling enabled, assuming LuaJIT is not broken")
CHECK_C_SOURCE_RUNS(" set(VALID_LUAJIT_VERSION 1)
#include <luajit.h> elseif(CMAKE_CROSSCOMPILING)
#include <stdio.h> set(BACKUP_REQUIRED_INCS CMAKE_REQUIRED_INCLUDES)
#include <string.h> set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES} ${LUA_INCLUDE_DIR}")
CHECK_C_SOURCE_RUNS("
#include <luajit.h>
#include <stdio.h>
#include <string.h>
static char** broken_luajit_versions = (char *[]) { static char** broken_luajit_versions = (char *[]) {
\"LuaJIT 2.0.0-beta7\", \"LuaJIT 2.0.0-beta7\",
\"LuaJIT 2.0.0-beta6\", \"LuaJIT 2.0.0-beta6\",
\"LuaJIT 2.0.0-beta5\", \"LuaJIT 2.0.0-beta5\",
\"LuaJIT 2.0.0-beta4\", \"LuaJIT 2.0.0-beta4\",
\"LuaJIT 2.0.0-beta3\", \"LuaJIT 2.0.0-beta3\",
\"LuaJIT 2.0.0-beta2\", \"LuaJIT 2.0.0-beta2\",
\"LuaJIT 2.0.0-beta1\" \"LuaJIT 2.0.0-beta1\"
}; };
int main(int argc,char** argv) { int main(int argc,char** argv) {
unsigned int i = 0; unsigned int i = 0;
for (i=0; i < sizeof(broken_luajit_versions); i++) { for (i=0; i < sizeof(broken_luajit_versions); i++) {
if (strcmp(LUAJIT_VERSION,broken_luajit_versions[i]) == 0) { if (strcmp(LUAJIT_VERSION,broken_luajit_versions[i]) == 0) {
return 1; return 1;
}
} }
return 0;
} }
return 0; "
} VALID_LUAJIT_VERSION)
" set(CMAKE_REQUIRED_INCLUDES BACKUP_REQUIRED_INCS)
VALID_LUAJIT_VERSION) endif(CMAKE_CROSSCOMPILING)
set(CMAKE_REQUIRED_INCLUDES BACKUP_REQUIRED_INCS)
if (VALID_LUAJIT_VERSION) if (VALID_LUAJIT_VERSION)
message (STATUS "LuaJIT version ok") message (STATUS "LuaJIT version ok")
set(USE_LUAJIT 1) set(USE_LUAJIT 1)