Spinning Topp Logo BlackTopp Studios
inc
building_the_engine.h
1 // © Copyright 2010 - 2016 BlackTopp Studios Inc.
2 /* This file is part of The Mezzanine Engine.
3 
4  The Mezzanine Engine is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  The Mezzanine Engine is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with The Mezzanine Engine. If not, see <http://www.gnu.org/licenses/>.
16 */
17 /* The original authors have included a copy of the license specified above in the
18  'Docs' folder. See 'gpl.txt'
19 */
20 /* We welcome the use of the Mezzanine engine to anyone, including companies who wish to
21  Build professional software and charge for their product.
22 
23  However there are some practical restrictions, so if your project involves
24  any of the following you should contact us and we will try to work something
25  out:
26  - DRM or Copy Protection of any kind(except Copyrights)
27  - Software Patents You Do Not Wish to Freely License
28  - Any Kind of Linking to Non-GPL licensed Works
29  - Are Currently In Violation of Another Copyright Holder's GPL License
30  - If You want to change our code and not add a few hundred MB of stuff to
31  your distribution
32 
33  These and other limitations could cause serious legal problems if you ignore
34  them, so it is best to simply contact us or the Free Software Foundation, if
35  you have any questions.
36 
37  Joseph Toppi - toppij@gmail.com
38  John Blackwood - makoenergy02@gmail.com
39 */
40 
41 #ifndef building_the_engine_h
42 #define building_the_engine_h
43 
44 /**
45  @page building_the_engine Building the %Mezzanine Engine
46  @section building_the_engine_tools Build Tools
47  First thing you will want to do is get the right tools for building and working with the
48  @ref mezzanine_engine. We have pages for each supported platforms tool set, pick the appropriate
49  set for your uses:
50  - @ref dev_tools_windows
51  - @ref dev_tools_linux
52  - @ref dev_tools_mac
53 
54  And be sure you have any optional dependencies installed that you want or need
55 
56  - @ref installing_engine_deps_windows
57  - @ref installing_engine_deps_linux
58  - @ref installing_engine_deps_macosx
59 
60  If you are planning on developing software too it may be a good idea to install a copy of
61  @htmlonly<a href="http://www.codeblocks.org/downloads/26">@endhtmlonly
62  Code::blocks IDE
63  @htmlonly</a>@endhtmlonly
64  ,
65  @htmlonly<a href="http://www.qt.io/ide/">@endhtmlonly
66  Qt Creator
67  @htmlonly</a>@endhtmlonly
68  or another IDE (Integrated Development Environment). You can use any IDE you like, but if you
69  want to ask us IDE questions we will only have answers for the ones we have used. On Mac OS x
70  you will probably want to use xcode.
71 
72  @section building_the_engine_get_source Get the Source Code
73  From a command prompt you can run a few commands to get a copy of the source on your
74  workstation. If you are using windows you could use the
75  @htmlonly<a href="https://git-scm.com/">@endhtmlonly
76  git bash prompt
77  @htmlonly</a>@endhtmlonly
78  , and on Mac OS or Linux the normal terminal or bash prompts should work. If you are using some
79  @htmlonly<a href="https://desktop.github.com/">@endhtmlonly
80  graphical tool
81  @htmlonly</a>@endhtmlonly
82  the steps are the same, but you will have to figure out how to make the software you use perform
83  them.
84  @n @n
85  These commands if copied verbatim on windows will navigate to your C: Drive and create a folder
86  called “Mezzanine” with the source code in it. The actual commands you will type are in
87  italics/highlighted. You can change “c:” to a directory of your choice, such as your desktop or
88  documents folder. You will have to change it if you are not using windows. One thing to note is
89  that one of the linker’s used, windres.exe, does not like spaces in the paths that are passed to
90  it. If you place the Mezzanine repo in a path that has a space in one of the folder names your
91  compile will fail. Avoid paths with spaces in directory names. I.E., a folder named
92  “Documents/Mezzanine” will be ok, but “My Documents/Mezzanine” will fail during compilation.
93  @code
94  dev@DEV-PC ~
95  $ cd c:
96  dev@DEV-PC /c
97  $ git clone git://github.com/BlackToppStudios/Mezzanine.git
98  Cloning into Mezzanine...
99  remote: Counting objects: 117277, done.
100  remote: Compressing objects: 100% (51597/51597), done.
101  remote: Total 117277 (delta 65098), reused 114360 (delta 62444)
102  Receiving objects: 100% (117277/117277), 572.91 MiB | 1.60 MiB/s, done.
103  Resolving deltas: 100% (65098/65098), done.
104  @endcode
105 
106  @n
107  Here is an example of similar commands on Linux:
108 
109  @code
110  sqeaky@Tachyon:~$ mkdir projects
111  sqeaky@Tachyon:~$ cd projects/
112  sqeaky@Tachyon:~/projects$ git clone git://github.com/BlackToppStudios/Mezzanine.git
113  Cloning into 'Mezzanine'...
114  remote: Counting objects: 117277, done.
115  remote: Compressing objects: 100% (51597/51597), done.
116  remote: Total 117277 (delta 65102), reused 114356 (delta 62444)
117  Receiving objects: 100% (117277/117277), 572.90 MiB | 1.94 MiB/s, done.
118  Resolving deltas: 100% (65102/65102), done.
119  @endcode
120 
121  @section building_the_engine_git_urls Git URLs
122  There are a few places and ways you can download the source code. The ones that provide
123  “read only” access refer only to the ability to upload to changes. With any of these methods you
124  can make as many changes as you like to the copy on your machine:
125 
126  - git://github.com/BlackToppStudios/Mezzanine.git – For read only access.
127  - git@github.com:BlackToppStudios/Mezzanine.git – For read/write access (must as us to get
128  write access).
129  @n
130  When using git “git://”, “https://” and “http://” URLs will work with no extra configuration but
131  generally will be read-only. To use a URL that starts with “git@", an SSH URL, you will need an
132  account with the people maintaining the URL (like
133  @htmlonly<a href="https://github.com/join?source=header">@endhtmlonly
134  github.com
135  @htmlonly</a>@endhtmlonly
136  ), setup an RSA-Keypair, and upload your public key to them. See the
137  @htmlonly<a href="https://help.github.com/articles/set-up-git/">@endhtmlonly
138  Github setup page
139  @htmlonly</a>@endhtmlonly
140  setup page for more info, and be certain that the RSA fingerprint matches if it asks you.
141  Additionally, to upload changes a BTS administrator will have to give you permissions on Github
142  to contribute.
143 
144  @n
145  Once you have cloned the Mezzanine repository (or physgame repository if from the older
146  Gitorious backup) the URL setting is stored in “.git/config” and it can be changed with any text
147  editor. The “.git” folder is hidden by default.
148 
149  @n
150  You can also download a zip archive of the source from
151  https://github.com/BlackToppStudios/Mezzanine/. You may have to adjust certain steps if this is
152  the case.
153 
154  @subsection building_the_engine_git_urls_gitorious Gitorious is dead
155  @htmlonly<a href="https://gitorious.org/">@endhtmlonly
156  Gitorious
157  @htmlonly</a>@endhtmlonly
158  , the original hosting site for BTS source code seemed to be non longer functional at the time
159  of this writing. For historic interest here are the old links to those repositories.
160  - git://gitorious.org/physgame/physgame.git – Read only access to the backup
161  - git@gitorious.org:physgame/physgame.git – Read/write access to the backup
162  - http://git.gitorious.org/physgame/physgame.git – Read Only
163 
164  @section building_the_engine_deps Dependencies
165  After you get the source code there may be some steps you need to take to get any software the
166  @ref mezzanine_engine depends on installed and configured. Please take a look at any appropriate
167  steps for your platform:
168 
169  - @ref installing_engine_deps_windows
170  - @ref installing_engine_deps_linux
171  - @ref installing_engine_deps_macosx
172 
173  @subsection building_the_engine_deps_building Building the Shipped Dependencies
174  In the past this was a significantly complex procedure, now almost all of our dependencies have
175  been integrated tightly. Ogre, SDL, Bullet3d and a few others are all built during the CMake
176  build process.
177 
178  The Mezzanine source ships with a copy of SDL and Ogre3d (and a few other) libraries source code
179  that are used internally by it. You won’t need to use these unless you are making advanced
180  changes to the Mezzanine itself, but they will need to be compiled. This will be handled
181  automatically as part of the main source build process.
182 
183  @section building_the_engine_using_cmake Using CMake
184  Cmake will create a set of project files that will tell the compiler how to compile the source
185  you just downloaded. The steps listed here assume that you have the source files in
186  “c:\\Mezzanine\\” and want to have your compiled binaries in “c:\\Mezzbuild\\”. There are a
187  couple of way to do this. You can use the graphical Cmake program or the command line tool.
188 
189  @subsection building_the_engine_cmake_options CMake Options
190  In the graphical version these appear as series of checkboxes, in the command line version you
191  can use the “-D” flag to set these:
192 
193  - Mezz_Debug – Enables Debuging symbols in the Mezzanine library and enable extra logging
194  message. Defaults to false.
195  - Mezz_Doc – Enable Bulding the doxygen documentation
196  - Mezz_Lua51 – Enable/Disable the whole Lua system. Defaults to true/enabled.
197  - Mezz_Network – Enable Networking support. Defaults to true.
198  - Mezz_BuildRenderSystemDirectX9 – This controls support for DirectX 9 a common RenderSystem on
199  all microsoft operating systems. This is experimental.
200  - Mezz_BuildRenderSystemDirectX11 – Controls support DirectX 11 a more advanced RenderSystem
201  only available on newer microsoft operating systems. This is experimental.
202  - Mezz_BuildRenderSystemOpenGL – This is default Render system on Windows, Linux and Mac OS X.
203  - Mezz_BuildRenderSystemOpenGLES – Experimental, this is the render that will be used on some
204  mobiles platforms.
205  - Mezz_BuildRenderSystemOpenGLES2 – Experimental, this is the render that will be used on some
206  mobiles platforms.
207 
208  @subsubsection building_the_engine_advanced_cmake_options Advanced CMake Options
209  Here are some of the advanced features:
210 
211  - Mezz_Profile – Enable compiler level profiling support. Defaults to false.
212  - Mezz_ForceBuildType – Forces The CMake build type to match the Mezz_Debug flag, useful if you
213  to not have debug symbols but want the extra logging Mezz_Debug enables.
214  - Mezz_ThrowOnSingletonFetch – Controls whether getting a singleton when it is invalid throws or
215  returns null.
216  - Mezz_UseOgreVersion – This must be set to match the Ogre3d version if you want to use one not
217  integrated you will need to adjust this.
218 
219  @subsubsection building_the_engine_cmake_option_caveats CMake Option Caveats
220  Currently the Mezz_Profile cmake flag does not work on windows, and will give errors while
221  trying to compile it. Avoid enabling it on windows.
222  @n
223  Mezz_XML Has been deprecated and removed. The XML system is central to many other features, and
224  maintaining this option takes too much time for the value it adds.
225 
226  @subsection building_the_engine_cmake_graphical Graphical Tool
227  First thing to do is open Cmake. The default installation in windows should have put a Cmake
228  icon on you desktop, and another in your start menu. In Ubuntu (and most other modern Linux
229  distributions) when you install “cmake-gui” an entry will be made in the KDE or Gnome menu or
230  Unity panel. Use that icon or menu entry to start it or use "cmake-gui" from a terminal.
231  @n
232  The first box at the top of the screen is called “Where is the source code:”. Select the folder
233  using the “Browse Source” button, or manully type in “c:/Mezzanine”. The next box asks “Where
234  to build binaries:” enter “c:/Mezzbuild”. After that click the configure button in the lower
235  left corner. This will prompt you for what kind of project files to make. If you just want to
236  build the engine and not work with it’s source directly select “Unix Makefiles” or “MinGW
237  Makefiles”, if you do directly want to work with the source code select “Codeblocks – Unix
238  Makefiles” or “Codeblocks – MinGW Makefiles”. When you click finish on this screen Cmake will
239  have figured out most of the information it needs to make the files.
240  @n
241  The last information required before creating project files is any options you want to select.
242  Read below about “The Options” then click “Configure” again after you have made your choice.
243  Then click “Generate” to actually make the project files.
244 
245  @subsection building_the_engine_cmake_cmd Command Line Tool
246  There are a few different ways to use CMake from the command line. Ideally this should be run
247  from the directory the compiled binaries are desired in, this is called the build directory.
248  Cmake should be passed the directory with the Mezzanine repository. On Linux, but otherwise
249  similar to our previous example, you could:
250 
251  @code
252  cmake ../Mezzanine/
253  @endcode
254 
255  @n
256  When run from windows it might look the same if run from a Git bash prompt, or it could like the
257  following if run from a DOS prompt:
258 
259  @code
260  cmake ..\\Mezzanine\\
261  @endcode
262 
263  @subsubsection building_the_engine_cmake_generators CMake Generators
264  There are many kinds of files CMake can output. The way you select these are by passing cmake a
265  generator. Most commonly we will recommend Makefiles or Codeblocks project files. There are
266  several other kinds of files available for creation, but they are beyond the scope of this
267  document. The most common generators we use are:
268  @n
269  On Linux:
270 
271  - CodeBlocks - Unix Makefiles
272  - CodeBlocks - Ninja
273  - Unix Makefiles
274  - Ninja
275 
276  @n
277  On Windows:
278 
279  - Codeblocks – MinGW Makefiles
280  - MinGW Makefiles
281 
282  @n
283  These can be entered with the “-G” switch (also called an argument) for example:
284 
285  @code
286  cmake ../Mezzanine/ -G"CodeBlocks - Unix Makefiles"
287  @endcode
288 
289  @subsection building_the_engine_entering_option Entering options
290  All of the options listed above can be entered with the “-D” switch. After the name of the name
291  of the option you need to include either “:boolean=true” or “:boolean=false”, for example:
292 
293  @code
294  cmake ../Mezzanine/ -G"CodeBlocks - Unix Makefiles" -DMezz_Debug:boolean=true
295  @endcode
296  Game Developers will probably want the default options, which leave Profiling support and
297  debugging support off.
298 
299  If you read the output of cmake, it will tell you what is enabled or disabled in plain
300  English. With messages being similar to
301 
302  @code
303  -- MezzanineAndCatch - Disabling gcc profiling and unsetting MEZZPROFILE
304  -- MezzanineAndCatch - Enabling Network subsystem, and setting MEZZNETWORK
305  -- MezzanineAndCatch - Enabling Support for Lua Scripting Language, and setting MEZZLUA51
306  -- MezzanineAndCatch - Disabling Support for Ruby Scripting Language, and unsetting MEZZRUBY
307  -- MezzanineAndCatch - Disabling Swig execution each build.
308  -- MezzanineAndCatch - Enabling EntreLua build.
309  @endcode
310 
311  You might want to disable an option, or use multiple. Here is an example of enabling debug
312  support and disabling DirectX 11.
313 
314  @code
315  cmake ../Mezzanine/ -G"CodeBlocks - Unix Makefiles" -DMezz_Debug:boolean=true -DMezz_BuildRenderSystemDirectX11:boolean=false
316  @endcode
317 
318  @subsection building_the_engine_common_cmake_issues Common Issues with CMake
319  On windows, if CMake complains about finding “sh.exe” in the system path then you will need to
320  edit the system path variable to remove “c:\\program files\\git\\bin” from your PATH. See above
321  for instructions on Editing your PATH variable.
322 
323  @section building_the_engine_actually Compiling the Engine
324  Once you have your project files or makefiles you can compile the engine. There are two way to
325  do this. People interested in the engine code can use the Code::Blocks IDE to compile the engine
326  (Engine Developers and some Game Developers). People who aren’t interested in engine code can
327  use make or ninja from a command line (some Game Developers, people installing the engine and
328  Package Maintainers)
329 
330  @n
331  This can take anywhere from 10 seconds to a couple of hourse depending on the speed of your
332  computer. Various netbooks have taken between 30 and 45 minutes for a fresh compile all build
333  targets, and 20 seconds to 90 seconds for a partial compile of one build target that uses the
334  Mezzanine. Our i7 machine took around two minutes for a full build and less than a second for
335  a partial build.
336 
337  @subsection building_the_engine_using_codeblocks Build with Code::Blocks
338  All you have to do is open Code::Blocks by double clicking on the “MezzanineAndCatch.cbp” icon
339  in your build directory, selecting the Build Target you want to build, and finally clicking on
340  the green gear to compile.
341 
342  @n
343  To speed this up or better understand the process here is a little more information that might
344  be useful.
345 
346  @subsection building_the_engine_using_codeblocks_cpus Code::Blocks and Multiple CPUs
347  When Code::Blocks is already open you can go to the “Settings” menu and select “Compiler and
348  Debugger”, which will open a screen with a “Build Options” tab (you may need to scroll left or
349  right to see it), which will have the “Number of parallel builds” option. This should be set to
350  on or around the amount of hardware threads (CPUs + hyperthreading cores) your computer
351  supports. On our i7 it is set to 9 and on the netbooks it was set to two or three.
352 
353  @n
354  In an IDE that uses make for the build process, you just add an argument in the menu that
355  defines how make is called. In QT Creator, for example, you can configure it “-j9” for nine
356  compilation threads, in the “Projects” Sidebar in the “Build Steps” section. You can use any
357  amount of threads that you see fit, try numbers around the amount of “Cores” your CPU provides.
358 
359  @subsection building_the_engine_terminal Build with Command Line
360  If you open a Git Bash prompt on a window, or terminal on Mac OS X or Linux, then cd to your
361  build directory and enter the “make” command, you have started the engine compiling. (This only
362  works if using GCC, MinGW or Clang compilers)
363 
364  @n
365  This runs slightly faster than a compilation from Code::Blocks, but not by much. The easiest way
366  to speed this up is to tell make to use multiple thread to perform the compilation. This can be
367  done with the “-j” switch, and the number of threads you want to run.
368 
369  @n
370  The following examples will run the compilition in 4 threads which would be suitable for a
371  typical quad-core machine:
372 
373  @n On Linux or Mac OS X:
374  @code
375  make -j4
376  @endcode
377 
378  @n On windows:
379  @code
380  mingw32-make -j4
381  @endcode
382 
383  @n On any OS with ninja installed:
384  @code
385  ninja -j4
386  @endcode
387 
388  @section building_the_engine_build_targets Build Targets
389  There are many build targets to choose from, here is a brief synopsis of the interesting ones.
390 
391  - All – Builds Everything
392  - Mezzanine – The engine and what it requires
393  - Catch – Just the Catch game and the engine if the files present aren’t current
394  - UnitTests – the Testing suite and the engine if the files present aren’t current
395  - EngineDemo – A simple Engine Demo and the engine if the files present aren’t current
396  - /fast – (Code::Blocks only) Builds whatever * is, but skips any checks of the engine
397  - Anything else – A component of the engine
398 
399  @n In Code::Blocks you can just select these from the build menu, from the command prompt you
400  can add these to the end the build command to build just one target. For example these will all
401  build the EngineDemo and only what it requires (So it won't build Catch!):
402 
403  @n On Linux or Mac OS X:
404  @code
405  make -j4 EngineDemo
406  @endcode
407 
408  @n On windows:
409  @code
410  mingw32-make -j4 EngineDemo
411  @endcode
412 
413  @n On any OS with ninja installed:
414  @code
415  ninja -j4 EngineDemo
416  @endcode
417 
418  @section building_the_engine_compilation_issues Compilation Issues
419  The are a ton of waystis can fail, here are some.
420 
421  @subsection building_the_engine_issue_ogre_endian Ogre Little Endian issue
422  If you get the following warning, there is a workaround. This seems to have stopped happening
423  since the release of the 1.7 branch of cmake.
424 
425  @code
426  libincludes/linux/ogresrc/include/OgreBuildSettings.h:19:1: warning: "OGRE_CONFIG_LITTLE_ENDIAN" redefined
427  : warning: this is the location of the previous definition
428  @endcode
429 
430  You could remark our one of those definitions like this one on line 19 of OgreBuildSettings.h.
431  Double clicking on the warning message in the Messages Window which is at the bottom of
432  Code::Blocks will open the file to the error by default.
433 
434  @code
435  #define OGRE_CONFIG_LITTLE_ENDIAN
436  All you need to do is change the line like this:
437  //#define OGRE_CONFIG_LITTLE_ENDIAN
438  @endcode
439 
440  Then any time you compile the engine you won’t get anymore warnings for these bugs in the Ogre
441  build process.
442 
443  @subsection building_the_engine_issue_rendersystem_copy Rendersystem copy errors
444  Sometimes it is possible for Ogre to skip building a rendersystem, but does not to let you know
445  in a clear way. In general this happens if it have been tricked into compiling against a
446  software open renderer. The Error looks something like:
447 
448  @code
449  Preparing File: /home/sqeaky/Projects/MezzanineCurrent/Build/Mezzanine/bin/data/linux/ogre/RenderSystem_GL.so
450  Error copying file (if different) from “/home/sqeaky/Projects/MezzanineCurrent/Mezzanine/Mezzanine/data/linux/ogre/RenderSystem_GL.so” to “/home/sqeaky/Projects/MezzanineCurrent/Build/Mezzanine/bin/data/linux/ogre/RenderSystem_GL.so”.
451  @endcode
452 
453  This has only been experience on Ubuntu and installing the Mesa GL headers fixes it:
454  @code
455  sudo apt-get install libgles1-mesa-dev
456  @endcode
457 */
458 
459 #endif