Skip to content
Nicholas "LB" Braden edited this page Oct 4, 2015 · 26 revisions

Building the project is relatively simple. If you have no experience with building, start here. Firstly, you need to make sure you have boost 1.x and SFML 2.x installed and built properly - SFML is included with the project as a submodule that references the version this project works with, thus you can init and update the submodules to get the code (or git clone --recursive). For boost, you will have to build and install it yourself or use a pre-made distribution. We recommend at least version 1.59.0

Note that the executable must be placed in the same folder as the config/ and res/ directories. If the executable is run from any other location, the program will error out.

The project uses CMake 3.3+ to generate makefiles or project files of your choice. Most compilers can use the default settings - it will assume you have SFML and boost installed properly in your environment. You can override each path as shown in the configuration options below.

Scroll to the bottom of the page for a handy batch script for Windows users. If you're not a Windows user you probably know how to adapt it to your system or write your own.

Configuration Options

Pass these options to the CMake command line when first generating the project files.

ChessPlusPlus Configuration

  • -DCHESSPP_REDIRECT_OUTPUT=ON will force redirecting stdout and sterr to files, useful on Windows.
    • -DCHESSPP_TRUNC_LOGS=ON will cause the aforementioned files to be cleared on each startup.

SFML Configuration

  • -DSFML_ROOT=path/to/sfml tells CMake where to find SFML if you don't have it installed to a normal location.
  • -DSFML_STATIC_LIBRARIES=ON tells CMake that you built SFML statically and thus need to link to it statically. The default is dynamic linking (DLLs on Windows).
In the future we hope to have SFML be built automatically for you if you don't specify SFML_ROOT.

Boost Configuration

  • -DBOOST_ROOT=path/to/boost tells CMake where to find Boost if you don't have it installed to a normal location.
  • -DBoost_USE_STATIC_LIBS=ON tells CMake that you build Boost statically and thus need to link to it statically. On Windows this option is not automatically detected.
See also the CMake documentation for Boost.

MinGW Example

We recommend that you use the nuwen MinGW distribution as it includes a pre-built boost made especially for you. Use at least version 13.1 (with GCC 5.2 and Boost 1.59).

  • mkdir build && cd build
  • cmake -G "MinGW Makefiles" .. or cmake -G "Unix Makefiles" .. (whichever works on your system)
  • cmake --build .

Use at least Visual Studio 2015 - older versions don't have the necessary C++14 language and standard library support.

  • mkdir build && cd build
  • cmake -G "Visual Studio 14 2015 Win64" .. or cmake -G "Visual Studio 14 2015" .. (whichever works on your system)
  • cmake --build . or open the solution file and use the IDE to build.

Other

Click here for information on compiling with other compilers and platforms.

Windows Batch Script

This convenient batch script it useful for quickly building and/or developing the project. Place it in the root ChessPlusPlus folder with whatever name you like (e.g. build.dat) and run it - it will clear/create a folder called build, run CMake, and then build for you. After this the console will stay open allowing you to cls && cmake --build . over and over as you develop the project.

del /s /f /q .\build\* && for /f %%f in ('dir /ad /b .\build\ ') do rd /s /q .\build\%f
title ChessPlusPlus-Build && mkdir build
cd build && cmake -G "MinGW Makefiles" ..
cmd /k "cmake --build ."
Obviously you will need to edit some commands to fine-tune it to your environment and preferences.