Skip to content

Cinder CMake Documentation

Richard Eakin edited this page Jan 5, 2017 · 17 revisions

#Overview

This document describes how you can build libcinder and your application using cmake. This is our officially supported way to build system on most Posix platforms, while in general you can use cinder's cmake system on any platform. See the section on platform-specific notes for details.

General structure

Building libcinder with CMake

To build libcinder from the command line, first make sure you have CMake version 3.0 or later installed. Then the process is similar to most other cmake projects you may have used, for example you can do the following from within the main cinder repo path:

mkdir build
cd build
cmake ..
make -j4

Upon completion, this will deposit a static libcinder binary within the $(CINDER_PATH)/lib folder for your application to link against. By default you'll be building for Debug configuration, to build release you change the above cmake command to:

cmake -DCMAKE_BUILD_TYPE=Release ..
make -j4

The runtime output directory for different configurations will automatically end up within different folders (i.e. lib/macosx/Debug/libcinder.a and lib/macosx/Release/libcinder.a), so multiple configurations can live side by side.

Command-line Options

There are a few project configuration settings you can change by either editing the CMakeCache.txt file (or using some GUI to do this), or from the command line with the -D option. All settings related to cinder are prefixed with CINDER_. Some of the more common settings are listed below, take a look in the CMakeCache.txt file for a full and updated list.

CINDER_VERBOSE: prints out verbose information from within cinder's CMake scripts during configuration.

CINDER_TARGET: Sets the target to compile to. This defaults to one appropriate for the current operating system, but in some cases, for example android, you must set it manually (i.e. cmake -DCINDER_TARGET=android ..).

CINDER_TARGET_GL: Sets the target OpenGL version. Usually defaults to ogl (desktop modern OpenGL), but other valid options are es2, es3, and es31`. These are useful when you are building for something like the Raspberry Pi.

CINDER_COPY_ASSETS: By default this is False, and an application's assets directory is symlinked to next to where the output app is built. Set it to True in order to have the assets copied over, which is probably more desirable for a deploy.

CINDER_BUILD_TESTS: Builds the unit tests (You can then runt he tests from the command line with make test).

CINDER_BUILD_SAMPLE: Specify the name of a single sample to build, after libcinder successfully builds. It will end up in the current build folder. For example, adding the option -DCINDER_BUILD_SAMPLE=BasicApp will also build the BasicApp sample and place it at (for me currently) build/Debug/BasicApp/BasicApp.app.

CINDER_BUILD_ALL_SAMPLES: Specifying True here will tell CMake to try to build all of the samples within cinder's samples directory. Might take a while!

Building your application with CMake

Using ci_make_app() utility function

CinderBlocks and CMake

Using CLion to build libcinder and your application

Platform Specific Notes