Setting Up a Cross-platform Game Development Environment


CMake

Now we need a build system. Linux distributions and MinGW come with a make program (the MinGW provided one is named mingw32-make, though, since many users prefer to install a different make). Make is fantastically useful for automating build processes, but writing makefiles can be a real pain in the rear. That’s where CMake comes in.

CMake is like a make system for building makefiles. To use it you create a file called CMakeLists.txt using a very simple and easy to understand syntax to list where your source files are, where your libraries or dlls are, and how you want your program built. Then when you run cmake it creates the makefiles for you. CMake is cross platform itself, and it has lot’s of built in utilities for finding out where the libraries and dlls are on your system. It’s quite powerful, and I will be showing you a basic CMakeLists.txt file later on that provides a generic build system for simple games. If you follow the same file layout in your projects as mine then all you will have to do is edit the name of the program in the CMakeLists.txt file and everything will be handled automatically.

Installation:

Fedora

From the command line as root, run

$ yum install cmake

Ubuntu

From the command line, run

$ sudo apt-get install cmake cmake-curses-gui

Windows

Download and run the installer program from the CMake website. When you run the installer, be sure to select the option to add CMake to your path so that it will be available from the command line.

2 Comments

  1. Wow, awesome timing. You’ve published this and your later article on CMake as I’m embarking on this very task. Thanks for the articles!

    • You’re welcome. I hope the information is useful. I’ve never written for others before, and I’m still learning this stuff myself, so I’m not sure if I’m really presenting things in a way that others can use. I’m trying, though.

      My next major post is probably going to be presenting a sample program that is a Mandelbrot set viewer. It’s not a game, of course, but it demonstrates using SDL. Benoit Mandelbrot died this past week, so I was inspired to create it in honor of his work.

Comments are closed.