2024-01-07 01:18:15 +00:00
|
|
|
#include "components/misc/osgpluginchecker.hpp"
|
|
|
|
|
|
|
|
#include <components/debug/debuglog.hpp>
|
2024-01-07 17:32:54 +00:00
|
|
|
#include <components/misc/strings/conversion.hpp>
|
2024-01-07 01:18:15 +00:00
|
|
|
|
2024-01-07 17:32:54 +00:00
|
|
|
#include <osg/Config>
|
2024-01-07 01:18:15 +00:00
|
|
|
#include <osgDB/PluginQuery>
|
|
|
|
|
|
|
|
#include <algorithm>
|
2024-01-12 20:16:53 +00:00
|
|
|
#include <array>
|
2024-01-07 17:32:54 +00:00
|
|
|
#include <filesystem>
|
2024-01-07 01:18:15 +00:00
|
|
|
#include <string_view>
|
|
|
|
|
|
|
|
namespace Misc
|
|
|
|
{
|
2024-01-07 17:32:54 +00:00
|
|
|
#ifdef OSG_LIBRARY_STATIC
|
|
|
|
|
|
|
|
bool checkRequiredOSGPluginsArePresent()
|
|
|
|
{
|
|
|
|
// assume they were linked in at build time and CMake would have failed if they were missing
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
2024-01-07 01:18:15 +00:00
|
|
|
namespace
|
|
|
|
{
|
2024-01-12 20:16:53 +00:00
|
|
|
constexpr auto USED_OSG_PLUGIN_FILENAMES = std::to_array<std::string_view>({${USED_OSG_PLUGIN_FILENAMES_FORMATTED}});
|
2024-01-07 01:18:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool checkRequiredOSGPluginsArePresent()
|
|
|
|
{
|
|
|
|
auto availableOSGPlugins = osgDB::listAllAvailablePlugins();
|
|
|
|
bool haveAllPlugins = true;
|
2024-01-12 20:16:53 +00:00
|
|
|
for (std::string_view plugin : USED_OSG_PLUGIN_FILENAMES)
|
2024-01-07 01:18:15 +00:00
|
|
|
{
|
2024-01-07 17:35:52 +00:00
|
|
|
if (std::find_if(availableOSGPlugins.begin(), availableOSGPlugins.end(), [&](std::string_view availablePlugin) {
|
2024-01-07 17:32:54 +00:00
|
|
|
#ifdef OSG_USE_UTF8_FILENAME
|
|
|
|
std::filesystem::path pluginPath {stringToU8String(availablePlugin)};
|
|
|
|
#else
|
|
|
|
std::filesystem::path pluginPath {availablePlugin};
|
|
|
|
#endif
|
|
|
|
return pluginPath.filename() == plugin;
|
|
|
|
}) == availableOSGPlugins.end())
|
2024-01-07 01:18:15 +00:00
|
|
|
{
|
|
|
|
Log(Debug::Error) << "Missing OSG plugin: " << plugin;
|
|
|
|
haveAllPlugins = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return haveAllPlugins;
|
|
|
|
}
|
2024-01-07 17:32:54 +00:00
|
|
|
|
|
|
|
#endif
|
2024-01-07 01:18:15 +00:00
|
|
|
}
|