charon-core  0.3.1
Project build

This Project uses the CMake Makefile generator to manage the build process for various build tools.

Configure

To create the build files, run CMake (at least Version 2.8) on the project root directory and select the desired Makefile generator. More information about this step can be found at the CMake Documentation Website.

In and out-of-source builds

You can use in-source or out-of-source-builds. The advantage of in-source-builds is that you have all files (sources and binaries) in the same directories, but this makes it difficult to keep svn ignore lists etc. up to date. Source packages will be messed up too (see below). To keep the source directories clean, you can use out-of-source build which means that you create a second folder where binaries and tempoary files will be stored. It is possible to create multiple build directories where you can use different build systems (MinGW/MSVC/...) or different compiler settings.

If you use the CMake GUI, you have to specify two directories, the source and the build directory. If these are the same, you perform a in-source-build, if you select two different directories, the source directory will be kept clean.

Testet build environments

  • Linux gcc >= 4.1
  • Win32 Microsoft Visual Studio 2010

Configuration switches, customizing build

There are different configuration options that can be en- or disables as needed. These switches can be found in the CMake Cache editor (ccmake or cmake-gui). They are visible in the simple view.

  • CMAKE_BUILD_TYPE:
    (only avaiable on some build environments, e.g. gcc)
    Select build configuration, recommended values: Debug;Release
  • CMAKE_INSTALL_PREFIX:
    Select directory for installation using the make target "install".
  • USE_LATEX:
    (only avaiable if LaTeX is installed and found)
    Enable generation of pdf documentation using pdflatex.
  • BUILD_TESTING:
    Build test suite and enable make target "test".

Compiler flags

When using the GNU gcc compiler, some compiler flags are are very useful for debugging. The used flags can be modified in the CMake Cache editor. The simplest way is using the CMake GUI. Don't forget to select the advanced or grouped view to be able to change the settings mentioned below.

The recommended flags for CMAKE_CXXFLAGS and CMAKE_CFLAGS are:

  • -W -Wall -Wextra: Activate many compiler warnings
  • -pipe: try to avoid creation of temporary files (linux)

You can specify a project build type (Debug, Release, ...) using the CMake Cache editor (command-line: ccmake, graphical: cmake-gui).

Recommended settings for CMAKE_C(XX)FLAGS_DEBUG:

  • -g3 -O0: Add debug symbols and deactivate optimization

Recommended settings for CMAKE_C(XX)FLAGS_RELEASE:

  • -O2 -march=native

If you are using Visual Studio, you do not need to tweak any of these settings.

Build the project

After this configure step, you can build the project with your selected build tool (e.g. by typing mingw32-make in the console when using "MinGW Makefiles" as Makefile generator). The final executable will be avaiable in the app Directory. Unit tests are avaiable using the command make test

Installation and distribution

To install the software, use the install command (the target directory can be changed in the CMake Cache editor). More confortable is the usage of precompiled packages that can be generated using CPack.

If you want to use the <make> install command, check the following variables in the CMake Cache:

  • CMAKE_INSTALL_PREFIX: this is where the project will be installed
  • CMAKE_INSTALL_DOC: this is where the documentation will be installed (this can be used if you want to install the documentation in a seperate directory) Do not set this to an absolute path or a path outside the build directory (i.e. no path like ../blah) if you want to create packages.