Difference between revisions of "Compiling using CMake"

From OdaWiki
(Alternate SDL installations)
(Server notes)
 
(48 intermediate revisions by 5 users not shown)
Line 1: Line 1:
According to the Wikipedia page, CMake is a unified, cross-platform, open-source build system that enables developers to build, test and package software by specifying build parameters in simple, portable text files. It works in a compiler-independent manner and the build process works in conjunction with native build environments, such as make, Apple's Xcode and Microsoft Visual Studio. It also has minimal dependencies, C++ only. CMake is open source software and is developed by Kitware.
+
According to the Wikipedia page, [http://en.wikipedia.org/wiki/CMake CMake] is a unified, cross-platform, open-source build system that enables developers to build, test and package software by specifying build parameters in simple, portable text files. It works in a compiler-independent manner and the build process works in conjunction with native build environments, such as make, Apple's Xcode and Microsoft Visual Studio. It also has minimal dependencies, C++ only. CMake is open source software and is developed by Kitware.
  
CMake can:
+
== Compatibility ==
* Create libraries
+
* '''Windows'''
* Generate wrappers
+
**• ''Visual C++ 2010 (up to 2017)'' can compile the client, server and master without issues.
* Compile source code
+
**• ''MinGW Makefiles'' can compile the client, server and master without issues.
* Build executables in arbitrary combinations
+
**• ''Code::Blocks (MinGW)'' can compile the client, server and master without issues.
 
+
*** You '''must''' select a type of build (Debug/Release/etc.) when generating the project file, as the project does NOT have separate Debug and Release targets for every target'''This is by design and has no fix.'''  If you want to be able to switch between Debug and Release easily, keep two build directories.
Since the CMake build files are not in Odamex's source tree yet, you can grab a patch file that can be applied against the base directory of an SVN checkout [http://odamex.net/bugs/show_bug.cgi?id=284 link here]The correct patch is by Alexander Mayfield, the one by Albert Brown has not been updated since 2007.
+
* '''Mac OS X'''
 +
**• ''Makefiles'' on Mac OS X 10.6 can compile the client, server, launchers and master.
 +
* '''Linux'''
 +
**• ''Makefiles'' can compile the client, server, launcher, and master without issue.
 +
**• ''Code::Blocks'' uses Makefiles, so is equally as compatible.
 +
* '''FreeBSD'''
 +
**• ''Makefiles'' can compile the client, server and master without issue.
  
 
== Windows ==
 
== Windows ==
 +
 +
[[Image:CMake_Win_GUI.png|thumb|cmake-gui running in Windows]]
  
 
=== Installing CMake ===
 
=== Installing CMake ===
Line 17: Line 25:
 
=== Compiling Odamex ===
 
=== Compiling Odamex ===
  
Once you have Odamex checked out from SVN, start cmake-guiFrom there, you need to fill out two pieces of information:
+
There are many options for compiling Odamex on Windows using CMake, and what you decide depends heavily on which IDE and compiler you have installedIf you don't have a compiler or IDE yet, you have a couple of choices:  
  
* '''Where is the source code:''' Pick out the folder where you checked out Odamex.
+
* If you just want to compile Odamex with the least amount of hassle, '''MinGW Makefiles''' require the least amount of setup.
* '''Where to build the binaries:''' Create a folder somewhere where you would like the project files or makefile to be stored. If you're not sure where to put it, create a new folder called ''build'' in the folder where you checked out Odamex.
+
* If you want to use the same thing most other Odamex developers use, '''Code::Blocks''' is the recommended path.
 +
* You can also use '''Visual C++''' if you prefer to use a Microsoft IDE and compiler.
  
Once you've done that, click the button that says "Configure".  A box should pop up asking you for a "generator". The choice you make here will vary depending on your compiler:
+
There are many other generators available for CMake, however there are simply too many combinations and corner cases to cover in this wiki.
  
* '''Visual Studio 8 2005''': For compiling with Visual Studio 2005
+
==== MinGW Makefiles ====
* '''Visual Studio 9 2008''': For compiling with Visual Studio 2008
+
# If you do not have MinGW already installed, follow the installation instructions for MinGW [http://www.mingw.org/wiki/Getting_Started here].
* '''Visual Studio 10:''' For compiling with Visual Studio 2010
+
# Follow the installation instructions for any [[Required Libraries]] you might need.
 +
# Start up the CMake GUI tool.
 +
# In the input field labeled '''Where is the source code:''' pick out the folder where you checked out Odamex.
 +
# In the input field labeled '''Where to build the binaries:''' create a folder somewhere where you would like the Code::Blocks workspace to be created.  If you're not sure where to put it, create a new folder called <tt>build</tt> in the folder where you checked out Odamex.
 +
# Click '''Configure'''.
 +
#* If you get an error message at this point about a missing dll file, please re-read the installation instructions for MinGW [http://www.mingw.org/wiki/Getting_Started here], particularly the part about adding <tt>C:\MinGW\bin</tt> to your <tt>PATH</tt> environment.
 +
# You should see a dialog box pop up.  From the drop-down list, pick '''MinGW Makefiles''' and make sure '''Use default native compilers''' is selected, then click '''Finish'''.
 +
# After a few moments, you will see warnings about how SDL and SDL_mixer could not be found.
 +
#* If you don't care about building the client, skip to the next step.
 +
#* If you want to build the client, you need to set the '''SDL_INCLUDE_DIR''', '''SDL_LIBRARY_TEMP''', '''SDL_MIXER_INCLUDE_DIR''' and '''SDL_MIXER_LIBRARY''' cache variables.  You need to check the "advanced" checkbox in order to see some of them.  The INCLUDE_DIR entries points to the <tt>include</tt> directories of the libraries you just downloaded, '''SDL_LIBRARY_TEMP''' should point directly at the file <tt>libSDL.dll.a</tt> in the <tt>lib</tt> directory, and '''SDL_MIXER_LIBRARY''' should point directly at '''SDL_mixer.lib'''.
 +
#* '''If you have Odamex installed to C:\Program Files, read this!''' For some reason, CMake will point to the libraries you have in C:\Program Files\Odamex instead of the correct path.  Make sure that '''SDLMIXER_LIBRARY''' points to <tt>SDL_mixer.lib</tt>, and '''SDL_LIBRARY''' points to <tt>libSDL.dll.a</tt>.  If they're not, change them so they are.  All three of these files should be in the SDL library directories you just downloaded.
 +
# Click on the drop-down list next to '''CMAKE_BUILD_TYPE''' and select which type of build you would like to generate.  Most likely, you will want to select Debug.
 +
# Click '''Generate'''.
 +
# Open up a Command Prompt and change to the <tt>build</tt> directory you created earlier.
 +
# Run the following command:
 +
#* If you want to build everything: <code>mingw32-make</code>
 +
#* If you want to build just the client: <code>mingw32-make odamex</code>
 +
#* If you want to build just the server: <code>mingw32-make odasrv</code>
 +
#* If you want to build just the master: <code>mingw32-make odamast</code>
 +
#* If you want to clean up your build tree: <code>mingw32-make clean</code>
  
Make sure "Use default native compilers" is selected before hitting Finish.
+
==== Code::Blocks ====
 +
The configuration and generation steps are largely the same as above.  However, when the CMake GUI asks you to select a generator, make sure and select '''CodeBlocks - MinGW Makefiles'''.  And of course, instead of going to the command line and running <code>mingw32-make</code>, simply open the generated project with Code::Blocks.
  
Now, at this point you will see some output from CMake.  Once it finishes, you might notice that there are a few warning messages that pop up saying that CMake can't find SDL.
+
==== Visual C++ ====
 
+
# Follow the installation instructions for any [[Required Libraries]] you might need.
* If you are not interested in compiling the client, you can ignore those warnings and click Generate.
+
# Install a copy of Visual C++. We highly recommend you Visual Studio 2017 Community, available for free [https://visualstudio.microsoft.com/downloads here].
* If you want to compile the client, select the row in the upper box that says "SDLDIR" and click on the button with three dots in it. Once you see the folder dialog, select the folder where you extracted SDL to and hit OKRepeat the process for "SDLMIXERDIR" except this time you are looking for the folder where you extracted SDL_mixer to.  From there, click Configure again and this time you should get no warnings, so click Generate.
+
# Start up the CMake GUI tool.
 
+
# In the input field labeled '''Where is the source code:''', pick out the folder where you checked out Odamex.
If you take a look at the folder that you selected for '''Where to build the binaries''', you should now see a bunch of new filesWhat you do now depends on your compiler:
+
# In the input field labeled '''Where to build the binaries:''', create a folder somewhere where you would like the workspace to be createdIf you're not sure where to put it, create a new folder called <tt>build</tt> in the folder where you checked out Odamex.
 
+
# Click on '''Configure'''.
==== Visual Studio 2010 ====
+
# You should see a dialog box pop up. From the drop-down list, pick:
Double click on the .sln file to open it.  If you want to build all three projects simply hit '''F7''' to build the entire solution, otherwise simply right click on the project you want to compile in the Solution Explorer and click Build. From there, you can individually right click on each project in the Solution Explorer and click Debug -> Start new instance to launch the given project.
+
#*• '''"Visual Studio 15 2017"''' if you want to build 32-bit (x86) binaries.
 +
#*• '''"Visual Studio 15 2017 Win64"''' if you want to build 64-bit (x64) binaries.
 +
# Make sure '''Use default native compilers''' is selected, then click '''Finish'''.
 +
# After a few moments, you will see warnings that a few libraries (such as SDL2 and SDL2_mixer) could not be found.
 +
#*If you don't care about building the client, skip to the next step.
 +
#*• If you want to build the client, you need to set the '''SDL2_INCLUDE_DIR''', '''SDL2_LIBRARY''', '''SDL2_MIXER_INCLUDE_DIR''' and '''SDL2_MIXER_LIBRARY''' cache variablesYou may need to check the "advanced" checkbox in order to see some of themThe INCLUDE_DIR entries points to the <tt>include</tt> directories of the libraries you just downloaded, '''SDL2_LIBRARY''' should point directly at the file <tt>SDL2.lib</tt> in the <tt>lib</tt> directory, and '''SDL2_MIXER_LIBRARY''' should point directly at '''SDL2_mixer.lib'''.
 +
#* '''If you have Odamex installed to C:\Program Files, read this!''' For some reason, CMake will point to the libraries you have in C:\Program Files\Odamex instead of the correct pathMake sure that '''SDL2_MIXER_LIBRARY''' points to <tt>SDL2_mixer.lib</tt>, and '''SDL2_LIBRARY''' points to <tt>SDL2.lib</tt>.  If they're not, change them so they are.  All three of these files should be in the SDL library directories you just downloaded.
 +
# Click on '''Generate'''.
 +
# Navigate to the <tt>build</tt> directory you created earlier and double click on the '''Odamex.sln''' solution file to open it in Visual Studio.
 +
# Press F5 to build the entire project.
  
 
=== Running Odamex ===
 
=== Running Odamex ===
Line 45: Line 83:
  
 
==== Client notes ====
 
==== Client notes ====
 +
[[Image:CMake_Win_ClientDir.png|thumb|A fully-populated client directory]]
 
The first time you run the client after building it, you will get an error message about a missing SDL.dll file.  You need to copy:
 
The first time you run the client after building it, you will get an error message about a missing SDL.dll file.  You need to copy:
* SDL.dll from the SDL Development Library's ''lib'' folder.
+
* <tt>SDL.dll</tt> from the SDL Development Library's <tt>lib</tt> folder.
* All of the DLL files from the SDL_mixer Development Library's ''lib'' folder.
+
* All of the DLL files from the SDL_mixer Development Library's <tt>lib</tt> folder.
* odamex.wad from the base odamex SVN checkout folder.
+
* <tt>odamex.wad</tt> from the base odamex GitHub checkout folder.
 
* A DOOM IWAD from one of your installations of DOOM.
 
* A DOOM IWAD from one of your installations of DOOM.
...into the folder where odamex.exe is.  It is either located in the ''client'' subfolder of your build folder, or in one of the subfolders within ''client''.
+
...into the folder where <tt>odamex.exe</tt> is.  It is either located in the <tt>client</tt> subfolder of your build folder, or in one of the subfolders within <tt>client</tt>.
  
 
==== Server notes ====
 
==== Server notes ====
 
The first time you build the server after building it, you will get an error message about not being able to find odamex.wad.  You need to copy:
 
The first time you build the server after building it, you will get an error message about not being able to find odamex.wad.  You need to copy:
* odamex.wad from the base odamex SVN checkout folder.
+
* <tt>odamex.wad</tt> from the base odamex GitHub checkout folder.
 
* A DOOM IWAD from one of your installations of DOOM.
 
* A DOOM IWAD from one of your installations of DOOM.
...into the folder where odasrv.exe is.  It is either located in the ''server'' subfolder of your build folder, or in one of the subfolders within ''server''.
+
...into the folder where <tt>odasrv.exe</tt> is.  It is either located in the <tt>server</tt> subfolder of your build folder, or in one of the subfolders within <tt>server</tt>.
  
 
== Linux ==
 
== Linux ==
Line 66: Line 105:
 
Depending on your Linux distribution, you may or may not have a copy of CMake in your software repository.  Even if you do, the version that is available might not be up-to-date.  The following distributions have a version of CMake 2.8, which is what the current build script requires.
 
Depending on your Linux distribution, you may or may not have a copy of CMake in your software repository.  Even if you do, the version that is available might not be up-to-date.  The following distributions have a version of CMake 2.8, which is what the current build script requires.
  
* Debian 6.0: '''CMake 2.8.2''' aptitude install cmake
+
* Debian 6.0: '''CMake 2.8.2''' <code>aptitude install cmake</code>
* Fedora 15: '''CMake 2.8.4''' yum install cmake
+
* Fedora 15: '''CMake 2.8.4''' <code>yum install cmake</code>
* openSUSE 11.4: '''CMake 2.8.3''' zypper in cmake
+
* openSUSE 11.4: '''CMake 2.8.3''' <code>zypper in cmake</code>
* Slackware 13.37 '''CMake 2.8.4''' pkgtool
+
* Slackware 13.37 '''CMake 2.8.4''' <code>pkgtool</code>
* Ubuntu 10.04 LTS: '''CMake 2.8.0''' apt-get install cmake
+
* Ubuntu 10.04 LTS: '''CMake 2.8.0''' <code>apt-get install cmake</code>
* Ubuntu 11.04: '''CMake 2.8.3''' apt-get install cmake
+
* Ubuntu 11.04: '''CMake 2.8.3''' <code>apt-get install cmake</code>
  
 
The following distributions have an out-of-date version of CMake.  You are welcome to bypass the version check and see if it still works.  Assuming that there isn't too much breakage and workarounds needed to support it, "official" support for CMake 2.6 will be considered.
 
The following distributions have an out-of-date version of CMake.  You are welcome to bypass the version check and see if it still works.  Assuming that there isn't too much breakage and workarounds needed to support it, "official" support for CMake 2.6 will be considered.
  
* CentOS 5.x: '''CMake 2.6.4 (through [http://fedoraproject.org/wiki/EPEL EPEL])''' yum install cmake
+
* CentOS 5.x: '''CMake 2.6.4 (through [http://fedoraproject.org/wiki/EPEL EPEL])''' <code>yum install cmake</code>
* Debian 5.0: '''CMake 2.6.0''' aptitude install cmake
+
* Debian 5.0: '''CMake 2.6.0''' <code>aptitude install cmake</code>
* Red Hat Enterprise Linux 5.x: '''CMake 2.6.4 (through [http://fedoraproject.org/wiki/EPEL EPEL])''' yum install cmake
+
* Red Hat Enterprise Linux 5.x: '''CMake 2.6.4 (through [http://fedoraproject.org/wiki/EPEL EPEL])''' <code>yum install cmake</code>
* Scientific Linux 5.x: '''CMake 2.6.4 (through [http://fedoraproject.org/wiki/EPEL EPEL])''' yum install cmake
+
* Scientific Linux 5.x: '''CMake 2.6.4 (through [http://fedoraproject.org/wiki/EPEL EPEL])''' <code>yum install cmake</code>
  
 
If you do not have an up-to-date CMake, or would prefer to use the absolute latest version, both binary and source tarballs can be downloaded [http://www.cmake.org/cmake/resources/software.html here].
 
If you do not have an up-to-date CMake, or would prefer to use the absolute latest version, both binary and source tarballs can be downloaded [http://www.cmake.org/cmake/resources/software.html here].
  
 
=== Compiling Odamex ===
 
=== Compiling Odamex ===
 
+
[[Image:CMake_Linux_Compiled.png|thumb|Finished compiling!]]
Once you have Odamex checked out from SVN, change to the directory where you checked it out.  From there, the process is relatively simple:
+
Once you have Odamex checked out from GitHub, change to the directory where you checked it out.  From there, the process is relatively simple:
  
 
<pre>mkdir build && cd build && cmake ..</pre>
 
<pre>mkdir build && cd build && cmake ..</pre>
Line 90: Line 129:
 
You might see warnings about not being able to find SDL or SDL_mixer.  If you are not interested in compiling the client, ignore the warnings.  Otherwise, please see the [[Required Libraries]] page for instructions on how to install SDL and SDL_mixer and try again.
 
You might see warnings about not being able to find SDL or SDL_mixer.  If you are not interested in compiling the client, ignore the warnings.  Otherwise, please see the [[Required Libraries]] page for instructions on how to install SDL and SDL_mixer and try again.
  
==== Build Types ====
+
Once <tt>cmake</tt> finishes its job, run the following command:
 +
* If you want to build everything: <code>make</code>
 +
* If you want to build just the client: <code>make odamex</code>
 +
* If you want to build just the server: <code>make odasrv</code>
 +
* If you want to build just the master: <code>make odamast</code>
 +
* If you want to clean up your build tree: <code>make clean</code>
 +
 
 +
===== Build Types =====
  
 
CMake gives you a choice of four build types.  The default build type is Debug, but there are four choices:
 
CMake gives you a choice of four build types.  The default build type is Debug, but there are four choices:
Line 103: Line 149:
 
<pre>cmake .. -DCMAKE_BUILD_TYPE=Release</pre>
 
<pre>cmake .. -DCMAKE_BUILD_TYPE=Release</pre>
  
=== Alternate SDL installations ===
+
==== Using Clang + LLVM ====
 +
 
 +
If you prefer to use clang instead of gcc, you can:
 +
 
 +
<pre>export CC=/usr/bin/clang
 +
export CXX=/usr/bin/clang++
 +
cmake -D_CMAKE_TOOLCHAIN_PREFIX=llvm- ..</pre>
 +
 
 +
Note that CMake bakes the <tt>CC</tt> and <tt>CXX</tt> variables into the generated makefile, so you do not have to export them again if you run the makefile in a fresh shell environment.
 +
 
 +
==== Alternate SDL installations ====
  
 
If you are testing Odamex against multiple SDL versions, you can do so like this (assuming you compiled it with --prefix==/opt/SDL-1.2.13)
 
If you are testing Odamex against multiple SDL versions, you can do so like this (assuming you compiled it with --prefix==/opt/SDL-1.2.13)
Line 111: Line 167:
 
If you want to use a custom SDL_mixer as well, you can --prefix it into the same directory as your custom SDL and CMake will pick up on it automatically via SDLDIR.  Otherwise, you can also manually specify SDL_mixer like so:  
 
If you want to use a custom SDL_mixer as well, you can --prefix it into the same directory as your custom SDL and CMake will pick up on it automatically via SDLDIR.  Otherwise, you can also manually specify SDL_mixer like so:  
  
<pre>cmake .. -DSDLDIR=/opt/SDL_mixer-1.10</pre>
+
<pre>cmake .. -DSDLMIXERDIR=/opt/SDL_mixer-1.10</pre>
 +
 
 +
Obviously you can mix and match the two params as you please (stock SDL and custom SDL_mixer, stock SDL and custom SDL_mixer, etc).
 +
 
 +
==== GUI Tool ====
 +
 
 +
If you want a tool similar to cmake-gui on Windows, there is an ncurses tool that comes with CMake called <tt>ccmake</tt>.  The command-line syntax for using it is the same as <tt>cmake</tt>, but it gives you a nice little graphical interface to double-check the cache file with.
 +
 
 +
== Mac OS X ==
 +
 
 +
The latest version of CMake can be downloaded from Kitware's website [http://www.cmake.org/cmake/resources/software.html here].
 +
 
 +
You can also install the latest version using your package manager of choice:
 +
* Homebrew: <code>brew install cmake</code>
 +
 
 +
=== Compiling Odamex ===
 +
 
 +
See [http://odamex.net/w/index.php?title=Compiling_using_CMake&action=submit#Compiling_Odamex_2 Compiling Odamex on Linux]
 +
 
 +
==== Xcode ====
 +
 
 +
CMake supports generating Xcode project files.
 +
 
 +
<pre>cmake -G Xcode ..</pre>
 +
 
 +
==== OS X 10.4 Tiger ====
 +
 
 +
CMake can configure the build to use the OS X 10.4 Tiger SDK. This is useful for supporting as wide a range of OS X versions as possible. It is also required in order to build for ppc or to build a universal binary that includes ppc support.
 +
 
 +
<pre>cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.4 \
 +
  -DCMAKE_OSX_SYSROOT=/Developer/SDKs/MacOSX10.4u.sdk \
 +
  -DCMAKE_CXX_COMPILER=g++-4.0 ..</pre>
 +
 
 +
These options can also be used to support any other installed SDK when something other than the system default is desired.
 +
 
 +
==== Universal Binaries ====
  
Obviously you can mix and match the two params as you please (stock SDL and custom SDL_mixer, stock SDL and custom SDL_mixer, etc.).
+
CMake also supports building universal binaries. For example, if you were interested in building a universal binary with ppc and i386 support:
  
=== GUI Tool ===
+
<pre>cmake -DCMAKE_OSX_ARCHITECTURES="ppc;i386" ..</pre>
  
If you want a tool similar to cmake-gui on Windows, there is an ncurses tool that comes with cmake called ccmake.  The command-line syntax for using it is the same as cmake, but it gives you a nice little graphical interface to double-check the cache file with.
+
Valid values for CMAKE_OSX_ARCHITECTURES are <tt>ppc</tt>, <tt>i386</tt>, <tt>ppc64</tt> and <tt>x86_64</tt>.
  
 
== FreeBSD ==
 
== FreeBSD ==
  
FreeBSD has CMake in its ports tree as a port and a package.
+
FreeBSD has CMake in its ports tree as a port and a package:
* Package: pkg_add -r cmake
+
* Package: <code>pkg_add -r cmake</code>
* Port: cd /usr/ports/devel/cmake && make install clean
+
* Port: <code>cd /usr/ports/devel/cmake && make install clean</code>
  
 
=== Compiling Odamex ===
 
=== Compiling Odamex ===
  
 
See [http://odamex.net/w/index.php?title=Compiling_using_CMake&action=submit#Compiling_Odamex_2 Compiling Odamex on Linux]
 
See [http://odamex.net/w/index.php?title=Compiling_using_CMake&action=submit#Compiling_Odamex_2 Compiling Odamex on Linux]

Latest revision as of 20:44, 23 January 2019

According to the Wikipedia page, CMake is a unified, cross-platform, open-source build system that enables developers to build, test and package software by specifying build parameters in simple, portable text files. It works in a compiler-independent manner and the build process works in conjunction with native build environments, such as make, Apple's Xcode and Microsoft Visual Studio. It also has minimal dependencies, C++ only. CMake is open source software and is developed by Kitware.

Compatibility

  • Windows
    • Visual C++ 2010 (up to 2017) can compile the client, server and master without issues.
    • MinGW Makefiles can compile the client, server and master without issues.
    • Code::Blocks (MinGW) can compile the client, server and master without issues.
      • You must select a type of build (Debug/Release/etc.) when generating the project file, as the project does NOT have separate Debug and Release targets for every target. This is by design and has no fix. If you want to be able to switch between Debug and Release easily, keep two build directories.
  • Mac OS X
    • Makefiles on Mac OS X 10.6 can compile the client, server, launchers and master.
  • Linux
    • Makefiles can compile the client, server, launcher, and master without issue.
    • Code::Blocks uses Makefiles, so is equally as compatible.
  • FreeBSD
    • Makefiles can compile the client, server and master without issue.

Windows

cmake-gui running in Windows

Installing CMake

The latest version of CMake can be downloaded from Kitware's website here.

Compiling Odamex

There are many options for compiling Odamex on Windows using CMake, and what you decide depends heavily on which IDE and compiler you have installed. If you don't have a compiler or IDE yet, you have a couple of choices:

  • If you just want to compile Odamex with the least amount of hassle, MinGW Makefiles require the least amount of setup.
  • If you want to use the same thing most other Odamex developers use, Code::Blocks is the recommended path.
  • You can also use Visual C++ if you prefer to use a Microsoft IDE and compiler.

There are many other generators available for CMake, however there are simply too many combinations and corner cases to cover in this wiki.

MinGW Makefiles

  1. If you do not have MinGW already installed, follow the installation instructions for MinGW here.
  2. Follow the installation instructions for any Required Libraries you might need.
  3. Start up the CMake GUI tool.
  4. In the input field labeled Where is the source code: pick out the folder where you checked out Odamex.
  5. In the input field labeled Where to build the binaries: create a folder somewhere where you would like the Code::Blocks workspace to be created. If you're not sure where to put it, create a new folder called build in the folder where you checked out Odamex.
  6. Click Configure.
    • If you get an error message at this point about a missing dll file, please re-read the installation instructions for MinGW here, particularly the part about adding C:\MinGW\bin to your PATH environment.
  7. You should see a dialog box pop up. From the drop-down list, pick MinGW Makefiles and make sure Use default native compilers is selected, then click Finish.
  8. After a few moments, you will see warnings about how SDL and SDL_mixer could not be found.
    • If you don't care about building the client, skip to the next step.
    • If you want to build the client, you need to set the SDL_INCLUDE_DIR, SDL_LIBRARY_TEMP, SDL_MIXER_INCLUDE_DIR and SDL_MIXER_LIBRARY cache variables. You need to check the "advanced" checkbox in order to see some of them. The INCLUDE_DIR entries points to the include directories of the libraries you just downloaded, SDL_LIBRARY_TEMP should point directly at the file libSDL.dll.a in the lib directory, and SDL_MIXER_LIBRARY should point directly at SDL_mixer.lib.
    • If you have Odamex installed to C:\Program Files, read this! For some reason, CMake will point to the libraries you have in C:\Program Files\Odamex instead of the correct path. Make sure that SDLMIXER_LIBRARY points to SDL_mixer.lib, and SDL_LIBRARY points to libSDL.dll.a. If they're not, change them so they are. All three of these files should be in the SDL library directories you just downloaded.
  9. Click on the drop-down list next to CMAKE_BUILD_TYPE and select which type of build you would like to generate. Most likely, you will want to select Debug.
  10. Click Generate.
  11. Open up a Command Prompt and change to the build directory you created earlier.
  12. Run the following command:
    • If you want to build everything: mingw32-make
    • If you want to build just the client: mingw32-make odamex
    • If you want to build just the server: mingw32-make odasrv
    • If you want to build just the master: mingw32-make odamast
    • If you want to clean up your build tree: mingw32-make clean

Code::Blocks

The configuration and generation steps are largely the same as above. However, when the CMake GUI asks you to select a generator, make sure and select CodeBlocks - MinGW Makefiles. And of course, instead of going to the command line and running mingw32-make, simply open the generated project with Code::Blocks.

Visual C++

  1. Follow the installation instructions for any Required Libraries you might need.
  2. Install a copy of Visual C++. We highly recommend you Visual Studio 2017 Community, available for free here.
  3. Start up the CMake GUI tool.
  4. In the input field labeled Where is the source code:, pick out the folder where you checked out Odamex.
  5. In the input field labeled Where to build the binaries:, create a folder somewhere where you would like the workspace to be created. If you're not sure where to put it, create a new folder called build in the folder where you checked out Odamex.
  6. Click on Configure.
  7. You should see a dialog box pop up. From the drop-down list, pick:
    • "Visual Studio 15 2017" if you want to build 32-bit (x86) binaries.
    • "Visual Studio 15 2017 Win64" if you want to build 64-bit (x64) binaries.
  8. Make sure Use default native compilers is selected, then click Finish.
  9. After a few moments, you will see warnings that a few libraries (such as SDL2 and SDL2_mixer) could not be found.
    • • If you don't care about building the client, skip to the next step.
    • • If you want to build the client, you need to set the SDL2_INCLUDE_DIR, SDL2_LIBRARY, SDL2_MIXER_INCLUDE_DIR and SDL2_MIXER_LIBRARY cache variables. You may need to check the "advanced" checkbox in order to see some of them. The INCLUDE_DIR entries points to the include directories of the libraries you just downloaded, SDL2_LIBRARY should point directly at the file SDL2.lib in the lib directory, and SDL2_MIXER_LIBRARY should point directly at SDL2_mixer.lib.
    • If you have Odamex installed to C:\Program Files, read this! For some reason, CMake will point to the libraries you have in C:\Program Files\Odamex instead of the correct path. Make sure that SDL2_MIXER_LIBRARY points to SDL2_mixer.lib, and SDL2_LIBRARY points to SDL2.lib. If they're not, change them so they are. All three of these files should be in the SDL library directories you just downloaded.
  10. Click on Generate.
  11. Navigate to the build directory you created earlier and double click on the Odamex.sln solution file to open it in Visual Studio.
  12. Press F5 to build the entire project.

Running Odamex

The first time you run the client or server, you might run into some issues.

Client notes

A fully-populated client directory

The first time you run the client after building it, you will get an error message about a missing SDL.dll file. You need to copy:

  • SDL.dll from the SDL Development Library's lib folder.
  • All of the DLL files from the SDL_mixer Development Library's lib folder.
  • odamex.wad from the base odamex GitHub checkout folder.
  • A DOOM IWAD from one of your installations of DOOM.

...into the folder where odamex.exe is. It is either located in the client subfolder of your build folder, or in one of the subfolders within client.

Server notes

The first time you build the server after building it, you will get an error message about not being able to find odamex.wad. You need to copy:

  • odamex.wad from the base odamex GitHub checkout folder.
  • A DOOM IWAD from one of your installations of DOOM.

...into the folder where odasrv.exe is. It is either located in the server subfolder of your build folder, or in one of the subfolders within server.

Linux

Compiling Odamex using CMake has been tested on Debian Linux 6.0. The instructions for the other distributions have been inferred using available documentation. If you are having trouble with a specific configuration, please add a response to this bug.

Installing CMake

Depending on your Linux distribution, you may or may not have a copy of CMake in your software repository. Even if you do, the version that is available might not be up-to-date. The following distributions have a version of CMake 2.8, which is what the current build script requires.

  • Debian 6.0: CMake 2.8.2 aptitude install cmake
  • Fedora 15: CMake 2.8.4 yum install cmake
  • openSUSE 11.4: CMake 2.8.3 zypper in cmake
  • Slackware 13.37 CMake 2.8.4 pkgtool
  • Ubuntu 10.04 LTS: CMake 2.8.0 apt-get install cmake
  • Ubuntu 11.04: CMake 2.8.3 apt-get install cmake

The following distributions have an out-of-date version of CMake. You are welcome to bypass the version check and see if it still works. Assuming that there isn't too much breakage and workarounds needed to support it, "official" support for CMake 2.6 will be considered.

  • CentOS 5.x: CMake 2.6.4 (through EPEL) yum install cmake
  • Debian 5.0: CMake 2.6.0 aptitude install cmake
  • Red Hat Enterprise Linux 5.x: CMake 2.6.4 (through EPEL) yum install cmake
  • Scientific Linux 5.x: CMake 2.6.4 (through EPEL) yum install cmake

If you do not have an up-to-date CMake, or would prefer to use the absolute latest version, both binary and source tarballs can be downloaded here.

Compiling Odamex

Finished compiling!

Once you have Odamex checked out from GitHub, change to the directory where you checked it out. From there, the process is relatively simple:

mkdir build && cd build && cmake ..

You might see warnings about not being able to find SDL or SDL_mixer. If you are not interested in compiling the client, ignore the warnings. Otherwise, please see the Required Libraries page for instructions on how to install SDL and SDL_mixer and try again.

Once cmake finishes its job, run the following command:

  • If you want to build everything: make
  • If you want to build just the client: make odamex
  • If you want to build just the server: make odasrv
  • If you want to build just the master: make odamast
  • If you want to clean up your build tree: make clean
Build Types

CMake gives you a choice of four build types. The default build type is Debug, but there are four choices:

  • Debug: Debug information, -O1 optimization.
  • Release: No debug information, -O3 optimization.
  • RelWithDebInfo: Debug information, -O3 optimization. Useful for finding optimization bugs that only show up in Release.
  • MinSizRel: HOLY COW I'M TOTALLY GOING SO FAST OH F***.

To specify a build type, you need to pass it with your cmake command like so:

cmake .. -DCMAKE_BUILD_TYPE=Release

Using Clang + LLVM

If you prefer to use clang instead of gcc, you can:

export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
cmake -D_CMAKE_TOOLCHAIN_PREFIX=llvm- ..

Note that CMake bakes the CC and CXX variables into the generated makefile, so you do not have to export them again if you run the makefile in a fresh shell environment.

Alternate SDL installations

If you are testing Odamex against multiple SDL versions, you can do so like this (assuming you compiled it with --prefix==/opt/SDL-1.2.13)

cmake .. -DSDLDIR=/opt/SDL-1.2.13

If you want to use a custom SDL_mixer as well, you can --prefix it into the same directory as your custom SDL and CMake will pick up on it automatically via SDLDIR. Otherwise, you can also manually specify SDL_mixer like so:

cmake .. -DSDLMIXERDIR=/opt/SDL_mixer-1.10

Obviously you can mix and match the two params as you please (stock SDL and custom SDL_mixer, stock SDL and custom SDL_mixer, etc).

GUI Tool

If you want a tool similar to cmake-gui on Windows, there is an ncurses tool that comes with CMake called ccmake. The command-line syntax for using it is the same as cmake, but it gives you a nice little graphical interface to double-check the cache file with.

Mac OS X

The latest version of CMake can be downloaded from Kitware's website here.

You can also install the latest version using your package manager of choice:

  • Homebrew: brew install cmake

Compiling Odamex

See Compiling Odamex on Linux

Xcode

CMake supports generating Xcode project files.

cmake -G Xcode ..

OS X 10.4 Tiger

CMake can configure the build to use the OS X 10.4 Tiger SDK. This is useful for supporting as wide a range of OS X versions as possible. It is also required in order to build for ppc or to build a universal binary that includes ppc support.

cmake -DCMAKE_OSX_DEPLOYMENT_TARGET=10.4 \
  -DCMAKE_OSX_SYSROOT=/Developer/SDKs/MacOSX10.4u.sdk \
  -DCMAKE_CXX_COMPILER=g++-4.0 ..

These options can also be used to support any other installed SDK when something other than the system default is desired.

Universal Binaries

CMake also supports building universal binaries. For example, if you were interested in building a universal binary with ppc and i386 support:

cmake -DCMAKE_OSX_ARCHITECTURES="ppc;i386" ..

Valid values for CMAKE_OSX_ARCHITECTURES are ppc, i386, ppc64 and x86_64.

FreeBSD

FreeBSD has CMake in its ports tree as a port and a package:

  • Package: pkg_add -r cmake
  • Port: cd /usr/ports/devel/cmake && make install clean

Compiling Odamex

See Compiling Odamex on Linux