Building Ircos

It’s time to build the Ircos. I know it doesn’t do anything at the moment but we’ve got to start somewhere :)

One think I like about CMake is that you can easily target multiple build platforms. I’m currently using both Linux and Windows and will detail the build process for both.


In order to build for Windows you need to install the following tools:

  • Visual Studio (I am using Visual Studio Ultimate 2013 but I think the Express edition should work fine)
  • CMake
  • If you want to support unit testing then you will need CxxTest. I downloaded version 3.10.1. It’s really old but seems to be compatible with CMake.
  • CxxTest requires Python  so you need to install that too

Building is very simple and requires following a few steps:

  1. Unzip the project files (see previous post) into an empty directory
  2. Open a command prompt and change directory to the root of where you unzipped the source
  3. Make a new directory for the build (I use the very original name of “build”)
  4. Extract the CxxTest source somewhere
  5. Change to your newly created build directory
  6. Run the following cmake command:

  1. The CMake command should have generated a Visual Studio solution in the build directory. Open this in Visual Studio
  2. Build!

You only need to do the above process once and thereafter use the Visual Studio solution. If you make any changes to CMakeLists.txt this will automatically be picked up on the next build of the Visual Studio solution.


I base this on Debian based Linux  systems as I’m using Linux Mint.

  1. Install some pre-requisites

  1.  Unzip the source into a new empty directory
  2. Open a terminal and change to the root of the source directory
  3. Create a new directory to contain the build files
  4. Change to the build directory
  5. Run the following CMake command:

  1.  Run “make” to build the project

Let’s get started

I’m going to be writing my engine in my favourite language, C. This seems to be a natural choice for a chess engine as it lends itself to performance analysis and optimisation and can easily live alongside assembly language for those performance critical routines.

For a build system I’m going to be using CMake. This will provide cross-platform build capability as well as providing support for a number of toolchains and IDEs including Visual Studio and Eclipse.

So let’s start with some placeholder C files, starting with main.c the entry point for Ircos.

As you can see this file currently just calls “reset_board” which will ultimately set the initial configuration of the chess board.

Let’s follow that up with the header and implementation files for our chess board.


As you can see, these are just empty but compilable files at present so we can get the build environment working.

For CMake we need to provide a CMakeLists.txt that configures the build.

This maybe needs a short explanation.

Line #9 – defines the include directories for the project. The CMakeLists.txt lives in the root folder and the .c and .h files live in a subdirectory named “src”.

Line #15 – we build the engine source files into a static library. This allows us two link it into two modules; the main Ircos engine executable and a unit test executable (more on this later).

Line #20 – the main.c module is compiled and linked with the static library to generate the engine executable.

You’ll also notice that I’m looking for a package named “CxxTest”. This is a unit test framework that I’ll be using to test various parts of the engine. In order to achieve this we need to add a few more lines to CMakeLists.txt.

I’ve made the unit testing optional based on whether the CxxTest framework was found or not. This allows the engine to still be built on platforms that do not support CxxTest.

Line #4 – The CxxTest framework is found so we enable testing.

Line #7 – We will add a single test module at present. The tests are defined in “test_board.h”. CxxTest will auto-generate a source file from this named “test_board.cpp” (we do not need to provide this file) and the test module will be added to the target “test_ircos”

Line #9 – We can see now why I built the engine source into a static library. It can be added as a dependency of the unit test application “test_ircos” rather than having to rebuild the source files all over again.

Line #20 – Finally, we make the unit tests run as part of the build process after the build is complete.

The final piece of the puzzle is the unit test module, “test_board.h”. Again I provide a placeholder to be filled-in later.

In here we provide a single example test on line #12 that calls the (empty) reset_board() function before asserting ‘true’ (which will obviously never fail).

All that is left to do now is to build the engine and see if works! I’ll do this in the next post.