diff --git a/doc/changelog.dox b/doc/changelog.dox index 25d392d41..d9e261570 100644 --- a/doc/changelog.dox +++ b/doc/changelog.dox @@ -371,6 +371,11 @@ See also: - @ref building-packages-msys "MSYS2 packages" are now in official repositories, installable directly via `pacman` +- Plugin search path on Windows is now discovered relative to location of the + @ref Trade, @ref Text or @ref Audio library DLL instead of executable + location. That makes it behave better in case Magnum is installed via a + package and the installation directory hardcoded at build time doesn't + exist on the target machine (which is the case of MSYS2 packages). - `FindSDL2.cmake` was updated to work with MinGW version 2.0.5 and newer, since these dropped the old directory hierarchy. Older versions have both the original and the new hierarchy, so it should work with these as well. diff --git a/src/Magnum/Audio/AbstractImporter.cpp b/src/Magnum/Audio/AbstractImporter.cpp index 65d8e5cd2..c97dc26ca 100644 --- a/src/Magnum/Audio/AbstractImporter.cpp +++ b/src/Magnum/Audio/AbstractImporter.cpp @@ -44,10 +44,26 @@ std::string AbstractImporter::pluginInterface() { std::vector AbstractImporter::pluginSearchPaths() { return { #ifdef CORRADE_IS_DEBUG_BUILD + #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_BUILD_STATIC) + Utility::Directory::join(Utility::Directory::path(Utility::Directory::dllLocation( + #ifdef __MINGW32__ + "lib" + #endif + "MagnumAudio-d")), "magnum-d/audioimporters"), + #else "magnum-d/audioimporters", + #endif Utility::Directory::join(MAGNUM_PLUGINS_DEBUG_DIR, "audioimporters") #else + #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_BUILD_STATIC) + Utility::Directory::join(Utility::Directory::path(Utility::Directory::dllLocation( + #ifdef __MINGW32__ + "lib" + #endif + "MagnumAudio")), "magnum/audioimporters"), + #else "magnum/audioimporters", + #endif Utility::Directory::join(MAGNUM_PLUGINS_DIR, "audioimporters") #endif }; diff --git a/src/Magnum/Audio/AbstractImporter.h b/src/Magnum/Audio/AbstractImporter.h index 770e03c5a..95010fa70 100644 --- a/src/Magnum/Audio/AbstractImporter.h +++ b/src/Magnum/Audio/AbstractImporter.h @@ -98,12 +98,13 @@ class MAGNUM_AUDIO_EXPORT AbstractImporter: public PluginManager::AbstractManagi * @brief Plugin search paths * * First looks in `magnum/audioimporters/` or `magnum-d/audioimporters/` - * 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. + * next to the executable (or, in case of Windows and a non-static + * build, next to the DLL of the @ref Audio library) 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. * * Not defined on platforms without * @ref CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT "dynamic plugin support". diff --git a/src/Magnum/Text/AbstractFont.cpp b/src/Magnum/Text/AbstractFont.cpp index bb1ba9e80..7f309dfd0 100644 --- a/src/Magnum/Text/AbstractFont.cpp +++ b/src/Magnum/Text/AbstractFont.cpp @@ -50,10 +50,26 @@ std::string AbstractFont::pluginInterface() { std::vector AbstractFont::pluginSearchPaths() { return { #ifdef CORRADE_IS_DEBUG_BUILD + #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_BUILD_STATIC) + Utility::Directory::join(Utility::Directory::path(Utility::Directory::dllLocation( + #ifdef __MINGW32__ + "lib" + #endif + "MagnumText-d")), "magnum-d/fonts"), + #else "magnum-d/fonts", + #endif Utility::Directory::join(MAGNUM_PLUGINS_DEBUG_DIR, "fonts") #else + #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_BUILD_STATIC) + Utility::Directory::join(Utility::Directory::path(Utility::Directory::dllLocation( + #ifdef __MINGW32__ + "lib" + #endif + "MagnumText")), "magnum/fonts"), + #else "magnum/fonts", + #endif Utility::Directory::join(MAGNUM_PLUGINS_DIR, "fonts") #endif }; diff --git a/src/Magnum/Text/AbstractFont.h b/src/Magnum/Text/AbstractFont.h index ae6377cb6..63ba13557 100644 --- a/src/Magnum/Text/AbstractFont.h +++ b/src/Magnum/Text/AbstractFont.h @@ -170,11 +170,13 @@ class MAGNUM_TEXT_EXPORT AbstractFont: public PluginManager::AbstractPlugin { * @brief Plugin search paths * * First looks in `magnum/fonts/` or `magnum-d/fonts/` 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. + * executable (or, in case of Windows and a non-static build, next to + * the DLL of the @ref Text library) 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. * * 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 83bae0be5..1fe569a24 100644 --- a/src/Magnum/Text/AbstractFontConverter.cpp +++ b/src/Magnum/Text/AbstractFontConverter.cpp @@ -64,10 +64,26 @@ std::string AbstractFontConverter::pluginInterface() { std::vector AbstractFontConverter::pluginSearchPaths() { return { #ifdef CORRADE_IS_DEBUG_BUILD + #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_BUILD_STATIC) + Utility::Directory::join(Utility::Directory::path(Utility::Directory::dllLocation( + #ifdef __MINGW32__ + "lib" + #endif + "MagnumText-d")), "magnum-d/fontconverters"), + #else "magnum-d/fontconverters", + #endif Utility::Directory::join(MAGNUM_PLUGINS_DEBUG_DIR, "fontconverters") #else + #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_BUILD_STATIC) + Utility::Directory::join(Utility::Directory::path(Utility::Directory::dllLocation( + #ifdef __MINGW32__ + "lib" + #endif + "MagnumText")), "magnum/fontconverters"), + #else "magnum/fontconverters", + #endif Utility::Directory::join(MAGNUM_PLUGINS_DIR, "fontconverters") #endif }; diff --git a/src/Magnum/Text/AbstractFontConverter.h b/src/Magnum/Text/AbstractFontConverter.h index 9cfa1ac8f..b58be178c 100644 --- a/src/Magnum/Text/AbstractFontConverter.h +++ b/src/Magnum/Text/AbstractFontConverter.h @@ -150,12 +150,13 @@ class MAGNUM_TEXT_EXPORT AbstractFontConverter: public PluginManager::AbstractPl * @brief Plugin search paths * * First looks in `magnum/fontconverters/` or `magnum-d/fontconverters/` - * 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. + * next to the executable (or, in case of Windows and a non-static + * build, next to the DLL of the @ref Text library) 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. * * Not defined on platforms without * @ref CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT "dynamic plugin support". diff --git a/src/Magnum/Trade/AbstractImageConverter.cpp b/src/Magnum/Trade/AbstractImageConverter.cpp index 819eaaad8..61bb51a6d 100644 --- a/src/Magnum/Trade/AbstractImageConverter.cpp +++ b/src/Magnum/Trade/AbstractImageConverter.cpp @@ -50,10 +50,26 @@ std::string AbstractImageConverter::pluginInterface() { std::vector AbstractImageConverter::pluginSearchPaths() { return { #ifdef CORRADE_IS_DEBUG_BUILD + #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_BUILD_STATIC) + Utility::Directory::join(Utility::Directory::path(Utility::Directory::dllLocation( + #ifdef __MINGW32__ + "lib" + #endif + "MagnumTrade-d")), "magnum-d/imageconverters"), + #else "magnum-d/imageconverters", + #endif Utility::Directory::join(MAGNUM_PLUGINS_DEBUG_DIR, "imageconverters") #else + #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_BUILD_STATIC) + Utility::Directory::join(Utility::Directory::path(Utility::Directory::dllLocation( + #ifdef __MINGW32__ + "lib" + #endif + "MagnumTrade")), "magnum/imageconverters"), + #else "magnum/imageconverters", + #endif Utility::Directory::join(MAGNUM_PLUGINS_DIR, "imageconverters") #endif }; diff --git a/src/Magnum/Trade/AbstractImageConverter.h b/src/Magnum/Trade/AbstractImageConverter.h index 8a185fa3d..4c05a90af 100644 --- a/src/Magnum/Trade/AbstractImageConverter.h +++ b/src/Magnum/Trade/AbstractImageConverter.h @@ -123,12 +123,13 @@ class MAGNUM_TRADE_EXPORT AbstractImageConverter: public PluginManager::Abstract * @brief Plugin search paths * * First looks in `magnum/imageconverters/` or `magnum-d/imageconverters/` - * 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. + * next to the executable (or, in case of Windows and a non-static + * build, next to the DLL of the @ref Trade library) 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. * * 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 97de8f5dc..5238df027 100644 --- a/src/Magnum/Trade/AbstractImporter.cpp +++ b/src/Magnum/Trade/AbstractImporter.cpp @@ -59,10 +59,28 @@ std::string AbstractImporter::pluginInterface() { std::vector AbstractImporter::pluginSearchPaths() { return { #ifdef CORRADE_IS_DEBUG_BUILD + #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_BUILD_STATIC) + Utility::Directory::join(Utility::Directory::path(Utility::Directory::dllLocation( + #ifdef __MINGW32__ + "lib" + #endif + "MagnumTrade-d")), "magnum-d/importers"), + #else "magnum-d/importers", + #endif Utility::Directory::join(MAGNUM_PLUGINS_DEBUG_DIR, "importers") + #ifdef CORRADE_TARGET_WINDOWS + #endif + #else + #if defined(CORRADE_TARGET_WINDOWS) && !defined(MAGNUM_BUILD_STATIC) + Utility::Directory::join(Utility::Directory::path(Utility::Directory::dllLocation( + #ifdef __MINGW32__ + "lib" + #endif + "MagnumTrade")), "magnum/importers"), #else "magnum/importers", + #endif Utility::Directory::join(MAGNUM_PLUGINS_DIR, "importers") #endif }; diff --git a/src/Magnum/Trade/AbstractImporter.h b/src/Magnum/Trade/AbstractImporter.h index b41d1b6af..0c9bb3662 100644 --- a/src/Magnum/Trade/AbstractImporter.h +++ b/src/Magnum/Trade/AbstractImporter.h @@ -244,11 +244,13 @@ class MAGNUM_TRADE_EXPORT AbstractImporter: public PluginManager::AbstractManagi * @brief Plugin search paths * * First looks in `magnum/importers/` or `magnum-d/importers/` 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. + * the executable (or, in case of Windows and a non-static build, next + * to the DLL of the @ref Trade library) 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. * * Not defined on platforms without * @ref CORRADE_PLUGINMANAGER_NO_DYNAMIC_PLUGIN_SUPPORT "dynamic plugin support".