1
0

Fixed lua compilation under MinGW.

This commit is contained in:
Mattes D 2014-06-30 21:27:13 +02:00
parent a5a0533d79
commit ac01a8e483

View File

@ -11,21 +11,16 @@ file(GLOB SOURCE
list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/src/lua.c" "${PROJECT_SOURCE_DIR}/src/luac.c") list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/src/lua.c" "${PROJECT_SOURCE_DIR}/src/luac.c")
# add headers to MSVC project files: # add headers to MSVC project files:
if (WIN32) if (MSVC)
file(GLOB HEADERS "src/*.h") file(GLOB HEADERS "src/*.h")
list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/src/lua.h" "${PROJECT_SOURCE_DIR}/src/luac.h") list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/src/lua.h" "${PROJECT_SOURCE_DIR}/src/luac.h")
set(SOURCE ${SOURCE} ${HEADERS}) set(SOURCE ${SOURCE} ${HEADERS})
source_group("Sources" FILES ${SOURCE}) source_group("Sources" FILES ${SOURCE})
endif() endif()
# Lua needs to be linked dynamically on Windows and statically on *nix, so that LuaRocks work # Lua needs to be linked dynamically on Windows and statically on *nix, so that LuaRocks work
if (WIN32) if (WIN32)
#for compiliers other than msvc we need to tell lua that its building as a dll
if (NOT MSVC)
add_flags_cxx(-DLUA_BUILD_AS_DLL=1)
endif()
add_library(lua SHARED ${SOURCE}) add_library(lua SHARED ${SOURCE})
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/MCServer) set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/MCServer)
@ -53,7 +48,7 @@ if (WIN32)
) )
endif() endif()
set_target_properties(lua PROPERTIES OUTPUT_NAME "lua51") set_target_properties(lua PROPERTIES OUTPUT_NAME "lua51" PREFIX "")
# NOTE: The DLL for each configuration is stored at the same place, thus overwriting each other. # NOTE: The DLL for each configuration is stored at the same place, thus overwriting each other.
# This is known, however such behavior is needed for LuaRocks - they always load "lua5.1.dll" or "lua51.dll" # This is known, however such behavior is needed for LuaRocks - they always load "lua5.1.dll" or "lua51.dll"
@ -63,6 +58,7 @@ else()
add_library(lua ${SOURCE}) add_library(lua ${SOURCE})
endif() endif()
# Tell Lua what dynamic loader to use (for LuaRocks): # Tell Lua what dynamic loader to use (for LuaRocks):
if (UNIX) if (UNIX)
add_definitions(-DLUA_USE_DLOPEN) add_definitions(-DLUA_USE_DLOPEN)