diff --git a/cmake/FairMQLib.cmake b/cmake/FairMQLib.cmake index 2074df0e..2b2027d1 100644 --- a/cmake/FairMQLib.cmake +++ b/cmake/FairMQLib.cmake @@ -203,6 +203,13 @@ macro(set_fairmq_defaults) set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE}) endif() endif() + + if( CMAKE_CXX_COMPILER_ID STREQUAL "GNU" + AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 8) + set(FAIRMQ_HAS_STD_FILESYSTEM 0) + else() + set(FAIRMQ_HAS_STD_FILESYSTEM 1) + endif() endmacro() function(join VALUES GLUE OUTPUT) diff --git a/fairmq/CMakeLists.txt b/fairmq/CMakeLists.txt index 5d490ad1..a54e909b 100644 --- a/fairmq/CMakeLists.txt +++ b/fairmq/CMakeLists.txt @@ -283,6 +283,7 @@ if(BUILD_FAIRMQ) if(BUILD_OFI_TRANSPORT) target_compile_definitions(${_target} PRIVATE BUILD_OFI_TRANSPORT) endif() + target_compile_definitions(${_target} PUBLIC FAIRMQ_HAS_STD_FILESYSTEM=${FAIRMQ_HAS_STD_FILESYSTEM}) ####################### @@ -384,6 +385,7 @@ if(BUILD_FAIRMQ) $<$:rt> Boost::boost Boost::date_time + $<$:Boost::filesystem> Boost::program_options FairLogger::FairLogger PicoSHA2 @@ -391,6 +393,7 @@ if(BUILD_FAIRMQ) target_include_directories(fairmq-shmmonitor PUBLIC $ ) + target_compile_definitions(fairmq-shmmonitor PUBLIC FAIRMQ_HAS_STD_FILESYSTEM=${FAIRMQ_HAS_STD_FILESYSTEM}) add_executable(fairmq-uuid-gen tools/runUuidGenerator.cxx) target_link_libraries(fairmq-uuid-gen PUBLIC diff --git a/fairmq/shmem/Monitor.cxx b/fairmq/shmem/Monitor.cxx index ccc30b2e..3f85bc9d 100644 --- a/fairmq/shmem/Monitor.cxx +++ b/fairmq/shmem/Monitor.cxx @@ -20,7 +20,6 @@ #include #include -#include #include #include #include @@ -32,6 +31,14 @@ #include #include +#if FAIRMQ_HAS_STD_FILESYSTEM +#include +namespace fs = std::filesystem; +#else +#include +namespace fs = ::boost::filesystem; +#endif + using namespace std; using bie = ::boost::interprocess::interprocess_exception; namespace bipc = ::boost::interprocess; @@ -275,12 +282,12 @@ bool Monitor::PrintShm(const ShmId& shmId) void Monitor::ListAll(const std::string& path) { try { - if (std::filesystem::is_empty(path)) { - LOG(info) << "directory " << filesystem::path(path) << " is empty."; + if (fs::is_empty(path)) { + LOG(info) << "directory " << fs::path(path) << " is empty."; return; } - for (const auto& entry : filesystem::directory_iterator(path)) { + for (const auto& entry : fs::directory_iterator(path)) { string filename = entry.path().filename().string(); // LOG(info) << filename << ", size: " << entry.file_size() << " bytes"; if (tools::StrStartsWith(filename, "fmq_") || tools::StrStartsWith(filename, "sem.fmq_")) { @@ -296,7 +303,7 @@ void Monitor::ListAll(const std::string& path) LOG(info) << "The file '" << filename << "' does not belong to FairMQ, skipping..."; } } - } catch (filesystem::filesystem_error& fse) { + } catch (fs::filesystem_error& fse) { LOG(error) << "error: " << fse.what(); } }