Buildsystem reorganization for smaller minimal builds

Mag­num mas­ter branch re­ceived a few break­ing changes to the buildsys­tem to fur­ther slim down the li­brary in prepa­ra­tion for Vulkan sup­port.

As­set im­port func­tion­al­i­ty is now ful­ly op­tion­al

The Trade names­pace was his­tor­i­cal­ly a part of the core Mag­num li­brary. Based on re­cent feed­back and new use cas­es pop­ping up, it now made sense to sep­a­rate it in­to its own li­brary. This al­lows for even small­er builds for projects that don’t need any as­set man­age­ment func­tion­al­i­ty. That al­so means the Cor­rade::Plug­in­Man­ag­er li­brary is no longer an im­plic­it de­pen­den­cy — at the min­i­mum you now need to link just to the Cor­rade::Util­i­ty and core Mag­num li­brary.

If you are us­ing CMake, be sure to up­date your lo­cal copy of FindMagnum.cmake and ex­plic­it­ly link to the Magnum::Trade tar­get if you are us­ing any func­tion­al­i­ty from the Trade names­pace. Chances are that you are al­ready link­ing to an­oth­er li­brary which de­pends on Magnum::Trade so it gets linked tran­si­tive­ly, but it’s bet­ter to be ex­plic­it:

find_package(Magnum REQUIRED Trade)

# ...

target_link_libraries(your-app PRIVATE Magnum::Trade)

If you’re us­ing Vcp­kg with Vis­ual Stu­dio, the au­tomag­ic will take care of this be­hind the scenes. If you’re us­ing a cus­tom buildsys­tem, you may need to add MagnumTrade to your link­er com­mand line. If you are de­ploy­ing your app with a shared Mag­num build, don’t for­get to bun­dle the new shared MagnumTrade li­brary as well, if your project us­es it.

Any­Im­porter plug­ins are moved to the core re­pos­i­to­ry

In or­der to al­low core func­tion­al­i­ty to have more flex­i­ble ac­cess to im­age load­ing and oth­er plug­in ca­pa­bil­i­ties, the Any­Im­ageIm­porter, Any­Im­age­Con­vert­er, AnyAu­dioIm­porter and AnySceneIm­porter plug­ins were moved to the core repos­i­to­ry.

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 li­brary build in­stead of the plug­ins build in or­der to have the plug­ins en­abled. Like be­fore, these are not en­abled by de­fault. See the doc­u­men­ta­tion for more in­for­ma­tion.

If you are load­ing the plug­ins as dy­nam­ic, that’s all you need to do. Oth­er­wise (for ex­am­ple when build­ing your app for Em­scripten, An­droid or iOS), you need to up­date your lo­cal copies of FindMagnum.cmake and FindMagnumPlugins.cmake, ask the core repos­i­to­ry for these plug­ins 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 buildsys­tem, noth­ing sig­nif­i­cant­ly changes, as the li­braries stay prac­ti­cal­ly the same, on­ly are com­ing from a dif­fer­ent project now.

Con­sis­tent flags for build­ing stat­ic plug­ins

Both the core Mag­num repos­i­to­ry and the Mag­num Plug­ins repos­i­to­ry now use the BUILD_PLUGINS_STATIC CMake op­tion to build plug­ins as stat­ic. If you have been ex­plic­it­ly com­pil­ing the plug­ins as stat­ic be­fore you need to up­date your build set­up 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­plic­it­ly and you don’t need to change any­thing. See the doc­u­men­ta­tion for more in­for­ma­tion.

Stand­alone OpenD­DL pars­er li­brary

The OpenGex­Im­porter plug­in is built around an OpenD­DL pars­er li­brary. Since the be­gin­ning it was a pri­vate part of the plug­in and us­ing it di­rect­ly (for ex­am­ple to ac­cess OpenGEX ex­ten­sion struc­tures) meant one had to com­pile the plug­in 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 li­brary is com­plete­ly stand­alone in the Mag­num Plug­in repos­i­to­ry. It’s built im­plic­it­ly when­ev­er the OpenGEX im­porter plug­in is built, but can be al­so built ex­plic­it­ly by en­abling WITH_OPENDDL. The BUILD_STATIC flag was re­pur­posed to con­trol shared/stat­ic build of this li­brary. Again, see the doc­u­men­ta­tion for more in­for­ma­tion.

Us­ing it from CMake means sim­ply 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­sis­ten­cy with the rest of the project, the in­cludes were moved to a more in­tu­itive lo­ca­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 lo­ca­tion is still avail­able, but will is­sue dep­re­ca­tion warn­ings.

If you don’t need to use the li­brary di­rect­ly, you don’t need to up­date any­thing. De­ploy­ing an ap­pli­ca­tion that’s us­ing the OpenGex­Im­porter plug­in now needs to sup­ply the MagnumOpenDdl li­brary as well, in case it’s built as shared.