Search code examples
cmakeopenframeworks

Trying to build an OpenFrameworks example with CMake


I am trying to compile an OpenFrameworks example using CMake. However, I have not been successful so far. I know that asking this question here is a bit of a long shot, but I am desperately looking for a solution.

OpenFrameworks, does not support CMake natively, however I am using a template developed for building OpenFrameworks using Clion, which is effectively using CMake. Below is an explanation of what procedures I have followed to build the example so far.

Intro: OpenFrameworks lives here. It is a compilation of libs/headers and a stand-alone core. The examples build fine with Xcode but things are complicated when attempting to build without an IDE. The structure of OpenFrameworks is not a usual one, thus passing headers and libs is a bit of a manual work.

Let me explain how the build process of an OpenFrameworks app works (based on the template I have mentioned above):

1) The first CMakeLists.txt is designed to live inside the example application folder. The CMakeLists.txt script is located here.

2) The second CMakeLists.txt is designed to pull in all of the OpenFrameworks libs and headers and the CMakeLists.txt script is located here.

The idea is that, when you start building the example application, all of the OpenFrameworks bits and pieces will be built as a shared lib and pulled inside. However, this is not working for some reason and I am getting the following error.

[ 10%] Performing configure step for 'of_shared'
loading initial cache file /Users/me/dev/cpp_projects/of_sessions/of_3DPrimitivesExample/build/of_shared-    prefix/tmp/of_shared-cache.cmake
-- Configuring incomplete, errors occurred!
See also "/Users/me/dev/cpp_projects/of_sessions/of_3DPrimitivesExample/build/of_shared-prefix/src/of_shared-build/CMakeFiles/CMakeOutput.log".
make[2]: *** [of_shared-prefix/src/of_shared-stamp/of_shared-configure] Error 1
make[1]: *** [CMakeFiles/of_shared.dir/all] Error 2
make: *** [all] Error 2

It seems like the shared build stage fails for some reason. Unfortunately the convoluted lib/include structure of OpenFrameworks does not help either. Could you please help me to understand what might be going wrong here? I have already submitted an issue with the project maintainer, however, things are moving a bit slow in that community. (OSX, CMake 2.8.12)


Solution

  • After further investigation, I got the CMake scripts to work. I just needed a bit of time to understand what those CMake files are doing. I have tweaked and adjusted some bits. Now I am able to build and compile openFrameworks 0.9.3 as a static lib and as a shared lib.

    I also succeeded in building and compiling the 3DPrimitivesExample using both the STATIC and SHARED approaches. All these are done using CMake and VIM. No other IDE (XCode, QtCreator etc.) was used.