Browse Source

CMake: add a MAGNUM_PYTHON_BINDINGS_STATIC_PLUGINS CMake option.

Similar to the new options for Magnum command-line utilities.
pull/16/head
Vladimír Vondruš 4 years ago
parent
commit
1d662bcd48
  1. 6
      CMakeLists.txt
  2. 8
      doc/python/pages/building.rst
  3. 3
      doc/python/pages/changelog.rst
  4. 5
      src/python/magnum/CMakeLists.txt

6
CMakeLists.txt

@ -73,6 +73,12 @@ endif()
# Libraries to build # Libraries to build
option(MAGNUM_WITH_PYTHON "Build Python bindings" OFF) 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) option(MAGNUM_BUILD_TESTS "Build unit tests" OFF)
# Backwards compatibility for unprefixed CMake options. If the user isn't # Backwards compatibility for unprefixed CMake options. If the user isn't

8
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` / In case Corrade or Magnum is built with :dox:`CORRADE_BUILD_STATIC` /
:dox:`MAGNUM_BUILD_STATIC`, the corresponding bindings are compiled into a :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`_ `Running unit tests`_
--------------------- ---------------------

3
doc/python/pages/changelog.rst

@ -106,6 +106,9 @@ Changelog
compatibility, unless ``MAGNUM_BUILD_DEPRECATED`` is disabled and unless a compatibility, unless ``MAGNUM_BUILD_DEPRECATED`` is disabled and unless a
prefixed option is already set during the initial run, the unprefixed prefixed option is already set during the initial run, the unprefixed
options are still recognized with a warning. See also :gh:`mosra/corrade#139`. 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 <std:doc:building>` for more information.
`2020.06`_ `2020.06`_
========== ==========

5
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 # SceneGraph/Python.h for static build
${PROJECT_SOURCE_DIR}/src/python ${PROJECT_SOURCE_DIR}/src/python
${PROJECT_BINARY_DIR}/src/python) # for static build ${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 set_target_properties(magnum PROPERTIES
OUTPUT_NAME "_magnum" OUTPUT_NAME "_magnum"
LIBRARY_OUTPUT_DIRECTORY ${output_dir}) LIBRARY_OUTPUT_DIRECTORY ${output_dir})

Loading…
Cancel
Save