Describes how to generate build systems for Cinema 4D API projects.
A build system (also - build tool) is a system that allows users to define a set of build configurations required for building a software project from its source code and resources. Build systems can be invoked with a build configuration to run a build pipeline using compilers and similar tools to generate and compile output such as executables, libraries, debug information, and other meta-information for a project. Very tangible examples of build systems are apps such as Visual Studio and Xcode, which define build configurations in their project files which can then be built running these IDEs. But also more technical command-line tools such as Make, Ninja, or MSBuild are build systems. To build software for multiple operating systems one often requires multiple build systems.
The idea of build systems is complemented by build system generators (also - meta-build system). A build system generator generates configurations for a build system derived from its own configuration syntax. This is done to further simplify defining a build system by letting the build system generator handle common configuration options, and to bundle multiple build systems under one set of unified configuration files.
The Cinema 4D C++ SDK uses CMake as a build system generator and supports build systems for Windows (Visual Studio + Clang/MSVC), macOS (Xcode + Clang), and Linux (Ninja + GCC). The example shown below demonstrates common parts of a Cinema 4D C++ SDK project, especially in the context of build systems.
A Cinema 4D C++ project is structured into distinct components called modules which by default are located in a folder named plugins
in a project. Each module will compile into a dedicated binary which is meant to be loaded by a Cinema 4D instance on startup. Each module binary has an identifier and can either succeed or fail to register with Cinema 4D on startup. And while a module binary file such as my_module.xdl64
is usually referred to as 'a plugin' by users, it can actually contain the implementation and registration of zero-to-many plugin hooks. This means a module loaded by Cinema 4D could manifest as many plugins such as commands, objects, or tags; or alternatively only contain module code and do not register any plugin hooks. The latter case is very rare. The source code of a module is usually only found in its main.cpp/.h
file, while plugin code is conventionally given dedicated source code files as shown in Fig. I.
Besides its source code, a module can also contain resources in a folder called res
- resources include things such as UI definitions and string translations. But not all modules have such a folder, as not all plugins require resources. A module also always contains a project
folder which holds the build system settings of that module. These settings contain instructions for CMake on how the build system for this module should be set up. Common settings are frameworks that should be accessible in the module, module identifiers, custom linker and compiler settings, and style settings. These settings can be provided in two manners, as projectdefinition.txt
files - the module definition format of the former Cinema 4D SDK build system generator - and native CMakeLists.txt
files.
A project will also always contain a frameworks
folder which holds the Cinema 4D API against which the plugins in the project will link. This folder must never be modified, as plugins otherwise might become binary incompatible with Cinema 4D. The framework content is documented in the documentation you are reading right now. Once you have generated a build system for your project, you will also find a build system folder in it, as for example _build_v143
in Fig. I. It contains all the files generated for that build system, such as IDE files like a Visual Studio solution file, the compiled binaries and debug information, and the auto-generated and copied source code.
The following table highlights important paths in a Cinema 4D project and notes their purpose.
Purpose | Example Path | Description |
---|---|---|
Project Root | /my_project | Contains all files of a project (that are automatically ingested). The project name must be composed of characters from the alphabet, digits, and the underscore and point characters, but otherwise can be chosen freely.
|
Build System | /my_project/_build_v143 | Contains a build system. Build systems are not present by default in a project and must first be generated with CMake. A project can have multiple build systems. |
Binary Output | /my_project/_build_v143/bin | Contains the compiled plugins for a build system. Only present once a project has been compiled at least once. |
CMake Scripts | /my_project/cmake | Contains the scripts and settings such as compiler/linker options and warning/error settings which make up the Cinema 4D C++ SDK project generation logic.
|
SDK Frameworks | /my_project/frameworks | Contains the API declarations of the Cinema 4D API against which modules of this project will link.
|
Module Folder | /my_project/plugins/my_module | A module folder contains the source code, resources, and module definition of a module. It will compile into a dedicated module binary with the name of the module, e.g., my_module.xdl64 for a build system for Windows. This module binary is then loaded and registered by Cinema 4D on startup. A module can contain zero-to-many plugins. |
Module Project Folder | /my_project/plugins/my_module/project | Contains the build system definition for the module. This can either be provided as a projectdefinition.txt or CMakeLists.txt file, where the former is the recommended form. When both files are present, as shown in the example above, the CMake config will take precedence. |
Module Source Code | /my_project/plugins/my_module/source | Contains the source code and other files that are automatically included for this module. |
Module Resources | /my_project/plugins/my_module/res | Optionally contains the resources for a module. Resources usually contain GUI definitions, interface strings, symbol tables, and icon files. Not all plugin types use or need resources. |
While generating a build system from a build system configuration is the second step in the process of configuring and generating a build system, we recommend reading the generation guide first, as it will allow you to build the SDK. When you are already familiar with the generation process, you can directly proceed with the configuration guide.
projectdefinition.txt
files.