diff --git a/CMakeLists.txt b/CMakeLists.txt index 017035253..5e66ac66c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -112,7 +112,8 @@ if(BUILD_DEPRECATED) endif() option(BUILD_STATIC "Build static libraries (default are shared)" OFF) -cmake_dependent_option(BUILD_STATIC_PIC "Build static libraries with position-independent code" OFF "BUILD_STATIC" OFF) +cmake_dependent_option(BUILD_STATIC_PIC "Build static libraries and plugins with position-independent code" OFF "BUILD_STATIC" OFF) +option(BUILD_PLUGINS_STATIC "Build static plugins (default are dynamic)" OFF) option(BUILD_TESTS "Build unit tests." OFF) cmake_dependent_option(BUILD_GL_TESTS "Build unit tests for OpenGL code." OFF "BUILD_TESTS" OFF) if(BUILD_TESTS) @@ -142,6 +143,7 @@ endif() # meaningless on Emscripten and too inconvenient on Android if(CORRADE_TARGET_NACL_NEWLIB OR CORRADE_TARGET_EMSCRIPTEN OR CORRADE_TARGET_ANDROID) set(BUILD_STATIC ON) + set(BUILD_PLUGINS_STATIC ON) endif() if(BUILD_STATIC) diff --git a/doc/building.dox b/doc/building.dox index 663bb0a75..7178241c0 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -137,10 +137,12 @@ Installation to given prefix can be done from within QtCreator by adding new The libraries are build as shared by default. If you are developing for platform which doesn't support shared libraries or if you just want to link -them statically, enable `BUILD_STATIC` to build the libraries as static. If you -plan to use them with shared libraries later, enable also position-independent -code with `BUILD_STATIC_PIC`. If you want to build with another compiler (e.g. -Clang), pass `-DCMAKE_CXX_COMPILER=clang++` to CMake. +them statically, enable `BUILD_STATIC` to build the libraries as static. +Building of static plugins is controlled with separate `BUILD_PLUGINS_STATIC` +variable. If you plan to use the static libraries with shared libraries later, +enable also position-independent code with `BUILD_STATIC_PIC`. If you want to +build with another compiler (e.g. Clang), pass `-DCMAKE_CXX_COMPILER=clang++` +to CMake. Libraries and static plugins built in `Debug` configuration (e.g. with `CMAKE_BUILD_TYPE` set to `Debug`) have `-d` suffix to make it possible to have diff --git a/package/ci/jenkins-mingw-w64.xml b/package/ci/jenkins-mingw-w64.xml index 544e3cd18..e1f9162c1 100644 --- a/package/ci/jenkins-mingw-w64.xml +++ b/package/ci/jenkins-mingw-w64.xml @@ -69,7 +69,7 @@ git submodule init git submodule update if [ ${libraries} = "static" ] ; then - static_build_flag="-DBUILD_STATIC=ON -DBUILD_STATIC_PIC=ON" + static_build_flag="-DBUILD_STATIC=ON -DBUILD_PLUGINS_STATIC=ON -DBUILD_STATIC_PIC=ON" fi if [ "${compatibility}" = "deprecated" ] ; then diff --git a/package/ci/jenkins.xml b/package/ci/jenkins.xml index 7b5407cfd..cc5f3468c 100644 --- a/package/ci/jenkins.xml +++ b/package/ci/jenkins.xml @@ -85,7 +85,7 @@ else fi if [ ${libraries} = "static" ] ; then - static_build_flag="-DBUILD_STATIC=ON -DBUILD_STATIC_PIC=ON" + static_build_flag="-DBUILD_STATIC=ON -DBUILD_PLUGINS_STATIC=ON -DBUILD_STATIC_PIC=ON" fi if [ "${compatibility}" = "deprecated" ] ; then diff --git a/src/MagnumPlugins/CMakeLists.txt b/src/MagnumPlugins/CMakeLists.txt index 59dab5adb..8c0f1319c 100644 --- a/src/MagnumPlugins/CMakeLists.txt +++ b/src/MagnumPlugins/CMakeLists.txt @@ -25,7 +25,7 @@ # Wrapper for creating given plugin type macro(add_plugin plugin_name debug_install_dir release_install_dir metadata_file) - if(NOT BUILD_STATIC) + if(NOT BUILD_PLUGINS_STATIC) corrade_add_plugin(${plugin_name} ${debug_install_dir} ${release_install_dir} ${metadata_file} ${ARGN}) else() corrade_add_static_plugin(${plugin_name} ${release_install_dir} ${metadata_file} ${ARGN}) diff --git a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h index 6d11a34b6..fd8bb03c1 100644 --- a/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h +++ b/src/MagnumPlugins/TgaImageConverter/TgaImageConverter.h @@ -32,14 +32,10 @@ #include "Magnum/Trade/AbstractImageConverter.h" #ifndef DOXYGEN_GENERATING_OUTPUT -#ifndef MAGNUM_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 +#if defined(TgaImageConverter_EXPORTS) || defined(TgaImageConverterObjects_EXPORTS) + #define MAGNUM_TRADE_TGAIMAGECONVERTER_EXPORT CORRADE_VISIBILITY_EXPORT #else - #define MAGNUM_TRADE_TGAIMAGECONVERTER_EXPORT CORRADE_VISIBILITY_STATIC + #define MAGNUM_TRADE_TGAIMAGECONVERTER_EXPORT CORRADE_VISIBILITY_IMPORT #endif #define MAGNUM_TRADE_TGAIMAGECONVERTER_LOCAL CORRADE_VISIBILITY_LOCAL #endif diff --git a/src/MagnumPlugins/TgaImporter/TgaImporter.h b/src/MagnumPlugins/TgaImporter/TgaImporter.h index 1e175bd0a..752886558 100644 --- a/src/MagnumPlugins/TgaImporter/TgaImporter.h +++ b/src/MagnumPlugins/TgaImporter/TgaImporter.h @@ -34,14 +34,10 @@ #include "Magnum/Trade/AbstractImporter.h" #ifndef DOXYGEN_GENERATING_OUTPUT -#ifndef MAGNUM_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 +#if defined(TgaImporter_EXPORTS) || defined(TgaImporterObjects_EXPORTS) + #define MAGNUM_TRADE_TGAIMPORTER_EXPORT CORRADE_VISIBILITY_EXPORT #else - #define MAGNUM_TRADE_TGAIMPORTER_EXPORT CORRADE_VISIBILITY_STATIC + #define MAGNUM_TRADE_TGAIMPORTER_EXPORT CORRADE_VISIBILITY_IMPORT #endif #define MAGNUM_TRADE_TGAIMPORTER_LOCAL CORRADE_VISIBILITY_LOCAL #endif