From af30f7414596026b8f62a09685ea11d0d7c60c78 Mon Sep 17 00:00:00 2001 From: Sean Yen Date: Mon, 10 Aug 2020 18:01:58 -0700 Subject: [PATCH] [Gazebo9] More enhancement for Windows build (#2789) --- cmake/GazeboUtils.cmake | 6 +++++- gazebo/common/Material.cc | 4 ++++ gazebo/common/ModelDatabase.cc | 19 ++++++++++++++----- 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/cmake/GazeboUtils.cmake b/cmake/GazeboUtils.cmake index 9a0582dcdc..5e952b1c76 100644 --- a/cmake/GazeboUtils.cmake +++ b/cmake/GazeboUtils.cmake @@ -131,7 +131,11 @@ endmacro() ################################################# macro (gz_install_library _name) set_target_properties(${_name} PROPERTIES SOVERSION ${GAZEBO_MAJOR_VERSION} VERSION ${GAZEBO_VERSION_FULL}) - install (TARGETS ${_name} DESTINATION ${LIB_INSTALL_DIR} COMPONENT shlib) + install (TARGETS ${_name} + ARCHIVE DESTINATION ${LIB_INSTALL_DIR} + LIBRARY DESTINATION ${LIB_INSTALL_DIR} + RUNTIME DESTINATION ${BIN_INSTALL_DIR} + COMPONENT shlib) endmacro () ################################################# diff --git a/gazebo/common/Material.cc b/gazebo/common/Material.cc index 32363716f4..66d7cb961e 100644 --- a/gazebo/common/Material.cc +++ b/gazebo/common/Material.cc @@ -98,6 +98,10 @@ void Material::SetTextureImage(const std::string &_tex, } } } + + // normalize the path + this->texImage = boost::filesystem::path(this->texImage) + .make_preferred().string(); } ////////////////////////////////////////////////// diff --git a/gazebo/common/ModelDatabase.cc b/gazebo/common/ModelDatabase.cc index 660d156eda..003e74fe98 100644 --- a/gazebo/common/ModelDatabase.cc +++ b/gazebo/common/ModelDatabase.cc @@ -503,19 +503,28 @@ std::string ModelDatabase::GetModelPath(const std::string &_uri, continue; } + std::string outputPath = getenv("HOME"); + outputPath += "/.gazebo/models"; + #ifndef _WIN32 TAR *tar; tar_open(&tar, const_cast(tarfilename.c_str()), nullptr, O_RDONLY, 0644, TAR_GNU); - std::string outputPath = getenv("HOME"); - outputPath += "/.gazebo/models"; - tar_extract_all(tar, const_cast(outputPath.c_str())); +#else + // Tar now is a built-in tool since Windows 10 build 17063. + std::string cmdline = "tar xzf \""; + cmdline += tarfilename + "\" -C \""; + cmdline += outputPath + "\""; + auto ret = system(cmdline.c_str()); + if (ret != 0) + { + gzerr << "tar extract ret = " << ret << ", cmdline = " << cmdline << std::endl; + } +#endif path = outputPath + "/" + modelName; - ModelDatabase::DownloadDependencies(path); -#endif } curl_easy_cleanup(curl);