From: Perttu Ahola Date: Sat, 8 Jan 2011 22:49:32 +0000 (+0200) Subject: Mainly small build system fixes X-Git-Tag: 0.2.20110731_3~474 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=359e575ba377fa83317cd733f0c5eefdc0a8ff59;p=oweals%2Fminetest.git Mainly small build system fixes --- diff --git a/CMakeLists.txt b/CMakeLists.txt index a9d0f469b..106975a67 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,25 +10,25 @@ project(minetest) set(VERSION_MAJOR 0) set(VERSION_MINOR 0) set(VERSION_PATCH 1) +set(VERSION_STRING "${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH}") -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") -include(${CMAKE_SOURCE_DIR}/cmake/Modules/misc.cmake) - -# Default to Release -if(NOT CMAKE_BUILD_TYPE) - set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE) -endif() - -# Configuration +# Configuration options set(RUN_IN_PLACE 0 CACHE BOOL "Run directly in source directory structure") set(BUILD_CLIENT 1 CACHE BOOL "Build client") set(BUILD_SERVER 1 CACHE BOOL "Build server") -# Get date and time -GETDATETIME(BUILD_DATE) -MESSAGE(STATUS "BUILD_DATE = ${BUILD_DATE}") +set(WARN_ALL 1 CACHE BOOL "Enable -Wall for Release build") + +if(NOT CMAKE_BUILD_TYPE) + # Default to release + set(CMAKE_BUILD_TYPE Release CACHE STRING "Build type: Debug or Release" FORCE) +endif() + +# Included stuff +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/") +include(${CMAKE_SOURCE_DIR}/cmake/Modules/misc.cmake) # This is done here so that relative search paths are more reasnable find_package(Irrlicht) @@ -78,7 +78,7 @@ if(WIN32) install(FILES bin/minetestserver.exe DESTINATION bin) endif() - set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${BUILD_DATE}-win32") + set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-win32") set(CPACK_GENERATOR ZIP) @@ -87,7 +87,9 @@ if(WIN32) elseif(APPLE) # TODO # see http://cmake.org/Wiki/CMake:CPackPackageGenerators#Bundle_.28OSX_only.29 - set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${BUILD_DATE}-osx") + # this too http://0xfe.blogspot.com/2006/03/how-os-x-executes-applications.html + # + set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-osx") set(CPACK_PACKAGE_ICON "") set(CPACK_BUNDLE_NAME ${PROJECT_NAME}) set(CPACK_BUNDLE_ICON "") @@ -95,7 +97,7 @@ elseif(APPLE) set(CPACK_BUNDLE_STARTUP_COMMAND "Contents/MacOS/minetest") set(CPACK_GENERATOR BUNDLE) else() - set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${BUILD_DATE}-linux") + set(CPACK_PACKAGE_FILE_NAME "${PROJECT_NAME}-${VERSION_STRING}-linux") set(CPACK_GENERATOR TGZ) set(CPACK_SOURCE_GENERATOR TGZ) endif() diff --git a/cmake/Modules/misc.cmake b/cmake/Modules/misc.cmake index 61a7d1407..0bd2e3fce 100644 --- a/cmake/Modules/misc.cmake +++ b/cmake/Modules/misc.cmake @@ -1,3 +1,9 @@ +# +# Random macros +# + +# Not used ATM + MACRO (GETDATETIME RESULT) IF (WIN32) EXECUTE_PROCESS(COMMAND "cmd" /C echo %date% %time% OUTPUT_VARIABLE ${RESULT}) @@ -11,6 +17,5 @@ MACRO (GETDATETIME RESULT) ENDIF (WIN32) string(REGEX REPLACE " " "_" ${RESULT} "${${RESULT}}") - ENDMACRO (GETDATETIME) diff --git a/doc/README.txt b/doc/README.txt index 7e7403994..93203b3db 100644 --- a/doc/README.txt +++ b/doc/README.txt @@ -51,7 +51,8 @@ Compiling on GNU/Linux: * CMake * Irrlicht * Zlib - - You can probably find these in your distro's package manager +- You can probably find these in your distro's package repository. +- Building has been tested to work flawlessly on many systems. - Check possible options: $ cd whatever/minetest @@ -81,7 +82,7 @@ Compiling on GNU/Linux: $ ./bin/minetest Compiling on Windows: -- You need CMake, Irrlicht, zlib and Visual Studio or MinGW +- You need CMake, Irrlicht, Zlib and Visual Studio or MinGW - NOTE: Probably it will not work easily and you will need to fix some stuff. - Steps: - Start up the CMake GUI diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fea1f2644..c7c0a7025 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -131,40 +131,43 @@ if(BUILD_SERVER) ) endif(BUILD_SERVER) +# # Set some optimizations and tweaks -if( UNIX ) - # Unix - - # NOTE: -Wall gets applied automatically to debug builds - - #set(UNIX_FLAGS "") +# - if(BUILD_CLIENT) - set_target_properties(minetest PROPERTIES COMPILE_FLAGS - "${UNIX_FLAGS}") - endif(BUILD_CLIENT) +if(MSVC) + # Visual Studio + # EHa enables SEH exceptions (used for catching segfaults) + set(CMAKE_CXX_FLAGS_RELEASE "/EHa /MD /O2 /Ob2 /Oi /Ot /Oy /GL /FD /MT /GS- /arch:SSE /fp:fast") + set(CMAKE_CXX_FLAGS_DEBUG "/MDd /Zi /Ob0 /Od /RTC1") + if(BUILD_SERVER) - set_target_properties(minetestserver PROPERTIES COMPILE_FLAGS - "${UNIX_FLAGS} -DSERVER") + set_target_properties(minetestserver PROPERTIES + COMPILE_FLAGS "/D SERVER") endif(BUILD_SERVER) -else( UNIX ) - # Windows +else() + # Probably GCC - if(BUILD_CLIENT) - # EHa enables SEH exceptions (used for catching segfaults) - set_target_properties(minetest PROPERTIES COMPILE_FLAGS - "/O2 /Ob2 /Oi /Ot /Oy /GL /EHa") - endif(BUILD_CLIENT) + if(WARN_ALL) + set(WARNING_FLAGS "-Wall") + else() + set(WARNING_FLAGS "") + endif() + set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG ${WARNING_FLAGS} -O3 -ffast-math -Wall -fomit-frame-pointer -pipe -funroll-loops") + set(CMAKE_CXX_FLAGS_DEBUG "-g -O1 -Wall") + if(BUILD_SERVER) - # EHa enables SEH exceptions (used for catching segfaults) - set_target_properties(minetestserver PROPERTIES COMPILE_FLAGS - "/O2 /Ob2 /Oi /Ot /Oy /GL /EHa /D SERVER") + set_target_properties(minetestserver PROPERTIES + COMPILE_FLAGS "-DSERVER") endif(BUILD_SERVER) -endif( UNIX ) +endif() + +#MESSAGE(STATUS "CMAKE_CXX_FLAGS_RELEASE=${CMAKE_CXX_FLAGS_RELEASE}") +#MESSAGE(STATUS "CMAKE_CXX_FLAGS_DEBUG=${CMAKE_CXX_FLAGS_DEBUG}") # # Installation diff --git a/src/config.h.in b/src/config.h.in index 9f65386c2..42deb4bc5 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -4,8 +4,13 @@ #define CONFIG_H #define INSTALL_PREFIX "@CMAKE_INSTALL_PREFIX@" -#define VERSION_STRING "@VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@" -#define BUILD_INFO "VER="VERSION_STRING" BUILD_DATE=@BUILD_DATE@ RUN_IN_PLACE=@RUN_IN_PLACE@ INSTALL_PREFIX=@CMAKE_INSTALL_PREFIX@" +#define VERSION_STRING "@VERSION_STRING@" +#ifdef NDEBUG + #define BUILD_TYPE "Release" +#else + #define BUILD_TYPE "Debug" +#endif +#define BUILD_INFO "VER="VERSION_STRING" BUILD_DATE=@BUILD_DATE@ RUN_IN_PLACE=@RUN_IN_PLACE@ INSTALL_PREFIX=@CMAKE_INSTALL_PREFIX@ BUILD_TYPE="BUILD_TYPE #endif diff --git a/src/guiPauseMenu.cpp b/src/guiPauseMenu.cpp index 46bb799e6..574cc774f 100644 --- a/src/guiPauseMenu.cpp +++ b/src/guiPauseMenu.cpp @@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc., #include "debug.h" #include "serialization.h" #include "porting.h" +#include "config.h" GUIPauseMenu::GUIPauseMenu(gui::IGUIEnvironment* env, gui::IGUIElement* parent, s32 id, @@ -127,11 +128,11 @@ void GUIPauseMenu::regenerateGui(v2u32 screensize) L"Minetest-c55\n" L"by Perttu Ahola\n" L"celeron55@gmail.com\n\n" - L"SER_FMT_VER_HIGHEST=%i\n" - L"userdata path = \n" + SWPRINTF_CHARSTRING L"\n" + L"userdata path = " SWPRINTF_CHARSTRING , - (int)SER_FMT_VER_HIGHEST, + BUILD_INFO, porting::path_userdata.c_str() );