Browse Source

Automagic way of importing static plugins.

Statically built plugins get imported automatically when using CMake
3.1 and newer. Otherwise simply #include a corresponding
importStaticPlugin.cpp file.
pull/205/head
Vladimír Vondruš 8 years ago
parent
commit
e27f3b4e12
  1. 4
      doc/changelog.dox
  2. 11
      modules/FindMagnum.cmake
  3. 8
      src/MagnumPlugins/MagnumFont/CMakeLists.txt
  4. 35
      src/MagnumPlugins/MagnumFont/importStaticPlugin.cpp
  5. 8
      src/MagnumPlugins/MagnumFontConverter/CMakeLists.txt
  6. 35
      src/MagnumPlugins/MagnumFontConverter/importStaticPlugin.cpp
  7. 8
      src/MagnumPlugins/ObjImporter/CMakeLists.txt
  8. 35
      src/MagnumPlugins/ObjImporter/importStaticPlugin.cpp
  9. 8
      src/MagnumPlugins/TgaImageConverter/CMakeLists.txt
  10. 35
      src/MagnumPlugins/TgaImageConverter/importStaticPlugin.cpp
  11. 8
      src/MagnumPlugins/TgaImporter/CMakeLists.txt
  12. 35
      src/MagnumPlugins/TgaImporter/importStaticPlugin.cpp
  13. 8
      src/MagnumPlugins/WavAudioImporter/CMakeLists.txt
  14. 35
      src/MagnumPlugins/WavAudioImporter/importStaticPlugin.cpp

4
doc/changelog.dox

@ -80,6 +80,10 @@ See also:
for plugin directory autodetection --- you no longer need to specify the
plugin directory explicitly when loading plugins. See @ref plugins-loading
for more information.
- Plugins now provide an automatic means of static plugin import via CMake
targets, no need to call @ref CORRADE_PLUGIN_IMPORT() implicitly anymore.
For this to work, you just need to update local copies of all Find modules.
See @ref plugins-static for more information.
@subsection changelog-latest-bugfixes Bug fixes

11
modules/FindMagnum.cmake

@ -642,6 +642,17 @@ foreach(_component ${Magnum_FIND_COMPONENTS})
mark_as_advanced(_MAGNUM_${_COMPONENT}_INCLUDE_DIR)
endif()
# Automatic import of static plugins on CMake >= 3.1
if(_component MATCHES ${_MAGNUM_PLUGIN_COMPONENTS} AND NOT CMAKE_VERSION VERSION_LESS 3.1)
# Automatic import of static plugins
file(READ ${_MAGNUM_${_COMPONENT}_INCLUDE_DIR}/configure.h _magnum${_component}Configure)
string(FIND "${_magnum${_component}Configure}" "#define MAGNUM_${_COMPONENT}_BUILD_STATIC" _magnum${_component}_BUILD_STATIC)
if(NOT _magnum${_component}_BUILD_STATIC EQUAL -1)
set_property(TARGET Magnum::${_component} APPEND PROPERTY
INTERFACE_SOURCES ${_MAGNUM_${_COMPONENT}_INCLUDE_DIR}/importStaticPlugin.cpp)
endif()
endif()
# Link to core Magnum library, add inter-library dependencies
if(_component MATCHES ${_MAGNUM_LIBRARY_COMPONENTS} OR _component MATCHES ${_MAGNUM_PLUGIN_COMPONENTS})
set_property(TARGET Magnum::${_component} APPEND PROPERTY

8
src/MagnumPlugins/MagnumFont/CMakeLists.txt

@ -69,6 +69,14 @@ endif()
install(FILES ${MagnumFont_HEADERS} DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/MagnumFont)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/configure.h DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/MagnumFont)
# Automatic static plugin import
if(BUILD_PLUGINS_STATIC)
install(FILES importStaticPlugin.cpp DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/MagnumFont)
if(NOT CMAKE_VERSION VERSION_LESS 3.1)
target_sources(MagnumFont INTERFACE importStaticPlugin.cpp)
endif()
endif()
if(BUILD_GL_TESTS)
# On Win32 we need to avoid dllimporting TgaImporter symbols, because it
# would search for the symbols in some DLL even when they were linked

