-
Notifications
You must be signed in to change notification settings - Fork 26
Building
Building the project is relatively simple. Firstly, you need to make sure you have boost and SFML 2.1 installed and built properly - they are included with the project as submodules that reference working versions, if you want to can init and update the submodules to get the code (or git clone --recursive).
Note that the executable must be placed in the same folder as config.json - the program gets resource paths based off of that location. If the executable is run from any other location, the program will error out. (You can also adjust the program's working directory and run it from anywhere)
The project uses CMake to generate makefiles or project files of your choice. Make sure you `git checkout cmake` after cloning to us CMake. Most compilers can use the default settings - it will assume you have SFML and json-parser installed to the lib folder as expected, and that you have 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.
Pass these to the commandline:
- DCMAKE_BUILD_TYPE=Release or DCMAKE_BUILD_TYPE=Debug - controls whether the build is for release mode or debug mode.
- -DSTATIC_BUILD=1 - link statically to libraries like SFML and Boost instead of dynamically.
- -DJSONLIB=path set an alternate path for json-parser
- -DBOOSTLIB=path set an alternate path for Boost
- -DSFMLLIB=path set an alternate path for SFML
- cmake -G "MinGW Makefiles" -DCMAKE_CXX_FLAGS="-std=c++11" .
- mingw32-make or make
On Windows, we recommend that you use clang++ in combination with MinGW. The latest versions of clang no longer include binaries that work with MinGW on Windows, instead you have to build clang yourself. This can be a daunting task, but if you ask LB he might help. The generator you have to use is "MinGW Makefiles", but we will be instructing it to use clang as the compiler (the linker, etc. will still default to MinGW).
- cmake -G "MinGW Makefiles" -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_FLAGS="-std=c++11" -DSTATIC_BUILD=1 .
- make or mingw32-make
The ChessPlusPlus project uses C++11 heavily, and unfortunately no version of Visual Studio fully supports all of the features we use. We considered supporting it at first, but it would just be too limiting. When Microsoft catches up, cmake already has support for building MSVC project files for you (and it will be the default if you have Visual Studio installed on Windows).
Click here for information on compiling with other compilers and platforms.
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 run `make` for you. After this the console will stay open allowing you to `cls && make` over and over as you develop the project. If files are added or removed, you need to close the window and run the script again to re-run CMake.
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" -DCMAKE_BUILD_TYPE=RELEASE -DCMAKE_CXX_COMPILER=clang++ -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_FLAGS="-std=c++11" -DSTATIC_BUILD=1 ../
cmd /k "mingw32-make"