Difference between revisions of "Compiling using CMake"

From OdaWiki
(Client notes)
Line 81: Line 81:
  
 
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 ===
 +
 +
Once you have Odamex checked out from SVN, change to the directory where you checked it out.  From there, the process is relatively simple:
 +
 +
<pre>mkdir build && cd build && cmake ..</pre>
 +
 +
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 ====
 +
 +
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: [http://funroll-loops.info/ 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:
 +
 +
<pre>cmake .. -DCMAKE_BUILD_TYPE=Release</pre>
 +
 +
=== 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)
 +
 +
<pre>cmake .. -DSDLDIR=/opt/SDL-1.2.13</pre>
 +
 +
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.  Otherwise, you can also manually specify SDL_mixer like so:
 +
 +
<pre>cmake .. -DSDLDIR=/opt/SDL_mixer-1.10</pre>
 +
 +
Obviously you can mix and match as you please.
 +
 +
=== 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.
  
 
== FreeBSD ==
 
== FreeBSD ==
Line 87: Line 124:
 
* Package: pkg_add -r cmake
 
* Package: pkg_add -r cmake
 
* Port: cd /usr/ports/devel/cmake && make install clean
 
* Port: cd /usr/ports/devel/cmake && make install clean
 +
 +
=== Compiling Odamex ===
 +
 +
See [http://odamex.net/w/index.php?title=Compiling_using_CMake&action=submit#Compiling_Odamex_2 Compiling Odamex on Linux]

Revision as of 00:43, 10 July 2011

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.

CMake can:

  • Create libraries
  • Generate wrappers
  • Compile source code
  • Build executables in arbitrary combinations

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 link here. The correct patch is by Alexander Mayfield, the one by Albert Brown has not been updated since 2007.

Windows

Installing CMake

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

Compiling Odamex

Once you have Odamex checked out from SVN, start cmake-gui. From there, you need to fill out two pieces of information:

  • Where is the source code: Pick out the folder where you checked out Odamex.
  • 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.

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:

  • Visual Studio 8 2005: For compiling with Visual Studio 2005
  • Visual Studio 9 2008: For compiling with Visual Studio 2008
  • Visual Studio 10: For compiling with Visual Studio 2010

Make sure "Use default native compilers" is selected before hitting Finish.

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.

  • If you are not interested in compiling the client, you can ignore those warnings and click Generate.
  • 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 OK. Repeat 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.

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 files. What you do now depends on your compiler:

Visual Studio 2010

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.

Running Odamex

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

Client notes

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 SVN 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 SVN 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

Once you have Odamex checked out from SVN, 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.

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

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. Otherwise, you can also manually specify SDL_mixer like so:

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

Obviously you can mix and match as you please.

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.

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