diff --git a/CMakeLists.txt b/CMakeLists.txt index 75912d567..48b06611c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -380,29 +380,36 @@ endif() # always converts the path to an absolute location internally, making it # impossible to specify relative paths there. Sorry in advance for not having # the dir selection button in CMake GUI. -set(MAGNUM_PLUGINS_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR_INIT} +set(MAGNUM_PLUGINS_DEBUG_DIR "" CACHE STRING "Base directory where to look for Magnum plugins for debug builds") -set(MAGNUM_PLUGINS_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR_INIT} +set(MAGNUM_PLUGINS_RELEASE_DIR "" CACHE STRING "Base directory where to look for Magnum plugins for release builds") -set(MAGNUM_PLUGINS_DIR ${MAGNUM_PLUGINS_DIR_INIT} +set(MAGNUM_PLUGINS_DIR "" CACHE STRING "Base directory where to look for Magnum plugins") -# Plugin directories -set(MAGNUM_PLUGINS_FONT_DIR ${MAGNUM_PLUGINS_DIR}/fonts) -set(MAGNUM_PLUGINS_FONT_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/fonts) -set(MAGNUM_PLUGINS_FONT_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/fonts) -set(MAGNUM_PLUGINS_FONTCONVERTER_DIR ${MAGNUM_PLUGINS_DIR}/fontconverters) -set(MAGNUM_PLUGINS_FONTCONVERTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/fontconverters) -set(MAGNUM_PLUGINS_FONTCONVERTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/fontconverters) -set(MAGNUM_PLUGINS_IMAGECONVERTER_DIR ${MAGNUM_PLUGINS_DIR}/imageconverters) -set(MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/imageconverters) -set(MAGNUM_PLUGINS_IMAGECONVERTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/imageconverters) -set(MAGNUM_PLUGINS_IMPORTER_DIR ${MAGNUM_PLUGINS_DIR}/importers) -set(MAGNUM_PLUGINS_IMPORTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/importers) -set(MAGNUM_PLUGINS_IMPORTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/importers) -set(MAGNUM_PLUGINS_AUDIOIMPORTER_DIR ${MAGNUM_PLUGINS_DIR}/audioimporters) -set(MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/audioimporters) -set(MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/audioimporters) +# Plugin directories. Set only if the above are non-empty. otherwise empty as +# well. +if(MAGNUM_PLUGINS_DIR) + set(MAGNUM_PLUGINS_FONT_DIR ${MAGNUM_PLUGINS_DIR}/fonts) + set(MAGNUM_PLUGINS_FONTCONVERTER_DIR ${MAGNUM_PLUGINS_DIR}/fontconverters) + set(MAGNUM_PLUGINS_IMAGECONVERTER_DIR ${MAGNUM_PLUGINS_DIR}/imageconverters) + set(MAGNUM_PLUGINS_IMPORTER_DIR ${MAGNUM_PLUGINS_DIR}/importers) + set(MAGNUM_PLUGINS_AUDIOIMPORTER_DIR ${MAGNUM_PLUGINS_DIR}/audioimporters) +endif() +if(MAGNUM_PLUGINS_DEBUG_DIR) + set(MAGNUM_PLUGINS_FONT_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/fonts) + set(MAGNUM_PLUGINS_FONTCONVERTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/fontconverters) + set(MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/imageconverters) + set(MAGNUM_PLUGINS_IMPORTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/importers) + set(MAGNUM_PLUGINS_FONT_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/fonts) + set(MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/audioimporters) +endif() +if(MAGNUM_PLUGINS_RELEASE_DIR) + set(MAGNUM_PLUGINS_FONTCONVERTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/fontconverters) + set(MAGNUM_PLUGINS_IMAGECONVERTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/imageconverters) + set(MAGNUM_PLUGINS_IMPORTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/importers) + set(MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/audioimporters) +endif() # Library version set(MAGNUM_LIBRARY_VERSION 2.3) diff --git a/doc/building.dox b/doc/building.dox index a62e7711c..cf0c631db 100644 --- a/doc/building.dox +++ b/doc/building.dox @@ -521,14 +521,19 @@ thread-local Magnum contents. This is inherited from the @ref CORRADE_BUILD_MULTITHREADED option --- if you are sure that you will never need such feature, disable it when building Corrade itself. -Various plugin interfaces by default search for plugins in pre-defined -locations. By default those are defined to the installation location and can be -overriden using the `MAGNUM_PLUGINS_DIR`, `MAGNUM_PLUGINS_DEBUG_DIR` and -`MAGNUM_PLUGINS_RELEASE_DIR` CMake variables --- see also +Various plugin interfaces search for plugins in locations and order documented +in @ref Corrade::PluginManager::implicitPluginSearchPaths(), @ref Trade::AbstractImporter::pluginSearchPaths() and equivalent functions in -other plugin interfaces. Another option is supplying the plugin search path -explicitly on the user side either using the same CMake variables (passed -through to preprocessor, see @ref cmake) or via other autodetection means. +other plugin interfaces. In most cases the implicit behavior does the right +thing, but if you need to override those, use the `MAGNUM_PLUGINS_DIR`, +`MAGNUM_PLUGINS_DEBUG_DIR` and `MAGNUM_PLUGINS_RELEASE_DIR` CMake variables. +Those are empty by default, which means no hardcoded path is used. Another +option is supplying the plugin search path to the +@ref Corrade::PluginManager::Manger constructor either using the same CMake +variables (passed through to preprocessor, see @ref cmake) or via any other +means. All builtin Magnum utilities such as @ref magnum-imageconverter also +provide a way to override the plugin directory via the `--plugin-dir` +command-line option. The features used can be conveniently detected in depending projects both in CMake and C++ sources, see @ref cmake and @ref Magnum/Magnum.h for more diff --git a/doc/changelog.dox b/doc/changelog.dox index 8b66c23ce..8ed59f4c8 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -297,6 +297,10 @@ See also: @ref Corrade::Utility::Arguments - @ref Resource is now nothrow-movable and thus can be used with growable @ref Corrade::Containers::Array instances +- Reworked plugin search paths to prefer autodetection based on library or + executable location where possible and use hardcoded paths only if + explicitly specified. See @ref Trade::AbstractImporter::pluginSearchPaths() + for more information. @subsubsection changelog-latest-changes-audio Audio library diff --git a/doc/cmake.dox b/doc/cmake.dox index b4e0bd4d4..e241be070 100644 --- a/doc/cmake.dox +++ b/doc/cmake.dox @@ -154,12 +154,12 @@ following: - `MAGNUM_INCLUDE_INSTALL_PREFIX` --- Prefix where to put platform-independent include and other files, defaults to `.`. If a relative path is used, it's relative to `CMAKE_INSTALL_PREFIX`. -- `MAGNUM_PLUGINS_DEBUG_DIR` --- Base directory with dynamic plugins for debug - builds, defaults to `magnum-d/` subdirectory of dir where Magnum library - was found +- `MAGNUM_PLUGINS_DEBUG_DIR` --- Base directory with dynamic plugins for + debug builds. Empty by default, which means the directory is autodetected + based on library and executable location; override if needed. - `MAGNUM_PLUGINS_RELEASE_DIR` --- Base directory with dynamic plugins for - release builds, defaults to `magnum/` subdirectory of dir where Magnum - library was found + release builds. Empty by default, which means the directory is autodetected + based on library and executable location; override if needed. - `MAGNUM_PLUGINS_DIR` --- Base directory with dynamic plugins, defaults to `MAGNUM_PLUGINS_RELEASE_DIR` in release builds and multi-configuration builds or to `MAGNUM_PLUGINS_DEBUG_DIR` in debug builds. @@ -297,7 +297,7 @@ release libraries). Note that this autodetection might fail for the `MAGNUM_PLUGINS_DIR` variable, especially on multi-configuration build systems. You can make use of @ref corrade-cmake "CORRADE_IS_DEBUG_BUILD" preprocessor variable along with `MAGNUM_PLUGINS_*_DEBUG_DIR` / `MAGNUM_PLUGINS_*_RELEASE_DIR` -variables to decide in preprocessing step instead. +variables to decide in a preprocessing step instead. Features of found Magnum library are exposed in these CMake variables, they are also available as preprocessor variables if including diff --git a/modules/FindMagnum.cmake b/modules/FindMagnum.cmake index c12c35b10..30161db04 100644 --- a/modules/FindMagnum.cmake +++ b/modules/FindMagnum.cmake @@ -1127,26 +1127,33 @@ set(MAGNUM_PLUGINS_INCLUDE_INSTALL_DIR ${MAGNUM_INCLUDE_INSTALL_PREFIX}/include/ # because CMake always converts the path to an absolute location internally, # making it impossible to specify relative paths there. Sorry in advance for # not having the dir selection button in CMake GUI. -set(MAGNUM_PLUGINS_DEBUG_DIR ${_MAGNUM_PLUGINS_DIR_PREFIX}/magnum-d +set(MAGNUM_PLUGINS_DEBUG_DIR "" CACHE STRING "Base directory where to look for Magnum plugins for debug builds") -set(MAGNUM_PLUGINS_RELEASE_DIR ${_MAGNUM_PLUGINS_DIR_PREFIX}/magnum +set(MAGNUM_PLUGINS_RELEASE_DIR "" CACHE STRING "Base directory where to look for Magnum plugins for release builds") -set(MAGNUM_PLUGINS_DIR ${_MAGNUM_PLUGINS_DIR_PREFIX}/magnum${_MAGNUM_PLUGINS_DIR_SUFFIX} +set(MAGNUM_PLUGINS_DIR "" CACHE STRING "Base directory where to look for Magnum plugins") -# Plugin directories -set(MAGNUM_PLUGINS_FONT_DIR ${MAGNUM_PLUGINS_DIR}/fonts) -set(MAGNUM_PLUGINS_FONT_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/fonts) -set(MAGNUM_PLUGINS_FONT_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/fonts) -set(MAGNUM_PLUGINS_FONTCONVERTER_DIR ${MAGNUM_PLUGINS_DIR}/fontconverters) -set(MAGNUM_PLUGINS_FONTCONVERTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/fontconverters) -set(MAGNUM_PLUGINS_FONTCONVERTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/fontconverters) -set(MAGNUM_PLUGINS_IMAGECONVERTER_DIR ${MAGNUM_PLUGINS_DIR}/imageconverters) -set(MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/imageconverters) -set(MAGNUM_PLUGINS_IMAGECONVERTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/imageconverters) -set(MAGNUM_PLUGINS_IMPORTER_DIR ${MAGNUM_PLUGINS_DIR}/importers) -set(MAGNUM_PLUGINS_IMPORTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/importers) -set(MAGNUM_PLUGINS_IMPORTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/importers) -set(MAGNUM_PLUGINS_AUDIOIMPORTER_DIR ${MAGNUM_PLUGINS_DIR}/audioimporters) -set(MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/audioimporters) -set(MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/audioimporters) +# Plugin directories. Set only if the above are non-empty. otherwise empty as +# well. +if(MAGNUM_PLUGINS_DIR) + set(MAGNUM_PLUGINS_FONT_DIR ${MAGNUM_PLUGINS_DIR}/fonts) + set(MAGNUM_PLUGINS_FONTCONVERTER_DIR ${MAGNUM_PLUGINS_DIR}/fontconverters) + set(MAGNUM_PLUGINS_IMAGECONVERTER_DIR ${MAGNUM_PLUGINS_DIR}/imageconverters) + set(MAGNUM_PLUGINS_IMPORTER_DIR ${MAGNUM_PLUGINS_DIR}/importers) + set(MAGNUM_PLUGINS_AUDIOIMPORTER_DIR ${MAGNUM_PLUGINS_DIR}/audioimporters) +endif() +if(MAGNUM_PLUGINS_DEBUG_DIR) + set(MAGNUM_PLUGINS_FONT_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/fonts) + set(MAGNUM_PLUGINS_FONTCONVERTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/fontconverters) + set(MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/imageconverters) + set(MAGNUM_PLUGINS_IMPORTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/importers) + set(MAGNUM_PLUGINS_FONT_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/fonts) + set(MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_DIR ${MAGNUM_PLUGINS_DEBUG_DIR}/audioimporters) +endif() +if(MAGNUM_PLUGINS_RELEASE_DIR) + set(MAGNUM_PLUGINS_FONTCONVERTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/fontconverters) + set(MAGNUM_PLUGINS_IMAGECONVERTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/imageconverters) + set(MAGNUM_PLUGINS_IMPORTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/importers) + set(MAGNUM_PLUGINS_AUDIOIMPORTER_RELEASE_DIR ${MAGNUM_PLUGINS_RELEASE_DIR}/audioimporters) +endif() diff --git a/src/Magnum/Audio/AbstractImporter.cpp b/src/Magnum/Audio/AbstractImporter.cpp index 3738d6fa3..4c18bbfaa 100644 --- a/src/Magnum/Audio/AbstractImporter.cpp +++ b/src/Magnum/Audio/AbstractImporter.cpp @@ -43,34 +43,23 @@ std::string AbstractImporter::pluginInterface() { #ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT std::vector AbstractImporter::pluginSearchPaths() { - return { - /* Debug build */ - #ifdef CORRADE_IS_DEBUG_BUILD + return PluginManager::implicitPluginSearchPaths( #ifndef MAGNUM_BUILD_STATIC - Utility::Directory::join(Utility::Directory::path(Utility::Directory::libraryLocation(&pluginInterface)), "magnum-d/audioimporters"), + Utility::Directory::libraryLocation(&pluginInterface), #else - #ifndef CORRADE_TARGET_WINDOWS - /* On Windows, the plugin DLLs are next to the executable, so the one - below works. Elsewhere the plugins are in the lib dir instead */ - "../lib/magnum-d/audioimporters", - #endif - "magnum-d/audioimporters", + {}, #endif - Utility::Directory::join(MAGNUM_PLUGINS_DEBUG_DIR, "audioimporters") - - /* Release build */ - #else - #ifndef MAGNUM_BUILD_STATIC - Utility::Directory::join(Utility::Directory::path(Utility::Directory::libraryLocation(&pluginInterface)), "magnum/audioimporters"), + #ifdef CORRADE_IS_DEBUG_BUILD + MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_DIR, #else - #ifndef CORRADE_TARGET_WINDOWS - "../lib/magnum/audioimporters", - #endif - "magnum/audioimporters", + MAGNUM_PLUGINS_AUDIOIMPORTER_DIR, #endif - Utility::Directory::join(MAGNUM_PLUGINS_DIR, "audioimporters") + #ifdef CORRADE_IS_DEBUG_BUILD + "magnum-d/" + #else + "magnum/" #endif - }; + "audioimporters"); } #endif diff --git a/src/Magnum/Audio/AbstractImporter.h b/src/Magnum/Audio/AbstractImporter.h index 74e8dabbc..e9712ca37 100644 --- a/src/Magnum/Audio/AbstractImporter.h +++ b/src/Magnum/Audio/AbstractImporter.h @@ -133,14 +133,12 @@ class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractManagi /** * @brief Plugin search paths * - * First looks in `magnum/audioimporters/` or `magnum-d/audioimporters/` - * next to the dynamic @ref Audio library (unless it's a static build), - * then in the same location next to the executable and as a fallback - * in `magnum/audioimporters/` or `magnum-d/audioimporters/` in the - * runtime install location (`lib[64]/` on Unix-like systems, `bin/` on - * Windows). The system-wide plugin search directory is configurable - * using the `MAGNUM_PLUGINS_DIR` CMake variables, see @ref building - * for more information. + * Looks into `magnum/audioimporters/` or `magnum-d/audioimporters/` + * next to the dynamic @ref Trade library, next to the executable and + * elsewhere according to the rules documented in + * @ref Corrade::PluginManager::implicitPluginSearchPaths(). The search + * directory can be also hardcoded using the `MAGNUM_PLUGINS_DIR` CMake + * variables, see @ref building for more information. * * Not defined on platforms without * @ref CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT "dynamic plugin support". diff --git a/src/Magnum/Audio/configure.h.cmake b/src/Magnum/Audio/configure.h.cmake index 3b1cd7f51..da9eac224 100644 --- a/src/Magnum/Audio/configure.h.cmake +++ b/src/Magnum/Audio/configure.h.cmake @@ -23,6 +23,5 @@ DEALINGS IN THE SOFTWARE. */ -#define MAGNUM_PLUGINS_DIR "${MAGNUM_PLUGINS_DIR}" -#define MAGNUM_PLUGINS_DEBUG_DIR "${MAGNUM_PLUGINS_DEBUG_DIR}" - +#define MAGNUM_PLUGINS_AUDIOIMPORTER_DIR "${MAGNUM_PLUGINS_AUDIOIMPORTER_DIR}" +#define MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_DIR "${MAGNUM_PLUGINS_AUDIOIMPORTER_DEBUG_DIR}" diff --git a/src/Magnum/Text/AbstractFont.cpp b/src/Magnum/Text/AbstractFont.cpp index d2e590454..b88d0cd05 100644 --- a/src/Magnum/Text/AbstractFont.cpp +++ b/src/Magnum/Text/AbstractFont.cpp @@ -48,34 +48,23 @@ std::string AbstractFont::pluginInterface() { #ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT std::vector AbstractFont::pluginSearchPaths() { - return { - /* Debug build */ - #ifdef CORRADE_IS_DEBUG_BUILD + return PluginManager::implicitPluginSearchPaths( #ifndef MAGNUM_BUILD_STATIC - Utility::Directory::join(Utility::Directory::path(Utility::Directory::libraryLocation(&pluginInterface)), "magnum-d/fonts"), + Utility::Directory::libraryLocation(&pluginInterface), #else - #ifndef CORRADE_TARGET_WINDOWS - /* On Windows, the plugin DLLs are next to the executable, so the one - below works. Elsewhere the plugins are in the lib dir instead */ - "../lib/magnum-d/fonts", - #endif - "magnum-d/fonts", + {}, #endif - Utility::Directory::join(MAGNUM_PLUGINS_DEBUG_DIR, "fonts") - - /* Release build */ - #else - #ifndef MAGNUM_BUILD_STATIC - Utility::Directory::join(Utility::Directory::path(Utility::Directory::libraryLocation(&pluginInterface)), "magnum/fonts"), + #ifdef CORRADE_IS_DEBUG_BUILD + MAGNUM_PLUGINS_FONT_DEBUG_DIR, #else - #ifndef CORRADE_TARGET_WINDOWS - "../lib/magnum/fonts", - #endif - "magnum/fonts", + MAGNUM_PLUGINS_FONT_DIR, #endif - Utility::Directory::join(MAGNUM_PLUGINS_DIR, "fonts") + #ifdef CORRADE_IS_DEBUG_BUILD + "magnum-d/" + #else + "magnum/" #endif - }; + "fonts"); } #endif diff --git a/src/Magnum/Text/AbstractFont.h b/src/Magnum/Text/AbstractFont.h index c1163d22e..10e53ee28 100644 --- a/src/Magnum/Text/AbstractFont.h +++ b/src/Magnum/Text/AbstractFont.h @@ -198,14 +198,12 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { /** * @brief Plugin search paths * - * First looks in `magnum/fonts/` or `magnum-d/fonts/` next to the - * dynamic @ref Text library (unless it's a static build), then in the - * same location next to the executable and as a fallback in - * `magnum/fonts/` or `magnum-d/fonts/` in the runtime install location - * (`lib[64]/` on Unix-like systems, `bin/` on Windows). The - * system-wide plugin search directory is configurable using the - * `MAGNUM_PLUGINS_DIR` CMake variables, see @ref building for more - * information. + * Looks into `magnum/fonts/` or `magnum-d/fonts/` next to the dynamic + * @ref Trade library, next to the executable and elsewhere according + * to the rules documented in + * @ref Corrade::PluginManager::implicitPluginSearchPaths(). The search + * directory can be also hardcoded using the `MAGNUM_PLUGINS_DIR` CMake + * variables, see @ref building for more information. * * Not defined on platforms without * @ref CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT "dynamic plugin support". diff --git a/src/Magnum/Text/AbstractFontConverter.cpp b/src/Magnum/Text/AbstractFontConverter.cpp index 24e219eae..1ee245f2c 100644 --- a/src/Magnum/Text/AbstractFontConverter.cpp +++ b/src/Magnum/Text/AbstractFontConverter.cpp @@ -63,34 +63,23 @@ std::string AbstractFontConverter::pluginInterface() { #ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT std::vector AbstractFontConverter::pluginSearchPaths() { - return { - /* Debug build */ - #ifdef CORRADE_IS_DEBUG_BUILD + return PluginManager::implicitPluginSearchPaths( #ifndef MAGNUM_BUILD_STATIC - Utility::Directory::join(Utility::Directory::path(Utility::Directory::libraryLocation(&pluginInterface)), "magnum-d/fontconverters"), + Utility::Directory::libraryLocation(&pluginInterface), #else - #ifndef CORRADE_TARGET_WINDOWS - /* On Windows, the plugin DLLs are next to the executable, so the one - below works. Elsewhere the plugins are in the lib dir instead */ - "../lib/magnum-d/fontconverters", - #endif - "magnum-d/fontconverters", + {}, #endif - Utility::Directory::join(MAGNUM_PLUGINS_DEBUG_DIR, "fontconverters") - - /* Release build */ - #else - #ifndef MAGNUM_BUILD_STATIC - Utility::Directory::join(Utility::Directory::path(Utility::Directory::libraryLocation(&pluginInterface)), "magnum/fontconverters"), + #ifdef CORRADE_IS_DEBUG_BUILD + MAGNUM_PLUGINS_FONTCONVERTER_DEBUG_DIR, #else - #ifndef CORRADE_TARGET_WINDOWS - "../lib/magnum/fontconverters", - #endif - "magnum/fontconverters", + MAGNUM_PLUGINS_FONTCONVERTER_DIR, #endif - Utility::Directory::join(MAGNUM_PLUGINS_DIR, "fontconverters") + #ifdef CORRADE_IS_DEBUG_BUILD + "magnum-d/" + #else + "magnum/" #endif - }; + "fontconverters"); } #endif diff --git a/src/Magnum/Text/AbstractFontConverter.h b/src/Magnum/Text/AbstractFontConverter.h index ce5559226..13025e06d 100644 --- a/src/Magnum/Text/AbstractFontConverter.h +++ b/src/Magnum/Text/AbstractFontConverter.h @@ -182,14 +182,12 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl /** * @brief Plugin search paths * - * First looks in `magnum/fontconverters/` or `magnum-d/fontconverters/` - * next to the dynamic @ref Text library (unless it's a static build), - * then in the same location next to the executable and as a fallback - * in `magnum/fontconverters/` or `magnum-d/fontconverters/` in the - * runtime install location (`lib[64]/` on Unix-like systems, `bin/` on - * Windows). The system-wide plugin search directory is configurable - * using the `MAGNUM_PLUGINS_DIR` CMake variables, see @ref building - * for more information. + * Looks into `magnum/fontconverters/` or `magnum-d/fontconverters/` + * next to the dynamic @ref Trade library, next to the executable and + * elsewhere according to the rules documented in + * @ref Corrade::PluginManager::implicitPluginSearchPaths(). The search + * directory can be also hardcoded using the `MAGNUM_PLUGINS_DIR` CMake + * variables, see @ref building for more information. * * Not defined on platforms without * @ref CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT "dynamic plugin support". diff --git a/src/Magnum/Text/configure.h.cmake b/src/Magnum/Text/configure.h.cmake index 21de7073d..05517df9a 100644 --- a/src/Magnum/Text/configure.h.cmake +++ b/src/Magnum/Text/configure.h.cmake @@ -23,5 +23,7 @@ DEALINGS IN THE SOFTWARE. */ -#define MAGNUM_PLUGINS_DEBUG_DIR "${MAGNUM_PLUGINS_DEBUG_DIR}" -#define MAGNUM_PLUGINS_DIR "${MAGNUM_PLUGINS_DIR}" +#define MAGNUM_PLUGINS_FONT_DIR "${MAGNUM_PLUGINS_FONT_DIR}" +#define MAGNUM_PLUGINS_FONT_DEBUG_DIR "${MAGNUM_PLUGINS_FONT_DEBUG_DIR}" +#define MAGNUM_PLUGINS_FONTCONVERTER_DIR "${MAGNUM_PLUGINS_FONTCONVERTER_DIR}" +#define MAGNUM_PLUGINS_FONTCONVERTER_DEBUG_DIR "${MAGNUM_PLUGINS_FONTCONVERTER_DEBUG_DIR}" diff --git a/src/Magnum/Trade/AbstractImageConverter.cpp b/src/Magnum/Trade/AbstractImageConverter.cpp index 6501e614a..739759d74 100644 --- a/src/Magnum/Trade/AbstractImageConverter.cpp +++ b/src/Magnum/Trade/AbstractImageConverter.cpp @@ -48,34 +48,23 @@ std::string AbstractImageConverter::pluginInterface() { #ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT std::vector AbstractImageConverter::pluginSearchPaths() { - return { - /* Debug build */ - #ifdef CORRADE_IS_DEBUG_BUILD + return PluginManager::implicitPluginSearchPaths( #ifndef MAGNUM_BUILD_STATIC - Utility::Directory::join(Utility::Directory::path(Utility::Directory::libraryLocation(&pluginInterface)), "magnum-d/imageconverters"), + Utility::Directory::libraryLocation(&pluginInterface), #else - #ifndef CORRADE_TARGET_WINDOWS - /* On Windows, the plugin DLLs are next to the executable, so the one - below works. Elsewhere the plugins are in the lib dir instead */ - "../lib/magnum-d/imageconverters", - #endif - "magnum-d/imageconverters", + {}, #endif - Utility::Directory::join(MAGNUM_PLUGINS_DEBUG_DIR, "imageconverters") - - /* Release build */ - #else - #ifndef MAGNUM_BUILD_STATIC - Utility::Directory::join(Utility::Directory::path(Utility::Directory::libraryLocation(&pluginInterface)), "magnum/imageconverters"), + #ifdef CORRADE_IS_DEBUG_BUILD + MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_DIR, #else - #ifndef CORRADE_TARGET_WINDOWS - "../lib/magnum/imageconverters", - #endif - "magnum/imageconverters", + MAGNUM_PLUGINS_IMAGECONVERTER_DIR, #endif - Utility::Directory::join(MAGNUM_PLUGINS_DIR, "imageconverters") + #ifdef CORRADE_IS_DEBUG_BUILD + "magnum-d/" + #else + "magnum/" #endif - }; + "imageconverters"); } #endif diff --git a/src/Magnum/Trade/AbstractImageConverter.h b/src/Magnum/Trade/AbstractImageConverter.h index 4d162c066..4ad3f6534 100644 --- a/src/Magnum/Trade/AbstractImageConverter.h +++ b/src/Magnum/Trade/AbstractImageConverter.h @@ -177,14 +177,12 @@ class MAGNUM_TRADE_EXPORT AbstractImageConverter: public PluginManager::Abstract /** * @brief Plugin search paths * - * First looks in `magnum/imageconverters/` or `magnum-d/imageconverters/` - * next to the dynamic @ref Trade library (unless it's a static build), - * then in the same location next to the executable and as a fallback - * in `magnum/imageconverters/` or `magnum-d/imageconverters/` in the - * runtime install location (`lib[64]/` on Unix-like systems, `bin/` on - * Windows). The system-wide plugin search directory is configurable - * using the `MAGNUM_PLUGINS_DIR` CMake variables, see @ref building - * for more information. + * Looks into `magnum/imageconverters/` or `magnum-d/imageconverters/` + * next to the dynamic @ref Trade library, next to the executable and + * elsewhere according to the rules documented in + * @ref Corrade::PluginManager::implicitPluginSearchPaths(). The search + * directory can be also hardcoded using the `MAGNUM_PLUGINS_DIR` CMake + * variables, see @ref building for more information. * * Not defined on platforms without * @ref CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT "dynamic plugin support". diff --git a/src/Magnum/Trade/AbstractImporter.cpp b/src/Magnum/Trade/AbstractImporter.cpp index ff618d1e6..d7d853ef9 100644 --- a/src/Magnum/Trade/AbstractImporter.cpp +++ b/src/Magnum/Trade/AbstractImporter.cpp @@ -64,34 +64,23 @@ std::string AbstractImporter::pluginInterface() { #ifndef CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT std::vector AbstractImporter::pluginSearchPaths() { - return { - /* Debug build */ - #ifdef CORRADE_IS_DEBUG_BUILD + return PluginManager::implicitPluginSearchPaths( #ifndef MAGNUM_BUILD_STATIC - Utility::Directory::join(Utility::Directory::path(Utility::Directory::libraryLocation(&pluginInterface)), "magnum-d/importers"), + Utility::Directory::libraryLocation(&pluginInterface), #else - #ifndef CORRADE_TARGET_WINDOWS - /* On Windows, the plugin DLLs are next to the executable, so the one - below works. Elsewhere the plugins are in the lib dir instead */ - "../lib/magnum-d/importers", - #endif - "magnum-d/importers", + {}, #endif - Utility::Directory::join(MAGNUM_PLUGINS_DEBUG_DIR, "importers") - - /* Release build */ - #else - #ifndef MAGNUM_BUILD_STATIC - Utility::Directory::join(Utility::Directory::path(Utility::Directory::libraryLocation(&pluginInterface)), "magnum/importers"), + #ifdef CORRADE_IS_DEBUG_BUILD + MAGNUM_PLUGINS_IMPORTER_DEBUG_DIR, #else - #ifndef CORRADE_TARGET_WINDOWS - "../lib/magnum/importers", - #endif - "magnum/importers", + MAGNUM_PLUGINS_IMPORTER_DIR, #endif - Utility::Directory::join(MAGNUM_PLUGINS_DIR, "importers") + #ifdef CORRADE_IS_DEBUG_BUILD + "magnum-d/" + #else + "magnum/" #endif - }; + "importers"); } #endif diff --git a/src/Magnum/Trade/AbstractImporter.h b/src/Magnum/Trade/AbstractImporter.h index 60f881fa2..35105d1f5 100644 --- a/src/Magnum/Trade/AbstractImporter.h +++ b/src/Magnum/Trade/AbstractImporter.h @@ -297,14 +297,12 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi /** * @brief Plugin search paths * - * First looks in `magnum/importers/` or `magnum-d/importers/` next to - * the dynamic @ref Trade library (unless it's a static build), then in - * the same location next to the executable and as a fallback in - * `magnum/importers/` or `magnum-d/importers/` in the runtime install - * location (`lib[64]/` on Unix-like systems, `bin/` on Windows). The - * system-wide plugin search directory is configurable using the - * `MAGNUM_PLUGINS_DIR` CMake variables, see @ref building for more - * information. + * Looks into `magnum/importers/` or `magnum-d/importers/` next to the + * dynamic @ref Trade library, next to the executable and elsewhere + * according to the rules documented in + * @ref Corrade::PluginManager::implicitPluginSearchPaths(). The search + * directory can be also hardcoded using the `MAGNUM_PLUGINS_DIR` CMake + * variables, see @ref building for more information. * * Not defined on platforms without * @ref CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT "dynamic plugin support". diff --git a/src/Magnum/Trade/configure.h.cmake b/src/Magnum/Trade/configure.h.cmake index a4fc9f82a..024c1178f 100644 --- a/src/Magnum/Trade/configure.h.cmake +++ b/src/Magnum/Trade/configure.h.cmake @@ -23,5 +23,7 @@ DEALINGS IN THE SOFTWARE. */ -#define MAGNUM_PLUGINS_DIR "${MAGNUM_PLUGINS_DIR}" -#define MAGNUM_PLUGINS_DEBUG_DIR "${MAGNUM_PLUGINS_DEBUG_DIR}" +#define MAGNUM_PLUGINS_IMPORTER_DIR "${MAGNUM_PLUGINS_IMPORTER_DIR}" +#define MAGNUM_PLUGINS_IMPORTER_DEBUG_DIR "${MAGNUM_PLUGINS_IMPORTER_DEBUG_DIR}" +#define MAGNUM_PLUGINS_IMAGECONVERTER_DIR "${MAGNUM_PLUGINS_IMAGECONVERTER_DIR}" +#define MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_DIR "${MAGNUM_PLUGINS_IMAGECONVERTER_DEBUG_DIR}"