1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-15 22:49:48 +00:00

Get OSG to tell us the plugin filenames it's going to use

That way, we don't have issues like the checker getting false positives when the right plugins are present for the wrong OSG version or build config, or false negatives when we've generated the wrong filenames.
This commit is contained in:
AnyOldName3 2024-03-10 18:04:38 +00:00
parent 61d01f3b62
commit 0730dc2ebb
2 changed files with 10 additions and 14 deletions

View File

@ -46,17 +46,10 @@ list (APPEND COMPONENT_FILES "${OpenMW_BINARY_DIR}/${VERSION_CPP_FILE}")
# OSG plugin checker
# Helpfully, OSG doesn't export this to its CMake config as it doesn't have one
set(OSG_PLUGIN_PREFIX "")
if (CYGWIN)
SET(OSG_PLUGIN_PREFIX "cygwin_")
elseif(MINGW)
SET(OSG_PLUGIN_PREFIX "mingw_")
endif()
list(TRANSFORM USED_OSG_PLUGINS PREPEND "${OSG_PLUGIN_PREFIX}" OUTPUT_VARIABLE USED_OSG_PLUGIN_FILENAMES)
list(TRANSFORM USED_OSG_PLUGIN_FILENAMES APPEND "${CMAKE_SHARED_MODULE_SUFFIX}")
list(TRANSFORM USED_OSG_PLUGIN_FILENAMES PREPEND "\"" OUTPUT_VARIABLE USED_OSG_PLUGIN_FILENAMES_FORMATTED)
list(TRANSFORM USED_OSG_PLUGIN_FILENAMES_FORMATTED APPEND "\"")
list(JOIN USED_OSG_PLUGIN_FILENAMES_FORMATTED ", " USED_OSG_PLUGIN_FILENAMES_FORMATTED)
list(TRANSFORM USED_OSG_PLUGINS REPLACE "^osgdb_" "" OUTPUT_VARIABLE USED_OSG_PLUGIN_NAMES)
list(TRANSFORM USED_OSG_PLUGIN_NAMES PREPEND "\"" OUTPUT_VARIABLE USED_OSG_PLUGIN_NAMES_FORMATTED)
list(TRANSFORM USED_OSG_PLUGIN_NAMES_FORMATTED APPEND "\"")
list(JOIN USED_OSG_PLUGIN_NAMES_FORMATTED ", " USED_OSG_PLUGIN_NAMES_FORMATTED)
set(OSG_PLUGIN_CHECKER_CPP_FILE "components/misc/osgpluginchecker.cpp")
configure_file("${OpenMW_SOURCE_DIR}/${OSG_PLUGIN_CHECKER_CPP_FILE}.in" "${OpenMW_BINARY_DIR}/${OSG_PLUGIN_CHECKER_CPP_FILE}")

View File

@ -30,7 +30,7 @@ namespace Misc
namespace
{
constexpr auto USED_OSG_PLUGIN_FILENAMES = std::to_array<std::string_view>({${USED_OSG_PLUGIN_FILENAMES_FORMATTED}});
constexpr auto USED_OSG_PLUGIN_NAMES = std::to_array<std::string_view>({${USED_OSG_PLUGIN_NAMES_FORMATTED}});
}
bool checkRequiredOSGPluginsArePresent()
@ -62,7 +62,7 @@ namespace Misc
auto availableOSGPlugins = osgDB::listAllAvailablePlugins();
bool haveAllPlugins = true;
for (std::string_view plugin : USED_OSG_PLUGIN_FILENAMES)
for (std::string_view plugin : USED_OSG_PLUGIN_NAMES)
{
if (std::find_if(availableOSGPlugins.begin(), availableOSGPlugins.end(),
[&](std::string_view availablePlugin) {
@ -71,7 +71,10 @@ namespace Misc
#else
std::filesystem::path pluginPath {availablePlugin};
#endif
return pluginPath.filename() == plugin;
return pluginPath.filename()
== std::filesystem::path(
osgDB::Registry::instance()->createLibraryNameForExtension(std::string{ plugin }))
.filename();
})
== availableOSGPlugins.end())
{