summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattes D <github@xoft.cz>2014-07-01 08:54:44 +0200
committerMattes D <github@xoft.cz>2014-07-01 08:54:44 +0200
commit24c86df12ecf69ae3ddaf707b2116b73c45402cc (patch)
tree92fe7519642865c344f5efcd974208ac11daea2a
parentFixed cFile compilation under MinGW. (diff)
parentProper sqlite dependency fix. (diff)
downloadcuberite-24c86df12ecf69ae3ddaf707b2116b73c45402cc.tar
cuberite-24c86df12ecf69ae3ddaf707b2116b73c45402cc.tar.gz
cuberite-24c86df12ecf69ae3ddaf707b2116b73c45402cc.tar.bz2
cuberite-24c86df12ecf69ae3ddaf707b2116b73c45402cc.tar.lz
cuberite-24c86df12ecf69ae3ddaf707b2116b73c45402cc.tar.xz
cuberite-24c86df12ecf69ae3ddaf707b2116b73c45402cc.tar.zst
cuberite-24c86df12ecf69ae3ddaf707b2116b73c45402cc.zip
Diffstat (limited to '')
-rw-r--r--.gitignore1
-rw-r--r--lib/lua/CMakeLists.txt12
-rw-r--r--lib/sqlite/CMakeLists.txt9
-rw-r--r--lib/tolua++/CMakeLists.txt1
-rw-r--r--src/CMakeLists.txt2
-rw-r--r--src/Globals.h21
6 files changed, 33 insertions, 13 deletions
diff --git a/.gitignore b/.gitignore
index 859ef28ea..4a319c5ef 100644
--- a/.gitignore
+++ b/.gitignore
@@ -26,6 +26,7 @@ cloc.xsl
## Eclipse
.cproject
.project
+*.cbp
# world inside source
ChunkWorx.ini
diff --git a/lib/lua/CMakeLists.txt b/lib/lua/CMakeLists.txt
index 6e5e0f565..0a04d1ee6 100644
--- a/lib/lua/CMakeLists.txt
+++ b/lib/lua/CMakeLists.txt
@@ -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)
diff --git a/lib/sqlite/CMakeLists.txt b/lib/sqlite/CMakeLists.txt
index 9add2280b..993dac146 100644
--- a/lib/sqlite/CMakeLists.txt
+++ b/lib/sqlite/CMakeLists.txt
@@ -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})
diff --git a/lib/tolua++/CMakeLists.txt b/lib/tolua++/CMakeLists.txt
index 44a4f1c6f..12054323b 100644
--- a/lib/tolua++/CMakeLists.txt
+++ b/lib/tolua++/CMakeLists.txt
@@ -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)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 2f4d6ea13..b1b880b7b 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -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)
diff --git a/src/Globals.h b/src/Globals.h
index c5768facf..0c11429bd 100644
--- a/src/Globals.h
+++ b/src/Globals.h
@@ -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__))