From 5c75770a1b436f0827a75714c6c7cd43edba7ae2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 27 Jan 2015 23:25:46 +0100 Subject: [PATCH] TgaImageConverter, TgaImporter: export symbols only on dynamic build. Mainly to fix linker errors on Windows when using static plugins as dependencies of other plugins. Don't even let me get started on how much I hate the dllexport/dllimport hell. --- .../TgaImageConverter/CMakeLists.txt | 8 ++++++ .../TgaImageConverter/TgaImageConverter.h | 12 ++++++--- .../TgaImageConverter/configure.h.cmake | 26 +++++++++++++++++++ src/MagnumPlugins/TgaImporter/CMakeLists.txt | 8 ++++++ src/MagnumPlugins/TgaImporter/TgaImporter.h | 12 ++++++--- .../TgaImporter/configure.h.cmake | 26 +++++++++++++++++++ 6 files changed, 86 insertions(+), 6 deletions(-) create mode 100644 src/MagnumPlugins/TgaImageConverter/configure.h.cmake create mode 100644 src/MagnumPlugins/TgaImporter/configure.h.cmake diff --git a/src/MagnumPlugins/TgaImageConverter/CMakeLists.txt b/src/MagnumPlugins/TgaImageConverter/CMakeLists.txt index 93f671bac..e15dadd10 100644 --- a/src/MagnumPlugins/TgaImageConverter/CMakeLists.txt +++ b/src/MagnumPlugins/TgaImageConverter/CMakeLists.txt @@ -23,6 +23,13 @@ # DEALINGS IN THE SOFTWARE. # +if(BUILD_PLUGINS_STATIC) + set(MAGNUM_TGAIMAGECONVERTER_BUILD_STATIC 1) +endif() + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/configure.h) + set(TgaImageConverter_SRCS TgaImageConverter.cpp) @@ -52,6 +59,7 @@ endif() 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/configure.h) if(BUILD_TESTS) add_library(MagnumTgaImageConverterTestLib STATIC $) diff --git a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h index b9b9aeb82..625abf4eb 100644 --- a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h +++ b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h @@ -31,11 +31,17 @@ #include "Magnum/Trade/AbstractImageConverter.h" +#include "MagnumPlugins/TgaImageConverter/configure.h" + #ifndef DOXYGEN_GENERATING_OUTPUT -#if defined(TgaImageConverter_EXPORTS) || defined(TgaImageConverterObjects_EXPORTS) - #define MAGNUM_TRADE_TGAIMAGECONVERTER_EXPORT CORRADE_VISIBILITY_EXPORT +#ifndef MAGNUM_TGAIMAGECONVERTER_BUILD_STATIC + #if defined(TgaImageConverter_EXPORTS) || defined(TgaImageConverterObjects_EXPORTS) + #define MAGNUM_TRADE_TGAIMAGECONVERTER_EXPORT CORRADE_VISIBILITY_EXPORT + #else + #define MAGNUM_TRADE_TGAIMAGECONVERTER_EXPORT CORRADE_VISIBILITY_IMPORT + #endif #else - #define MAGNUM_TRADE_TGAIMAGECONVERTER_EXPORT CORRADE_VISIBILITY_IMPORT + #define MAGNUM_TRADE_TGAIMAGECONVERTER_EXPORT CORRADE_VISIBILITY_STATIC #endif #define MAGNUM_TRADE_TGAIMAGECONVERTER_LOCAL CORRADE_VISIBILITY_LOCAL #endif diff --git a/src/MagnumPlugins/TgaImageConverter/configure.h.cmake b/src/MagnumPlugins/TgaImageConverter/configure.h.cmake new file mode 100644 index 000000000..d0c23cf82 --- /dev/null +++ b/src/MagnumPlugins/TgaImageConverter/configure.h.cmake @@ -0,0 +1,26 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + 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_TGAIMAGECONVERTER_BUILD_STATIC diff --git a/src/MagnumPlugins/TgaImporter/CMakeLists.txt b/src/MagnumPlugins/TgaImporter/CMakeLists.txt index e09a210b2..732250c03 100644 --- a/src/MagnumPlugins/TgaImporter/CMakeLists.txt +++ b/src/MagnumPlugins/TgaImporter/CMakeLists.txt @@ -23,6 +23,13 @@ # DEALINGS IN THE SOFTWARE. # +if(BUILD_PLUGINS_STATIC) + set(MAGNUM_TGAIMPORTER_BUILD_STATIC 1) +endif() + +configure_file(${CMAKE_CURRENT_SOURCE_DIR}/configure.h.cmake + ${CMAKE_CURRENT_BINARY_DIR}/configure.h) + set(TgaImporter_SRCS TgaImporter.cpp) @@ -53,6 +60,7 @@ endif() 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/configure.h) if(BUILD_TESTS) add_library(MagnumTgaImporterTestLib STATIC $) diff --git a/src/MagnumPlugins/TgaImporter/TgaImporter.h b/src/MagnumPlugins/TgaImporter/TgaImporter.h index 2a98ffe95..c7890c0cb 100644 --- a/src/MagnumPlugins/TgaImporter/TgaImporter.h +++ b/src/MagnumPlugins/TgaImporter/TgaImporter.h @@ -33,11 +33,17 @@ #include "Magnum/Trade/AbstractImporter.h" +#include "MagnumPlugins/TgaImporter/configure.h" + #ifndef DOXYGEN_GENERATING_OUTPUT -#if defined(TgaImporter_EXPORTS) || defined(TgaImporterObjects_EXPORTS) - #define MAGNUM_TRADE_TGAIMPORTER_EXPORT CORRADE_VISIBILITY_EXPORT +#ifndef MAGNUM_TGAIMPORTER_BUILD_STATIC + #if defined(TgaImporter_EXPORTS) || defined(TgaImporterObjects_EXPORTS) + #define MAGNUM_TRADE_TGAIMPORTER_EXPORT CORRADE_VISIBILITY_EXPORT + #else + #define MAGNUM_TRADE_TGAIMPORTER_EXPORT CORRADE_VISIBILITY_IMPORT + #endif #else - #define MAGNUM_TRADE_TGAIMPORTER_EXPORT CORRADE_VISIBILITY_IMPORT + #define MAGNUM_TRADE_TGAIMPORTER_EXPORT CORRADE_VISIBILITY_STATIC #endif #define MAGNUM_TRADE_TGAIMPORTER_LOCAL CORRADE_VISIBILITY_LOCAL #endif diff --git a/src/MagnumPlugins/TgaImporter/configure.h.cmake b/src/MagnumPlugins/TgaImporter/configure.h.cmake new file mode 100644 index 000000000..aea9ee97c --- /dev/null +++ b/src/MagnumPlugins/TgaImporter/configure.h.cmake @@ -0,0 +1,26 @@ +/* + This file is part of Magnum. + + Copyright © 2010, 2011, 2012, 2013, 2014, 2015 + 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_TGAIMPORTER_BUILD_STATIC