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

Fix compilation when using Ubuntu 18.04 #134

Merged
merged 3 commits into from
May 18, 2021
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
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