35
src/MagnumPlugins/MagnumFont/importStaticPlugin.cpp

@ -0,0 +1,35 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "MagnumPlugins/MagnumFont/configure.h"
#ifdef MAGNUM_MAGNUMFONT_BUILD_STATIC
#include <Corrade/PluginManager/AbstractManager.h>
static int magnumMagnumFontStaticImporter() {
CORRADE_PLUGIN_IMPORT(MagnumFont)
return 1;
} CORRADE_AUTOMATIC_INITIALIZER(magnumMagnumFontStaticImporter)
#endif

8
src/MagnumPlugins/MagnumFontConverter/CMakeLists.txt

@ -69,6 +69,14 @@ endif()
install(FILES ${MagnumFontConverter_HEADERS} DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/MagnumFontConverter)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/configure.h DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/MagnumFontConverter)
# Automatic static plugin import
if(BUILD_PLUGINS_STATIC)
install(FILES importStaticPlugin.cpp DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/MagnumFontConverter)
if(NOT CMAKE_VERSION VERSION_LESS 3.1)
target_sources(MagnumFontConverter INTERFACE importStaticPlugin.cpp)
endif()
endif()
if(BUILD_GL_TESTS)
# On Win32 we need to avoid dllimporting TgaImageConverter symbols, because
# it would search for the symbols in some DLL even when they were linked

35
src/MagnumPlugins/MagnumFontConverter/importStaticPlugin.cpp

@ -0,0 +1,35 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "MagnumPlugins/MagnumFontConverter/configure.h"
#ifdef MAGNUM_MAGNUMFONTCONVERTER_BUILD_STATIC
#include <Corrade/PluginManager/AbstractManager.h>
static int magnumMagnumFontConverterStaticImporter() {
CORRADE_PLUGIN_IMPORT(MagnumFontConverter)
return 1;
} CORRADE_AUTOMATIC_INITIALIZER(magnumMagnumFontConverterStaticImporter)
#endif

8
src/MagnumPlugins/ObjImporter/CMakeLists.txt

