craftr-build / net.maxon.c4d

Build module for the MAXON Cinema 4D SDK
4 stars 3 forks source link
build-system cinema4d craftr

Module net.maxon.c4d

Build Status Build status

– Build Cinema 4D plugins with Craftr 4.

Contents

Features

Legacy / Bridge API

Many symbol names in the C4D SDK changed drastically in R15. Maxon provided a __LEGACY_API preprocessor switch that enabled most of the old names, however that switch is discontinued since R17.

This Craftr module provides the old C4D legacy API header as "c4d_legacy.h", which allows you to use much of the old API even in R17 to R19. It will be available by adding the net.maxon.c4d:addons target to your plugins' dependencies.

You can also depend on the net.maxon.c4d:legacy target instead which will add the c4d_legacy.h as a prefix header, thus you won't need to manually add this include to all source files.


The R16 SDK uses #define override on Windows which is actually invalid and Visual Studio 2015 (aka. 14.0) complains about this. We provide a <r16_compilerdetection_fix.h> header (depend on net.maxon.c4d:addons) that has this error fixed.


With R20, the Cinema 4D SDK changed drastically. Most prominent are the changes to enumerations which all changed to enum class declarations. Macros like NewObj()/NewMem() and functions like String::GetCStringCopy() return a maxon::ResultPtr<T> instead of a raw pointer which can not be implicitly cast to the type T*, rendering all existing code using these functions invalid.

This Craftr module provides a bridge API – meaning that it is a new and separate API that is compatible with the pre-R20 and R20 SDK. This API must be explicitly included with the "c4d_apibridge.h" header. It provides the pre-R20 enumerations (generated using the scripts/r20enums.py script) but encrouages use of API that is more similar to R20 (eg. aims to provide R19 compatible iferr() and ifnoerr() macros).

Todolist

Configuration

Option Description
:directory The directory of the Cinema 4D installation. If this option is not set, it will be automatically determined from the install location of the @craftr/maxon.c4d package.
:release Specify the Cinema 4D release number if it can not be determined automatically from the directory option. In case no Cinema 4D Application directory was specified and none was automatically determined, the Cinema 4D SDK matching this release will be downloaded (if available).
:rtti Usually the Cinema 4D SDK is compiled without RTTI, thus the default value for this option is false. Set it to true to enable RTTI.

Version Matrix

Cinema 4D Windows OSX
R20 Visual Studio 2015 Apple XCode 9 (?)
R19 Visual Studio 2015 Apple XCode 8
R18 Visual Studio 2013 Apple XCode 7
R17 Visual Studio 2013 Apple XCode 6
R16 Visual Studio 2012 Apple XCode 5.0.2
R15 Visual Studio 2012 Apple XCode 4.6.3
R14 Visual Studio 2010 Apple XCode 4.3.2
R13 Visual Studio 2005 Apple XCode 3.2.6

Source: https://developers.maxon.net/?page_id=1108

Example build script

project('myplugin', '1.0-0')

c4d = require('net.maxon.c4d')

@target(builders=[c4d.build])
def plugin():
  depends('net.maxon.c4d:sdk')
  properties({
    'cxx.srcs': glob('src/**/*.cpp'),
    'cxx.includes': ['plugin'],
    'cxx.productName': 'myplugin' + c4d.plugin_suffix,
    'cxx.productDirectory': './plugin',
    'cxx.type': 'library',
    'cxx.preferredLinkage': 'shared'
  })

Depend on the net.maxon.c4d:legacy target instead if your project uses old API (pre-R16).

A note about R20

With R20, Maxon introduced a tool to produce project files from a projectdefinitions.txt file. Craftr supports building R20 projects without the MAXON Project Tool. Depending on the net.maxon.c4d:sdk target is no longer required and will do nothing (for backwards compatibility when building for previous Cinema 4D releases).

Craftr can however take the following information from the projectdefinitions.txt into account:

FAQ

Known Issues