From ac01a8e483f84d94f57c38d6882acd31d7e0fc91 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Mon, 30 Jun 2014 21:27:13 +0200 Subject: Fixed lua compilation under MinGW. --- lib/lua/CMakeLists.txt | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) 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) -- cgit v1.2.3 From f9f3f7eac59c8de2bcb3f878849d355d5b9e3c9a Mon Sep 17 00:00:00 2001 From: Mattes D Date: Mon, 30 Jun 2014 21:58:23 +0200 Subject: Fixed size_t printfing under MinGW. --- src/Globals.h | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) 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__)) -- cgit v1.2.3 From 84272fb155d48f999441b7aaba9ca8b21584ad21 Mon Sep 17 00:00:00 2001 From: worktycho Date: Mon, 30 Jun 2014 22:21:07 +0100 Subject: Added dependecy of tolualib on lua --- lib/tolua++/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/tolua++/CMakeLists.txt b/lib/tolua++/CMakeLists.txt index 44a4f1c6f..56ffc0dc1 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_library(tolualib lua) #m is the standard math librarys if(UNIX) -- cgit v1.2.3 From 0fb236bfe46782dc4e7c5b76db7b7c25671e3d66 Mon Sep 17 00:00:00 2001 From: worktycho Date: Mon, 30 Jun 2014 22:21:22 +0100 Subject: typo --- lib/tolua++/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/tolua++/CMakeLists.txt b/lib/tolua++/CMakeLists.txt index 56ffc0dc1..12054323b 100644 --- a/lib/tolua++/CMakeLists.txt +++ b/lib/tolua++/CMakeLists.txt @@ -46,7 +46,7 @@ file(GLOB BIN_SOURCE add_executable(tolua ${BIN_SOURCE}) add_library(tolualib ${LIB_SOURCE}) -target_link_library(tolualib lua) +target_link_libraries(tolualib lua) #m is the standard math librarys if(UNIX) -- cgit v1.2.3 From 4f60f5aef4517d6d3eaf2ea9f7aae30e6a97da25 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 1 Jul 2014 06:40:38 +0200 Subject: Fixed linking order under MinGW. Ref.: #1044 --- lib/sqlite/CMakeLists.txt | 10 ++++++++-- src/CMakeLists.txt | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/sqlite/CMakeLists.txt b/lib/sqlite/CMakeLists.txt index 9add2280b..48bb5f15c 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}) @@ -25,5 +31,5 @@ endif() add_library(sqlite ${SOURCE}) if (UNIX) - target_link_libraries(sqlite ${DYNAMIC_LOADER}) + target_link_libraries(sqlite ${DYNAMIC_LOADER} lua) endif() 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) -- cgit v1.2.3 From 194678100a81134eeabb720d84fd987ef35946c6 Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 1 Jul 2014 06:41:35 +0200 Subject: Ignore Code:::Blocks project files. --- .gitignore | 1 + 1 file changed, 1 insertion(+) 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 -- cgit v1.2.3 From eb8244f1c286ec33c30ba205eb5cebc1f2a0430d Mon Sep 17 00:00:00 2001 From: Mattes D Date: Tue, 1 Jul 2014 08:01:39 +0200 Subject: Proper sqlite dependency fix. --- lib/sqlite/CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/sqlite/CMakeLists.txt b/lib/sqlite/CMakeLists.txt index 48bb5f15c..993dac146 100644 --- a/lib/sqlite/CMakeLists.txt +++ b/lib/sqlite/CMakeLists.txt @@ -29,7 +29,8 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD") endif() add_library(sqlite ${SOURCE}) +target_link_libraries(sqlite lua) if (UNIX) - target_link_libraries(sqlite ${DYNAMIC_LOADER} lua) + target_link_libraries(sqlite ${DYNAMIC_LOADER}) endif() -- cgit v1.2.3