Skip to content

Commit

Permalink
Merge pull request #134 from traversaro/fix/ubuntu/focal
Browse files Browse the repository at this point in the history
Fix compilation when using Ubuntu 18.04
  • Loading branch information
Nicogene authored May 18, 2021
2 parents c5938f9 + 17658b9 commit 49b2304
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions src/libYARP_telemetry/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,11 @@ target_link_libraries(YARP_telemetry PUBLIC Boost::boost
Threads::Threads
YARP::YARP_conf
PRIVATE nlohmann_json::nlohmann_json)
# Support using filesystem on GCC < 9.1,
# see https://en.cppreference.com/w/cpp/filesystem#Notes
if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.1))
target_link_libraries(YARP_telemetry PUBLIC stdc++fs)
endif()
list(APPEND YARP_telemetry_PUBLIC_DEPS Boost
matioCpp
Threads)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,20 @@
#include <atomic>
#include <mutex>
#include <condition_variable>
#include <filesystem>

#ifndef __has_include
static_assert(false, "__has_include not supported");
#else
# if __has_include(<filesystem>)
# include <filesystem>
namespace yarp_telemetry_fs = std::filesystem;
# elif __has_include(<experimental/filesystem>)
# include <experimental/filesystem>
namespace yarp_telemetry_fs = std::experimental::filesystem;
# else
static_assert(false, "Neither <filesystem> nor <experimental/filesystem> headers are present in the system, but they are required");
# endif
#endif


namespace yarp::telemetry::experimental {
Expand Down Expand Up @@ -136,7 +149,7 @@ class BufferManager {
ok = ok && enablePeriodicSave(_bufferConfig.save_period);
}
populateDescriptionCellArray();
if (!m_bufferConfig.path.empty() && !std::filesystem::exists(m_bufferConfig.path)) {
if (!m_bufferConfig.path.empty() && !yarp_telemetry_fs::exists(m_bufferConfig.path)) {
std::cout << m_bufferConfig.path << " does not exists." << std::endl;
return false;
}
Expand Down

0 comments on commit 49b2304

Please sign in to comment.