diff --git a/CMakeLists.txt b/CMakeLists.txt index 7a5958c..d36ac57 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -73,6 +73,12 @@ endif() # Libraries to build option(MAGNUM_WITH_PYTHON "Build Python bindings" OFF) +# There's no global MAGNUM_BUILD_PLUGINS_STATIC option (only exposed as +# per-plugin define), so not checking it. +if(MAGNUM_WITH_PYTHON AND MAGNUM_BUILD_STATIC) + set(MAGNUM_PYTHON_BINDINGS_STATIC_PLUGINS "" CACHE STRING "Static plugins to link to Magnum Python bindings") +endif() + option(MAGNUM_BUILD_TESTS "Build unit tests" OFF) # Backwards compatibility for unprefixed CMake options. If the user isn't diff --git a/doc/python/pages/building.rst b/doc/python/pages/building.rst index 05b1474..4128657 100644 --- a/doc/python/pages/building.rst +++ b/doc/python/pages/building.rst @@ -139,7 +139,13 @@ containing location of all built libraries for use with Python setuptools: In case Corrade or Magnum is built with :dox:`CORRADE_BUILD_STATIC` / :dox:`MAGNUM_BUILD_STATIC`, the corresponding bindings are compiled into a -single dynamic module instead of one module per Corrade/Magnum library. +single dynamic module instead of one module per Corrade/Magnum library. In this +case, similarly to linking static plugins to Magnum's own command-line +utilities, you can use the ``MAGNUM_PYTHON_BINDINGS_STATIC_PLUGINS`` CMake +variable to link static plugins to the Python module, assuming Magnum, Magnum +Plugins and Magnum Bindings are all CMake subprojects. It's a +semicolon-separated list of existing CMake targets, for example +``Magnum::AnyImageImporter;MagnumPlugins::StbImageImporter``. `Running unit tests`_ --------------------- diff --git a/doc/python/pages/changelog.rst b/doc/python/pages/changelog.rst index 6685a39..8322670 100644 --- a/doc/python/pages/changelog.rst +++ b/doc/python/pages/changelog.rst @@ -106,6 +106,9 @@ Changelog compatibility, unless ``MAGNUM_BUILD_DEPRECATED`` is disabled and unless a prefixed option is already set during the initial run, the unprefixed options are still recognized with a warning. See also :gh:`mosra/corrade#139`. +- Added a ``MAGNUM_PYTHON_BINDINGS_STATIC_PLUGINS`` CMake option for linking + static plugins to the Python bindings module. See the + :ref:`building documentation ` for more information. `2020.06`_ ========== diff --git a/src/python/magnum/CMakeLists.txt b/src/python/magnum/CMakeLists.txt index f0a0410..758087c 100644 --- a/src/python/magnum/CMakeLists.txt +++ b/src/python/magnum/CMakeLists.txt @@ -244,7 +244,10 @@ target_include_directories(magnum PRIVATE ${PROJECT_SOURCE_DIR}/src # SceneGraph/Python.h for static build ${PROJECT_SOURCE_DIR}/src/python ${PROJECT_BINARY_DIR}/src/python) # for static build -target_link_libraries(magnum PRIVATE Magnum::Magnum ${magnum_LIBS}) +target_link_libraries(magnum PRIVATE + Magnum::Magnum + ${magnum_LIBS} + ${MAGNUM_PYTHON_BINDINGS_STATIC_PLUGINS}) set_target_properties(magnum PROPERTIES OUTPUT_NAME "_magnum" LIBRARY_OUTPUT_DIRECTORY ${output_dir})