diff options
Diffstat (limited to 'src')
32 files changed, 333 insertions, 545 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2ce108681..b33bea87b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,7 +1,8 @@ -project(minetest) -cmake_minimum_required( VERSION 2.6 ) +cmake_minimum_required(VERSION 2.6) + +project(Minetest) +string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LOWER) -INCLUDE(CheckCSourceRuns) INCLUDE(CheckIncludeFiles) # Add custom SemiDebug build mode @@ -22,83 +23,69 @@ set(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING FORCE ) + # Set some random things default to not being visible in the GUI mark_as_advanced(EXECUTABLE_OUTPUT_PATH LIBRARY_OUTPUT_PATH) -option(ENABLE_CURL "Enable cURL support for fetching media" 1) -if (NOT ENABLE_CURL) - mark_as_advanced(CLEAR CURL_LIBRARY CURL_INCLUDE_DIR) -endif(NOT ENABLE_CURL) +option(ENABLE_CURL "Enable cURL support for fetching media" TRUE) +set(USE_CURL FALSE) -if( ENABLE_CURL ) +if(ENABLE_CURL) find_package(CURL) -endif( ENABLE_CURL ) -set(USE_CURL 0) -if (CURL_FOUND AND ENABLE_CURL) - message(STATUS "cURL support enabled") - set(USE_CURL 1) -endif(CURL_FOUND AND ENABLE_CURL) + if (CURL_FOUND) + message(STATUS "cURL support enabled.") + set(USE_CURL TRUE) + endif() +else() + mark_as_advanced(CLEAR CURL_LIBRARY CURL_INCLUDE_DIR) +endif() -# user-visible option to enable/disable gettext usage -OPTION(ENABLE_GETTEXT "Use GetText for internationalization" 0) -# this is only set to 1 if gettext is enabled _and_ available -set(USE_GETTEXT 0) +option(ENABLE_GETTEXT "Use GetText for internationalization" FALSE) +set(USE_GETTEXT FALSE) if(ENABLE_GETTEXT) find_package(GettextLib) + if(GETTEXT_FOUND) + if(WIN32) + message(STATUS "GetText library: ${GETTEXT_LIBRARY}") + message(STATUS "GetText DLL: ${GETTEXT_DLL}") + message(STATUS "GetText iconv DLL: ${GETTEXT_ICONV_DLL}") + endif() + set(USE_GETTEXT TRUE) + message(STATUS "GetText enabled; locales found: ${GETTEXT_AVAILABLE_LOCALES}") + endif(GETTEXT_FOUND) else() - MARK_AS_ADVANCED(GETTEXT_ICONV_DLL GETTEXT_INCLUDE_DIR GETTEXT_LIBRARY GETTEXT_MSGFMT) + mark_as_advanced(GETTEXT_ICONV_DLL GETTEXT_INCLUDE_DIR GETTEXT_LIBRARY GETTEXT_MSGFMT) + message(STATUS "GetText disabled.") endif() -if(GETTEXT_FOUND AND ENABLE_GETTEXT) - message(STATUS "gettext include path: ${GETTEXT_INCLUDE_DIR}") - message(STATUS "gettext msgfmt path: ${GETTEXT_MSGFMT}") - if(WIN32) - message(STATUS "gettext library: ${GETTEXT_LIBRARY}") - message(STATUS "gettext dll: ${GETTEXT_DLL}") - message(STATUS "gettext iconv dll: ${GETTEXT_ICONV_DLL}") - endif() - set(USE_GETTEXT 1) - message(STATUS "GetText enabled; locales found: ${GETTEXT_AVAILABLE_LOCALES}") -elseif(GETTEXT_FOUND AND NOT ENABLE_GETTEXT) - MESSAGE(STATUS "GetText found but disabled;") -else(GETTEXT_FOUND AND ENABLE_GETTEXT) - message(STATUS "GetText disabled") -endif(GETTEXT_FOUND AND ENABLE_GETTEXT) - -# user visible option to enable/disable sound -OPTION(ENABLE_SOUND "Enable sound" ON) - -# this is only set to 1 if sound is enabled _and_ available -set(USE_SOUND 0) -set(SOUND_PROBLEM 0) - -if(ENABLE_SOUND AND BUILD_CLIENT) + +option(ENABLE_SOUND "Enable sound" TRUE) +set(USE_SOUND FALSE) + +if(BUILD_CLIENT AND ENABLE_SOUND) # Sound libraries find_package(OpenAL) find_package(Vorbis) if(NOT OPENAL_FOUND) message(STATUS "Sound enabled, but OpenAL not found!") - set(SOUND_PROBLEM 1) - MARK_AS_ADVANCED(CLEAR OPENAL_LIBRARY OPENAL_INCLUDE_DIR) + mark_as_advanced(CLEAR OPENAL_LIBRARY OPENAL_INCLUDE_DIR) endif() if(NOT VORBIS_FOUND) message(STATUS "Sound enabled, but Vorbis libraries not found!") - set(SOUND_PROBLEM 1) - MARK_AS_ADVANCED(CLEAR OGG_INCLUDE_DIR VORBIS_INCLUDE_DIR OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY) + mark_as_advanced(CLEAR OGG_INCLUDE_DIR VORBIS_INCLUDE_DIR OGG_LIBRARY VORBIS_LIBRARY VORBISFILE_LIBRARY) endif() if(OPENAL_FOUND AND VORBIS_FOUND) - set(USE_SOUND 1) - message(STATUS "Sound enabled") + set(USE_SOUND TRUE) + message(STATUS "Sound enabled.") + else() + message(FATAL_ERROR "Sound enabled, but cannot be used.\n" + "To continue, either fill in the required paths or disable sound. (-DENABLE_SOUND=0)") endif() -endif(ENABLE_SOUND AND BUILD_CLIENT) - -if(SOUND_PROBLEM) - message(FATAL_ERROR "Sound enabled, but cannot be used.\n" - "To continue, either fill in the required paths or disable sound. (-DENABLE_SOUND=0)") endif() + if(USE_SOUND) set(sound_SRCS sound_openal.cpp) set(SOUND_INCLUDE_DIRS @@ -112,18 +99,87 @@ if(USE_SOUND) ) endif() -option(ENABLE_FREETYPE "Enable freetype2 (truetype fonts and basic unicode support)" OFF) -set(USE_FREETYPE 0) + +option(ENABLE_GLES "Enable OpenGL ES support" FALSE) +mark_as_advanced(ENABLE_GLES) +if(ENABLE_GLES) + find_package(OpenGLES2) +endif() + + +option(ENABLE_FREETYPE "Enable FreeType2 (TrueType fonts and basic unicode support)" TRUE) +set(USE_FREETYPE FALSE) + if(ENABLE_FREETYPE) - set(USE_FREETYPE 1) + if(UNIX) + include(FindPkgConfig) + if(PKG_CONFIG_FOUND) + pkg_check_modules(FREETYPE QUIET freetype2) + if(FREETYPE_FOUND) + SET(FREETYPE_PKGCONFIG_FOUND TRUE) + SET(FREETYPE_LIBRARY ${FREETYPE_LIBRARIES}) + # Because CMake is idiotic + string(REPLACE ";" " " FREETYPE_CFLAGS_STR ${FREETYPE_CFLAGS}) + string(REPLACE ";" " " FREETYPE_LDFLAGS_STR ${FREETYPE_LDFLAGS}) + endif(FREETYPE_FOUND) + endif(PKG_CONFIG_FOUND) + endif(UNIX) + if(NOT FREETYPE_FOUND) + find_package(Freetype) + endif() + if(FREETYPE_FOUND) + set(USE_FREETYPE TRUE) + set(CGUITTFONT_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cguittfont") + set(CGUITTFONT_LIBRARY cguittfont) + endif() endif(ENABLE_FREETYPE) + +find_package(Lua REQUIRED) + + +option(ENABLE_LEVELDB "Enable LevelDB backend" TRUE) +set(USE_LEVELDB FALSE) + +if(ENABLE_LEVELDB) + find_library(LEVELDB_LIBRARY leveldb) + find_path(LEVELDB_INCLUDE_DIR db.h PATH_SUFFIXES leveldb) + if(LEVELDB_LIBRARY AND LEVELDB_INCLUDE_DIR) + set(USE_LEVELDB TRUE) + message(STATUS "LevelDB backend enabled.") + include_directories(${LEVELDB_INCLUDE_DIR}) + else() + message(STATUS "LevelDB not found!") + endif() +endif(ENABLE_LEVELDB) + + +OPTION(ENABLE_REDIS "Enable Redis backend" TRUE) +set(USE_REDIS FALSE) + +if(ENABLE_REDIS) + find_library(REDIS_LIBRARY hiredis) + find_path(REDIS_INCLUDE_DIR hiredis.h PATH_SUFFIXES hiredis) + if(REDIS_LIBRARY AND REDIS_INCLUDE_DIR) + set(USE_REDIS TRUE) + message(STATUS "Redis backend enabled.") + include_directories(${REDIS_INCLUDE_DIR}) + else(REDIS_LIBRARY AND REDIS_INCLUDE_DIR) + message(STATUS "Redis not found!") + endif(REDIS_LIBRARY AND REDIS_INCLUDE_DIR) +endif(ENABLE_REDIS) + + +find_package(SQLite3 REQUIRED) +find_package(Json REQUIRED) + + if(NOT MSVC) - set(USE_GPROF 0 CACHE BOOL "Use -pg flag for g++") + set(USE_GPROF FALSE CACHE BOOL "Use -pg flag for g++") endif() # Use cmake_config.h -add_definitions ( -DUSE_CMAKE_CONFIG_H ) +add_definitions(-DUSE_CMAKE_CONFIG_H) if(WIN32) # Windows @@ -150,7 +206,7 @@ if(WIN32) CACHE PATH "freetype include dir") set(FREETYPE_LIBRARY "${PROJECT_SOURCE_DIR}/../../freetype2/objs/win32/vc2005/freetype247.lib" CACHE FILEPATH "Path to freetype247.lib") - endif(USE_FREETYPE) + endif() if(ENABLE_SOUND) set(OPENAL_DLL "" CACHE FILEPATH "Path to OpenAL32.dll for installation (optional)") set(OGG_DLL "" CACHE FILEPATH "Path to libogg.dll for installation (optional)") @@ -166,9 +222,9 @@ else() find_package(BZip2 REQUIRED) find_package(PNG REQUIRED) if(APPLE) - FIND_LIBRARY(CARBON_LIB Carbon) - FIND_LIBRARY(COCOA_LIB Cocoa) - FIND_LIBRARY(IOKIT_LIB IOKit) + find_library(CARBON_LIB Carbon) + find_library(COCOA_LIB Cocoa) + find_library(IOKIT_LIB IOKit) mark_as_advanced( CARBON_LIB COCOA_LIB @@ -191,156 +247,14 @@ else() set(CLIENT_PLATFORM_LIBS ${CLIENT_PLATFORM_LIBS} ${XXF86VM_LIBRARY}) endif() -find_package(SQLite3 REQUIRED) -find_package(Json REQUIRED) - -option(ENABLE_GLES "Enable OpenGL ES support" 0) -mark_as_advanced(ENABLE_GLES) -if(ENABLE_GLES) - find_package(OpenGLES2) -endif(ENABLE_GLES) - -if(USE_FREETYPE) - if(UNIX) - include(FindPkgConfig) - if(PKG_CONFIG_FOUND) - pkg_check_modules(FREETYPE QUIET freetype2) - if(FREETYPE_FOUND) - SET(FREETYPE_PKGCONFIG_FOUND TRUE) - SET(FREETYPE_LIBRARY ${FREETYPE_LIBRARIES}) - # because cmake is idiotic - string(REPLACE ";" " " FREETYPE_CFLAGS_STR ${FREETYPE_CFLAGS}) - string(REPLACE ";" " " FREETYPE_LDFLAGS_STR ${FREETYPE_LDFLAGS}) - endif(FREETYPE_FOUND) - endif(PKG_CONFIG_FOUND) - endif(UNIX) - if(NOT FREETYPE_FOUND) - find_package(Freetype REQUIRED) - endif(NOT FREETYPE_FOUND) - set(CGUITTFONT_INCLUDE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cguittfont") - set(CGUITTFONT_LIBRARY cguittfont) -endif(USE_FREETYPE) - -if (NOT DISABLE_LUAJIT) - find_library(LUA_LIBRARY luajit - NAMES luajit-5.1) - find_path(LUA_INCLUDE_DIR luajit.h - NAMES luajit.h - PATH_SUFFIXES luajit-2.0) - message (STATUS "LuaJIT library: ${LUA_LIBRARY}") - message (STATUS "LuaJIT headers: ${LUA_INCLUDE_DIR}") -else (NOT ${DISABLE_LUAJIT} MATCHES "1") - message (STATUS "LuaJIT detection disabled! (DISABLE_LUAJIT=1)") - set(LUA_LIBRARY "") - set(LUA_INCLUDE_DIR "") -endif (NOT DISABLE_LUAJIT) - -set(USE_LUAJIT 0) -if(LUA_LIBRARY AND LUA_INCLUDE_DIR) - message (STATUS "LuaJIT found, checking for broken versions...") - if(CMAKE_CROSSCOMPILING) - message(WARNING "Cross-compiling enabled, assuming LuaJIT is not broken") - set(VALID_LUAJIT_VERSION 1) - else(CMAKE_CROSSCOMPILING) - set(BACKUP_REQUIRED_INCS CMAKE_REQUIRED_INCLUDES) - set(CMAKE_REQUIRED_INCLUDES "${CMAKE_REQUIRED_INCLUDES} ${LUA_INCLUDE_DIR}") - CHECK_C_SOURCE_RUNS(" - #include <luajit.h> - #include <stdio.h> - #include <string.h> - - #define ARRAYSIZE(a) (sizeof(a) / sizeof((a)[0])) - - static char *broken_luajit_versions[] = { - \"LuaJIT 2.0.0-beta7\", - \"LuaJIT 2.0.0-beta6\", - \"LuaJIT 2.0.0-beta5\", - \"LuaJIT 2.0.0-beta4\", - \"LuaJIT 2.0.0-beta3\", - \"LuaJIT 2.0.0-beta2\", - \"LuaJIT 2.0.0-beta1\" - }; - - int main(int argc, char *argv[]) { - unsigned int i; - for (i = 0; i < ARRAYSIZE(broken_luajit_versions); i++) { - if (strcmp(LUAJIT_VERSION, broken_luajit_versions[i]) == 0) { - return 1; - } - } - return 0; - } - " - VALID_LUAJIT_VERSION) - set(CMAKE_REQUIRED_INCLUDES BACKUP_REQUIRED_INCS) - endif(CMAKE_CROSSCOMPILING) - if (VALID_LUAJIT_VERSION) - message (STATUS "LuaJIT version ok") - set(USE_LUAJIT 1) - else (VALID_LUAJIT_VERSION) - message (STATUS "LuaJIT versions till 2.0.0beta7 known to be broken, update to at least beta8") - set(USE_LUAJIT 0) - endif (VALID_LUAJIT_VERSION) -endif (LUA_LIBRARY AND LUA_INCLUDE_DIR) - -if(NOT USE_LUAJIT) - message (STATUS "LuaJIT not found, using bundled Lua.") - set(LUA_INCLUDE_DIR "${PROJECT_SOURCE_DIR}/lua/src") - set(LUA_LIBRARY "lua") - add_subdirectory(lua) -endif(NOT USE_LUAJIT) - -mark_as_advanced(LUA_LIBRARY) -mark_as_advanced(LUA_INCLUDE_DIR) - -set(USE_LEVELDB 0) - -OPTION(ENABLE_LEVELDB "Enable LevelDB backend") - -if(ENABLE_LEVELDB) - find_library(LEVELDB_LIBRARY leveldb) - find_path(LEVELDB_INCLUDE_DIR db.h PATH_SUFFIXES leveldb) - message (STATUS "LevelDB library: ${LEVELDB_LIBRARY}") - message (STATUS "LevelDB headers: ${LEVELDB_INCLUDE_DIR}") - if(LEVELDB_LIBRARY AND LEVELDB_INCLUDE_DIR) - set(USE_LEVELDB 1) - message(STATUS "LevelDB backend enabled") - include_directories(${LEVELDB_INCLUDE_DIR}) - else(LEVELDB_LIBRARY AND LEVELDB_INCLUDE_DIR) - set(USE_LEVELDB 0) - message(STATUS "LevelDB not found!") - endif(LEVELDB_LIBRARY AND LEVELDB_INCLUDE_DIR) -endif(ENABLE_LEVELDB) - -set(USE_REDIS 0) - -OPTION(ENABLE_REDIS "Enable redis backend" 0) - -if(ENABLE_REDIS) - find_library(REDIS_LIBRARY hiredis) - find_path(REDIS_INCLUDE_DIR hiredis.h PATH_SUFFIXES hiredis) - message(STATUS "redis library: ${REDIS_LIBRARY}") - message(STATUS "redis headers: ${REDIS_INCLUDE_DIR}") - if(REDIS_LIBRARY AND REDIS_INCLUDE_DIR) - set(USE_REDIS 1) - message(STATUS "redis backend enabled") - include_directories(${REDIS_INCLUDE_DIR}) - else(REDIS_LIBRARY AND REDIS_INCLUDE_DIR) - set(USE_REDIS 0) - message(STATUS "redis not found!") - endif(REDIS_LIBRARY AND REDIS_INCLUDE_DIR) -endif(ENABLE_REDIS) - -CHECK_INCLUDE_FILES(endian.h HAVE_ENDIAN_H) -if(NOT HAVE_ENDIAN_H) - set(HAVE_ENDIAN_H 0) -endif(NOT HAVE_ENDIAN_H) +check_include_files(endian.h HAVE_ENDIAN_H) configure_file( "${PROJECT_SOURCE_DIR}/cmake_config.h.in" "${PROJECT_BINARY_DIR}/cmake_config.h" ) + # Add a target that always rebuilds cmake_config_githash.h add_custom_target(GenerateVersion COMMAND ${CMAKE_COMMAND} @@ -351,11 +265,13 @@ add_custom_target(GenerateVersion -P "${CMAKE_SOURCE_DIR}/cmake/Modules/GenerateVersion.cmake" WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}") + add_subdirectory(jthread) add_subdirectory(network) add_subdirectory(script) add_subdirectory(util) + set (unittests_SRCS test.cpp ) @@ -437,9 +353,10 @@ set(common_SRCS ${unittests_SRCS} ) + # This gives us the icon and file version information if(WIN32) - set(WINRESOURCE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../misc/winresource.rc) + set(WINRESOURCE_FILE "${CMAKE_CURRENT_SOURCE_DIR}/../misc/winresource.rc") if(MINGW) if(NOT CMAKE_RC_COMPILER) set(CMAKE_RC_COMPILER "windres.exe") @@ -456,16 +373,16 @@ if(WIN32) endif(MINGW) endif() -# Client sources +# Client sources if (BUILD_CLIENT) add_subdirectory(client) endif(BUILD_CLIENT) -set(minetest_SRCS +set(client_SRCS + ${client_SRCS} ${common_SRCS} ${sound_SRCS} - ${client_SRCS} ${client_network_SRCS} camera.cpp chat.cpp @@ -500,16 +417,16 @@ set(minetest_SRCS shader.cpp sky.cpp wieldmesh.cpp - ${minetest_SCRIPT_SRCS} + ${client_SCRIPT_SRCS} ) -list(SORT minetest_SRCS) +list(SORT client_SRCS) # Server sources -set(minetestserver_SRCS +set(server_SRCS ${common_SRCS} main.cpp ) -list(SORT minetestserver_SRCS) +list(SORT server_SRCS) include_directories( ${PROJECT_BINARY_DIR} @@ -526,26 +443,24 @@ include_directories( ${PROJECT_SOURCE_DIR}/script ) + if(USE_FREETYPE) - include_directories( - ${FREETYPE_INCLUDE_DIRS} - ${CGUITTFONT_INCLUDE_DIR} - ) -endif(USE_FREETYPE) + include_directories(${FREETYPE_INCLUDE_DIRS} ${CGUITTFONT_INCLUDE_DIR}) +endif() if(USE_CURL) - include_directories( - ${CURL_INCLUDE_DIR} - ) -endif(USE_CURL) + include_directories(${CURL_INCLUDE_DIR}) +endif() + set(EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin") + if(BUILD_CLIENT) - add_executable(${PROJECT_NAME} ${minetest_SRCS}) - add_dependencies(${PROJECT_NAME} GenerateVersion) - set(minetest_LIBS - ${PROJECT_NAME} + add_executable(${PROJECT_NAME_LOWER} ${client_SRCS}) + add_dependencies(${PROJECT_NAME_LOWER} GenerateVersion) + set(client_LIBS + ${PROJECT_NAME_LOWER} ${ZLIB_LIBRARIES} ${IRRLICHT_LIBRARY} ${OPENGL_LIBRARIES} @@ -564,46 +479,47 @@ if(BUILD_CLIENT) ) if(APPLE) target_link_libraries( - ${minetest_LIBS} + ${client_LIBS} ${ICONV_LIBRARY} ) else() target_link_libraries( - ${minetest_LIBS} + ${client_LIBS} ) endif() if(USE_CURL) target_link_libraries( - ${PROJECT_NAME} + ${PROJECT_NAME_LOWER} ${CURL_LIBRARY} ) - endif(USE_CURL) + endif() if(USE_FREETYPE) if(FREETYPE_PKGCONFIG_FOUND) - set_target_properties(${PROJECT_NAME} + set_target_properties(${PROJECT_NAME_LOWER} PROPERTIES COMPILE_FLAGS "${FREETYPE_CFLAGS_STR}" ) - endif(FREETYPE_PKGCONFIG_FOUND) + endif() target_link_libraries( - ${PROJECT_NAME} + ${PROJECT_NAME_LOWER} ${FREETYPE_LIBRARY} ${CGUITTFONT_LIBRARY} ) - endif(USE_FREETYPE) + endif() if (USE_LEVELDB) - target_link_libraries(${PROJECT_NAME} ${LEVELDB_LIBRARY}) - endif(USE_LEVELDB) + target_link_libraries(${PROJECT_NAME_LOWER} ${LEVELDB_LIBRARY}) + endif() if (USE_REDIS) - target_link_libraries(${PROJECT_NAME} ${REDIS_LIBRARY}) - endif(USE_REDIS) + target_link_libraries(${PROJECT_NAME_LOWER} ${REDIS_LIBRARY}) + endif() endif(BUILD_CLIENT) + if(BUILD_SERVER) - add_executable(${PROJECT_NAME}server ${minetestserver_SRCS}) - add_dependencies(${PROJECT_NAME}server GenerateVersion) + add_executable(${PROJECT_NAME_LOWER}server ${server_SRCS}) + add_dependencies(${PROJECT_NAME_LOWER}server GenerateVersion) target_link_libraries( - ${PROJECT_NAME}server + ${PROJECT_NAME_LOWER}server ${ZLIB_LIBRARIES} ${SQLITE3_LIBRARY} ${JSON_LIBRARY} @@ -611,24 +527,24 @@ if(BUILD_SERVER) ${LUA_LIBRARY} ${PLATFORM_LIBS} ) + set_target_properties(${PROJECT_NAME_LOWER}server PROPERTIES + COMPILE_DEFINITIONS "SERVER") if (USE_LEVELDB) - target_link_libraries(${PROJECT_NAME}server ${LEVELDB_LIBRARY}) - endif(USE_LEVELDB) + target_link_libraries(${PROJECT_NAME_LOWER}server ${LEVELDB_LIBRARY}) + endif() if (USE_REDIS) - target_link_libraries(${PROJECT_NAME}server ${REDIS_LIBRARY}) - endif(USE_REDIS) + target_link_libraries(${PROJECT_NAME_LOWER}server ${REDIS_LIBRARY}) + endif() if(USE_CURL) target_link_libraries( - ${PROJECT_NAME}server + ${PROJECT_NAME_LOWER}server ${CURL_LIBRARY} ) - endif(USE_CURL) + endif() endif(BUILD_SERVER) -# # Set some optimizations and tweaks -# include(CheckCXXCompilerFlag) @@ -649,12 +565,6 @@ if(MSVC) # Flags for C files (sqlite) # /MT = Link statically with standard library stuff set(CMAKE_C_FLAGS_RELEASE "/O2 /Ob2 /MT") - - if(BUILD_SERVER) - set_target_properties(${PROJECT_NAME}server PROPERTIES - COMPILE_DEFINITIONS "SERVER") - endif(BUILD_SERVER) - else() # Probably GCC if(APPLE) @@ -687,20 +597,11 @@ else() if(USE_GPROF) set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -pg") endif() - - if(BUILD_SERVER) - set_target_properties(${PROJECT_NAME}server PROPERTIES - COMPILE_DEFINITIONS "SERVER") - endif(BUILD_SERVER) - endif() -#MESSAGE(STATUS "CMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}") -#MESSAGE(STATUS "CMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}") -# # Installation -# + if(WIN32) if(USE_SOUND) if(OPENAL_DLL) @@ -737,7 +638,7 @@ if(WIN32) endif() if(BUILD_CLIENT) - install(TARGETS ${PROJECT_NAME} + install(TARGETS ${PROJECT_NAME_LOWER} RUNTIME DESTINATION ${BINDIR} LIBRARY DESTINATION ${BINDIR} ARCHIVE DESTINATION ${BINDIR} @@ -755,9 +656,9 @@ if(BUILD_CLIENT) if(USE_GETTEXT) foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES}) set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE}) - set(MO_BUILD_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo") + set(MO_BUILD_PATH "${MO_BUILD_PATH}/${PROJECT_NAME_LOWER}.mo") install(FILES ${MO_BUILD_PATH} DESTINATION ${MO_DEST_PATH}) - endforeach(LOCALE ${GETTEXT_AVAILABLE_LOCALES}) + endforeach() endif() if(WIN32) @@ -771,21 +672,21 @@ if(BUILD_CLIENT) if(DEFINED GETTEXT_ICONV_DLL) install(FILES ${GETTEXT_ICONV_DLL} DESTINATION ${BINDIR}) endif() - endif(USE_GETTEXT) + endif() endif() endif(BUILD_CLIENT) if(BUILD_SERVER) - install(TARGETS ${PROJECT_NAME}server DESTINATION ${BINDIR}) -endif(BUILD_SERVER) + install(TARGETS ${PROJECT_NAME_LOWER}server DESTINATION ${BINDIR}) +endif() if (USE_GETTEXT) set(MO_FILES) foreach(LOCALE ${GETTEXT_AVAILABLE_LOCALES}) - set(PO_FILE_PATH "${GETTEXT_PO_PATH}/${LOCALE}/minetest.po") + set(PO_FILE_PATH "${GETTEXT_PO_PATH}/${LOCALE}/${PROJECT_NAME_LOWER}.po") set_mo_paths(MO_BUILD_PATH MO_DEST_PATH ${LOCALE}) - set(MO_FILE_PATH "${MO_BUILD_PATH}/${PROJECT_NAME}.mo") + set(MO_FILE_PATH "${MO_BUILD_PATH}/${PROJECT_NAME_LOWER}.mo") add_custom_command(OUTPUT ${MO_BUILD_PATH} COMMAND ${CMAKE_COMMAND} -E make_directory ${MO_BUILD_PATH} @@ -800,20 +701,15 @@ if (USE_GETTEXT) ) set(MO_FILES ${MO_FILES} ${MO_FILE_PATH}) - endforeach(LOCALE ${GETTEXT_AVAILABLE_LOCALES}) + endforeach() add_custom_target(translations ALL COMMENT "mo update" DEPENDS ${MO_FILES}) -endif(USE_GETTEXT) +endif() + # Subdirectories if (BUILD_CLIENT AND USE_FREETYPE) add_subdirectory(cguittfont) -endif (BUILD_CLIENT AND USE_FREETYPE) - -if (JSON_FOUND) -else (JSON_FOUND) - add_subdirectory(json) -endif (JSON_FOUND) +endif() -#end diff --git a/src/cguittfont/CMakeLists.txt b/src/cguittfont/CMakeLists.txt index 21448ecb8..7717a2f91 100644 --- a/src/cguittfont/CMakeLists.txt +++ b/src/cguittfont/CMakeLists.txt @@ -27,3 +27,4 @@ target_link_libraries( ${FREETYPE_LIBRARY} ${ZLIB_LIBRARIES} # needed by freetype, repeated here for safety ) + diff --git a/src/client.cpp b/src/client.cpp index b637e0336..6ee918ad0 100644 --- a/src/client.cpp +++ b/src/client.cpp @@ -1126,12 +1126,12 @@ void Client::sendReady() DSTACK(__FUNCTION_NAME); NetworkPacket pkt(TOSERVER_CLIENT_READY, - 1 + 1 + 1 + 1 + 2 + sizeof(char) * strlen(minetest_version_hash)); + 1 + 1 + 1 + 1 + 2 + sizeof(char) * strlen(g_version_hash)); - pkt << (u8) VERSION_MAJOR << (u8) VERSION_MINOR << (u8) VERSION_PATCH_ORIG - << (u8) 0 << (u16) strlen(minetest_version_hash); + pkt << (u8) VERSION_MAJOR << (u8) VERSION_MINOR << (u8) VERSION_PATCH + << (u8) 0 << (u16) strlen(g_version_hash); - pkt.putRawString(minetest_version_hash, (u16) strlen(minetest_version_hash)); + pkt.putRawString(g_version_hash, (u16) strlen(g_version_hash)); Send(&pkt); } diff --git a/src/client/CMakeLists.txt b/src/client/CMakeLists.txt index 288acf14c..a1ec37fe3 100644 --- a/src/client/CMakeLists.txt +++ b/src/client/CMakeLists.txt @@ -3,3 +3,4 @@ set(client_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/tile.cpp PARENT_SCOPE ) + diff --git a/src/client/clientlauncher.cpp b/src/client/clientlauncher.cpp index 7bf849624..ca5e12482 100644 --- a/src/client/clientlauncher.cpp +++ b/src/client/clientlauncher.cpp @@ -94,7 +94,7 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args) return false; } - porting::setXorgClassHint(video_driver->getExposedVideoData(), "Minetest"); + porting::setXorgClassHint(video_driver->getExposedVideoData(), PROJECT_NAME); /* This changes the minimum allowed number of vertices in a VBO. @@ -170,7 +170,7 @@ bool ClientLauncher::run(GameParams &game_params, const Settings &cmd_args) { // Set the window caption const wchar_t *text = wgettext("Main Menu"); - device->setWindowCaption((std::wstring(L"Minetest [") + text + L"]").c_str()); + device->setWindowCaption((narrow_to_wide(PROJECT_NAME) + L" [" + text + L"]").c_str()); delete[] text; try { // This is used for catching disconnects diff --git a/src/cmake_config.h.in b/src/cmake_config.h.in index e111a650d..7d446d178 100644 --- a/src/cmake_config.h.in +++ b/src/cmake_config.h.in @@ -3,31 +3,24 @@ #ifndef CMAKE_CONFIG_H #define CMAKE_CONFIG_H -#define CMAKE_PROJECT_NAME "@PROJECT_NAME@" -#define CMAKE_VERSION_STRING "@VERSION_STRING@" -#define CMAKE_PRODUCT_VERSION_STRING "@VERSION_MAJOR@.@VERSION_MINOR@" -#define CMAKE_RUN_IN_PLACE @RUN_IN_PLACE@ -#define CMAKE_USE_GETTEXT @USE_GETTEXT@ -#define CMAKE_USE_CURL @USE_CURL@ -#define CMAKE_USE_SOUND @USE_SOUND@ -#define CMAKE_USE_FREETYPE @USE_FREETYPE@ -#define CMAKE_STATIC_SHAREDIR "@SHAREDIR@" -#define CMAKE_USE_LEVELDB @USE_LEVELDB@ -#define CMAKE_USE_LUAJIT @USE_LUAJIT@ -#define CMAKE_USE_REDIS @USE_REDIS@ -#define CMAKE_VERSION_MAJOR @VERSION_MAJOR@ -#define CMAKE_VERSION_MINOR @VERSION_MINOR@ -#define CMAKE_VERSION_PATCH @VERSION_PATCH@ -#define CMAKE_VERSION_PATCH_ORIG @VERSION_PATCH_ORIG@ -#define CMAKE_VERSION_EXTRA_STRING "@VERSION_EXTRA@" -#define CMAKE_HAVE_ENDIAN_H @HAVE_ENDIAN_H@ - -#ifdef NDEBUG - #define CMAKE_BUILD_TYPE "Release" -#else - #define CMAKE_BUILD_TYPE "Debug" -#endif -#define CMAKE_BUILD_INFO "BUILD_TYPE=" CMAKE_BUILD_TYPE " RUN_IN_PLACE=@RUN_IN_PLACE@ USE_GETTEXT=@USE_GETTEXT@ USE_SOUND=@USE_SOUND@ USE_CURL=@USE_CURL@ USE_FREETYPE=@USE_FREETYPE@ USE_LUAJIT=@USE_LUAJIT@ STATIC_SHAREDIR=@SHAREDIR@" +#define PROJECT_NAME "@PROJECT_NAME@" +#define VERSION_MAJOR @VERSION_MAJOR@ +#define VERSION_MINOR @VERSION_MINOR@ +#define VERSION_PATCH @VERSION_PATCH@ +#define VERSION_EXTRA "@VERSION_EXTRA@" +#define VERSION_STRING "@VERSION_STRING@" +#define PRODUCT_VERSION_STRING "@VERSION_MAJOR@.@VERSION_MINOR@" +#define STATIC_SHAREDIR "@SHAREDIR@" +#define BUILD_TYPE "@CMAKE_BUILD_TYPE@" +#cmakedefine01 RUN_IN_PLACE +#cmakedefine01 USE_GETTEXT +#cmakedefine01 USE_CURL +#cmakedefine01 USE_SOUND +#cmakedefine01 USE_FREETYPE +#cmakedefine01 USE_LEVELDB +#cmakedefine01 USE_LUAJIT +#cmakedefine01 USE_REDIS +#cmakedefine01 HAVE_ENDIAN_H #endif diff --git a/src/cmake_config_githash.h.in b/src/cmake_config_githash.h.in index 4d5fcd60f..c72960c9f 100644 --- a/src/cmake_config_githash.h.in +++ b/src/cmake_config_githash.h.in @@ -4,7 +4,7 @@ #ifndef CMAKE_CONFIG_GITHASH_H #define CMAKE_CONFIG_GITHASH_H -#define CMAKE_VERSION_GITHASH "@VERSION_GITHASH@" +#define VERSION_GITHASH "@VERSION_GITHASH@" #endif diff --git a/src/config.h b/src/config.h index b07aa5d22..ac7684e20 100644 --- a/src/config.h +++ b/src/config.h @@ -6,82 +6,43 @@ #ifndef CONFIG_H #define CONFIG_H -#define PROJECT_NAME "Minetest" -#define RUN_IN_PLACE 0 -#define STATIC_SHAREDIR "" +#define STRINGIFY(x) #x +#define STR(x) STRINGIFY(x) -#define USE_GETTEXT 0 -#ifndef USE_SOUND - #define USE_SOUND 0 -#endif - -#ifndef USE_CURL +#ifdef USE_CMAKE_CONFIG_H + #include "cmake_config.h" +#else + #define PROJECT_NAME "Minetest" + #define RUN_IN_PLACE 0 #define USE_CURL 0 -#endif - -#ifndef USE_FREETYPE #define USE_FREETYPE 0 -#endif - -#ifndef USE_LEVELDB + #define USE_GETTEXT 0 #define USE_LEVELDB 0 -#endif - -#ifndef USE_LUAJIT #define USE_LUAJIT 0 -#endif - -#ifndef USE_REDIS #define USE_REDIS 0 -#endif - -#define HAVE_ENDIAN_H 0 - -#ifdef USE_CMAKE_CONFIG_H - #include "cmake_config.h" - #undef PROJECT_NAME - #define PROJECT_NAME CMAKE_PROJECT_NAME - #undef RUN_IN_PLACE - #define RUN_IN_PLACE CMAKE_RUN_IN_PLACE - #undef USE_GETTEXT - #define USE_GETTEXT CMAKE_USE_GETTEXT - #undef USE_SOUND - #define USE_SOUND CMAKE_USE_SOUND - #undef USE_CURL - #define USE_CURL CMAKE_USE_CURL - #undef USE_FREETYPE - #define USE_FREETYPE CMAKE_USE_FREETYPE - #undef STATIC_SHAREDIR - #define STATIC_SHAREDIR CMAKE_STATIC_SHAREDIR - #undef USE_LEVELDB - #define USE_LEVELDB CMAKE_USE_LEVELDB - #undef USE_LUAJIT - #define USE_LUAJIT CMAKE_USE_LUAJIT - #undef USE_REDIS - #define USE_REDIS CMAKE_USE_REDIS - #undef VERSION_MAJOR - #define VERSION_MAJOR CMAKE_VERSION_MAJOR - #undef VERSION_MINOR - #define VERSION_MINOR CMAKE_VERSION_MINOR - #undef VERSION_PATCH - #define VERSION_PATCH CMAKE_VERSION_PATCH - #undef VERSION_PATCH_ORIG - #define VERSION_PATCH_ORIG CMAKE_VERSION_PATCH_ORIG - #undef VERSION_STRING - #define VERSION_STRING CMAKE_VERSION_STRING - #undef PRODUCT_VERSION_STRING - #define PRODUCT_VERSION_STRING CMAKE_PRODUCT_VERSION_STRING - #undef VERSION_EXTRA_STRING - #define VERSION_EXTRA_STRING CMAKE_VERSION_EXTRA_STRING - #undef HAVE_ENDIAN_H - #define HAVE_ENDIAN_H CMAKE_HAVE_ENDIAN_H + #define USE_SOUND 0 + #define HAVE_ENDIAN_H 0 + #define STATIC_SHAREDIR "" + #ifdef NDEBUG + #define BUILD_TYPE "Release" + #else + #define BUILD_TYPE "Debug" + #endif #endif #ifdef __ANDROID__ #include "android_version.h" - #define VERSION_STRING CMAKE_VERSION_STRING #endif +#define BUILD_INFO "BUILD_TYPE=" BUILD_TYPE \ + " RUN_IN_PLACE=" STR(RUN_IN_PLACE) \ + " USE_GETTEXT=" STR(USE_GETTEXT) \ + " USE_SOUND=" STR(USE_SOUND) \ + " USE_CURL=" STR(USE_CURL) \ + " USE_FREETYPE=" STR(USE_FREETYPE) \ + " USE_LUAJIT=" STR(USE_LUAJIT) \ + " STATIC_SHAREDIR=" STR(STATIC_SHAREDIR) + #endif diff --git a/src/debug.cpp b/src/debug.cpp index 521891bbd..ecaf8c2a5 100644 --- a/src/debug.cpp +++ b/src/debug.cpp @@ -385,9 +385,8 @@ long WINAPI Win32ExceptionHandler(struct _EXCEPTION_POINTERS *pExceptInfo) MINIDUMP_USER_STREAM_INFORMATION mdusi; MINIDUMP_USER_STREAM mdus; bool minidump_created = false; - std::string version_str("Minetest "); - std::string dumpfile = porting::path_user + DIR_DELIM "minetest.dmp"; + std::string dumpfile = porting::path_user + DIR_DELIM PROJECT_NAME ".dmp"; HANDLE hFile = CreateFileA(dumpfile.c_str(), GENERIC_WRITE, FILE_SHARE_WRITE, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); @@ -401,7 +400,8 @@ long WINAPI Win32ExceptionHandler(struct _EXCEPTION_POINTERS *pExceptInfo) mdei.ExceptionPointers = pExceptInfo; mdei.ThreadId = GetCurrentThreadId(); - version_str += minetest_version_hash; + std::string version_str(PROJECT_NAME " "); + version_str += g_version_hash; mdus.Type = CommentStreamA; mdus.BufferSize = version_str.size(); diff --git a/src/defaultsettings.cpp b/src/defaultsettings.cpp index 4ad0418bb..0acb4a730 100644 --- a/src/defaultsettings.cpp +++ b/src/defaultsettings.cpp @@ -319,7 +319,7 @@ void set_default_settings(Settings *settings) settings->setDefault("enable_particles", "false"); settings->setDefault("video_driver", "ogles1"); settings->setDefault("touchtarget", "true"); - settings->setDefault("TMPFolder","/sdcard/Minetest/tmp/"); + settings->setDefault("TMPFolder","/sdcard/" PROJECT_NAME "/tmp/"); settings->setDefault("touchscreen_threshold","20"); settings->setDefault("smooth_lighting", "false"); settings->setDefault("max_simultaneous_block_sends_per_client", "3"); diff --git a/src/emerge.cpp b/src/emerge.cpp index 89153cdb6..bf104e035 100644 --- a/src/emerge.cpp +++ b/src/emerge.cpp @@ -519,20 +519,22 @@ void *EmergeThread::Thread() } catch (VersionMismatchException &e) { std::ostringstream err; - err << "World data version mismatch in MapBlock "<<PP(last_tried_pos)<<std::endl; - err << "----"<<std::endl; - err << "\""<<e.what()<<"\""<<std::endl; - err << "See debug.txt."<<std::endl; - err << "World probably saved by a newer version of Minetest."<<std::endl; + err << "World data version mismatch in MapBlock " << PP(last_tried_pos) << std::endl + << "----" << std::endl + << "\"" << e.what() << "\"" << std::endl + << "See debug.txt." << std::endl + << "World probably saved by a newer version of " PROJECT_NAME "." + << std::endl; m_server->setAsyncFatalError(err.str()); } catch (SerializationError &e) { std::ostringstream err; - err << "Invalid data in MapBlock "<<PP(last_tried_pos)<<std::endl; - err << "----"<<std::endl; - err << "\""<<e.what()<<"\""<<std::endl; - err << "See debug.txt."<<std::endl; - err << "You can ignore this using [ignore_world_load_errors = true]."<<std::endl; + err << "Invalid data in MapBlock " << PP(last_tried_pos) << std::endl + << "----" << std::endl + << "\"" << e.what() << "\"" << std::endl + << "See debug.txt." << std::endl + << "You can ignore this using [ignore_world_load_errors = true]." + << std::endl; m_server->setAsyncFatalError(err.str()); } diff --git a/src/game.cpp b/src/game.cpp index df0895ae1..8a9f3e1ea 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1134,8 +1134,8 @@ static void show_pause_menu(GUIFormSpecMenu **cur_formspec, os << "button_exit[4," << (ypos++) << ";3,0.5;btn_exit_os;" << wide_to_narrow(wstrgettext("Exit to OS")) << "]" << "textarea[7.5,0.25;3.9,6.25;;" << control_text << ";]" - << "textarea[0.4,0.25;3.5,6;;" << "Minetest\n" - << minetest_build_info << "\n" + << "textarea[0.4,0.25;3.5,6;;" << PROJECT_NAME "\n" + << g_build_info << "\n" << "path_user = " << wrap_rows(porting::path_user, 20) << "\n;]"; @@ -2033,9 +2033,10 @@ bool Game::createClient(const std::string &playername, /* Set window caption */ - core::stringw str = L"Minetest ["; + std::wstring str = narrow_to_wide(PROJECT_NAME); + str += L" ["; str += driver->getName(); - str += "]"; + str += L"]"; device->setWindowCaption(str.c_str()); LocalPlayer *player = client->getEnv().getLocalPlayer(); @@ -2057,7 +2058,7 @@ bool Game::initGui(std::wstring *error_message) { // First line of debug text guitext = guienv->addStaticText( - L"Minetest", + narrow_to_wide(PROJECT_NAME).c_str(), core::rect<s32>(0, 0, 0, 0), false, false, guiroot); @@ -3994,7 +3995,7 @@ void Game::updateGui(float *statustext_time, const RunStats &stats, std::ostringstream os(std::ios_base::binary); os << std::fixed - << "Minetest " << minetest_version_hash + << PROJECT_NAME " " << g_version_hash << " FPS = " << fps << " (R: range_all=" << draw_control->range_all << ")" << std::setprecision(0) @@ -4010,7 +4011,7 @@ void Game::updateGui(float *statustext_time, const RunStats &stats, guitext->setVisible(true); } else if (flags.show_hud || flags.show_chat) { std::ostringstream os(std::ios_base::binary); - os << "Minetest " << minetest_version_hash; + os << PROJECT_NAME " " << g_version_hash; guitext->setText(narrow_to_wide(os.str()).c_str()); guitext->setVisible(true); } else { @@ -4245,7 +4246,7 @@ void the_game(bool *kill, } catch (SerializationError &e) { error_message = L"A serialization error occurred:\n" + narrow_to_wide(e.what()) + L"\n\nThe server is probably " - L" running a different version of Minetest."; + L" running a different version of " PROJECT_NAME "."; errorstream << wide_to_narrow(error_message) << std::endl; } catch (ServerError &e) { error_message = narrow_to_wide(e.what()); diff --git a/src/guiEngine.cpp b/src/guiEngine.cpp index 30296b40c..c143e5110 100644 --- a/src/guiEngine.cpp +++ b/src/guiEngine.cpp @@ -171,8 +171,8 @@ GUIEngine::GUIEngine( irr::IrrlichtDevice* dev, m_sound_manager = &dummySoundManager; //create topleft header - std::wstring t = narrow_to_wide(std::string("Minetest ") + - minetest_version_hash); + std::wstring t = narrow_to_wide(std::string(PROJECT_NAME " ") + + g_version_hash); core::rect<s32> rect(0, 0, g_fontengine->getTextWidth(t), g_fontengine->getTextHeight()); rect += v2s32(4, 0); @@ -571,8 +571,8 @@ bool GUIEngine::downloadFile(std::string url, std::string target) /******************************************************************************/ void GUIEngine::setTopleftText(std::string append) { - std::wstring toset = narrow_to_wide( std::string("Minetest ") + - minetest_version_hash); + std::wstring toset = narrow_to_wide(std::string(PROJECT_NAME " ") + + g_version_hash); if (append != "") { diff --git a/src/httpfetch.cpp b/src/httpfetch.cpp index 40ad92da3..e17a8b187 100644 --- a/src/httpfetch.cpp +++ b/src/httpfetch.cpp @@ -48,7 +48,7 @@ HTTPFetchRequest::HTTPFetchRequest() connect_timeout = timeout; multipart = false; - useragent = std::string("Minetest/") + minetest_version_hash + " (" + porting::get_sysinfo() + ")"; + useragent = std::string(PROJECT_NAME "/") + g_version_hash + " (" + porting::get_sysinfo() + ")"; } diff --git a/src/json/CMakeLists.txt b/src/json/CMakeLists.txt index 5887d523a..206c6ea9c 100644 --- a/src/json/CMakeLists.txt +++ b/src/json/CMakeLists.txt @@ -1,14 +1,4 @@ -if( UNIX ) - set(json_SRCS jsoncpp.cpp) - set(json_platform_LIBS "") -else( UNIX ) - set(json_SRCS jsoncpp.cpp) - set(json_platform_LIBS "") -endif( UNIX ) +add_library(jsoncpp jsoncpp.cpp) -add_library(jsoncpp ${json_SRCS}) +target_link_libraries(jsoncpp) -target_link_libraries( - jsoncpp - ${json_platform_LIBS} -) diff --git a/src/jthread/CMakeLists.txt b/src/jthread/CMakeLists.txt index a581a3b02..cebb35caa 100644 --- a/src/jthread/CMakeLists.txt +++ b/src/jthread/CMakeLists.txt @@ -1,15 +1,14 @@ -if( UNIX ) - set(JTHREAD_SRCS - ${CMAKE_CURRENT_SOURCE_DIR}/pthread/jmutex.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/pthread/jthread.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/pthread/jsemaphore.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/pthread/jevent.cpp - PARENT_SCOPE) -else( UNIX ) - set(JTHREAD_SRCS - ${CMAKE_CURRENT_SOURCE_DIR}/win32/jmutex.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/win32/jthread.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/win32/jsemaphore.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/win32/jevent.cpp - PARENT_SCOPE) -endif( UNIX ) +if(UNIX) + set(THREAD_SYS_DIR pthread) +else() + set(THREAD_SYS_DIR win32) +endif() + +set(SRC_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/${THREAD_SYS_DIR}) +set(JTHREAD_SRCS + ${SRC_PREFIX}/jmutex.cpp + ${SRC_PREFIX}/jthread.cpp + ${SRC_PREFIX}/jsemaphore.cpp + ${SRC_PREFIX}/jevent.cpp + PARENT_SCOPE) + diff --git a/src/lua/CMakeLists.txt b/src/lua/CMakeLists.txt index 4bfe318ee..119dd6302 100644 --- a/src/lua/CMakeLists.txt +++ b/src/lua/CMakeLists.txt @@ -1,10 +1,12 @@ -# -# Lua 5.1.x -# cmake_minimum_required(VERSION 2.4 FATAL_ERROR) project(lua C) +set(LUA_VERSION_MAJOR 5) +set(LUA_VERSION_MINOR 1) +set(LUA_VERSION_PATCH 4) +set(LUA_VERSION "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.${LUA_VERSION_PATCH}") + set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) set(COMMON_CFLAGS) @@ -16,9 +18,7 @@ if(APPLE) set(DEFAULT_DLOPEN ON) # use this on Mac OS X 10.3- option(LUA_USE_MACOSX "Mac OS X 10.3-" OFF) -elseif(CYGWIN) - set(DEFAULT_POSIX TRUE) -elseif(UNIX) +elseif(UNIX OR CYGWIN) set(DEFAULT_POSIX TRUE) elseif(WIN32) set(LUA_WIN TRUE) @@ -32,50 +32,18 @@ if(CMAKE_SYSTEM_NAME STREQUAL "Linux") set(DEFAULT_DLOPEN ON) endif() -if(WIN32) - #set(BUILD_STATIC OFF) - set(BUILD_STATIC ON) -else() - #option(BUILD_STATIC "build static library" ON) - set(BUILD_STATIC ON) -endif() - -if(DEFAULT_DLOPEN) - option(LUA_USE_DLOPEN "Enable dlopen support." ON) -else() - option(LUA_USE_DLOPEN "Enable dlopen support." OFF) -endif() -mark_as_advanced(LUA_USE_DLOPEN) - -if(DEFAULT_ANSI) - option(LUA_ANSI "Disable non-ansi features." ON) -else() - option(LUA_ANSI "Disable non-ansi features." OFF) -endif() -mark_as_advanced(LUA_ANSI) - -# -# Lua version -# -set(LUA_VERSION_MAJOR 5) -set(LUA_VERSION_MINOR 1) -set(LUA_VERSION_PATCH 4) -set(LUA_VERSION - "${LUA_VERSION_MAJOR}.${LUA_VERSION_MINOR}.${LUA_VERSION_PATCH}") -set(LUA_SOVERSION - "${LUA_VERSION_MAJOR}") - -# -# libs & cflags -# -set(COMMON_LDFLAGS "${COMMON_LDFLAGS}") - # For "Mac OS X 10.3-" if(LUA_USE_MACOSX) set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_USE_MACOSX") set(LUA_USE_DLOPEN FALSE) endif(LUA_USE_MACOSX) +option(LUA_USE_DLOPEN "Enable dlopen support." ${DEFAULT_DLOPEN}) +mark_as_advanced(LUA_USE_DLOPEN) + +option(LUA_ANSI "Disable non-ANSI features." ${DEFAULT_ANSI}) +mark_as_advanced(LUA_ANSI) + if(LUA_USE_DLOPEN) set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_USE_DLOPEN") if(NOT APPLE) @@ -91,14 +59,11 @@ if(LUA_ANSI) set(COMMON_CFLAGS "${COMMON_CFLAGS} -DLUA_ANSI") endif(LUA_ANSI) -# # COMMON_CFLAGS has no effect without this line -# set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMMON_CFLAGS}") -# -# standard flags to use for each build type. -# + +# Standard flags to use for each build type. if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pipe -Wall -Wextra -Wshadow -W -pedantic -std=gnu99") set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O2") @@ -107,8 +72,6 @@ if(CMAKE_COMPILER_IS_GNUCC) set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_WITHDEBINFO} -O2 -g") endif(CMAKE_COMPILER_IS_GNUCC) -# -# sub-folders -# -ADD_SUBDIRECTORY(src build) + +add_subdirectory(src build) diff --git a/src/lua/src/CMakeLists.txt b/src/lua/src/CMakeLists.txt index 8fdc7e58b..8f6cc1213 100644 --- a/src/lua/src/CMakeLists.txt +++ b/src/lua/src/CMakeLists.txt @@ -39,11 +39,9 @@ set(LUA_LIB_HEADERS ) include_directories(${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR}) + ${CMAKE_CURRENT_BINARY_DIR}) -# # Lua library. -# add_library(lua STATIC ${LUA_CORE_SRC}) target_link_libraries(lua ${LIBS}) set(LUA_STATIC_LIB lua) @@ -51,13 +49,6 @@ set(LUA_LIBS lua) set_target_properties(${LUA_LIBS} PROPERTIES VERSION ${LUA_VERSION} - SOVERSION ${LUA_SOVERSION} CLEAN_DIRECT_OUTPUT 1 ) -# Install library -#install(TARGETS ${LUA_LIBS} -# RUNTIME DESTINATION bin -# LIBRARY DESTINATION lib -# ARCHIVE DESTINATION lib) - diff --git a/src/main.cpp b/src/main.cpp index d84a09f76..3893b9a82 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -400,13 +400,11 @@ static void print_allowed_options(const OptionList &allowed_options) static void print_version() { -#ifdef SERVER - dstream << "minetestserver " << minetest_version_hash << std::endl; -#else - dstream << "Minetest " << minetest_version_hash << std::endl; + dstream << PROJECT_NAME " " << g_version_hash << std::endl; +#ifndef SERVER dstream << "Using Irrlicht " << IRRLICHT_SDK_VERSION << std::endl; #endif - dstream << "Build info: " << minetest_build_info << std::endl; + dstream << "Build info: " << g_build_info << std::endl; } static void list_game_ids() @@ -543,7 +541,7 @@ static void startup_message() infostream << PROJECT_NAME << " " << _("with") << " SER_FMT_VER_HIGHEST_READ=" << (int)SER_FMT_VER_HIGHEST_READ << ", " - << minetest_build_info << std::endl; + << g_build_info << std::endl; } static bool read_config_file(const Settings &cmd_args) diff --git a/src/network/CMakeLists.txt b/src/network/CMakeLists.txt index 4095ace26..3805c323d 100644 --- a/src/network/CMakeLists.txt +++ b/src/network/CMakeLists.txt @@ -12,4 +12,5 @@ if (BUILD_CLIENT) ${CMAKE_CURRENT_SOURCE_DIR}/clientpackethandler.cpp PARENT_SCOPE ) -endif(BUILD_CLIENT) +endif() + diff --git a/src/network/serverpackethandler.cpp b/src/network/serverpackethandler.cpp index 7d5a9bc71..e01aeaa55 100644 --- a/src/network/serverpackethandler.cpp +++ b/src/network/serverpackethandler.cpp @@ -388,7 +388,7 @@ void Server::handleCommand_Init_Legacy(NetworkPacket* pkt) DenyAccess_Legacy(pkt->getPeerId(), std::wstring( L"Your client's version is not supported.\n" L"Server version is ") - + narrow_to_wide(minetest_version_simple) + L"." + + narrow_to_wide(g_version_string) + L"." ); return; } @@ -436,7 +436,7 @@ void Server::handleCommand_Init_Legacy(NetworkPacket* pkt) DenyAccess_Legacy(pkt->getPeerId(), std::wstring( L"Your client's version is not supported.\n" L"Server version is ") - + narrow_to_wide(minetest_version_simple) + L",\n" + + narrow_to_wide(g_version_string) + L",\n" + L"server's PROTOCOL_VERSION is " + narrow_to_wide(itos(SERVER_PROTOCOL_VERSION_MIN)) + L"..." @@ -456,7 +456,7 @@ void Server::handleCommand_Init_Legacy(NetworkPacket* pkt) DenyAccess_Legacy(pkt->getPeerId(), std::wstring( L"Your client's version is not supported.\n" L"Server version is ") - + narrow_to_wide(minetest_version_simple) + L",\n" + + narrow_to_wide(g_version_string) + L",\n" + L"server's PROTOCOL_VERSION (strict) is " + narrow_to_wide(itos(LATEST_PROTOCOL_VERSION)) + L", client's PROTOCOL_VERSION is " diff --git a/src/porting.cpp b/src/porting.cpp index 710446363..5b0de1305 100644 --- a/src/porting.cpp +++ b/src/porting.cpp @@ -461,7 +461,7 @@ void initializePaths() // Use "C:\Documents and Settings\user\Application Data\<PROJECT_NAME>" len = GetEnvironmentVariable("APPDATA", buf, buflen); FATAL_ERROR_IF(len >= buflen, "Overlow"); - path_user = std::string(buf) + DIR_DELIM + PROJECT_NAME; + path_user = std::string(buf) + DIR_DELIM + lowercase(PROJECT_NAME); /* Linux @@ -491,7 +491,7 @@ void initializePaths() if(static_sharedir != "" && static_sharedir != ".") trylist.push_back(static_sharedir); trylist.push_back( - bindir + DIR_DELIM + ".." + DIR_DELIM + "share" + DIR_DELIM + PROJECT_NAME); + bindir + DIR_DELIM + ".." + DIR_DELIM + "share" + DIR_DELIM + lowercase(PROJECT_NAME)); trylist.push_back(bindir + DIR_DELIM + ".."); #ifdef __ANDROID__ trylist.push_back(path_user); @@ -515,7 +515,7 @@ void initializePaths() break; } #ifndef __ANDROID__ - path_user = std::string(getenv("HOME")) + DIR_DELIM + "." + PROJECT_NAME; + path_user = std::string(getenv("HOME")) + DIR_DELIM + "." + lowercase(PROJECT_NAME); #endif /* @@ -532,12 +532,13 @@ void initializePaths() dstream << "WARNING: Could not determine bundle resource path" << std::endl; } CFRelease(resources_url); - path_user = std::string(getenv("HOME")) + "/Library/Application Support/" + PROJECT_NAME; + + path_user = std::string(getenv("HOME")) + "/Library/Application Support/" + lowercase(PROJECT_NAME); #else // FreeBSD, and probably many other POSIX-like systems. path_share = STATIC_SHAREDIR; - path_user = std::string(getenv("HOME")) + DIR_DELIM + "." + PROJECT_NAME; + path_user = std::string(getenv("HOME")) + DIR_DELIM + "." + lowercase(PROJECT_NAME); #endif diff --git a/src/script/CMakeLists.txt b/src/script/CMakeLists.txt index 491c05a1e..5ef672ca9 100644 --- a/src/script/CMakeLists.txt +++ b/src/script/CMakeLists.txt @@ -11,9 +11,10 @@ set(common_SCRIPT_SRCS PARENT_SCOPE) # Used by client only -set(minetest_SCRIPT_SRCS +set(client_SCRIPT_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/scripting_mainmenu.cpp - ${minetest_SCRIPT_COMMON_SRCS} - ${minetest_SCRIPT_CPP_API_SRCS} - ${minetest_SCRIPT_LUA_API_SRCS} + ${client_SCRIPT_COMMON_SRCS} + ${client_SCRIPT_CPP_API_SRCS} + ${client_SCRIPT_LUA_API_SRCS} PARENT_SCOPE) + diff --git a/src/script/common/CMakeLists.txt b/src/script/common/CMakeLists.txt index 27e2fb4d5..4a8e6bab5 100644 --- a/src/script/common/CMakeLists.txt +++ b/src/script/common/CMakeLists.txt @@ -1,4 +1,3 @@ -# Used by server and client set(common_SCRIPT_COMMON_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/c_content.cpp ${CMAKE_CURRENT_SOURCE_DIR}/c_converter.cpp @@ -6,6 +5,6 @@ set(common_SCRIPT_COMMON_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/c_internal.cpp PARENT_SCOPE) -# Used by client only -set(minetest_SCRIPT_COMMON_SRCS +set(client_SCRIPT_COMMON_SRCS PARENT_SCOPE) + diff --git a/src/script/cpp_api/CMakeLists.txt b/src/script/cpp_api/CMakeLists.txt index c45020055..4584962f1 100644 --- a/src/script/cpp_api/CMakeLists.txt +++ b/src/script/cpp_api/CMakeLists.txt @@ -1,4 +1,3 @@ -# Used by server and client set(common_SCRIPT_CPP_API_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/s_base.cpp ${CMAKE_CURRENT_SOURCE_DIR}/s_entity.cpp @@ -12,7 +11,7 @@ set(common_SCRIPT_CPP_API_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/s_async.cpp PARENT_SCOPE) -# Used by client only -set(minetest_SCRIPT_CPP_API_SRCS +set(client_SCRIPT_CPP_API_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/s_mainmenu.cpp PARENT_SCOPE) + diff --git a/src/script/lua_api/CMakeLists.txt b/src/script/lua_api/CMakeLists.txt index 08960d2ad..aaabc213e 100644 --- a/src/script/lua_api/CMakeLists.txt +++ b/src/script/lua_api/CMakeLists.txt @@ -1,4 +1,3 @@ -# Used by server and client set(common_SCRIPT_LUA_API_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/l_base.cpp ${CMAKE_CURRENT_SOURCE_DIR}/l_craft.cpp @@ -18,7 +17,7 @@ set(common_SCRIPT_LUA_API_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/l_settings.cpp PARENT_SCOPE) -# Used by client only -set(minetest_SCRIPT_LUA_API_SRCS +set(client_SCRIPT_LUA_API_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/l_mainmenu.cpp PARENT_SCOPE) + diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index 36b97b2d1..f90508012 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -980,7 +980,7 @@ int ModApiMainMenu::l_show_file_open_dialog(lua_State *L) /******************************************************************************/ int ModApiMainMenu::l_get_version(lua_State *L) { - lua_pushstring(L, minetest_version_simple); + lua_pushstring(L, g_version_string); return 1; } diff --git a/src/server.cpp b/src/server.cpp index 8c76fdc16..3b4c3c3f0 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -2687,7 +2687,7 @@ std::wstring Server::getStatusString() std::wostringstream os(std::ios_base::binary); os<<L"# Server: "; // Version - os<<L"version="<<narrow_to_wide(minetest_version_simple); + os<<L"version="<<narrow_to_wide(g_version_string); // Uptime os<<L", uptime="<<m_uptime.get(); // Max lag estimate diff --git a/src/serverlist.cpp b/src/serverlist.cpp index a3353340e..978175a2a 100644 --- a/src/serverlist.cpp +++ b/src/serverlist.cpp @@ -212,7 +212,7 @@ void sendAnnounce(const std::string &action, bool strict_checking = g_settings->getBool("strict_protocol_version_checking"); server["name"] = g_settings->get("server_name"); server["description"] = g_settings->get("server_description"); - server["version"] = minetest_version_simple; + server["version"] = g_version_string; server["proto_min"] = strict_checking ? LATEST_PROTOCOL_VERSION : SERVER_PROTOCOL_VERSION_MIN; server["proto_max"] = strict_checking ? LATEST_PROTOCOL_VERSION : SERVER_PROTOCOL_VERSION_MAX; server["url"] = g_settings->get("server_url"); diff --git a/src/util/CMakeLists.txt b/src/util/CMakeLists.txt index 56bf8a25a..112f09bb9 100644 --- a/src/util/CMakeLists.txt +++ b/src/util/CMakeLists.txt @@ -8,3 +8,4 @@ set(UTIL_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/string.cpp ${CMAKE_CURRENT_SOURCE_DIR}/timetaker.cpp PARENT_SCOPE) + diff --git a/src/version.cpp b/src/version.cpp index ecfeb95f8..ed167cd24 100644 --- a/src/version.cpp +++ b/src/version.cpp @@ -20,27 +20,18 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "version.h" #include "config.h" -#ifdef __ANDROID__ +#if defined(__ANDROID__) #include "android_version.h" #elif defined(USE_CMAKE_CONFIG_H) #include "cmake_config_githash.h" #endif -#ifdef CMAKE_VERSION_GITHASH - #define VERSION_GITHASH CMAKE_VERSION_GITHASH -#else +#ifndef VERSION_GITHASH #define VERSION_GITHASH VERSION_STRING #endif -const char *minetest_version_simple = VERSION_STRING; -const char *minetest_version_hash = VERSION_GITHASH; -#ifdef USE_CMAKE_CONFIG_H -const char *minetest_build_info = - "VER=" VERSION_GITHASH " " CMAKE_BUILD_INFO; -#elif defined(ANDROID) -const char *minetest_build_info = "android jni"; -#else -const char *minetest_build_info = "non-cmake"; -#endif +const char *g_version_string = VERSION_STRING; +const char *g_version_hash = VERSION_GITHASH; +const char *g_build_info = "VER=" VERSION_GITHASH " " BUILD_INFO; diff --git a/src/version.h b/src/version.h index b23e770aa..0b803b82c 100644 --- a/src/version.h +++ b/src/version.h @@ -20,9 +20,9 @@ with this program; if not, write to the Free Software Foundation, Inc., #ifndef VERSION_HEADER #define VERSION_HEADER -extern const char *minetest_version_simple; -extern const char *minetest_version_hash; -extern const char *minetest_build_info; +extern const char *g_version_string; +extern const char *g_version_hash; +extern const char *g_build_info; #endif |