diff --git a/src/MagnumPlugins/MagnumFont/CMakeLists.txt b/src/MagnumPlugins/MagnumFont/CMakeLists.txt index 3a0c799d3..5d3777628 100644 --- a/src/MagnumPlugins/MagnumFont/CMakeLists.txt +++ b/src/MagnumPlugins/MagnumFont/CMakeLists.txt @@ -23,6 +23,13 @@ # DEALINGS IN THE SOFTWARE. # +if(BUILD_PLUGINS_STATIC) + set(MAGNUM_MAGNUMFONT_BUILD_STATIC 1) +endif() + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/configure.h) + set(MagnumFont_SRCS MagnumFont.cpp) @@ -34,6 +41,9 @@ add_library(MagnumFontObjects OBJECT ${MagnumFont_SRCS} ${MagnumFont_HEADERS}) target_include_directories(MagnumFontObjects PUBLIC $) +if(NOT BUILD_PLUGINS_STATIC) + target_compile_definitions(MagnumFontObjects PRIVATE "MagnumFontObjects_EXPORTS") +endif() if(NOT BUILD_PLUGINS_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumFontObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() @@ -53,6 +63,7 @@ if(CORRADE_TARGET_WINDOWS) 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) if(BUILD_GL_TESTS) # On Win32 we need to avoid dllimporting TgaImporter symbols, because it @@ -63,7 +74,9 @@ if(BUILD_GL_TESTS) add_library(MagnumMagnumFontTestLib STATIC ${MagnumFont_SRCS} ${MagnumFont_HEADERS}) - target_compile_definitions(MagnumMagnumFontTestLib PRIVATE "MAGNUM_TGAIMPORTER_BUILD_STATIC") + target_compile_definitions(MagnumMagnumFontTestLib + PRIVATE "MAGNUM_TGAIMPORTER_BUILD_STATIC" + PUBLIC "MAGNUM_MAGNUMFONT_BUILD_STATIC") else() add_library(MagnumMagnumFontTestLib STATIC $ diff --git a/src/MagnumPlugins/MagnumFont/MagnumFont.h b/src/MagnumPlugins/MagnumFont/MagnumFont.h index 0496e64a3..5f12a7ca3 100644 --- a/src/MagnumPlugins/MagnumFont/MagnumFont.h +++ b/src/MagnumPlugins/MagnumFont/MagnumFont.h @@ -32,6 +32,21 @@ #include "Magnum/Text/AbstractFont.h" #include "Magnum/Trade/Trade.h" +#include "MagnumPlugins/MagnumFont/configure.h" + +#ifndef DOXYGEN_GENERATING_OUTPUT +#ifndef MAGNUM_MAGNUMFONT_BUILD_STATIC + #if defined(MagnumFont_EXPORTS) || defined(MagnumFontObjects_EXPORTS) + #define MAGNUM_MAGNUMFONT_EXPORT CORRADE_VISIBILITY_EXPORT + #else + #define MAGNUM_MAGNUMFONT_EXPORT CORRADE_VISIBILITY_IMPORT + #endif +#else + #define MAGNUM_MAGNUMFONT_EXPORT CORRADE_VISIBILITY_STATIC +#endif +#define MAGNUM_MAGNUMFONT_LOCAL CORRADE_VISIBILITY_LOCAL +#endif + namespace Magnum { namespace Text { /** @@ -101,9 +116,9 @@ The file syntax is as in following: # ... -@see Trade::TgaImporter +@see @ref Trade::TgaImporter */ -class MagnumFont: public AbstractFont { +class MAGNUM_MAGNUMFONT_EXPORT MagnumFont: public AbstractFont { public: /** @brief Default constructor */ explicit MagnumFont(); @@ -116,25 +131,18 @@ class MagnumFont: public AbstractFont { private: struct Data; - Features doFeatures() const override; - - bool doIsOpened() const override; - - Metrics doOpenData(const std::vector>>& data, Float) override; - - Metrics doOpenFile(const std::string& filename, Float) override; - - void doClose() override; - - UnsignedInt doGlyphId(char32_t character) override; - - Vector2 doGlyphAdvance(UnsignedInt glyph) override; - - std::unique_ptr doCreateGlyphCache() override; + MAGNUM_MAGNUMFONT_LOCAL Features doFeatures() const override; + MAGNUM_MAGNUMFONT_LOCAL bool doIsOpened() const override; + MAGNUM_MAGNUMFONT_LOCAL Metrics doOpenData(const std::vector>>& data, Float) override; + MAGNUM_MAGNUMFONT_LOCAL Metrics doOpenFile(const std::string& filename, Float) override; + MAGNUM_MAGNUMFONT_LOCAL void doClose() override; - std::unique_ptr doLayout(const GlyphCache& cache, Float size, const std::string& text) override; + MAGNUM_MAGNUMFONT_LOCAL UnsignedInt doGlyphId(char32_t character) override; + MAGNUM_MAGNUMFONT_LOCAL Vector2 doGlyphAdvance(UnsignedInt glyph) override; + MAGNUM_MAGNUMFONT_LOCAL std::unique_ptr doCreateGlyphCache() override; + MAGNUM_MAGNUMFONT_LOCAL std::unique_ptr doLayout(const GlyphCache& cache, Float size, const std::string& text) override; - Metrics openInternal(Utility::Configuration&& conf, Trade::ImageData2D&& image); + MAGNUM_MAGNUMFONT_LOCAL Metrics openInternal(Utility::Configuration&& conf, Trade::ImageData2D&& image); Data* _opened; }; diff --git a/src/MagnumPlugins/MagnumFont/configure.h.cmake b/src/MagnumPlugins/MagnumFont/configure.h.cmake new file mode 100644 index 000000000..b3d53b96a --- /dev/null +++ b/src/MagnumPlugins/MagnumFont/configure.h.cmake @@ -0,0 +1,26 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 + Vladimír Vondruš + + 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. +*/ + +#cmakedefine MAGNUM_MAGNUMFONT_BUILD_STATIC diff --git a/src/MagnumPlugins/MagnumFontConverter/CMakeLists.txt b/src/MagnumPlugins/MagnumFontConverter/CMakeLists.txt index 0140e479e..a89ae6e88 100644 --- a/src/MagnumPlugins/MagnumFontConverter/CMakeLists.txt +++ b/src/MagnumPlugins/MagnumFontConverter/CMakeLists.txt @@ -23,6 +23,13 @@ # DEALINGS IN THE SOFTWARE. # +if(BUILD_PLUGINS_STATIC) + set(MAGNUM_MAGNUMFONTCONVERTER_BUILD_STATIC 1) +endif() + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/configure.h) + set(MagnumFontConverter_SRCS MagnumFontConverter.cpp) @@ -34,6 +41,9 @@ add_library(MagnumFontConverterObjects OBJECT ${MagnumFontConverter_SRCS} ${MagnumFontConverter_HEADERS}) target_include_directories(MagnumFontConverterObjects PUBLIC $) +if(NOT BUILD_PLUGINS_STATIC) + target_compile_definitions(MagnumFontConverterObjects PRIVATE "MagnumFontConverterObjects_EXPORTS") +endif() if(NOT BUILD_PLUGINS_STATIC OR BUILD_STATIC_PIC) set_target_properties(MagnumFontConverterObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() @@ -53,6 +63,7 @@ if(CORRADE_TARGET_WINDOWS) 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) if(BUILD_GL_TESTS) # On Win32 we need to avoid dllimporting TgaImageConverter symbols, because @@ -63,7 +74,9 @@ if(BUILD_GL_TESTS) add_library(MagnumMagnumFontConverterTestLib STATIC ${MagnumFontConverter_SRCS} ${MagnumFontConverter_HEADERS}) - target_compile_definitions(MagnumMagnumFontConverterTestLib PRIVATE "MAGNUM_TGAIMAGECONVERTER_BUILD_STATIC") + target_compile_definitions(MagnumMagnumFontConverterTestLib + PRIVATE "MAGNUM_TGAIMAGECONVERTER_BUILD_STATIC" + PUBLIC "MAGNUM_MAGNUMFONTCONVERTER_BUILD_STATIC") else() add_library(MagnumMagnumFontConverterTestLib STATIC $ diff --git a/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h b/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h index 4f6595db2..8c72749c0 100644 --- a/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h +++ b/src/MagnumPlugins/MagnumFontConverter/MagnumFontConverter.h @@ -31,6 +31,21 @@ #include "Magnum/Text/AbstractFontConverter.h" +#include "MagnumPlugins/MagnumFontConverter/configure.h" + +#ifndef DOXYGEN_GENERATING_OUTPUT +#ifndef MAGNUM_MAGNUMFONTCONVERTER_BUILD_STATIC + #if defined(MagnumFontConverter_EXPORTS) || defined(MagnumFontConverterObjects_EXPORTS) + #define MAGNUM_MAGNUMFONTCONVERTER_EXPORT CORRADE_VISIBILITY_EXPORT + #else + #define MAGNUM_MAGNUMFONTCONVERTER_EXPORT CORRADE_VISIBILITY_IMPORT + #endif +#else + #define MAGNUM_MAGNUMFONTCONVERTER_EXPORT CORRADE_VISIBILITY_STATIC +#endif +#define MAGNUM_MAGNUMFONTCONVERTER_LOCAL CORRADE_VISIBILITY_LOCAL +#endif + namespace Magnum { namespace Text { /** @@ -49,7 +64,7 @@ dependency of another plugin, you need to request `MagnumFontConverter` component of `Magnum` package in CMake and link to `Magnum::MagnumFontConverter` target. See @ref building, @ref cmake and @ref plugins for more information. */ -class MagnumFontConverter: public Text::AbstractFontConverter { +class MAGNUM_MAGNUMFONTCONVERTER_EXPORT MagnumFontConverter: public Text::AbstractFontConverter { public: /** @brief Default constructor */ explicit MagnumFontConverter(); @@ -58,8 +73,8 @@ class MagnumFontConverter: public Text::AbstractFontConverter { explicit MagnumFontConverter(PluginManager::AbstractManager& manager, std::string plugin); private: - Features doFeatures() const override; - std::vector>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const override; + MAGNUM_MAGNUMFONTCONVERTER_LOCAL Features doFeatures() const override; + MAGNUM_MAGNUMFONTCONVERTER_LOCAL std::vector>> doExportFontToData(AbstractFont& font, GlyphCache& cache, const std::string& filename, const std::u32string& characters) const override; }; }} diff --git a/src/MagnumPlugins/MagnumFontConverter/Test/CMakeLists.txt b/src/MagnumPlugins/MagnumFontConverter/Test/CMakeLists.txt index 2e859b71b..fa42cba7a 100644 --- a/src/MagnumPlugins/MagnumFontConverter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/MagnumFontConverter/Test/CMakeLists.txt @@ -31,7 +31,6 @@ corrade_add_test(MagnumFontConverterGLTest MagnumFontConverterGLTest.cpp LIBRARI MagnumTgaImporterTestLib ${GL_TEST_LIBRARIES}) target_include_directories(MagnumFontConverterGLTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) - # On Win32 we need to avoid dllimporting TgaImporter symbols, because it would # search for the symbols in some DLL even though they were linked statically. # However it apparently doesn't matter that they were dllexported when building diff --git a/src/MagnumPlugins/MagnumFontConverter/configure.h.cmake b/src/MagnumPlugins/MagnumFontConverter/configure.h.cmake new file mode 100644 index 000000000..1eb6102a9 --- /dev/null +++ b/src/MagnumPlugins/MagnumFontConverter/configure.h.cmake @@ -0,0 +1,26 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 + Vladimír Vondruš + + 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. +*/ + +#cmakedefine MAGNUM_MAGNUMFONTCONVERTER_BUILD_STATIC diff --git a/src/MagnumPlugins/ObjImporter/CMakeLists.txt b/src/MagnumPlugins/ObjImporter/CMakeLists.txt index 558cbfabf..7726b2e33 100644 --- a/src/MagnumPlugins/ObjImporter/CMakeLists.txt +++ b/src/MagnumPlugins/ObjImporter/CMakeLists.txt @@ -23,6 +23,13 @@ # DEALINGS IN THE SOFTWARE. # +if(BUILD_PLUGINS_STATIC) + set(MAGNUM_OBJIMPORTER_BUILD_STATIC 1) +endif() + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/configure.h) + set(ObjImporter_SRCS ObjImporter.cpp) @@ -34,6 +41,9 @@ add_library(ObjImporterObjects OBJECT ${ObjImporter_SRCS} ${ObjImporter_HEADERS}) target_include_directories(ObjImporterObjects PUBLIC $) +if(NOT BUILD_PLUGINS_STATIC) + target_compile_definitions(ObjImporterObjects PRIVATE "ObjImporterObjects_EXPORTS") +endif() if(NOT BUILD_PLUGINS_STATIC OR BUILD_STATIC_PIC) set_target_properties(ObjImporterObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() @@ -49,12 +59,14 @@ endif() 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) if(BUILD_TESTS) add_library(MagnumObjImporterTestLib STATIC $ ${PROJECT_SOURCE_DIR}/src/dummy.cpp) # XCode workaround, see file comment for details target_link_libraries(MagnumObjImporterTestLib Magnum MagnumMeshTools) + add_subdirectory(Test) endif() diff --git a/src/MagnumPlugins/ObjImporter/ObjImporter.h b/src/MagnumPlugins/ObjImporter/ObjImporter.h index 29d150f16..74e6d85dd 100644 --- a/src/MagnumPlugins/ObjImporter/ObjImporter.h +++ b/src/MagnumPlugins/ObjImporter/ObjImporter.h @@ -31,6 +31,21 @@ #include "Magnum/Trade/AbstractImporter.h" +#include "MagnumPlugins/ObjImporter/configure.h" + +#ifndef DOXYGEN_GENERATING_OUTPUT +#ifndef MAGNUM_OBJIMPORTER_BUILD_STATIC + #if defined(ObjImporter_EXPORTS) || defined(ObjImporterObjects_EXPORTS) + #define MAGNUM_OBJIMPORTER_EXPORT CORRADE_VISIBILITY_EXPORT + #else + #define MAGNUM_OBJIMPORTER_EXPORT CORRADE_VISIBILITY_IMPORT + #endif +#else + #define MAGNUM_OBJIMPORTER_EXPORT CORRADE_VISIBILITY_STATIC +#endif +#define MAGNUM_OBJIMPORTER_LOCAL CORRADE_VISIBILITY_LOCAL +#endif + namespace Magnum { namespace Trade { /** @@ -51,7 +66,7 @@ of another plugin, you need to request `ObjImporter` component of `Magnum` package in CMake and link to `Magnum::ObjImporter` target. See @ref building, @ref cmake and @ref plugins for more information. */ -class ObjImporter: public AbstractImporter { +class MAGNUM_OBJIMPORTER_EXPORT ObjImporter: public AbstractImporter { public: /** @brief Default constructor */ explicit ObjImporter(); @@ -64,19 +79,19 @@ class ObjImporter: public AbstractImporter { private: struct File; - Features doFeatures() const override; + MAGNUM_OBJIMPORTER_LOCAL Features doFeatures() const override; - bool doIsOpened() const override; - void doOpenData(Containers::ArrayView data) override; - void doOpenFile(const std::string& filename) override; - void doClose() override; + MAGNUM_OBJIMPORTER_LOCAL bool doIsOpened() const override; + MAGNUM_OBJIMPORTER_LOCAL void doOpenData(Containers::ArrayView data) override; + MAGNUM_OBJIMPORTER_LOCAL void doOpenFile(const std::string& filename) override; + MAGNUM_OBJIMPORTER_LOCAL void doClose() override; - UnsignedInt doMesh3DCount() const override; - Int doMesh3DForName(const std::string& name) override; - std::string doMesh3DName(UnsignedInt id) override; - std::optional doMesh3D(UnsignedInt id) override; + MAGNUM_OBJIMPORTER_LOCAL UnsignedInt doMesh3DCount() const override; + MAGNUM_OBJIMPORTER_LOCAL Int doMesh3DForName(const std::string& name) override; + MAGNUM_OBJIMPORTER_LOCAL std::string doMesh3DName(UnsignedInt id) override; + MAGNUM_OBJIMPORTER_LOCAL std::optional doMesh3D(UnsignedInt id) override; - void parseMeshNames(); + MAGNUM_OBJIMPORTER_LOCAL void parseMeshNames(); std::unique_ptr _file; }; diff --git a/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt b/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt index e51873f87..c8bf7e8b4 100644 --- a/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/ObjImporter/Test/CMakeLists.txt @@ -34,6 +34,13 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake corrade_add_test(ObjImporterTest Test.cpp LIBRARIES MagnumObjImporterTestLib) target_include_directories(ObjImporterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +# On Win32 we need to avoid dllimporting ObjImporter symbols, because it would +# search for the symbols in some DLL even though they were linked statically. +# However it apparently doesn't matter that they were dllexported when building +# the static library. EH. +if(WIN32) + target_compile_definitions(ObjImporterTest PRIVATE "MAGNUM_OBJIMPORTER_BUILD_STATIC") +endif() if(CORRADE_TARGET_EMSCRIPTEN) emscripten_embed_file(ObjImporterTest "" "/") diff --git a/src/MagnumPlugins/ObjImporter/configure.h.cmake b/src/MagnumPlugins/ObjImporter/configure.h.cmake new file mode 100644 index 000000000..e30d44ad2 --- /dev/null +++ b/src/MagnumPlugins/ObjImporter/configure.h.cmake @@ -0,0 +1,26 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 + Vladimír Vondruš + + 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. +*/ + +#cmakedefine MAGNUM_OBJIMPORTER_BUILD_STATIC diff --git a/src/MagnumPlugins/WavAudioImporter/CMakeLists.txt b/src/MagnumPlugins/WavAudioImporter/CMakeLists.txt index 3280459d4..b17bcb8ea 100644 --- a/src/MagnumPlugins/WavAudioImporter/CMakeLists.txt +++ b/src/MagnumPlugins/WavAudioImporter/CMakeLists.txt @@ -23,6 +23,13 @@ # DEALINGS IN THE SOFTWARE. # +if(BUILD_PLUGINS_STATIC) + set(MAGNUM_WAVAUDIOIMPORTER_BUILD_STATIC 1) +endif() + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/configure.h) + set(WavAudioImporter_SRCS WavHeader.cpp WavImporter.cpp) @@ -38,6 +45,9 @@ add_library(WavAudioImporterObjects OBJECT target_include_directories(WavAudioImporterObjects PUBLIC $ $) +if(NOT BUILD_PLUGINS_STATIC) + target_compile_definitions(WavAudioImporterObjects PRIVATE "WavAudioImporterObjects_EXPORTS") +endif() if(NOT BUILD_PLUGINS_STATIC OR BUILD_STATIC_PIC) set_target_properties(WavAudioImporterObjects PROPERTIES POSITION_INDEPENDENT_CODE ON) endif() @@ -53,12 +63,14 @@ endif() 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) if(BUILD_TESTS) add_library(MagnumWavAudioImporterTestLib STATIC $ ${PROJECT_SOURCE_DIR}/src/dummy.cpp) # XCode workaround, see file comment for details target_link_libraries(MagnumWavAudioImporterTestLib Magnum MagnumAudio) + add_subdirectory(Test) endif() diff --git a/src/MagnumPlugins/WavAudioImporter/Test/CMakeLists.txt b/src/MagnumPlugins/WavAudioImporter/Test/CMakeLists.txt index ccd145822..ae3132c39 100644 --- a/src/MagnumPlugins/WavAudioImporter/Test/CMakeLists.txt +++ b/src/MagnumPlugins/WavAudioImporter/Test/CMakeLists.txt @@ -34,6 +34,13 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake corrade_add_test(WavAudioImporterTest WavImporterTest.cpp LIBRARIES MagnumWavAudioImporterTestLib) target_include_directories(WavAudioImporterTest PRIVATE ${CMAKE_CURRENT_BINARY_DIR}) +# On Win32 we need to avoid dllimporting WavAudioImporter symbols, because it +# would search for the symbols in some DLL even though they were linked +# statically. However it apparently doesn't matter that they were dllexported +# when building the static library. EH. +if(WIN32) + target_compile_definitions(WavAudioImporterTest PRIVATE "MAGNUM_WAVAUDIOIMPORTER_BUILD_STATIC") +endif() if(CORRADE_TARGET_EMSCRIPTEN) emscripten_embed_file(WavAudioImporterTest mono8.wav "/mono8.wav") diff --git a/src/MagnumPlugins/WavAudioImporter/WavImporter.h b/src/MagnumPlugins/WavAudioImporter/WavImporter.h index 3300821e9..aecd6f726 100644 --- a/src/MagnumPlugins/WavAudioImporter/WavImporter.h +++ b/src/MagnumPlugins/WavAudioImporter/WavImporter.h @@ -33,6 +33,21 @@ #include "Magnum/Audio/AbstractImporter.h" +#include "MagnumPlugins/WavAudioImporter/configure.h" + +#ifndef DOXYGEN_GENERATING_OUTPUT +#ifndef MAGNUM_WAVAUDIOIMPORTER_BUILD_STATIC + #if defined(WavAudioImporter_EXPORTS) || defined(WavAudioImporterObjects_EXPORTS) + #define MAGNUM_WAVAUDIOIMPORTER_EXPORT CORRADE_VISIBILITY_EXPORT + #else + #define MAGNUM_WAVAUDIOIMPORTER_EXPORT CORRADE_VISIBILITY_IMPORT + #endif +#else + #define MAGNUM_WAVAUDIOIMPORTER_EXPORT CORRADE_VISIBILITY_STATIC +#endif +#define MAGNUM_WAVAUDIOIMPORTER_LOCAL CORRADE_VISIBILITY_LOCAL +#endif + namespace Magnum { namespace Audio { /** @@ -49,7 +64,7 @@ dependency of another plugin, you need to request `WavAudioImporter` component of `Magnum` package in CMake and link to `Magnum::WavAudioImporter` target. See @ref building, @ref cmake and @ref plugins for more information. */ -class WavImporter: public AbstractImporter { +class MAGNUM_WAVAUDIOIMPORTER_EXPORT WavImporter: public AbstractImporter { public: /** @brief Default constructor */ explicit WavImporter(); @@ -58,14 +73,14 @@ class WavImporter: public AbstractImporter { explicit WavImporter(PluginManager::AbstractManager& manager, std::string plugin); private: - Features doFeatures() const override; - bool doIsOpened() const override; - void doOpenData(Containers::ArrayView data) override; - void doClose() override; - - Buffer::Format doFormat() const override; - UnsignedInt doFrequency() const override; - Containers::Array doData() override; + MAGNUM_WAVAUDIOIMPORTER_LOCAL Features doFeatures() const override; + MAGNUM_WAVAUDIOIMPORTER_LOCAL bool doIsOpened() const override; + MAGNUM_WAVAUDIOIMPORTER_LOCAL void doOpenData(Containers::ArrayView data) override; + MAGNUM_WAVAUDIOIMPORTER_LOCAL void doClose() override; + + MAGNUM_WAVAUDIOIMPORTER_LOCAL Buffer::Format doFormat() const override; + MAGNUM_WAVAUDIOIMPORTER_LOCAL UnsignedInt doFrequency() const override; + MAGNUM_WAVAUDIOIMPORTER_LOCAL Containers::Array doData() override; Containers::Array _data; Buffer::Format _format; diff --git a/src/MagnumPlugins/WavAudioImporter/configure.h.cmake b/src/MagnumPlugins/WavAudioImporter/configure.h.cmake new file mode 100644 index 000000000..511a9a0a6 --- /dev/null +++ b/src/MagnumPlugins/WavAudioImporter/configure.h.cmake @@ -0,0 +1,26 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015, 2016 + Vladimír Vondruš + + 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. +*/ + +#cmakedefine MAGNUM_WAVAUDIOIMPORTER_BUILD_STATIC