1
0
Fork 0

Merge pull request #1140 from mc-server/FixMingw

Fix mingw
This commit is contained in:
Mattes D 2014-07-01 08:54:44 +02:00
commit 24c86df12e
6 changed files with 33 additions and 13 deletions

1
.gitignore vendored
View File

@ -26,6 +26,7 @@ cloc.xsl
## Eclipse
.cproject
.project
*.cbp
# world inside source
ChunkWorx.ini

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")
# add headers to MSVC project files:
if (WIN32)
if (MSVC)
file(GLOB HEADERS "src/*.h")
list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/src/lua.h" "${PROJECT_SOURCE_DIR}/src/luac.h")
set(SOURCE ${SOURCE} ${HEADERS})
source_group("Sources" FILES ${SOURCE})
endif()
# Lua needs to be linked dynamically on Windows and statically on *nix, so that LuaRocks work
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})
set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/MCServer)
@ -53,7 +48,7 @@ if (WIN32)
)
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.
# 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})
endif()
# Tell Lua what dynamic loader to use (for LuaRocks):
if (UNIX)
add_definitions(-DLUA_USE_DLOPEN)

View File

@ -9,8 +9,14 @@ file(GLOB SOURCE
)
# add headers to MSVC project files:
# Lua is required as a DLL for LuaSQLite:
if (WIN32)
add_definitions(-DLUA_BUILD_AS_DLL)
endif()
# add headers to MSVC project files:
if (MSVC)
file(GLOB HEADERS "src/*.h")
list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/src/lua.h" "${PROJECT_SOURCE_DIR}/src/luac.h")
set(SOURCE ${SOURCE} ${HEADERS})
@ -23,6 +29,7 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
endif()
add_library(sqlite ${SOURCE})
target_link_libraries(sqlite lua)
if (UNIX)
target_link_libraries(sqlite ${DYNAMIC_LOADER})

View File

@ -46,6 +46,7 @@ file(GLOB BIN_SOURCE
add_executable(tolua ${BIN_SOURCE})
add_library(tolualib ${LIB_SOURCE})
target_link_libraries(tolualib lua)
#m is the standard math librarys
if(UNIX)

View File

@ -261,4 +261,4 @@ endif ()
if (WIN32)
target_link_libraries(${EXECUTABLE} expat tolualib ws2_32.lib Psapi.lib)
endif()
target_link_libraries(${EXECUTABLE} luaexpat iniFile jsoncpp polarssl zlib lua sqlite)
target_link_libraries(${EXECUTABLE} luaexpat iniFile jsoncpp polarssl zlib sqlite lua)

View File

@ -71,9 +71,24 @@
#define FORMATSTRING(formatIndex, va_argsIndex) __attribute__((format (printf, formatIndex, va_argsIndex)))
#define SIZE_T_FMT "%zu"
#define SIZE_T_FMT_PRECISION(x) "%" #x "zu"
#define SIZE_T_FMT_HEX "%zx"
#if defined(_WIN32)
// We're compiling on MinGW, which uses an old MSVCRT library that has no support for size_t printfing.
// We need direct size formats:
#if defined(_WIN64)
#define SIZE_T_FMT "%I64u"
#define SIZE_T_FMT_PRECISION(x) "%" #x "I64u"
#define SIZE_T_FMT_HEX "%I64x"
#else
#define SIZE_T_FMT "%u"
#define SIZE_T_FMT_PRECISION(x) "%" #x "u"
#define SIZE_T_FMT_HEX "%x"
#endif
#else
// We're compiling on Linux, so we can use libc's size_t printf format:
#define SIZE_T_FMT "%zu"
#define SIZE_T_FMT_PRECISION(x) "%" #x "zu"
#define SIZE_T_FMT_HEX "%zx"
#endif
#define NORETURN __attribute((__noreturn__))