Buildsystem reorganization for smaller minimal builds

Mag­num mas­ter branch re­ceived a few break­ing changes to the build­sys­tem to fur­ther slim down the lib­rary in pre­par­a­tion for Vulkan sup­port.

As­set im­port func­tion­al­ity is now fully op­tion­al

The Trade namespace was his­tor­ic­ally a part of the core Mag­num lib­rary. Based on re­cent feed­back and new use cases pop­ping up, it now made sense to sep­ar­ate it in­to its own lib­rary. This al­lows for even smal­ler builds for pro­jects that don’t need any as­set man­age­ment func­tion­al­ity. That also means the Cor­rade::Plu­gin­Man­ager lib­rary is no longer an im­pli­cit de­pend­ency — at the min­im­um you now need to link just to the Cor­rade::Util­ity and core Mag­num lib­rary.

If you are us­ing CMake, be sure to up­date your loc­al copy of FindMagnum.cmake and ex­pli­citly link to the Magnum::Trade tar­get if you are us­ing any func­tion­al­ity from the Trade namespace. Chances are that you are already link­ing to an­oth­er lib­rary which de­pends on Magnum::Trade so it gets linked trans­it­ively, but it’s bet­ter to be ex­pli­cit:

find_package(Magnum REQUIRED Trade)

# ...

target_link_libraries(your-app PRIVATE Magnum::Trade)

If you’re us­ing Vcp­kg with Visu­al Stu­dio, the auto­ma­gic will take care of this be­hind the scenes. If you’re us­ing a cus­tom build­sys­tem, you may need to add MagnumTrade to your linker com­mand line. If you are de­ploy­ing your app with a shared Mag­num build, don’t for­get to bundle the new shared MagnumTrade lib­rary as well, if your pro­ject uses it.

Any­Im­port­er plu­gins are moved to the core re­pos­it­ory

In or­der to al­low core func­tion­al­ity to have more flex­ible ac­cess to im­age load­ing and oth­er plu­gin cap­ab­il­it­ies, the Any­Im­ageIm­port­er, Any­Im­age­Con­vert­er, An­y­Au­di­oIm­port­er and Any­SceneIm­port­er plu­gins were moved to the core re­pos­it­ory.

If you are not us­ing a pack­age, this means that now you need to pass the WITH_ANY* CMake op­tions to the core lib­rary build in­stead of the plu­gins build in or­der to have the plu­gins en­abled. Like be­fore, these are not en­abled by de­fault. See the doc­u­ment­a­tion for more in­form­a­tion.

If you are load­ing the plu­gins as dy­nam­ic, that’s all you need to do. Oth­er­wise (for ex­ample when build­ing your app for Em­scripten, An­droid or iOS), you need to up­date your loc­al cop­ies of FindMagnum.cmake and FindMagnumPlugins.cmake, ask the core re­pos­it­ory for these plu­gins and link to e.g. Magnum::AnyImageImporter in­stead of MagnumPlugins::AnyImageImporter.

find_package(Magnum REQUIRED AnyImageImporter)

# ...

target_link_libraries(your-app PRIVATE Magnum::AnyImageImporter)

If you are us­ing a cus­tom build­sys­tem, noth­ing sig­ni­fic­antly changes, as the lib­rar­ies stay prac­tic­ally the same, only are com­ing from a dif­fer­ent pro­ject now.

Con­sist­ent flags for build­ing stat­ic plu­gins

Both the core Mag­num re­pos­it­ory and the Mag­num Plu­gins re­pos­it­ory now use the BUILD_PLUGINS_STATIC CMake op­tion to build plu­gins as stat­ic. If you have been ex­pli­citly com­pil­ing the plu­gins as stat­ic be­fore you need to up­date your build setup from the pre­vi­ous BUILD_STATIC op­tion. If you are build­ing for An­droid, Em­scripten or iOS, the stat­ic build is en­abled im­pli­citly and you don’t need to change any­thing. See the doc­u­ment­a­tion for more in­form­a­tion.

Stan­dalone OpenDDL pars­er lib­rary

The OpenGex­Im­port­er plu­gin is built around an OpenDDL pars­er lib­rary. Since the be­gin­ning it was a private part of the plu­gin and us­ing it dir­ectly (for ex­ample to ac­cess OpenGEX ex­ten­sion struc­tures) meant one had to com­pile the plu­gin as stat­ic or go through oth­er ex­tra steps to be able to call its APIs. This is now sim­pler, as the lib­rary is com­pletely stan­dalone in the Mag­num Plu­gin re­pos­it­ory. It’s built im­pli­citly whenev­er the OpenGEX im­port­er plu­gin is built, but can be also built ex­pli­citly by en­abling WITH_OPENDDL. The BUILD_STATIC flag was re­pur­posed to con­trol shared/stat­ic build of this lib­rary. Again, see the doc­u­ment­a­tion for more in­form­a­tion.

Us­ing it from CMake means simply up­dat­ing your copy of FindMagnumPlugins.cmake and link­ing to it:

find_package(MagnumPlugins REQUIRED OpenDdl)

# ...

target_link_libraries(your-app PRIVATE MagnumPlugins::OpenDdl)

For con­sist­ency with the rest of the pro­ject, the in­cludes were moved to a more in­tu­it­ive loc­a­tion — in­stead of e.g.

#include <MagnumPlugins/OpenGexImporter/OpenDdl/Document.h>

it’s now just

#include <Magnum/OpenDdl/Document.h>

The old head­er loc­a­tion is still avail­able, but will is­sue de­prec­a­tion warn­ings.

If you don’t need to use the lib­rary dir­ectly, you don’t need to up­date any­thing. De­ploy­ing an ap­plic­a­tion that’s us­ing the OpenGex­Im­port­er plu­gin now needs to sup­ply the MagnumOpenDdl lib­rary as well, in case it’s built as shared.