Mainly small build system fixes
authorPerttu Ahola <celeron55@gmail.com>
Sat, 8 Jan 2011 22:49:32 +0000 (00:49 +0200)
committerPerttu Ahola <celeron55@gmail.com>
Sat, 8 Jan 2011 22:49:32 +0000 (00:49 +0200)
CMakeLists.txt
cmake/Modules/misc.cmake
doc/README.txt
src/CMakeLists.txt
src/config.h.in
src/guiPauseMenu.cpp

index a9d0f469b2fe4399108e87ccce0c5350cc2f020e..106975a67c878644a4b525cfe5d74bd0d201c1f5 100644 (file)
@@ -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()
index 61a7d140780a2b1a167959c265b50e90aa63a21b..0bd2e3fcebe6e0e0bfcd70b759285b45b05d67d8 100644 (file)
@@ -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)
 
index 7e74039941f7c1cbe1688832381e74be2259226c..93203b3db5b35c7b56dcad9a7a7837a5b935d8ca 100644 (file)
@@ -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
index fea1f264410db7d1df536a5e77c11e1709b6803f..c7c0a702556c0e0ae44bacf94a13b73addf2eae3 100644 (file)
@@ -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
index 9f65386c2abb7a07d0dc75444f60001c79b3791a..42deb4bc54cb4ba04d9fc07d2a769cc637f73080 100644 (file)
@@ -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
 
index 46bb799e68c28ac1531ee572a5e06476884e80ad..574cc774f011b018ca5f48e80d15d7e847b082e1 100644 (file)
@@ -21,6 +21,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
 #include "debug.h"\r
 #include "serialization.h"\r
 #include "porting.h"\r
+#include "config.h"\r
 \r
 GUIPauseMenu::GUIPauseMenu(gui::IGUIEnvironment* env,\r
                gui::IGUIElement* parent, s32 id,\r
@@ -127,11 +128,11 @@ void GUIPauseMenu::regenerateGui(v2u32 screensize)
                                L"Minetest-c55\n"\r
                                L"by Perttu Ahola\n"\r
                                L"celeron55@gmail.com\n\n"\r
-                               L"SER_FMT_VER_HIGHEST=%i\n"\r
-                               L"userdata path = \n"\r
+                               SWPRINTF_CHARSTRING L"\n"\r
+                               L"userdata path = "\r
                                SWPRINTF_CHARSTRING\r
                                ,\r
-                               (int)SER_FMT_VER_HIGHEST,\r
+                               BUILD_INFO,\r
                                porting::path_userdata.c_str()\r
                );\r
        \r