Browse Source

CMake: add a possibility to link static plugins to utility executables.

Funny/sad that this possibility took me so long to realize. Until now it
was "you can have command-line utilities or static plugins but never
both", and only with CMake 3.13+ it was possible to link static plugins
to these executables from outside. Now it's a builtin and supported
option.
pull/580/head
Vladimír Vondruš 4 years ago
parent
commit
5c36b39ba2
  1. 7
      CMakeLists.txt
  2. 16
      doc/building.dox
  3. 7
      doc/changelog.dox
  4. 14
      src/Magnum/SceneTools/CMakeLists.txt
  5. 3
      src/Magnum/ShaderTools/CMakeLists.txt
  6. 3
      src/Magnum/Text/CMakeLists.txt
  7. 15
      src/Magnum/TextureTools/CMakeLists.txt
  8. 3
      src/Magnum/Trade/CMakeLists.txt

7
CMakeLists.txt

@ -157,6 +157,9 @@ endif()
if(CORRADE_TARGET_UNIX OR CORRADE_TARGET_WINDOWS)
option(MAGNUM_WITH_FONTCONVERTER "Build magnum-fontconverter utility" OFF)
option(MAGNUM_WITH_DISTANCEFIELDCONVERTER "Build magnum-distancefieldconverter utility" OFF)
set(MAGNUM_FONTCONVERTER_STATIC_PLUGINS "" CACHE STRING "Static plugins to link to the magnum-fontconverter utility")
set(MAGNUM_DISTANCEFIELDCONVERTER_STATIC_PLUGINS "" CACHE STRING "Static plugins to link to the magnum-distancefieldconverter utility")
endif()
# API-independent utilities
@ -164,6 +167,10 @@ option(MAGNUM_WITH_IMAGECONVERTER "Build magnum-imageconverter utility" OFF)
option(MAGNUM_WITH_SCENECONVERTER "Build magnum-sceneconverter utility" OFF)
option(MAGNUM_WITH_SHADERCONVERTER "Build magnum-shaderconverter utility" OFF)
set(MAGNUM_IMAGECONVERTER_STATIC_PLUGINS "" CACHE STRING "Static plugins to link to the magnum-imageconverter utility")
set(MAGNUM_SCENECONVERTER_STATIC_PLUGINS "" CACHE STRING "Static plugins to link to the magnum-sceneconverter utility")
set(MAGNUM_SHADERCONVERTER_STATIC_PLUGINS "" CACHE STRING "Static plugins to link to the magnum-shaderconverter utility")
# Magnum AL Info
option(MAGNUM_WITH_AL_INFO "Build magnum-al-info utility" OFF)

16
doc/building.dox

@ -674,6 +674,22 @@ Options controlling the build:
update your code whenever there's a breaking API change. It's however
recommended to have this option disabled when deploying a final application
as it can result in smaller binaries.
- `MAGNUM_DISTANCEFIELDCONVERTER_STATIC_PLUGINS`,
`MAGNUM_FONTCONVERTER_STATIC_PLUGINS`,
`MAGNUM_IMAGECONVERTER_STATIC_PLUGINS`,
`MAGNUM_SCENECONVERTER_STATIC_PLUGINS` and
`MAGNUM_SHADERCONVERTER_STATIC_PLUGINS` --- Static plugins to link to the
@ref magnum-distancefieldconverter "magnum-distancefieldconverter",
@ref magnum-fontconverter "magnum-fontconverter",
@ref magnum-imageconverter "magnum-imageconverter",
@ref magnum-sceneconverter "magnum-sceneconverter" and
@ref magnum-shaderconverter "magnum-shaderconverter" utilities,
respectively. Intended for use in scenarios where both
`MAGNUM_BUILD_STATIC` and `MAGNUM_BUILD_PLUGINS_STATIC` is enabled, in
which case these executables don't have a possibility to load dynamic
plugins from a filesystem. Plugins from the Magnum Plugins repository
(and elsewhere) can be linked if it's added as a CMake subproject. Expects
a semicolon-separated list of existing CMake targets, for example `Magnum::AnyImageImporter;MagnumPlugins::StbImageImporter`.
- Additional options are inherited from the @ref CORRADE_BUILD_MULTITHREADED,
@ref CORRADE_BUILD_CPU_RUNTIME_DISPATCH and @ref CORRADE_CPU_USE_IFUNC
options specified when building Corrade.

7
doc/changelog.dox

