Navigation Menu

Skip to content

Commit

Permalink
Improve Lua handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire committed Jun 4, 2018
1 parent a630a68 commit fc3f521
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 36 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Expand Up @@ -76,9 +76,9 @@ IF(WIN32)
MESSAGE(FATAL_ERROR "Unknown platform for sizeof(void*)=${CMAKE_SIZEOF_VOID_P}")
ENDIF ()
ELSE()
IF("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i386" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686")
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "i.86")
SET(PLATFORM_ARCH "i386")
ELSEIF("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "amd64" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64")
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "amd64|AMD64|x86_64")
SET(PLATFORM_ARCH "x86_64")
ELSEIF(("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "universal" OR "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "") AND APPLE)
SET(PLATFORM_ARCH "universal")
Expand Down
4 changes: 1 addition & 3 deletions cmake/toolchains/c.linux.i386.cmake
Expand Up @@ -11,9 +11,7 @@ SET(CMAKE_RANLIB i686-pc-linux-gnu-ranlib CACHE PATH "" FORCE)
SET(CMAKE_AR i686-pc-linux-gnu-ar CACHE PATH "" FORCE)

# set search prefix
SET(CMAKE_PREFIX_PATH "/usr/i686-pc-linux-gnu")
SET(CMAKE_FIND_ROOT_PATH ${CMAKE_PREFIX_PATH})
SET(BOOST_ROOT ${CMAKE_PREFIX_PATH})
SET(CMAKE_FIND_ROOT_PATH "/usr/i686-pc-linux-gnu")

# search for programs in the build host directories
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
65 changes: 34 additions & 31 deletions src/libGamedata/CMakeLists.txt
Expand Up @@ -15,40 +15,43 @@ SOURCE_GROUP(other FILES ${SOURCES_OTHER})
# LUA
################################################################################

# If not set we set hints for the LUA library. Those can be overwritten by
# setting CMAKE_FIND_ROOT_PATH properly
# Note: We only set those for the libraries we use for official builds. Normally
# those should be on the build server but we make them available here for convenience.
# Here we set hints to lua libraries used for official builds Normally those should be
# on the build server but we make them available here for convenience.
# As this will be appended to CMAKE_PREFIX_PATH one can use other version by setting
# that appropriately

if(NOT ENV{LUA_DIR})
if(NOT EXISTS "${CMAKE_SOURCE_DIR}/contrib/lua/include/lua.h")
message(WARNING "Could not find lua.h in contrib")
endif()
set(_contrib_lua_path ${CMAKE_SOURCE_DIR}/contrib/lua)

set(LUA_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/contrib/lua/include)
if(MSVC)
# Library is in contrib archive which is in prefix path.
# We just need the includes (which we did not duplicate in the msvc-contrib
list(APPEND CMAKE_PREFIX_PATH ${_contrib_lua_path})
elseif(WIN32 OR CYGWIN)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(_contrib_lua_libpath ${_contrib_lua_path}/win64)
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(_contrib_lua_libpath ${_contrib_lua_path}/win32)
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "i.86")
set(_contrib_lua_libpath ${_contrib_lua_path}/lin32)
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "amd64|AMD64|x86_64")
set(_contrib_lua_libpath ${_contrib_lua_path}/lin64)
endif()
elseif(APPLE)
set(_contrib_lua_libpath ${_contrib_lua_path}/mac)
endif()

if(MSVC)
# Library is in contrib archive which is in prefix path.
# We just need to the includes to be found
list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_SOURCE_DIR}/contrib/lua")
elseif(WIN32 OR CYGWIN)
list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_SOURCE_DIR}/contrib/lua")
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(ENV{LUA_DIR} "${CMAKE_SOURCE_DIR}/contrib/lua/win64")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(ENV{LUA_DIR} "${CMAKE_SOURCE_DIR}/contrib/lua/win32")
endif()
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
if(${CMAKE_SYSTEM_PROCESSOR} MATCHES "i.86")
list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_SOURCE_DIR}/contrib/lua")
set(ENV{LUA_DIR} "${CMAKE_SOURCE_DIR}/contrib/lua/lin32")
elseif(${CMAKE_SYSTEM_PROCESSOR} MATCHES "amd64|AMD64|x86_64")
list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_SOURCE_DIR}/contrib/lua")
set(ENV{LUA_DIR} "${CMAKE_SOURCE_DIR}/contrib/lua/lin64")
endif()
elseif(APPLE)
list(APPEND CMAKE_FIND_ROOT_PATH "${CMAKE_SOURCE_DIR}/contrib/lua")
set(ENV{LUA_DIR} "${CMAKE_SOURCE_DIR}/contrib/lua/mac")
# Set only if we have a library for this arch
if(_contrib_lua_libpath)
if(NOT EXISTS ${_contrib_lua_path}/include/lua.h)
message(WARNING "Could not find lua.h in contrib")
endif()
# For cross compilation we must set CMAKE_FIND_ROOT_PATH instead
if(CMAKE_CROSSCOMPILING)
list(APPEND CMAKE_FIND_ROOT_PATH ${_contrib_lua_path} ${_contrib_lua_libpath})
else()
list(APPEND CMAKE_PREFIX_PATH ${_contrib_lua_path} ${_contrib_lua_libpath})
endif()
endif()

Expand Down

0 comments on commit fc3f521

Please sign in to comment.