Skip to content
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

Parse correctly OGRE2_RESOURCE_PATH on Windows #996

Merged
merged 1 commit into from
May 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion ogre2/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ set(engine_name "ogre2")
gz_add_component(${engine_name} SOURCES ${sources} GET_TARGET_NAME ogre2_target)

set(OGRE2_RESOURCE_PATH_STR "${OGRE2_RESOURCE_PATH}")
string(REPLACE ";" ":" OGRE2_RESOURCE_PATH_STR "${OGRE2_RESOURCE_PATH}")
# On non-Windows, we need to convert the CMake list delimited (;) to the
# list delimiter used in list of paths in code (:)
# On Windows, the list delimiter in code is already ;, not need to change it to :
if(NOT WIN32)
string(REPLACE ";" ":" OGRE2_RESOURCE_PATH_STR "${OGRE2_RESOURCE_PATH}")
endif()

set_property(
SOURCE Ogre2RenderEngine.cc
PROPERTY COMPILE_DEFINITIONS
Expand Down
7 changes: 5 additions & 2 deletions ogre2/src/Ogre2RenderEngine.cc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
#endif
#include <gz/common/Console.hh>
#include <gz/common/Filesystem.hh>
#include <gz/common/StringUtils.hh>
#include <gz/common/SystemPaths.hh>
#include <gz/common/Util.hh>

#include <gz/plugin/Register.hh>
Expand Down Expand Up @@ -118,14 +120,15 @@
this->dummyWindowId = 0;

std::string ogrePath = std::string(OGRE2_RESOURCE_PATH);
std::vector<std::string> paths = common::split(ogrePath, ":");
std::vector<std::string> paths = common::Split(ogrePath,
common::SystemPaths::Delimiter());
for (const auto &path : paths)
this->ogrePaths.push_back(path);

const char *env = std::getenv("OGRE2_RESOURCE_PATH");
if (env)
{
paths = common::split(std::string(env), ":");
paths = common::Split(std::string(env), common::SystemPaths::Delimiter());

Check warning on line 131 in ogre2/src/Ogre2RenderEngine.cc

View check run for this annotation

Codecov / codecov/patch

ogre2/src/Ogre2RenderEngine.cc#L131

Added line #L131 was not covered by tests
for (const auto &path : paths)
this->ogrePaths.push_back(path);
}
Expand Down