@ -672,6 +672,13 @@ See also:
[mosra/magnum#570](https://github.com/mosra/magnum/pull/570).
- Fixed wrong `.gitattributes` option for LF line endings in MSYS PKGBUILDs
(see [mosra/magnum#574](https://github.com/mosra/magnum/issues/574))
- Added `MAGNUM_DISTANCEFIELDCONVERTER_STATIC_PLUGINS`,
`MAGNUM_FONTCONVERTER_STATIC_PLUGINS`,
`MAGNUM_IMAGECONVERTER_STATIC_PLUGINS`,
`MAGNUM_SCENECONVERTER_STATIC_PLUGINS` and
`MAGNUM_SHADERCONVERTER_STATIC_PLUGINS` CMake options for linking static
plugins to the command-line utilities. See @ref building-features for more
information.
@subsection changelog-latest-bugfixes Bug fixes

14
src/Magnum/SceneTools/CMakeLists.txt

@ -27,6 +27,17 @@
# property that would have to be set on each target separately.
set(CMAKE_FOLDER "Magnum/SceneTools")
# Somehow, due to MagnumTradeObjects having target_include_directories() with
# $<TARGET_PROPERTY:Corrade::PluginManager,INTERFACE_INCLUDE_DIRECTORIES>,
# if MAGNUM_SCENECONVERTER_STATIC_PLUGINS is non-empty then CMake fails with
#
# Target "Corrade::PluginManager" not found.
#
# unless the find_package() is here. Not sure why, probably some bug in CMake
# dependency handling? Changing target_include_directories() to PRIVATE doesn't
# help, removing it altogether helps.
find_package(Corrade REQUIRED PluginManager)
# Files shared between main library and unit test library
set(MagnumSceneTools_SRCS )
@ -88,7 +99,8 @@ if(MAGNUM_WITH_SCENECONVERTER)
Magnum
MagnumMeshTools
MagnumSceneTools
MagnumTrade)
MagnumTrade
${MAGNUM_SCENECONVERTER_STATIC_PLUGINS})
install(TARGETS magnum-sceneconverter DESTINATION ${MAGNUM_BINARY_INSTALL_DIR})

3
src/Magnum/ShaderTools/CMakeLists.txt

@ -91,7 +91,8 @@ if(MAGNUM_WITH_SHADERCONVERTER)
add_executable(magnum-shaderconverter shaderconverter.cpp)
target_link_libraries(magnum-shaderconverter PRIVATE
Magnum
MagnumShaderTools)
MagnumShaderTools
${MAGNUM_SHADERCONVERTER_STATIC_PLUGINS})
install(TARGETS magnum-shaderconverter DESTINATION ${MAGNUM_BINARY_INSTALL_DIR})

3
src/Magnum/Text/CMakeLists.txt

@ -116,7 +116,8 @@ if(MAGNUM_WITH_FONTCONVERTER)
target_link_libraries(magnum-fontconverter PRIVATE
Magnum
MagnumText
MagnumTrade)
MagnumTrade
${MAGNUM_FONTCONVERTER_STATIC_PLUGINS})
if(MAGNUM_TARGET_EGL)
target_link_libraries(magnum-fontconverter PRIVATE MagnumWindowlessEglApplication)
elseif(CORRADE_TARGET_IOS)

15
src/Magnum/TextureTools/CMakeLists.txt

@ -27,6 +27,18 @@
# property that would have to be set on each target separately.
set(CMAKE_FOLDER "Magnum/TextureTools")
# Somehow, due to MagnumTradeObjects having target_include_directories() with
# $<TARGET_PROPERTY:Corrade::PluginManager,INTERFACE_INCLUDE_DIRECTORIES>,
# if MAGNUM_DISTANCEFIELDCONVERTER_STATIC_PLUGINS is non-empty then CMake fails
# with
#
# Target "Corrade::PluginManager" not found.
#
# unless the find_package() is here. Not sure why, probably some bug in CMake
# dependency handling? Changing target_include_directories() to PRIVATE doesn't
# help, removing it altogether helps.
find_package(Corrade REQUIRED PluginManager)
set(MagnumTextureTools_GracefulAssert_SRCS
Atlas.cpp)
@ -84,7 +96,8 @@ if(MAGNUM_WITH_DISTANCEFIELDCONVERTER)
target_link_libraries(magnum-distancefieldconverter PRIVATE
Magnum
MagnumTextureTools
MagnumTrade)
MagnumTrade
${MAGNUM_DISTANCEFIELDCONVERTER_STATIC_PLUGINS})
if(MAGNUM_TARGET_EGL)
target_link_libraries(magnum-distancefieldconverter PRIVATE MagnumWindowlessEglApplication)
elseif(CORRADE_TARGET_IOS)

3
src/Magnum/Trade/CMakeLists.txt

@ -160,7 +160,8 @@ if(MAGNUM_WITH_IMAGECONVERTER)
MagnumTrade
# BasisImageConverter uses these, and linking pthread to just the
# plugin doesn't work. See its documentation for details.
Threads::Threads)
Threads::Threads
${MAGNUM_IMAGECONVERTER_STATIC_PLUGINS})
install(TARGETS magnum-imageconverter DESTINATION ${MAGNUM_BINARY_INSTALL_DIR})

Loading…
Cancel
Save