Difference between revisions of "Compiling using CMake"
(→Alternate SDL installations) |
|||
Line 1: | Line 1: | ||
− | According to the Wikipedia page | + | 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. |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
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. | 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. | ||
Line 17: | Line 11: | ||
=== Compiling Odamex === | === 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 ==== | |
− | + | # If you do not have MinGW already installed, follow the installation instructions for MinGW [http://www.mingw.org/wiki/Getting_Started here]. | |
− | * ''' | + | # 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 will need to make sure that the '''SDLMAIN''' variable points to the base directory of your extracted SDL development library and that '''SDLMIXERMAIN''' points to the base directory of your extracted SDL_mixer development library. Simply click on the variable you want to edit and a button with three dots should appear on the right side of the box that will take you to a folder selection dialog. Once both of those variables have been filled out, go to the next step. | ||
+ | # 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: <tt>mingw32-make</tt> | ||
+ | #* If you want to build just the client: <tt>mingw32-make odamex</tt> | ||
+ | #* If you want to build just the server: <tt>mingw32-make odasrv</tt> | ||
+ | #* If you want to build just the master: <tt>mingw32-make odamast</tt> | ||
+ | #* If you want to clean up your build tree: <tt>mingw32-make clean</tt> | ||
− | + | ==== Code::Blocks ==== | |
+ | # Follow steps 1 and 2 in the MinGW Makefiles section above. | ||
+ | # Download and install Code::Blocks. | ||
+ | #* Latest stable version can be found [http://www.codeblocks.org/downloads/26 here]. You want the one without MinGW included, since you got it already in the first step. | ||
+ | #* Nightly builds can be found [http://forums.codeblocks.org/index.php?PHPSESSID=4utemm0mg590il43pcrmlegvd3&board=20.0 here]. | ||
+ | # Follow steps 3-6 in the MinGW Makefiles section above. | ||
+ | # 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'''. | ||
+ | # Follow steps 8 and 9 in the MinGW Makefiles section above. | ||
+ | # ''To Be Continued...'' | ||
− | + | ==== Visual C++ ==== | |
− | + | # Follow step 2 in the MinGW Makefiles section above. | |
− | * | + | # Install a copy of Visual C++. |
− | * If you | + | #* Visual C++ 2010 Express is free and more than capable of compiling Odamex. You can download it [http://www.microsoft.com/visualstudio/en-us/products/2010-editions/visual-cpp-express here]. |
− | + | #* If you are a college student, your university might be participating in MSDNAA. If so, you might be eligible for a copy of Visual Studio Professional for free. Check out [http://msdn.microsoft.com/en-us/academic this website] for details. | |
− | If you | + | #* If you personally own any version of Visual Studio since 2005, Visual C++ is included on your Visual Studio DVD as Visual C++ has not been sold as a separate product since 2003. |
− | + | #* Finally, if you feel like shelling out money for it, various editions of Visual Studio 2010 are available from [http://www.amazon.com/s/ref=nb_sb_ss_c_2_18?url=search-alias%3Dsoftware&field-keywords=visual+studio+2010&sprefix=visual+studio+2010 Amazon] and [http://www.newegg.com/Product/ProductList.aspx?Submit=ENE&DEPA=0&Order=BESTMATCH&Description=Visual+Studio+2010&x=0&y=0 Newegg]. Given all of the free alternatives this is not recommended, and if you do any serious development work on Windows you likely already have a copy. | |
− | ==== Visual Studio 2010 == | + | # Follow steps 3-6 in the MinGW Makefiles section above. |
− | + | # You should see a dialog box pop up. From the drop-down list, pick: | |
+ | #* '''Visual Studio 10''' if you have Visual C++ 2010. | ||
+ | #* '''Visual Studio 9 2008''' if you have Visual C++ 2008. | ||
+ | #* '''Visual Studio 8 2005''' if you have Visual C++ 2005. | ||
+ | # Make sure '''Use default native compilers''' is selected, then click '''Finish'''. | ||
+ | # Follow steps 8 and 9 in the MinGW Makefiles section above. | ||
+ | # Navigate to the <tt>build</tt> directory you created earlier and double click on the '''Odamex.sln''' solution file to open it in Visual C++. | ||
+ | # ''To Be Continued...'' | ||
=== Running Odamex === | === Running Odamex === | ||
Line 46: | Line 73: | ||
==== Client notes ==== | ==== 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: | 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 | + | * <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 | + | * 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 SVN 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 | + | ...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 SVN 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 | + | ...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 93: | ||
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''' <tt>aptitude install cmake</tt> |
− | * Fedora 15: '''CMake 2.8.4''' yum install cmake | + | * Fedora 15: '''CMake 2.8.4''' <tt>yum install cmake</tt> |
− | * openSUSE 11.4: '''CMake 2.8.3''' zypper in cmake | + | * openSUSE 11.4: '''CMake 2.8.3''' <tt>zypper in cmake</tt> |
− | * Slackware 13.37 '''CMake 2.8.4''' pkgtool | + | * Slackware 13.37 '''CMake 2.8.4''' <tt>pkgtool</tt> |
− | * Ubuntu 10.04 LTS: '''CMake 2.8.0''' apt-get install cmake | + | * Ubuntu 10.04 LTS: '''CMake 2.8.0''' <tt>apt-get install cmake</tt> |
− | * Ubuntu 11.04: '''CMake 2.8.3''' apt-get install cmake | + | * Ubuntu 11.04: '''CMake 2.8.3''' <tt>apt-get install cmake</tt> |
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])''' <tt>yum install cmake</tt> |
− | * Debian 5.0: '''CMake 2.6.0''' aptitude install cmake | + | * Debian 5.0: '''CMake 2.6.0''' <tt>aptitude install cmake</tt> |
− | * 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])''' <tt>yum install cmake</tt> |
− | * 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])''' <tt>yum install cmake</tt> |
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]. | ||
Line 89: | Line 116: | ||
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. | ||
+ | |||
+ | Once <tt>cmake</tt> finishes its job, run the following command: | ||
+ | * If you want to build everything: <tt>make</tt> | ||
+ | * If you want to build just the client: <tt>make odamex</tt> | ||
+ | * If you want to build just the server: <tt>make odasrv</tt> | ||
+ | * If you want to build just the master: <tt>make odamast</tt> | ||
+ | * If you want to clean up your build tree: <tt>make clean</tt> | ||
==== Build Types ==== | ==== Build Types ==== | ||
Line 117: | Line 151: | ||
=== GUI Tool === | === GUI Tool === | ||
− | If you want a tool similar to cmake-gui on Windows, there is an ncurses tool that comes with | + | 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. |
== 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: <tt>pkg_add -r cmake</tt> |
− | * Port: cd /usr/ports/devel/cmake && make install clean | + | * Port: <tt>cd /usr/ports/devel/cmake && make install clean</tt> |
=== 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] |
Revision as of 16:55, 11 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.
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
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
- If you do not have MinGW already installed, follow the installation instructions for MinGW here.
- 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 build 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 here, particularly the part about adding C:\MinGW\bin to your PATH 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 will need to make sure that the SDLMAIN variable points to the base directory of your extracted SDL development library and that SDLMIXERMAIN points to the base directory of your extracted SDL_mixer development library. Simply click on the variable you want to edit and a button with three dots should appear on the right side of the box that will take you to a folder selection dialog. Once both of those variables have been filled out, go to the next step.
- Click Generate.
- Open up a Command Prompt and change to the build directory you created earlier.
- 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
- Follow steps 1 and 2 in the MinGW Makefiles section above.
- Download and install Code::Blocks.
- Follow steps 3-6 in the MinGW Makefiles section above.
- 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.
- Follow steps 8 and 9 in the MinGW Makefiles section above.
- To Be Continued...
Visual C++
- Follow step 2 in the MinGW Makefiles section above.
- Install a copy of Visual C++.
- Visual C++ 2010 Express is free and more than capable of compiling Odamex. You can download it here.
- If you are a college student, your university might be participating in MSDNAA. If so, you might be eligible for a copy of Visual Studio Professional for free. Check out this website for details.
- If you personally own any version of Visual Studio since 2005, Visual C++ is included on your Visual Studio DVD as Visual C++ has not been sold as a separate product since 2003.
- Finally, if you feel like shelling out money for it, various editions of Visual Studio 2010 are available from Amazon and Newegg. Given all of the free alternatives this is not recommended, and if you do any serious development work on Windows you likely already have a copy.
- Follow steps 3-6 in the MinGW Makefiles section above.
- You should see a dialog box pop up. From the drop-down list, pick:
- Visual Studio 10 if you have Visual C++ 2010.
- Visual Studio 9 2008 if you have Visual C++ 2008.
- Visual Studio 8 2005 if you have Visual C++ 2005.
- Make sure Use default native compilers is selected, then click Finish.
- Follow steps 8 and 9 in the MinGW Makefiles section above.
- Navigate to the build directory you created earlier and double click on the Odamex.sln solution file to open it in Visual C++.
- To Be Continued...
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.
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
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.
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