diff options
-rw-r--r-- | CMakeLists.txt | 10 | ||||
-rw-r--r-- | COMPILING.md | 73 | ||||
m--------- | MCServer/Plugins/Core | 0 |
3 files changed, 72 insertions, 11 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6e88a8337..f2ad8b364 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,13 @@ endif() if(MSVC) # Make build use multiple threads under MSVC: add_flags_cxx("/MP") + + # Make release builds use link-time code generation: + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /GL") + set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /GL") + set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /LTCG") + set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /LTCG") + set(CMAKE_MODULE_LINKER_FLAGS_RELEASE "${CMAKE_MODULE_LINKER_FLAGS_RELEASE} /LTCG") elseif(APPLE) #on os x clang adds pthread for us but we need to add it for gcc if (NOT "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") @@ -172,7 +179,6 @@ MARK_AS_ADVANCED( set(CMAKE_CONFIGURATION_TYPES "Debug;Release;DebugProfile;ReleaseProfile" CACHE STRING "" FORCE) project (MCServer) - # Include all the libraries: add_subdirectory(lib/inifile/) add_subdirectory(lib/jsoncpp/) @@ -196,5 +202,5 @@ if (NOT MSVC) string(REPLACE "-w" "" CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG}") endif() -add_subdirectory (src) +add_subdirectory (src) diff --git a/COMPILING.md b/COMPILING.md index e10acee98..6438a2839 100644 --- a/COMPILING.md +++ b/COMPILING.md @@ -1,24 +1,79 @@ -COMPILING -========= +# COMPILING # -To compile MCServer on *nix, you need CMake and make, as well as a C compiler, C++ compiler and linker. +To compile MCServer from source, you need CMake and make, as well as a C compiler, C++ compiler and linker. To contribute code, you also need a Git client. -Release Mode ------------- +## Windows ## + +We use Microsoft Visual Studio for Windows compilation. It is possible to use other toolchains, but it isn't tested nor supported. Visual Studio versions 2008 Express and 2013 Express are being actively used for development, so either should work. +You can find download links for VS2008 Express here: http://stackoverflow.com/questions/15318560/visual-c-2008-express-download-link-dead +And VS2013 Express here: http://www.microsoft.com/en-us/download/details.aspx?id=40787 + +Next, you need to download and install CMake. Download from here: http://cmake.org/cmake/resources/software.html . You should download a full installation package, so that the installer will set everything up for you (especially the paths). + +To contribute your changes to the sources back to the repository, you need a Git client. Options are: +- MsysGit: http://msysgit.github.io/ +- GitHub windows client: http://windows.github.com/ +- TortoiseGit: http://code.google.com/p/tortoisegit/ + +Alternatively, if you want only to compile the source, without contributing, you can download the sources in a ZIP file directly from GitHub: https://github.com/mc-server/MCServer/archive/master.zip +If you're using Git to get the sources, use the following set of commands to set up the local workspace correctly: +``` +mkdir MCServer +cd MCServer +git clone https://github.com/mc-server/MCServer.git . +git submodule init +git submodule update +``` + +Now that you have the sources, it's time to prepare the project files for your favorite compiler. Open a command window in the folder with the sources and type in `cmake .` . This will run CMake, it will auto-detect your Visual Studio version and produce the appropriate project and solution files. + +Finally, open the newly created file, `MCServer.sln`, in your Visual Studio. + +If you want to run MCServer from within the IDE, you need to first make sure that it will be run with the correct home folder. Normally this happens automatically, but for some Visual Studio versions the process doesn't stick. Right-click on the MCServer project in the Solution Explorer tool window, and select Properties. In the dialog, navigate to Configuration properties -> Debugging in the tree on the left, then make sure the value `Working Directory` is set to `../MCServer`. If you don't do this, the server won't be able to find crafting recipes, item names or plugins. + +### Release configuration ### + +To make Visual Studio produce the version with the best performance, you will need to select a Release configuration. Go to menu Build -> Configuration Manager, and in the opened dialog, change the top left combo box (Active solution configuration) to Release. Close the dialog and build the solution. The resulting executable is called `MCServer.exe` in the `MCServer` folder. + +### Debug configuration ### + +In order to tinker with the code, you'll more than likely need to use the debugging features of the IDE. To make them the easiest to use, you should switch to the Debug configuration - this provides the highest level of information while debugging, for the price of the executable being 2 - 10 times slower. Go to menu Build -> Configuration Manager, and in the opened dialog, change the top left combo box (Active solution configuration) to Debug. Close the dialog and build the solution. The resulting executable is called `MCServer_debug.exe` in the `MCServer` folder. + +### Profiling ### + +It is possible to use an external profiler to learn more about how the code performs. You can find more information about the techniques in the article here: http://www.codeproject.com/Articles/144643/Profiling-of-C-Applications-in-Visual-Studio-for-F + +There's a script file, `MCServer/profile_run.cmd` that encapsulates most of the profiling work, have a look at the comments at the top of that script for details on how to get it to work. You'll need to change to a profiled configuration (both debug and release can be profiled). + +## Linux, MacOS, FreeBSD etc. ## + +Install git, cmake and gcc or clang, using your platform's package manager: +``` +sudo apt-get install git cmake gcc +``` + +### Getting the sources ### +``` +mkdir MCServer +cd MCServer +git clone https://github.com/mc-server/MCServer.git . +git submodule init +git submodule update +``` + +### Release Mode ### Release mode is preferred for almost all cases, it has much better speed and less console spam. However, if you are developing MCServer actively, debug mode might be better. cmake . -DCMAKE_BUILD_TYPE=RELEASE && make -Debug Mode ----------- +### Debug Mode ### Debug mode is useful if you want more debugging information about MCServer as it's running or if you want to use a debugger like GDB to debug issues and crashes. cmake . -DCMAKE_BUILD_TYPE=DEBUG && make -32 Bit Mode ------------ +### 32 Bit Mode ### This is useful if you want to compile MCServer to use on another 32-bit machine. It can be used with debug or release mode. To use 32 bit mode, simply add: diff --git a/MCServer/Plugins/Core b/MCServer/Plugins/Core -Subproject 944b0e95303a17200e52699c3bc7c349424be58 +Subproject decc72f3a9134d80df5e14c3f2570e1479d521c |