After months of hard work by multiple people, we’ve come to a decent approach at incorporating CMake as a build tool in a manner we hope to be extendable. It is currently the only supported build tool on Linux (and related devices like raspberry pi or TK1), and it comes as an addition to Xcode on Mac OS X (the old, hand-tuned xcode projects remain). Moving over the current android cmake files to the new cross-platform approach is on the way, so in the meantime things haven’t been touched there. This work was merged into the android_linux branch with this PR.
Now, we’d like to ask for community feedback for those who are interested, as we move closer towards the 0.9.1 milestone. To partake in this, please work from the
android_linux branch. Testing samples, adding cmake to existing projects, or just general feedback are all welcome. Feel free to PR fixes or improvements.
To build cinder with cmake, you can either use the command line, or Jetbrains CLion, which has been maturing quite a bit in the past few months. For command line, the process is similar to most other cmake projects you might have used, for example from the main cinder repo path
mkdir build cd build cmake .. make -j4
As with all cmake projects, you only need to perform the
cmake command once, afterwards calling
make is enough. There are a few options in the cmake cache that you can define define from the command line as well.
//Build a specific sample by specifying its path relative to the // samples directory (ex. '_opengl/Cube'). CINDER_BUILD_SAMPLE:STRING=Extrude //Build all samples. CINDER_BUILD_SAMPLES:BOOL= //Target platform to build for. CINDER_TARGET:STRING= //Target GL for the system. Valid options : ogl, es2, es3, es31, // es32, es2-rpi CINDER_TARGET_GL:STRING= //Print verbose build configuration messages. CINDER_VERBOSE:BOOL=1
In the above, I’ve also set
-DCINDER_BUILD_SAMPLE=Extrude, which tells cmake to also build the Extrude sample with libcinder as a dependency of it (this is great when you are working on cinder core code, and want to see the results in your application in one build step).
Note that you can also build the samples directly:
cd samples/Extrude mkdir build cd build cmake ../proj/cmake make -j4
Building libcinder with CLion is as easy as opening up the main repo folder within the CLion IDE, selecting the
cinder configuration in the top-right, and building. You can also build samples from this project, or you can open up the individual sample’s proj/cmake folder in CLion and build it that way.
Let us know what you find. Personally, I find myself using CLion more and more on Mac OS X as the debugger works better and the editor has more features. At the same time, we’ve tried to keep the cmake setup as ‘traditional’ as possible, so that it is familiar to those coming from other projects that use this build tool. I’d also like to take this moment to say thanks to @petros who has worked on this the entire way through, as well as @chaoticbob who wrote the original cmake files (and of course the majority of the android and linux ports that will be making their way into 0.9.1, hopefully soon!).