mirror of
https://github.com/OpenMW/openmw.git
synced 2025-04-02 04:36:39 +00:00
Split list in CMake instead of C++
That avoids the need for constexpr work, and therefore the need for an MSVC-specific extension
This commit is contained in:
parent
de107c6a98
commit
62f5c46f25
2 changed files with 6 additions and 20 deletions
|
@ -43,6 +43,9 @@ list (APPEND COMPONENT_FILES "${OpenMW_BINARY_DIR}/${VERSION_CPP_FILE}")
|
||||||
# OSG plugin checker
|
# OSG plugin checker
|
||||||
list(TRANSFORM USED_OSG_PLUGINS PREPEND "${CMAKE_SHARED_MODULE_PREFIX}" OUTPUT_VARIABLE USED_OSG_PLUGIN_FILENAMES)
|
list(TRANSFORM USED_OSG_PLUGINS PREPEND "${CMAKE_SHARED_MODULE_PREFIX}" OUTPUT_VARIABLE USED_OSG_PLUGIN_FILENAMES)
|
||||||
list(TRANSFORM USED_OSG_PLUGIN_FILENAMES APPEND "${CMAKE_SHARED_MODULE_SUFFIX}")
|
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)
|
||||||
|
|
||||||
set(OSG_PLUGIN_CHECKER_CPP_FILE "components/misc/osgpluginchecker.cpp")
|
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}")
|
configure_file("${OpenMW_SOURCE_DIR}/${OSG_PLUGIN_CHECKER_CPP_FILE}.in" "${OpenMW_BINARY_DIR}/${OSG_PLUGIN_CHECKER_CPP_FILE}")
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include <osgDB/PluginQuery>
|
#include <osgDB/PluginQuery>
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <array>
|
||||||
#include <filesystem>
|
#include <filesystem>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
|
@ -24,32 +25,14 @@ namespace Misc
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
std::string_view USED_OSG_PLUGIN_FILENAMES = "${USED_OSG_PLUGIN_FILENAMES}";
|
constexpr auto USED_OSG_PLUGIN_FILENAMES = std::to_array<std::string_view>({${USED_OSG_PLUGIN_FILENAMES_FORMATTED}});
|
||||||
|
|
||||||
constexpr auto getRequiredOSGPlugins()
|
|
||||||
{
|
|
||||||
// TODO: this is only constexpr due to an MSVC extension, so doesn't work on GCC and Clang
|
|
||||||
// I tried replacing it with std::views::split_range, but we support compilers without that bit of C++20, and it wasn't obvious how to use the result as a string_view without C++23
|
|
||||||
std::vector<std::string_view> requiredOSGPlugins;
|
|
||||||
auto currentStart = USED_OSG_PLUGIN_FILENAMES.begin();
|
|
||||||
while (currentStart != USED_OSG_PLUGIN_FILENAMES.end())
|
|
||||||
{
|
|
||||||
auto currentEnd = std::find(currentStart, USED_OSG_PLUGIN_FILENAMES.end(), ';');
|
|
||||||
requiredOSGPlugins.emplace_back(currentStart, currentEnd);
|
|
||||||
if (currentEnd == USED_OSG_PLUGIN_FILENAMES.end())
|
|
||||||
break;
|
|
||||||
currentStart = currentEnd + 1;
|
|
||||||
}
|
|
||||||
return requiredOSGPlugins;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool checkRequiredOSGPluginsArePresent()
|
bool checkRequiredOSGPluginsArePresent()
|
||||||
{
|
{
|
||||||
auto availableOSGPlugins = osgDB::listAllAvailablePlugins();
|
auto availableOSGPlugins = osgDB::listAllAvailablePlugins();
|
||||||
auto requiredOSGPlugins = getRequiredOSGPlugins();
|
|
||||||
bool haveAllPlugins = true;
|
bool haveAllPlugins = true;
|
||||||
for (std::string_view plugin : requiredOSGPlugins)
|
for (std::string_view plugin : USED_OSG_PLUGIN_FILENAMES)
|
||||||
{
|
{
|
||||||
if (std::find_if(availableOSGPlugins.begin(), availableOSGPlugins.end(), [&](std::string_view availablePlugin) {
|
if (std::find_if(availableOSGPlugins.begin(), availableOSGPlugins.end(), [&](std::string_view availablePlugin) {
|
||||||
#ifdef OSG_USE_UTF8_FILENAME
|
#ifdef OSG_USE_UTF8_FILENAME
|
||||||
|
|
Loading…
Reference in a new issue