diff --git a/.github/ci/packages.apt b/.github/ci/packages.apt index 1c14ce8f..7bf9b7e2 100644 --- a/.github/ci/packages.apt +++ b/.github/ci/packages.apt @@ -3,6 +3,7 @@ libcurl4-openssl-dev libgflags-dev libignition-cmake2-dev libignition-common3-dev +libignition-math6-dev libignition-msgs5-dev libignition-tools-dev libjsoncpp-dev diff --git a/CMakeLists.txt b/CMakeLists.txt index 9aa0d857..cff58878 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -50,6 +50,11 @@ ign_find_package(ZIP REQUIRED PRIVATE) ign_find_package(ignition-common3 REQUIRED PRIVATE) set(IGN_COMMON_MAJOR_VER ${ignition-common3_VERSION_MAJOR}) +#-------------------------------------- +# Find ignition-math +ign_find_package(ignition-math6 REQUIRED PRIVATE) +set(IGN_MSGS_MAJOR_VER ${ignition-math6_VERSION_MAJOR}) + #-------------------------------------- # Find ignition-msgs ign_find_package(ignition-msgs5 REQUIRED PRIVATE) diff --git a/src/LocalCache.cc b/src/LocalCache.cc index 0b5f54d2..c0167192 100644 --- a/src/LocalCache.cc +++ b/src/LocalCache.cc @@ -32,6 +32,7 @@ #include #include #include +#include #include "ignition/fuel_tools/ClientConfig.hh" #include "ignition/fuel_tools/LocalCache.hh" @@ -459,11 +460,24 @@ bool LocalCachePrivate::FixPaths(const std::string &_modelVersionedDir, // Get the element with the highest (most recent) version. tinyxml2::XMLElement *sdfElementLatest = nullptr; - double maxVersion = 0.0; + math::SemanticVersion maxVersion{"0.0"}; tinyxml2::XMLElement *sdfElement = modelElement->FirstChildElement("sdf"); while (sdfElement) { - double version = std::stod(sdfElement->Attribute("version")); + math::SemanticVersion version; + + auto versionAttribute = sdfElement->Attribute("version"); + if (nullptr == versionAttribute) + { + version.Parse("0.0.1"); + ignwarn << " element missing version attribute, assuming version [" + << version << "]" << std::endl; + } + else + { + version.Parse(versionAttribute); + } + if (version > maxVersion) { maxVersion = version;