@ -64,6 +64,14 @@ target_link_libraries(ObjImporter Magnum MagnumMeshTools)
install(FILES ${ObjImporter_HEADERS} DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/ObjImporter)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/configure.h DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/ObjImporter)
# Automatic static plugin import
if(BUILD_PLUGINS_STATIC)
install(FILES importStaticPlugin.cpp DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/ObjImporter)
if(NOT CMAKE_VERSION VERSION_LESS 3.1)
target_sources(ObjImporter INTERFACE importStaticPlugin.cpp)
endif()
endif()
if(BUILD_TESTS)
add_library(MagnumObjImporterTestLib STATIC
$<TARGET_OBJECTS:ObjImporterObjects>

35
src/MagnumPlugins/ObjImporter/importStaticPlugin.cpp

@ -0,0 +1,35 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "MagnumPlugins/ObjImporter/configure.h"
#ifdef MAGNUM_OBJIMPORTER_BUILD_STATIC
#include <Corrade/PluginManager/AbstractManager.h>
static int magnumObjImporterStaticImporter() {
CORRADE_PLUGIN_IMPORT(ObjImporter)
return 1;
} CORRADE_AUTOMATIC_INITIALIZER(magnumObjImporterStaticImporter)
#endif

8
src/MagnumPlugins/TgaImageConverter/CMakeLists.txt

@ -64,6 +64,14 @@ target_link_libraries(TgaImageConverter Magnum)
install(FILES ${TgaImageConverter_HEADERS} DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/TgaImageConverter)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/configure.h DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/TgaImageConverter)
# Automatic static plugin import
if(BUILD_PLUGINS_STATIC)
install(FILES importStaticPlugin.cpp DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/TgaImageConverter)
if(NOT CMAKE_VERSION VERSION_LESS 3.1)
target_sources(TgaImageConverter INTERFACE importStaticPlugin.cpp)
endif()
endif()
if(BUILD_TESTS)
add_library(MagnumTgaImageConverterTestLib STATIC
$<TARGET_OBJECTS:TgaImageConverterObjects>

35
src/MagnumPlugins/TgaImageConverter/importStaticPlugin.cpp

@ -0,0 +1,35 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "MagnumPlugins/TgaImageConverter/configure.h"
#ifdef MAGNUM_TGAIMAGECONVERTER_BUILD_STATIC
#include <Corrade/PluginManager/AbstractManager.h>
static int magnumTgaImageConverterStaticImporter() {
CORRADE_PLUGIN_IMPORT(TgaImageConverter)
return 1;
} CORRADE_AUTOMATIC_INITIALIZER(magnumTgaImageConverterStaticImporter)
#endif

8
src/MagnumPlugins/TgaImporter/CMakeLists.txt

@ -68,6 +68,14 @@ target_link_libraries(TgaImporter Magnum)
install(FILES ${TgaImporter_HEADERS} DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/TgaImporter)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/configure.h DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/TgaImporter)
# Automatic static plugin import
if(BUILD_PLUGINS_STATIC)
install(FILES importStaticPlugin.cpp DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/TgaImporter)
if(NOT CMAKE_VERSION VERSION_LESS 3.1)
target_sources(TgaImporter INTERFACE importStaticPlugin.cpp)
endif()
endif()
if(BUILD_TESTS)
add_library(MagnumTgaImporterTestLib STATIC
$<TARGET_OBJECTS:TgaImporterObjects>

35
src/MagnumPlugins/TgaImporter/importStaticPlugin.cpp

@ -0,0 +1,35 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "MagnumPlugins/TgaImporter/configure.h"
#ifdef MAGNUM_TGAIMPORTER_BUILD_STATIC
#include <Corrade/PluginManager/AbstractManager.h>
static int magnumTgaImporterStaticImporter() {
CORRADE_PLUGIN_IMPORT(TgaImporter)
return 1;
} CORRADE_AUTOMATIC_INITIALIZER(magnumTgaImporterStaticImporter)
#endif

8
src/MagnumPlugins/WavAudioImporter/CMakeLists.txt

@ -71,6 +71,14 @@ target_link_libraries(WavAudioImporter Magnum MagnumAudio)
install(FILES ${WavAudioImporter_HEADERS} DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/WavAudioImporter)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/configure.h DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/WavAudioImporter)
# Automatic static plugin import
if(BUILD_PLUGINS_STATIC)
install(FILES importStaticPlugin.cpp DESTINATION ${MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR}/WavAudioImporter)
if(NOT CMAKE_VERSION VERSION_LESS 3.1)
target_sources(WavAudioImporter INTERFACE importStaticPlugin.cpp)
endif()
endif()
if(BUILD_TESTS)
add_library(MagnumWavAudioImporterTestLib STATIC
$<TARGET_OBJECTS:WavAudioImporterObjects>

35
src/MagnumPlugins/WavAudioImporter/importStaticPlugin.cpp

@ -0,0 +1,35 @@
/*
This file is part of Magnum.
Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018
Vladimír Vondruš <mosra@centrum.cz>
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
*/
#include "MagnumPlugins/WavAudioImporter/configure.h"
#ifdef MAGNUM_WAVAUDIOIMPORTER_BUILD_STATIC
#include <Corrade/PluginManager/AbstractManager.h>
static int magnumWavAudioImporterStaticImporter() {
CORRADE_PLUGIN_IMPORT(WavAudioImporter)
return 1;
} CORRADE_AUTOMATIC_INITIALIZER(magnumWavAudioImporterStaticImporter)
#endif
Loading…
Cancel
Save