Skip to content

Plugin import breaks if CMAKE_RUNTIME_OUTPUT_DIRECTORY_* is set #486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Gollum999 opened this issue Dec 10, 2020 · 3 comments
Closed

Plugin import breaks if CMAKE_RUNTIME_OUTPUT_DIRECTORY_* is set #486

Gollum999 opened this issue Dec 10, 2020 · 3 comments

Comments

@Gollum999
Copy link

Environment

Problem

If CMAKE_RUNTIME_OUTPUT_DIRECTORY_<CONFIG> is set, trying to load plugins will fail. Example error message:

PluginManager::Manager::Manager(): none of the plugin search paths in {C:/code/magnum/bld/vs/Debug/bin/magnum-d/importers, magnum-d/importers} exists and pluginDirectory was not set, skipping plugin discovery
PluginManager::Manager::load(): plugin TgaImporter is not static and was not found in

As described here, if this variable is set, it is used to initialize the RUNTIME_OUTPUT_DIRECTORY_<CONFIG> property of each target. This property takes precedence over the RUNITME_OUPUT_DIRECTORY property. This means that the output directories that are set in each plugin's CMakeLists end up being overridden. This causes the plugin library to not be built into the expected location, causing it to fail to load at runtime.

To reproduce

Build Magnum as a subproject as in Example 1a of the Getting Started guide. Add the following lines to CMake before add_subdirectory(magnum):

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_RUNTIME_OUTPUT_DIRECTORY})

Then build with some plugin enabled and try to load the plugin at runtime.

@Gollum999
Copy link
Author

Just as a note, in my case I ran into this because of Conan. By default, conan_basic_setup modifies the build output directories by setting these CMake variables. I switched to using conan_basic_setup(NO_OUTPUT_DIRS) to avoid this behavior.

@mosra mosra added this to the 2020.0b milestone Dec 10, 2020
@mosra
Copy link
Owner

mosra commented Dec 10, 2020

Hi,

yeah, the plugins are expected to be in those particular subdirectories (magnum/blah) relative to the interface library, otherwise it's not really possible for the plugin manager to discover them or know which plugin is which. The library already decides based on presence / value of CMAKE_RUNTIME_OUTPUT_DIRECTORY on its own, but isn't currently aware of CMAKE_RUNTIME_OUTPUT_DIRECTORY_<CONFIG>.

I'll have to fix that.

@mosra
Copy link
Owner

mosra commented Jun 15, 2022

This should be fixed with #570. Sorry it took half a century to get this done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

2 participants