ofxCMake enables you to easily compile OpenFrameworks projects using CMake. The primary goal for its creation was to enable the use of Jetbrains' CLion in OF application development, but it should work in any other IDE that supports CMake, as well as in the command line.
This fork was originally created to give almul0's fork of BuildPeter's ofxCMake compatibility with OpenFrameworks 0.10.0, but it has evolved to work in a slightly different way than both.
Tested on macOS 10.11, 10.13, OF "0.10.0" (the master branch as of January 2018).
- Clone into
[OF DIR]/addons/ofxCMake
- Create a project using OF's Project Generator
- Copy
ofxCMake/project/CMakeLists.txt
into your project's folder. - In your copy of
CMakeLists.txt
: - Verify path of your OF folder.
- Set the name of your app.
- Open with CLion or compile via terminal.
- Any
.cpp
file that is in your project'ssrc
folder will automatically be added to the project.
- If you need to add your own static libraries add its path to the USER_LIBS list.
- If you need to add your own include directories, use the CMake command
include_directories
ofxCMake splits OF addons between Internal Addons (the ones that are distributed with OF) and External Addons (the ones that aren't).
- Add the name of the addon you want to use to the
OFX_ADDONS_ACTIVE
list inCMakeLists.txt
. All sources, headers, and libs will be automatically added to your project.
- Create a
.cmake
file for your addon (e.g.ofxNAME.cmake
). Check the supplied templates inofxCMake/addOns
for assistance. - Copy the file into
ofxCMake/addOns/external
. - Include your addon in
ofxCMake/modules/addOnsExternal.cmake
โ e.g.include( ${OF_CMAKE_ADDONS}/external/ofxNAME.cmake
- You will now be able to use your addon in any OF project.
- Prepare your project as explained above.
- Choose via CLion in the 'Open File or Project' the
CMakeLists.txt
.
- A prompt might ask, if you want to change the 'project root'. Ignore this.
- The CLion project files will be saved in a '.idea' folder. If you want, you can ignore that in your git repo.
- The project file
CMakeLists.txt
is simplified for readability. - Modular approach in which each OS has it's own .cmake files.
- Having all ofxCMake files in the addons folder has the following advantages:
- Can easily be installed
- It works within OF's file structure, without having to change anything that isn't supposed to be modified. Thus, OF can be updated easily.
At the moment (Jan 2018) only Mac OS is fully tested.
The infrastructure for other OS's (Linux, Windows) is already set up.