From ca6b4b545b8b61625047e96159dab64a781c5098 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Mon, 10 Jun 2019 21:41:13 +0200 Subject: [PATCH] Replace Boost::filesystem by std::filesystem if C++17 support is available --- CMakeLists.txt | 251 ++++++++++-------- cmake/Modules/FindGNURADIO.cmake | 14 + .../PVT/gnuradio_blocks/CMakeLists.txt | 9 +- .../PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 35 ++- src/algorithms/PVT/libs/CMakeLists.txt | 9 +- src/algorithms/PVT/libs/geojson_printer.cc | 30 ++- src/algorithms/PVT/libs/gpx_printer.cc | 31 ++- src/algorithms/PVT/libs/kml_printer.cc | 52 +++- src/algorithms/PVT/libs/nmea_printer.cc | 31 ++- src/algorithms/PVT/libs/rinex_printer.cc | 44 +-- src/algorithms/PVT/libs/rtcm_printer.cc | 31 ++- .../gnuradio_blocks/CMakeLists.txt | 8 +- .../gnuradio_blocks/pcps_acquisition.cc | 12 +- .../pcps_acquisition_fine_doppler_cc.cc | 12 +- src/algorithms/libs/CMakeLists.txt | 17 +- .../libs/gnss_sdr_create_directory.cc | 46 ++-- src/algorithms/libs/gnss_sdr_flags.cc | 19 +- .../cmake/Modules/FindFILESYSTEM.cmake | 10 + .../gnuradio_blocks/CMakeLists.txt | 8 +- .../gnuradio_blocks/hybrid_observables_gs.cc | 10 +- .../tracking/gnuradio_blocks/CMakeLists.txt | 7 + .../gnuradio_blocks/dll_pll_veml_tracking.cc | 11 +- .../dll_pll_veml_tracking_fpga.cc | 12 +- src/main/CMakeLists.txt | 9 +- src/main/main.cc | 42 +-- src/tests/CMakeLists.txt | 80 ++++-- src/tests/system-tests/position_test.cc | 13 +- .../unit-tests/arithmetic/fft_length_test.cc | 12 +- .../acquisition/acq_performance_test.cc | 24 +- .../beidou_b1i_pcps_acquisition_test.cc | 23 +- .../beidou_b3i_pcps_acquisition_test.cc | 25 +- ...ileo_e1_pcps_ambiguous_acquisition_test.cc | 23 +- .../gps_l1_ca_pcps_acquisition_test.cc | 24 +- .../gps_l2_m_pcps_acquisition_test.cc | 24 +- .../gps_l1_ca_dll_pll_tracking_test.cc | 14 +- .../tracking/gps_l1_ca_kf_tracking_test.cc | 14 +- .../tracking/tracking_pull-in_test.cc | 14 +- src/utils/front-end-cal/CMakeLists.txt | 8 +- src/utils/front-end-cal/main.cc | 15 +- src/utils/rinex2assist/CMakeLists.txt | 2 +- 40 files changed, 744 insertions(+), 331 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 703d474b5..f8d97c2a7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -596,113 +596,6 @@ endif() -################################################################################ -# Boost - https://www.boost.org -################################################################################ -if(UNIX AND EXISTS "/usr/lib64") - list(APPEND BOOST_LIBRARYDIR "/usr/lib64") # Fedora 64-bit fix -endif() -set(Boost_ADDITIONAL_VERSIONS - "1.53.0" "1.53" "1.54.0" "1.54" - "1.55.0" "1.55" "1.56.0" "1.56" "1.57.0" "1.57" "1.58.0" "1.58" "1.59.0" "1.59" - "1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64" - "1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69" - "1.70.0" "1.70" "1.71.0" "1.71" "1.72.0" "1.72" "1.73.0" "1.73" "1.74.0" "1.74" - "1.75.0" "1.75" "1.76.0" "1.76" "1.77.0" "1.77" "1.78.0" "1.78" "1.79.0" "1.79" - "1.80.0" "1.80" "1.81.0" "1.81" "1.82.0" "1.82" "1.83.0" "1.83" "1.84.0" "1.84" -) -set(Boost_USE_MULTITHREAD ON) -set(Boost_USE_STATIC_LIBS OFF) -find_package(Boost ${GNSSSDR_BOOST_MIN_VERSION} COMPONENTS atomic chrono date_time filesystem serialization system thread REQUIRED) -set_package_properties(Boost PROPERTIES - URL "https://www.boost.org" - DESCRIPTION "Portable C++ source libraries" - PURPOSE "Used widely across the source code." - TYPE REQUIRED -) -if(NOT Boost_FOUND) - message(FATAL_ERROR "Fatal error: Boost (version >=${GNSSSDR_BOOST_MIN_VERSION}) required.") -endif() - -if(CMAKE_VERSION VERSION_LESS 3.5) - if(NOT TARGET Boost::boost) - add_library(Boost::boost SHARED IMPORTED) # Trick for CMake 2.8.12 - set_target_properties(Boost::boost PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR} - IMPORTED_LOCATION ${Boost_DATE_TIME_LIBRARIES} - ) - endif() - if(NOT TARGET Boost::date_time) - add_library(Boost::date_time SHARED IMPORTED) - set_target_properties(Boost::date_time PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR} - INTERFACE_LINK_LIBRARIES ${Boost_DATE_TIME_LIBRARIES} - IMPORTED_LOCATION ${Boost_DATE_TIME_LIBRARIES} - ) - endif() - if(NOT TARGET Boost::system) - add_library(Boost::system SHARED IMPORTED) - set_target_properties(Boost::system PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR} - INTERFACE_LINK_LIBRARIES ${Boost_SYSTEM_LIBRARIES} - IMPORTED_LOCATION ${Boost_SYSTEM_LIBRARIES} - ) - endif() - if(NOT TARGET Boost::filesystem) - add_library(Boost::filesystem SHARED IMPORTED) - set_target_properties(Boost::filesystem PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR} - INTERFACE_LINK_LIBRARIES ${Boost_FILESYSTEM_LIBRARIES} - IMPORTED_LOCATION ${Boost_FILESYSTEM_LIBRARIES} - ) - endif() - if(NOT TARGET Boost::thread) - add_library(Boost::thread SHARED IMPORTED) - set_target_properties(Boost::thread PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR} - INTERFACE_LINK_LIBRARIES ${Boost_THREAD_LIBRARIES} - IMPORTED_LOCATION ${Boost_THREAD_LIBRARIES} - ) - endif() - if(NOT TARGET Boost::serialization) - add_library(Boost::serialization SHARED IMPORTED) - set_target_properties(Boost::serialization PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR} - INTERFACE_LINK_LIBRARIES ${Boost_SERIALIZATION_LIBRARIES} - IMPORTED_LOCATION ${Boost_SERIALIZATION_LIBRARIES} - ) - endif() - if(NOT TARGET Boost::chrono) - add_library(Boost::chrono SHARED IMPORTED) - set_target_properties(Boost::chrono PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR} - INTERFACE_LINK_LIBRARIES ${Boost_CHRONO_LIBRARIES} - IMPORTED_LOCATION ${Boost_CHRONO_LIBRARIES} - ) - endif() - if(NOT TARGET Boost::atomic) - add_library(Boost::atomic SHARED IMPORTED) - set_target_properties(Boost::atomic PROPERTIES - INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR} - INTERFACE_LINK_LIBRARIES ${Boost_ATOMIC_LIBRARIES} - IMPORTED_LOCATION ${Boost_ATOMIC_LIBRARIES} - ) - endif() -endif() - -# Fix for Boost Asio < 1.70 when using Clang in macOS -if(${Boost_VERSION} VERSION_LESS 107000) - # Check if we have std::string_view - include(CheckCXXSourceCompiles) - check_cxx_source_compiles(" - #include  - int main() - { std::string_view sv; }" - has_string_view - ) -endif() - - ################################################################################ # GNU Radio - https://gnuradio.org ################################################################################ @@ -859,6 +752,150 @@ endif() +################################################################################ +# Dectect availability of std::filesystem +################################################################################ +set(FILESYSTEM_FOUND FALSE) +if(NOT (GNURADIO_VERSION VERSION_LESS 3.8)) + # Check if we have std::filesystem + if(NOT (CMAKE_VERSION VERSION_LESS 3.8)) + if(POLICY CMP0057) + cmake_policy(SET CMP0057 NEW) + endif() + if(ENABLE_UNIT_TESTING_EXTRA OFF) # Workaround for GPSTk + find_package(FILESYSTEM) + set_package_properties(FILESYSTEM PROPERTIES + URL "https://en.cppreference.com/w/cpp/filesystem" + DESCRIPTION "Provides facilities for performing operations on file systems and their components" + PURPOSE "Work with paths, regular files, and directories." + TYPE OPTIONAL + ) + if(${FILESYSTEM_FOUND}) + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + endif() + endif() + endif() +endif() + + + +################################################################################ +# Boost - https://www.boost.org +################################################################################ +if(UNIX AND EXISTS "/usr/lib64") + list(APPEND BOOST_LIBRARYDIR "/usr/lib64") # Fedora 64-bit fix +endif() +set(Boost_ADDITIONAL_VERSIONS + "1.53.0" "1.53" "1.54.0" "1.54" + "1.55.0" "1.55" "1.56.0" "1.56" "1.57.0" "1.57" "1.58.0" "1.58" "1.59.0" "1.59" + "1.60.0" "1.60" "1.61.0" "1.61" "1.62.0" "1.62" "1.63.0" "1.63" "1.64.0" "1.64" + "1.65.0" "1.65" "1.66.0" "1.66" "1.67.0" "1.67" "1.68.0" "1.68" "1.69.0" "1.69" + "1.70.0" "1.70" "1.71.0" "1.71" "1.72.0" "1.72" "1.73.0" "1.73" "1.74.0" "1.74" + "1.75.0" "1.75" "1.76.0" "1.76" "1.77.0" "1.77" "1.78.0" "1.78" "1.79.0" "1.79" + "1.80.0" "1.80" "1.81.0" "1.81" "1.82.0" "1.82" "1.83.0" "1.83" "1.84.0" "1.84" +) +set(Boost_USE_MULTITHREAD ON) +set(Boost_USE_STATIC_LIBS OFF) +set(BOOST_COMPONENTS atomic chrono date_time serialization system thread) +if(NOT ${FILESYSTEM_FOUND}) + set(BOOST_COMPONENTS ${BOOST_COMPONENTS} filesystem) +endif() +find_package(Boost ${GNSSSDR_BOOST_MIN_VERSION} COMPONENTS ${BOOST_COMPONENTS} REQUIRED) +set_package_properties(Boost PROPERTIES + URL "https://www.boost.org" + DESCRIPTION "Portable C++ source libraries" + PURPOSE "Used widely across the source code." + TYPE REQUIRED +) +if(NOT Boost_FOUND) + message(FATAL_ERROR "Fatal error: Boost (version >=${GNSSSDR_BOOST_MIN_VERSION}) required.") +endif() + +if(CMAKE_VERSION VERSION_LESS 3.5) + if(NOT TARGET Boost::boost) + add_library(Boost::boost SHARED IMPORTED) # Trick for CMake 2.8.12 + set_target_properties(Boost::boost PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR} + IMPORTED_LOCATION ${Boost_DATE_TIME_LIBRARIES} + ) + endif() + if(NOT TARGET Boost::date_time) + add_library(Boost::date_time SHARED IMPORTED) + set_target_properties(Boost::date_time PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR} + INTERFACE_LINK_LIBRARIES ${Boost_DATE_TIME_LIBRARIES} + IMPORTED_LOCATION ${Boost_DATE_TIME_LIBRARIES} + ) + endif() + if(NOT TARGET Boost::system) + add_library(Boost::system SHARED IMPORTED) + set_target_properties(Boost::system PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR} + INTERFACE_LINK_LIBRARIES ${Boost_SYSTEM_LIBRARIES} + IMPORTED_LOCATION ${Boost_SYSTEM_LIBRARIES} + ) + endif() + if(NOT TARGET Boost::thread) + add_library(Boost::thread SHARED IMPORTED) + set_target_properties(Boost::thread PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR} + INTERFACE_LINK_LIBRARIES ${Boost_THREAD_LIBRARIES} + IMPORTED_LOCATION ${Boost_THREAD_LIBRARIES} + ) + endif() + if(NOT TARGET Boost::serialization) + add_library(Boost::serialization SHARED IMPORTED) + set_target_properties(Boost::serialization PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR} + INTERFACE_LINK_LIBRARIES ${Boost_SERIALIZATION_LIBRARIES} + IMPORTED_LOCATION ${Boost_SERIALIZATION_LIBRARIES} + ) + endif() + if(NOT TARGET Boost::chrono) + add_library(Boost::chrono SHARED IMPORTED) + set_target_properties(Boost::chrono PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR} + INTERFACE_LINK_LIBRARIES ${Boost_CHRONO_LIBRARIES} + IMPORTED_LOCATION ${Boost_CHRONO_LIBRARIES} + ) + endif() + if(NOT TARGET Boost::atomic) + add_library(Boost::atomic SHARED IMPORTED) + set_target_properties(Boost::atomic PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR} + INTERFACE_LINK_LIBRARIES ${Boost_ATOMIC_LIBRARIES} + IMPORTED_LOCATION ${Boost_ATOMIC_LIBRARIES} + ) + endif() + if(NOT ${FILESYSTEM_FOUND}) + if(NOT TARGET Boost::filesystem) + add_library(Boost::filesystem SHARED IMPORTED) + set_target_properties(Boost::filesystem PROPERTIES + INTERFACE_INCLUDE_DIRECTORIES ${Boost_INCLUDE_DIR} + INTERFACE_LINK_LIBRARIES ${Boost_FILESYSTEM_LIBRARIES} + IMPORTED_LOCATION ${Boost_FILESYSTEM_LIBRARIES} + ) + endif() + endif() +endif() + +# Fix for Boost Asio < 1.70 when using Clang in macOS +if(${Boost_VERSION} VERSION_LESS 107000) + # Check if we have std::string_view + include(CheckCXXSourceCompiles) + check_cxx_source_compiles(" + #include  + int main() + { std::string_view sv; }" + has_string_view + ) +endif() + + + + + ################################################################################ # VOLK - Vector-Optimized Library of Kernels ################################################################################ diff --git a/cmake/Modules/FindGNURADIO.cmake b/cmake/Modules/FindGNURADIO.cmake index d58e87c85..f4fd97503 100644 --- a/cmake/Modules/FindGNURADIO.cmake +++ b/cmake/Modules/FindGNURADIO.cmake @@ -166,6 +166,20 @@ gr_module(WAVELET gnuradio-wavelet gnuradio/wavelet/api.h gnuradio-wavelet) list(REMOVE_DUPLICATES GNURADIO_ALL_INCLUDE_DIRS) list(REMOVE_DUPLICATES GNURADIO_ALL_LIBRARIES) +if(NOT PC_GNURADIO_RUNTIME_VERSION) + list(GET GNURADIO_BLOCKS_LIBRARIES 0 FIRST_DIR) + get_filename_component(GNURADIO_BLOCKS_DIR ${FIRST_DIR} DIRECTORY) + if(EXISTS ${GNURADIO_BLOCKS_DIR}/cmake/gnuradio/GnuradioConfigVersion.cmake) + set(PACKAGE_FIND_VERSION_MAJOR 3) + set(PACKAGE_FIND_VERSION_MINOR 7) + set(PACKAGE_FIND_VERSION_PATCH 4) + include(${GNURADIO_BLOCKS_DIR}/cmake/gnuradio/GnuradioConfigVersion.cmake) + endif() + if(PACKAGE_VERSION) + set(PC_GNURADIO_RUNTIME_VERSION ${PACKAGE_VERSION}) + endif() +endif() + # Trick to find out that GNU Radio is >= 3.7.4 if pkgconfig is not present if(NOT PC_GNURADIO_RUNTIME_VERSION) find_file(GNURADIO_VERSION_GREATER_THAN_373 diff --git a/src/algorithms/PVT/gnuradio_blocks/CMakeLists.txt b/src/algorithms/PVT/gnuradio_blocks/CMakeLists.txt index 37f5de8fe..060318af0 100644 --- a/src/algorithms/PVT/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/PVT/gnuradio_blocks/CMakeLists.txt @@ -28,6 +28,13 @@ source_group(Headers FILES ${PVT_GR_BLOCKS_HEADERS}) add_library(pvt_gr_blocks ${PVT_GR_BLOCKS_SOURCES} ${PVT_GR_BLOCKS_HEADERS}) +if(${FILESYSTEM_FOUND}) + target_compile_definitions(pvt_gr_blocks PRIVATE -DHAS_STD_FILESYSTEM=1) + target_link_libraries(pvt_gr_blocks PRIVATE std::filesystem) +else() + target_link_libraries(pvt_gr_blocks PRIVATE Boost::filesystem Boost::system) +endif() + target_link_libraries(pvt_gr_blocks PUBLIC algorithms_libs_rtklib @@ -40,8 +47,6 @@ target_link_libraries(pvt_gr_blocks algorithms_libs Gflags::gflags Glog::glog - Boost::filesystem - Boost::system Boost::serialization ) diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index 0b6f265d0..3a8bfc697 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -66,10 +66,8 @@ #include // for bind_t, bind #include #include -#include #include #include // for nvp, make_nvp -#include // for error_code #include // for LOG #include // for io_signature #include // for mp @@ -83,6 +81,19 @@ #include // for length_error #include // for IPC_CREAT #include // for msgctl + +#if HAS_STD_FILESYSTEM +#include +#include +namespace fs = std::filesystem; +namespace errorlib = std; +#else +#include +#include // for error_code +namespace fs = boost::filesystem; +namespace errorlib = boost::system; +#endif + #if OLD_BOOST #include namespace bc = boost::math; @@ -140,7 +151,7 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, { d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of('.')); } - dump_ls_pvt_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename; + dump_ls_pvt_filename = dump_path + fs::path::preferred_separator + d_dump_filename; dump_ls_pvt_filename.append(".dat"); // create directory if (!gnss_sdr_create_directory(dump_path)) @@ -305,24 +316,24 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, if (d_xml_storage) { xml_base_path = conf_.xml_output_path; - boost::filesystem::path full_path(boost::filesystem::current_path()); - const boost::filesystem::path p(xml_base_path); - if (!boost::filesystem::exists(p)) + fs::path full_path(fs::current_path()); + const fs::path p(xml_base_path); + if (!fs::exists(p)) { std::string new_folder; - for (auto& folder : boost::filesystem::path(xml_base_path)) + for (auto& folder : fs::path(xml_base_path)) { new_folder += folder.string(); - boost::system::error_code ec; - if (!boost::filesystem::exists(new_folder)) + errorlib::error_code ec; + if (!fs::exists(new_folder)) { - if (!boost::filesystem::create_directory(new_folder, ec)) + if (!fs::create_directory(new_folder, ec)) { std::cout << "Could not create the " << new_folder << " folder." << std::endl; xml_base_path = full_path.string(); } } - new_folder += boost::filesystem::path::preferred_separator; + new_folder += fs::path::preferred_separator; } } else @@ -334,7 +345,7 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, std::cout << "XML files will be stored at " << xml_base_path << std::endl; } - xml_base_path = xml_base_path + boost::filesystem::path::preferred_separator; + xml_base_path = xml_base_path + fs::path::preferred_separator; } d_rx_time = 0.0; diff --git a/src/algorithms/PVT/libs/CMakeLists.txt b/src/algorithms/PVT/libs/CMakeLists.txt index bf66966a0..92e1aec04 100644 --- a/src/algorithms/PVT/libs/CMakeLists.txt +++ b/src/algorithms/PVT/libs/CMakeLists.txt @@ -61,6 +61,13 @@ source_group(Headers FILES ${PVT_LIB_HEADERS}) add_library(pvt_libs ${PVT_LIB_SOURCES} ${PVT_LIB_HEADERS}) +if(${FILESYSTEM_FOUND}) + target_compile_definitions(pvt_libs PRIVATE -DHAS_STD_FILESYSTEM=1) + target_link_libraries(pvt_libs PRIVATE std::filesystem) +else() + target_link_libraries(pvt_libs PRIVATE Boost::filesystem Boost::system) +endif() + target_link_libraries(pvt_libs PUBLIC Armadillo::armadillo @@ -70,8 +77,6 @@ target_link_libraries(pvt_libs core_system_parameters PRIVATE algorithms_libs - Boost::filesystem - Boost::system Gflags::gflags Glog::glog Matio::matio diff --git a/src/algorithms/PVT/libs/geojson_printer.cc b/src/algorithms/PVT/libs/geojson_printer.cc index e38984a88..6f9dcffe4 100644 --- a/src/algorithms/PVT/libs/geojson_printer.cc +++ b/src/algorithms/PVT/libs/geojson_printer.cc @@ -33,10 +33,15 @@ #include "geojson_printer.h" #include "pvt_solution.h" #include +#if HAS_STD_FILESYSTEM +#include +#include +#else #include // for create_directories, exists #include // for path, operator<< #include // for filesystem #include // for error_code +#endif #include #include // for remove #include // for tm @@ -45,29 +50,36 @@ #include // for cout, cerr #include // for stringstream +#if HAS_STD_FILESYSTEM +namespace fs = std::filesystem; +namespace errorlib = std; +#else +namespace fs = boost::filesystem; +namespace errorlib = boost::system; +#endif GeoJSON_Printer::GeoJSON_Printer(const std::string& base_path) { first_pos = true; geojson_base_path = base_path; - boost::filesystem::path full_path(boost::filesystem::current_path()); - const boost::filesystem::path p(geojson_base_path); - if (!boost::filesystem::exists(p)) + fs::path full_path(fs::current_path()); + const fs::path p(geojson_base_path); + if (!fs::exists(p)) { std::string new_folder; - for (auto& folder : boost::filesystem::path(geojson_base_path)) + for (auto& folder : fs::path(geojson_base_path)) { new_folder += folder.string(); - boost::system::error_code ec; - if (!boost::filesystem::exists(new_folder)) + errorlib::error_code ec; + if (!fs::exists(new_folder)) { - if (!boost::filesystem::create_directory(new_folder, ec)) + if (!fs::create_directory(new_folder, ec)) { std::cout << "Could not create the " << new_folder << " folder." << std::endl; geojson_base_path = full_path.string(); } } - new_folder += boost::filesystem::path::preferred_separator; + new_folder += fs::path::preferred_separator; } } else @@ -79,7 +91,7 @@ GeoJSON_Printer::GeoJSON_Printer(const std::string& base_path) std::cout << "GeoJSON files will be stored at " << geojson_base_path << std::endl; } - geojson_base_path = geojson_base_path + boost::filesystem::path::preferred_separator; + geojson_base_path = geojson_base_path + fs::path::preferred_separator; } diff --git a/src/algorithms/PVT/libs/gpx_printer.cc b/src/algorithms/PVT/libs/gpx_printer.cc index 3066ae824..8925f281a 100644 --- a/src/algorithms/PVT/libs/gpx_printer.cc +++ b/src/algorithms/PVT/libs/gpx_printer.cc @@ -33,10 +33,15 @@ #include "gpx_printer.h" #include "rtklib_solver.h" #include +#if HAS_STD_FILESYSTEM +#include +#include +#else #include // for create_directories, exists #include // for path, operator<< #include // for filesystem #include // for error_code +#endif #include #include // for remove #include // for tm @@ -45,30 +50,38 @@ #include // for cout, cerr #include // for stringstream +#if HAS_STD_FILESYSTEM +namespace fs = std::filesystem; +namespace errorlib = std; +#else +namespace fs = boost::filesystem; +namespace errorlib = boost::system; +#endif + Gpx_Printer::Gpx_Printer(const std::string& base_path) { positions_printed = false; indent = " "; gpx_base_path = base_path; - boost::filesystem::path full_path(boost::filesystem::current_path()); - const boost::filesystem::path p(gpx_base_path); - if (!boost::filesystem::exists(p)) + fs::path full_path(fs::current_path()); + const fs::path p(gpx_base_path); + if (!fs::exists(p)) { std::string new_folder; - for (auto& folder : boost::filesystem::path(gpx_base_path)) + for (auto& folder : fs::path(gpx_base_path)) { new_folder += folder.string(); - boost::system::error_code ec; - if (!boost::filesystem::exists(new_folder)) + errorlib::error_code ec; + if (!fs::exists(new_folder)) { - if (!boost::filesystem::create_directory(new_folder, ec)) + if (!fs::create_directory(new_folder, ec)) { std::cout << "Could not create the " << new_folder << " folder." << std::endl; gpx_base_path = full_path.string(); } } - new_folder += boost::filesystem::path::preferred_separator; + new_folder += fs::path::preferred_separator; } } else @@ -80,7 +93,7 @@ Gpx_Printer::Gpx_Printer(const std::string& base_path) std::cout << "GPX files will be stored at " << gpx_base_path << std::endl; } - gpx_base_path = gpx_base_path + boost::filesystem::path::preferred_separator; + gpx_base_path = gpx_base_path + fs::path::preferred_separator; } diff --git a/src/algorithms/PVT/libs/kml_printer.cc b/src/algorithms/PVT/libs/kml_printer.cc index e1335490c..2435f7e57 100644 --- a/src/algorithms/PVT/libs/kml_printer.cc +++ b/src/algorithms/PVT/libs/kml_printer.cc @@ -33,17 +33,34 @@ #include "kml_printer.h" #include "rtklib_solver.h" #include +#if HAS_STD_FILESYSTEM +#include +#include +#else #include // for create_directories, exists #include // for path, operator<< #include // for filesystem #include // for error_code +#endif #include #include // for remove +#include // for mkstemp +#include // for strncpy #include // for tm #include // for exception #include // for cout, cerr #include #include +#include // for S_IXUSR | S_IRWXG | S_IRWXO +#include //for mode_t + +#if HAS_STD_FILESYSTEM +namespace fs = std::filesystem; +namespace errorlib = std; +#else +namespace fs = boost::filesystem; +namespace errorlib = boost::system; +#endif Kml_Printer::Kml_Printer(const std::string& base_path) @@ -51,24 +68,24 @@ Kml_Printer::Kml_Printer(const std::string& base_path) positions_printed = false; indent = " "; kml_base_path = base_path; - boost::filesystem::path full_path(boost::filesystem::current_path()); - const boost::filesystem::path p(kml_base_path); - if (!boost::filesystem::exists(p)) + fs::path full_path(fs::current_path()); + const fs::path p(kml_base_path); + if (!fs::exists(p)) { std::string new_folder; - for (auto& folder : boost::filesystem::path(kml_base_path)) + for (auto& folder : fs::path(kml_base_path)) { new_folder += folder.string(); - boost::system::error_code ec; - if (!boost::filesystem::exists(new_folder)) + errorlib::error_code ec; + if (!fs::exists(new_folder)) { - if (!boost::filesystem::create_directory(new_folder, ec)) + if (!fs::create_directory(new_folder, ec)) { std::cout << "Could not create the " << new_folder << " folder." << std::endl; kml_base_path = full_path.string(); } } - new_folder += boost::filesystem::path::preferred_separator; + new_folder += fs::path::preferred_separator; } } else @@ -80,13 +97,22 @@ Kml_Printer::Kml_Printer(const std::string& base_path) std::cout << "KML files will be stored at " << kml_base_path << std::endl; } - kml_base_path = kml_base_path + boost::filesystem::path::preferred_separator; + kml_base_path = kml_base_path + fs::path::preferred_separator; - boost::filesystem::path tmp_base_path = boost::filesystem::temp_directory_path(); - boost::filesystem::path tmp_filename = boost::filesystem::unique_path(); - boost::filesystem::path tmp_file = tmp_base_path / tmp_filename; + char tmp_filename_[] = "/tmp/file.XXXXXX"; + mode_t mask = umask(S_IXUSR | S_IRWXG | S_IRWXO); + int fd = mkstemp(tmp_filename_); + if (fd == -1) + { + std::cerr << "Error in KML printer: failed to create temporary file" << std::endl; + } + else + { + close(fd); + } + fs::path tmp_filename = fs::path(tmp_filename_); - tmp_file_str = tmp_file.string(); + tmp_file_str = tmp_filename.string(); point_id = 0; } diff --git a/src/algorithms/PVT/libs/nmea_printer.cc b/src/algorithms/PVT/libs/nmea_printer.cc index 9186d48e0..0e7127003 100644 --- a/src/algorithms/PVT/libs/nmea_printer.cc +++ b/src/algorithms/PVT/libs/nmea_printer.cc @@ -36,10 +36,15 @@ #include "nmea_printer.h" #include "rtklib_solution.h" #include "rtklib_solver.h" +#if HAS_STD_FILESYSTEM +#include +#include +#else #include // for create_directories, exists #include // for path, operator<< #include // for filesystem #include // for error_code +#endif #include #include #include @@ -47,6 +52,14 @@ #include // for cout, cerr #include +#if HAS_STD_FILESYSTEM +namespace fs = std::filesystem; +namespace errorlib = std; +#else +namespace fs = boost::filesystem; +namespace errorlib = boost::system; +#endif + Nmea_Printer::Nmea_Printer(const std::string& filename, bool flag_nmea_output_file, bool flag_nmea_tty_port, std::string nmea_dump_devname, const std::string& base_path) { @@ -54,24 +67,24 @@ Nmea_Printer::Nmea_Printer(const std::string& filename, bool flag_nmea_output_fi d_flag_nmea_output_file = flag_nmea_output_file; if (d_flag_nmea_output_file == true) { - boost::filesystem::path full_path(boost::filesystem::current_path()); - const boost::filesystem::path p(nmea_base_path); - if (!boost::filesystem::exists(p)) + fs::path full_path(fs::current_path()); + const fs::path p(nmea_base_path); + if (!fs::exists(p)) { std::string new_folder; - for (auto& folder : boost::filesystem::path(nmea_base_path)) + for (auto& folder : fs::path(nmea_base_path)) { new_folder += folder.string(); - boost::system::error_code ec; - if (!boost::filesystem::exists(new_folder)) + errorlib::error_code ec; + if (!fs::exists(new_folder)) { - if (!boost::filesystem::create_directory(new_folder, ec)) + if (!fs::create_directory(new_folder, ec)) { std::cout << "Could not create the " << new_folder << " folder." << std::endl; nmea_base_path = full_path.string(); } } - new_folder += boost::filesystem::path::preferred_separator; + new_folder += fs::path::preferred_separator; } } else @@ -84,7 +97,7 @@ Nmea_Printer::Nmea_Printer(const std::string& filename, bool flag_nmea_output_fi std::cout << "NMEA files will be stored at " << nmea_base_path << std::endl; } - nmea_base_path = nmea_base_path + boost::filesystem::path::preferred_separator; + nmea_base_path = nmea_base_path + fs::path::preferred_separator; nmea_filename = nmea_base_path + filename; diff --git a/src/algorithms/PVT/libs/rinex_printer.cc b/src/algorithms/PVT/libs/rinex_printer.cc index bf9b73dbd..7da65c565 100644 --- a/src/algorithms/PVT/libs/rinex_printer.cc +++ b/src/algorithms/PVT/libs/rinex_printer.cc @@ -53,9 +53,15 @@ #include #include #include +#if HAS_STD_FILESYSTEM +#include +#include +#else #include // for create_directories, exists #include // for path, operator<< #include // for filesystem +#include // for error_code +#endif #include #include // for min and max #include // for floor @@ -69,28 +75,36 @@ #include #include +#if HAS_STD_FILESYSTEM +namespace fs = std::filesystem; +namespace errorlib = std; +#else +namespace fs = boost::filesystem; +namespace errorlib = boost::system; +#endif + Rinex_Printer::Rinex_Printer(int32_t conf_version, const std::string& base_path) { std::string base_rinex_path = base_path; - boost::filesystem::path full_path(boost::filesystem::current_path()); - const boost::filesystem::path p(base_rinex_path); - if (!boost::filesystem::exists(p)) + fs::path full_path(fs::current_path()); + const fs::path p(base_rinex_path); + if (!fs::exists(p)) { std::string new_folder; - for (auto& folder : boost::filesystem::path(base_rinex_path)) + for (auto& folder : fs::path(base_rinex_path)) { new_folder += folder.string(); - boost::system::error_code ec; - if (!boost::filesystem::exists(new_folder)) + errorlib::error_code ec; + if (!fs::exists(new_folder)) { - if (!boost::filesystem::create_directory(new_folder, ec)) + if (!fs::create_directory(new_folder, ec)) { std::cout << "Could not create the " << new_folder << " folder." << std::endl; base_rinex_path = full_path.string(); } } - new_folder += boost::filesystem::path::preferred_separator; + new_folder += fs::path::preferred_separator; } } else @@ -102,13 +116,13 @@ Rinex_Printer::Rinex_Printer(int32_t conf_version, const std::string& base_path) std::cout << "RINEX files will be stored at " << base_rinex_path << std::endl; } - navfilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_GPS_NAV"); - obsfilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_OBS"); - sbsfilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_SBAS"); - navGalfilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_GAL_NAV"); - navMixfilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_MIXED_NAV"); - navGlofilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_GLO_NAV"); - navBdsfilename = base_rinex_path + boost::filesystem::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_BDS_NAV"); + navfilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_GPS_NAV"); + obsfilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_OBS"); + sbsfilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_SBAS"); + navGalfilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_GAL_NAV"); + navMixfilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_MIXED_NAV"); + navGlofilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_GLO_NAV"); + navBdsfilename = base_rinex_path + fs::path::preferred_separator + Rinex_Printer::createFilename("RINEX_FILE_TYPE_BDS_NAV"); Rinex_Printer::navFile.open(navfilename, std::ios::out | std::ios::in | std::ios::app); Rinex_Printer::obsFile.open(obsfilename, std::ios::out | std::ios::in | std::ios::app); diff --git a/src/algorithms/PVT/libs/rtcm_printer.cc b/src/algorithms/PVT/libs/rtcm_printer.cc index fce92af08..bccec8dce 100644 --- a/src/algorithms/PVT/libs/rtcm_printer.cc +++ b/src/algorithms/PVT/libs/rtcm_printer.cc @@ -39,11 +39,16 @@ #include "gps_cnav_ephemeris.h" #include "gps_ephemeris.h" #include "rtcm.h" +#if HAS_STD_FILESYSTEM +#include +#include +#else #include #include // for create_directories, exists #include // for path, operator<< #include // for filesystem #include // for error_codes +#endif #include #include // for remove #include // for tm @@ -53,6 +58,14 @@ #include // for tcgetattr #include // for close, write +#if HAS_STD_FILESYSTEM +namespace fs = std::filesystem; +namespace errorlib = std; +#else +namespace fs = boost::filesystem; +namespace errorlib = boost::system; +#endif + Rtcm_Printer::Rtcm_Printer(const std::string& filename, bool flag_rtcm_file_dump, bool flag_rtcm_server, bool flag_rtcm_tty_port, uint16_t rtcm_tcp_port, uint16_t rtcm_station_id, const std::string& rtcm_dump_devname, bool time_tag_name, const std::string& base_path) { @@ -62,24 +75,24 @@ Rtcm_Printer::Rtcm_Printer(const std::string& filename, bool flag_rtcm_file_dump rtcm_base_path = base_path; if (d_rtcm_file_dump) { - boost::filesystem::path full_path(boost::filesystem::current_path()); - const boost::filesystem::path p(rtcm_base_path); - if (!boost::filesystem::exists(p)) + fs::path full_path(fs::current_path()); + const fs::path p(rtcm_base_path); + if (!fs::exists(p)) { std::string new_folder; - for (auto& folder : boost::filesystem::path(rtcm_base_path)) + for (auto& folder : fs::path(rtcm_base_path)) { new_folder += folder.string(); - boost::system::error_code ec; - if (!boost::filesystem::exists(new_folder)) + errorlib::error_code ec; + if (!fs::exists(new_folder)) { - if (!boost::filesystem::create_directory(new_folder, ec)) + if (!fs::create_directory(new_folder, ec)) { std::cout << "Could not create the " << new_folder << " folder." << std::endl; rtcm_base_path = full_path.string(); } } - new_folder += boost::filesystem::path::preferred_separator; + new_folder += fs::path::preferred_separator; } } else @@ -91,7 +104,7 @@ Rtcm_Printer::Rtcm_Printer(const std::string& filename, bool flag_rtcm_file_dump std::cout << "RTCM binary file will be stored at " << rtcm_base_path << std::endl; } - rtcm_base_path = rtcm_base_path + boost::filesystem::path::preferred_separator; + rtcm_base_path = rtcm_base_path + fs::path::preferred_separator; } if (time_tag_name) diff --git a/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt b/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt index a23bfba82..dfec5b089 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/acquisition/gnuradio_blocks/CMakeLists.txt @@ -66,6 +66,13 @@ source_group(Headers FILES ${ACQ_GR_BLOCKS_HEADERS}) add_library(acquisition_gr_blocks ${ACQ_GR_BLOCKS_SOURCES} ${ACQ_GR_BLOCKS_HEADERS}) +if(${FILESYSTEM_FOUND}) + target_compile_definitions(acquisition_gr_blocks PRIVATE -DHAS_STD_FILESYSTEM=1) + target_link_libraries(acquisition_gr_blocks PRIVATE std::filesystem) +else() + target_link_libraries(acquisition_gr_blocks PRIVATE Boost::filesystem) +endif() + target_link_libraries(acquisition_gr_blocks PUBLIC Gnuradio::runtime @@ -76,7 +83,6 @@ target_link_libraries(acquisition_gr_blocks core_system_parameters ${OPT_LIBRARIES} PRIVATE - Boost::filesystem Gflags::gflags Glog::glog Matio::matio diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc index a13794974..abb00ea79 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition.cc @@ -39,7 +39,11 @@ #include "gnss_frequencies.h" #include "gnss_sdr_create_directory.h" #include "gnss_synchro.h" +#if HAS_STD_FILESYSTEM +#include +#else #include +#endif #include #include #include @@ -53,6 +57,12 @@ #include #include +#if HAS_STD_FILESYSTEM +namespace fs = std::filesystem; +#else +namespace fs = boost::filesystem; +#endif + pcps_acquisition_sptr pcps_make_acquisition(const Acq_Conf& conf_) { @@ -184,7 +194,7 @@ pcps_acquisition::pcps_acquisition(const Acq_Conf& conf_) : gr::block("pcps_acqu { d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of('.')); } - d_dump_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename; + d_dump_filename = dump_path + fs::path::preferred_separator + d_dump_filename; // create directory if (!gnss_sdr_create_directory(dump_path)) { diff --git a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc index eab92d8a8..051c81130 100644 --- a/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc +++ b/src/algorithms/acquisition/gnuradio_blocks/pcps_acquisition_fine_doppler_cc.cc @@ -34,7 +34,11 @@ #include "GPS_L1_CA.h" #include "gnss_sdr_create_directory.h" #include "gps_sdr_signal_processing.h" +#if HAS_STD_FILESYSTEM +#include +#else #include +#endif #include #include #include @@ -43,6 +47,12 @@ #include // std::rotate, std::fill_n #include +#if HAS_STD_FILESYSTEM +namespace fs = std::filesystem; +#else +namespace fs = boost::filesystem; +#endif + pcps_acquisition_fine_doppler_cc_sptr pcps_make_acquisition_fine_doppler_cc(const Acq_Conf &conf_) { @@ -107,7 +117,7 @@ pcps_acquisition_fine_doppler_cc::pcps_acquisition_fine_doppler_cc(const Acq_Con { d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of('.')); } - d_dump_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename; + d_dump_filename = dump_path + fs::path::preferred_separator + d_dump_filename; // create directory if (!gnss_sdr_create_directory(dump_path)) { diff --git a/src/algorithms/libs/CMakeLists.txt b/src/algorithms/libs/CMakeLists.txt index a9c292c50..4dc71a6bb 100644 --- a/src/algorithms/libs/CMakeLists.txt +++ b/src/algorithms/libs/CMakeLists.txt @@ -88,6 +88,13 @@ source_group(Headers FILES ${GNSS_SPLIBS_HEADERS}) add_library(algorithms_libs ${GNSS_SPLIBS_SOURCES} ${GNSS_SPLIBS_HEADERS}) +if(${FILESYSTEM_FOUND}) + target_compile_definitions(algorithms_libs PRIVATE -DHAS_STD_FILESYSTEM=1) + target_link_libraries(algorithms_libs PRIVATE std::filesystem) +else() + target_link_libraries(algorithms_libs PRIVATE Boost::filesystem Boost::system) +endif() + target_link_libraries(algorithms_libs PUBLIC Armadillo::armadillo @@ -100,7 +107,6 @@ target_link_libraries(algorithms_libs core_system_parameters Volk::volk ${ORC_LIBRARIES} Volkgnsssdr::volkgnsssdr - Boost::filesystem Glog::glog ) @@ -133,11 +139,16 @@ source_group(Headers FILES gnss_sdr_flags.h) add_library(gnss_sdr_flags gnss_sdr_flags.cc gnss_sdr_flags.h) +if(${FILESYSTEM_FOUND}) + target_compile_definitions(gnss_sdr_flags PRIVATE -DHAS_STD_FILESYSTEM=1) + target_link_libraries(gnss_sdr_flags PRIVATE std::filesystem) +else() + target_link_libraries(gnss_sdr_flags PRIVATE Boost::filesystem) +endif() + target_link_libraries(gnss_sdr_flags PUBLIC Gflags::gflags - PRIVATE - Boost::filesystem ) if(${GFLAGS_GREATER_20}) diff --git a/src/algorithms/libs/gnss_sdr_create_directory.cc b/src/algorithms/libs/gnss_sdr_create_directory.cc index 2a3c66cad..325f5ebac 100644 --- a/src/algorithms/libs/gnss_sdr_create_directory.cc +++ b/src/algorithms/libs/gnss_sdr_create_directory.cc @@ -29,35 +29,46 @@ */ #include "gnss_sdr_create_directory.h" +#if HAS_STD_FILESYSTEM +#include +#include +#else #include // for create_directories, exists #include // for path, operator<< #include // for filesystem #include // for error_code -#include // for exception -#include // for ofstream +#endif +#include // for exception +#include // for ofstream + +#if HAS_STD_FILESYSTEM +namespace fs = std::filesystem; +namespace errorlib = std; +#else +namespace fs = boost::filesystem; +namespace errorlib = boost::system; +#endif bool gnss_sdr_create_directory(const std::string& foldername) { std::string new_folder; - for (auto& folder : boost::filesystem::path(foldername)) + for (auto& folder : fs::path(foldername)) { new_folder += folder.string(); - boost::system::error_code ec; - if (!boost::filesystem::exists(new_folder)) + errorlib::error_code ec; + if (!fs::exists(new_folder)) { - try + if (!fs::create_directory(new_folder, ec)) { - if (!boost::filesystem::create_directory(new_folder, ec)) - { - return false; - } + return false; } - catch (std::exception& e) + + if (static_cast(ec)) { return false; } } - new_folder += boost::filesystem::path::preferred_separator; + new_folder += fs::path::preferred_separator; } // Check if we have writing permissions @@ -67,19 +78,16 @@ bool gnss_sdr_create_directory(const std::string& foldername) if (os_test_file.is_open()) { - boost::system::error_code ec; + errorlib::error_code ec; os_test_file.close(); - try - { - boost::filesystem::remove(test_file, ec); - } - catch (std::exception& e) + + fs::remove(test_file, ec); + if (static_cast(ec)) { return false; } return true; } - os_test_file.close(); return false; } diff --git a/src/algorithms/libs/gnss_sdr_flags.cc b/src/algorithms/libs/gnss_sdr_flags.cc index e44812281..756d428f4 100644 --- a/src/algorithms/libs/gnss_sdr_flags.cc +++ b/src/algorithms/libs/gnss_sdr_flags.cc @@ -30,11 +30,22 @@ #include "gnss_sdr_flags.h" +#if HAS_STD_FILESYSTEM +#include +#else #include // for exists +#endif #include #include #include +#if HAS_STD_FILESYSTEM +namespace fs = std::filesystem; +#else +namespace fs = boost::filesystem; +#endif + + DEFINE_string(c, "-", "Path to the configuration file (if set, overrides --config_file)."); DEFINE_string(config_file, std::string(GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/default.conf"), @@ -69,7 +80,7 @@ DEFINE_double(pll_bw_hz, 0.0, "If defined, bandwidth of the PLL low pass filter, static bool ValidateC(const char* flagname, const std::string& value) { - if (boost::filesystem::exists(value) or value == "-") + if (fs::exists(value) or value == "-") { // value is ok return true; } @@ -80,7 +91,7 @@ static bool ValidateC(const char* flagname, const std::string& value) static bool ValidateConfigFile(const char* flagname, const std::string& value) { - if (boost::filesystem::exists(value) or value == std::string(GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/default.conf")) + if (fs::exists(value) or value == std::string(GNSSSDR_INSTALL_DIR "/share/gnss-sdr/conf/default.conf")) { // value is ok return true; } @@ -91,7 +102,7 @@ static bool ValidateConfigFile(const char* flagname, const std::string& value) static bool ValidateS(const char* flagname, const std::string& value) { - if (boost::filesystem::exists(value) or value == "-") + if (fs::exists(value) or value == "-") { // value is ok return true; } @@ -102,7 +113,7 @@ static bool ValidateS(const char* flagname, const std::string& value) static bool ValidateSignalSource(const char* flagname, const std::string& value) { - if (boost::filesystem::exists(value) or value == "-") + if (fs::exists(value) or value == "-") { // value is ok return true; } diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/FindFILESYSTEM.cmake b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/FindFILESYSTEM.cmake index 131d2ec1f..e77017e76 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/FindFILESYSTEM.cmake +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/cmake/Modules/FindFILESYSTEM.cmake @@ -129,6 +129,12 @@ set(CMAKE_REQUIRED_QUIET ${FILESYSTEM_FIND_QUIETLY}) # All of our tests require C++17 or later set(CMAKE_CXX_STANDARD 17) +if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER "9.0.0")) + set(CMAKE_REQUIRED_FLAGS "-std=c++17") +endif() +if((CMAKE_CXX_COMPILER_ID STREQUAL "Clang") AND NOT (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.99")) + set(CMAKE_REQUIRED_FLAGS "-std=c++17") +endif() # Normalize and check the component list we were given set(want_components ${FILESYSTEM_FIND_COMPONENTS}) @@ -236,6 +242,10 @@ if(CXX_FILESYSTEM_HAVE_FS) endif() endif() +if(NOT ${_found}) + set(CMAKE_CXX_STANDARD 11) +endif() + cmake_pop_check_state() set(FILESYSTEM_FOUND ${_found} CACHE BOOL "TRUE if we can compile and link a program using std::filesystem" FORCE) diff --git a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt index 90bc7236b..c1d7bd7dc 100644 --- a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt @@ -28,6 +28,13 @@ source_group(Headers FILES ${OBS_GR_BLOCKS_HEADERS}) add_library(obs_gr_blocks ${OBS_GR_BLOCKS_SOURCES} ${OBS_GR_BLOCKS_HEADERS}) +if(${FILESYSTEM_FOUND}) + target_compile_definitions(obs_gr_blocks PRIVATE -DHAS_STD_FILESYSTEM=1) + target_link_libraries(obs_gr_blocks PRIVATE std::filesystem) +else() + target_link_libraries(obs_gr_blocks PRIVATE Boost::filesystem) +endif() + target_include_directories(obs_gr_blocks PUBLIC ${CMAKE_SOURCE_DIR}/src/algorithms/libs @@ -42,7 +49,6 @@ target_link_libraries(obs_gr_blocks core_system_parameters Gflags::gflags Glog::glog - Boost::filesystem Matio::matio ) diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc index 24c53587c..36d977fdd 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc @@ -35,7 +35,6 @@ #include "gnss_circular_deque.h" #include "gnss_sdr_create_directory.h" #include "gnss_synchro.h" -#include #include #include #include @@ -46,6 +45,13 @@ #include // for numeric_limits #include // for move +#if HAS_STD_FILESYSTEM +#include +namespace fs = std::filesystem; +#else +#include +namespace fs = boost::filesystem; +#endif hybrid_observables_gs_sptr hybrid_observables_gs_make(unsigned int nchannels_in, unsigned int nchannels_out, bool dump, bool dump_mat, std::string dump_filename) { @@ -125,7 +131,7 @@ hybrid_observables_gs::hybrid_observables_gs(uint32_t nchannels_in, d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of('.')); } d_dump_filename.append(".dat"); - d_dump_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename; + d_dump_filename = dump_path + fs::path::preferred_separator + d_dump_filename; // create directory if (!gnss_sdr_create_directory(dump_path)) { diff --git a/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt b/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt index 48da0fc1b..35d1a71fb 100644 --- a/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt @@ -80,6 +80,13 @@ add_library(tracking_gr_blocks ${TRACKING_GR_BLOCKS_HEADERS} ) +if(${FILESYSTEM_FOUND}) + target_compile_definitions(tracking_gr_blocks PRIVATE -DHAS_STD_FILESYSTEM=1) + target_link_libraries(tracking_gr_blocks PRIVATE std::filesystem) +else() + target_link_libraries(tracking_gr_blocks PRIVATE Boost::filesystem) +endif() + target_link_libraries(tracking_gr_blocks PUBLIC Boost::boost diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc index 61e407656..2e9610bf5 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -54,7 +54,6 @@ #include "gps_sdr_signal_processing.h" #include "lock_detectors.h" #include "tracking_discriminators.h" -#include #include #include // for io_signature #include // for scoped_lock @@ -67,6 +66,14 @@ #include // for cout, cerr #include +#if HAS_STD_FILESYSTEM +#include +namespace fs = std::filesystem; +#else +#include +namespace fs = boost::filesystem; +#endif + dll_pll_veml_tracking_sptr dll_pll_veml_make_tracking(const Dll_Pll_Conf &conf_) { @@ -497,7 +504,7 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of('.')); } - d_dump_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename; + d_dump_filename = dump_path + fs::path::preferred_separator + d_dump_filename; // create directory if (!gnss_sdr_create_directory(dump_path)) { diff --git a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc index 43cc30e7a..5ee4bee2a 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking_fpga.cc @@ -46,7 +46,6 @@ #include "gnss_synchro.h" #include "lock_detectors.h" #include "tracking_discriminators.h" -#include #include #include #include @@ -60,6 +59,15 @@ #include #include +#if HAS_STD_FILESYSTEM +#include +namespace fs = std::filesystem; +#else +#include +namespace fs = boost::filesystem; +#endif + + dll_pll_veml_tracking_fpga_sptr dll_pll_veml_make_tracking_fpga(const Dll_Pll_Conf_Fpga &conf_) { return dll_pll_veml_tracking_fpga_sptr(new dll_pll_veml_tracking_fpga(conf_)); @@ -413,7 +421,7 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & d_dump_filename = d_dump_filename.substr(0, d_dump_filename.find_last_of('.')); } - d_dump_filename = dump_path + boost::filesystem::path::preferred_separator + d_dump_filename; + d_dump_filename = dump_path + fs::path::preferred_separator + d_dump_filename; // create directory if (!gnss_sdr_create_directory(dump_path)) { diff --git a/src/main/CMakeLists.txt b/src/main/CMakeLists.txt index 4561b7119..96e1d3c97 100644 --- a/src/main/CMakeLists.txt +++ b/src/main/CMakeLists.txt @@ -19,10 +19,15 @@ add_executable(gnss-sdr ${CMAKE_CURRENT_SOURCE_DIR}/main.cc) +if(${FILESYSTEM_FOUND}) + target_compile_definitions(gnss-sdr PRIVATE -DHAS_STD_FILESYSTEM=1) + target_link_libraries(gnss-sdr PRIVATE std::filesystem) +else() + target_link_libraries(gnss-sdr PRIVATE Boost::filesystem Boost::system) +endif() + target_link_libraries(gnss-sdr PUBLIC - Boost::filesystem - Boost::system Gflags::gflags Glog::glog Threads::Threads diff --git a/src/main/main.cc b/src/main/main.cc index 696ff412b..cf01b30b5 100644 --- a/src/main/main.cc +++ b/src/main/main.cc @@ -45,23 +45,35 @@ #include "gps_acq_assist.h" #include // for diagnostic_informatio #include // for exception -#include // for create_directories, exists -#include // for path, operator<< -#include // for error_code #include // for thread_resource_error -#include // for ShutDownCommandLineFlags -#include // for FLAGS_log_dir -#include // for time_point -#include // for exception -#include // for operator<<, endl -#include // for unique_ptr -#include // for string +#if HAS_STD_FILESYSTEM +#include +#include +#else +#include // for create_directories, exists +#include // for path, operator<< +#include // for error_code +#endif +#include // for ShutDownCommandLineFlags +#include // for FLAGS_log_dir +#include // for time_point +#include // for exception +#include // for operator<<, endl +#include // for unique_ptr +#include // for string #if CUDA_GPU_ACCEL // For the CUDA runtime routines (prefixed with "cuda_") #include #endif +#if HAS_STD_FILESYSTEM +namespace fs = std::filesystem; +namespace errorlib = std; +#else +namespace fs = boost::filesystem; +namespace errorlib = boost::system; +#endif /* * Concurrent queues that communicates the Telemetry Decoder @@ -103,22 +115,22 @@ int main(int argc, char** argv) if (FLAGS_log_dir.empty()) { std::cout << "Logging will be written at " - << boost::filesystem::temp_directory_path() + << fs::temp_directory_path() << std::endl << "Use gnss-sdr --log_dir=/path/to/log to change that." << std::endl; } else { - const boost::filesystem::path p(FLAGS_log_dir); - if (!boost::filesystem::exists(p)) + const fs::path p(FLAGS_log_dir); + if (!fs::exists(p)) { std::cout << "The path " << FLAGS_log_dir << " does not exist, attempting to create it." << std::endl; - boost::system::error_code ec; - if (!boost::filesystem::create_directory(p, ec)) + errorlib::error_code ec; + if (!fs::create_directory(p, ec)) { std::cerr << "Could not create the " << FLAGS_log_dir << " folder. GNSS-SDR program ended." << std::endl; google::ShutDownCommandLineFlags(); diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 3053df1d4..4bb206ad0 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -237,7 +237,7 @@ if(ENABLE_UNIT_TESTING_EXTRA OR ENABLE_SYSTEM_TESTING_EXTRA OR ENABLE_FPGA) if(NOT GPSTK_FOUND OR ENABLE_OWN_GPSTK) message(STATUS " GPSTk v${GNSSSDR_GPSTK_LOCAL_VERSION} will be automatically downloaded and built when doing 'make'.") if("${TOOLCHAIN_ARG}" STREQUAL "") - set(TOOLCHAIN_ARG "-DCMAKE_CXX_FLAGS=\"-Wno-deprecated\"") + set(TOOLCHAIN_ARG "-DCMAKE_CXX_FLAGS=-Wno-deprecated") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") endif() include(GNUInstallDirs) @@ -354,11 +354,15 @@ include_directories(${LIST_INCLUDE_DIRS}) ################################################################################ if(ENABLE_UNIT_TESTING) add_executable(run_tests ${CMAKE_CURRENT_SOURCE_DIR}/test_main.cc) + if(${FILESYSTEM_FOUND}) + target_compile_definitions(run_tests PRIVATE -DHAS_STD_FILESYSTEM=1) + target_link_libraries(run_tests PRIVATE std::filesystem) + else() + target_link_libraries(run_tests PRIVATE Boost::filesystem Boost::system) + endif() target_link_libraries(run_tests PUBLIC - Boost::filesystem - Boost::system Boost::thread Armadillo::armadillo Gflags::gflags @@ -441,11 +445,15 @@ if(ENABLE_FPGA) ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test_fpga.cc ) + if(${FILESYSTEM_FOUND}) + target_compile_definitions(gps_l1_ca_dll_pll_tracking_test_fpga PRIVATE -DHAS_STD_FILESYSTEM=1) + target_link_libraries(gps_l1_ca_dll_pll_tracking_test_fpga PRIVATE std::filesystem) + else() + target_link_libraries(gps_l1_ca_dll_pll_tracking_test_fpga PRIVATE Boost::filesystem Boost::system) + endif() target_link_libraries(gps_l1_ca_dll_pll_tracking_test_fpga PUBLIC Armadillo::armadillo - Boost::filesystem - Boost::system Boost::thread Gflags::gflags Glog::glog @@ -482,6 +490,12 @@ function(add_system_test executable) execute_process(COMMAND ${CMAKE_COMMAND} -E touch ${SYSTEM_TEST_SOURCES}) endif() add_executable(${executable} ${SYSTEM_TEST_SOURCES}) + if(${FILESYSTEM_FOUND}) + target_compile_definitions(${executable} PRIVATE -DHAS_STD_FILESYSTEM=1) + target_link_libraries(${executable} PRIVATE std::filesystem) + else() + target_link_libraries(${executable} PRIVATE Boost::filesystem Boost::system) + endif() target_include_directories(${executable} PUBLIC ${OPT_INCLUDES_} ${CMAKE_SOURCES_DIR}/src/algorithms/libs) target_link_libraries(${executable} PUBLIC ${OPT_LIBS_} algorithms_libs) @@ -521,7 +535,7 @@ if(ENABLE_SYSTEM_TESTING) add_definitions(-DHOST_SYSTEM="${HOST_SYSTEM}") #### TTFF - set(OPT_LIBS_ Boost::filesystem Boost::system Boost::thread Boost::date_time + set(OPT_LIBS_ Boost::thread Boost::date_time Threads::Threads Gflags::gflags Glog::glog Gnuradio::runtime GTest::GTest GTest::Main Gnuradio::blocks Gnuradio::filter @@ -532,7 +546,7 @@ if(ENABLE_SYSTEM_TESTING) if(ENABLE_SYSTEM_TESTING_EXTRA) #### POSITION_TEST - set(OPT_LIBS_ Boost::filesystem Boost::system Boost::thread + set(OPT_LIBS_ Boost::thread Threads::Threads Gflags::gflags Glog::glog GTest::GTest GTest::Main Gnuradio::runtime Gnuradio::blocks Gnuradio::filter @@ -569,11 +583,14 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/control-plane/gnss_flowgraph_test.cc ) - + if(${FILESYSTEM_FOUND}) + target_compile_definitions(flowgraph_test PRIVATE -DHAS_STD_FILESYSTEM=1) + target_link_libraries(flowgraph_test PRIVATE std::filesystem) + else() + target_link_libraries(flowgraph_test PRIVATE Boost::filesystem Boost::system) + endif() target_link_libraries(flowgraph_test PUBLIC - Boost::filesystem - Boost::system Boost::thread Gflags::gflags Glog::glog @@ -615,11 +632,14 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/adapter/adapter_test.cc ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/control-plane/gnss_block_factory_test.cc ) - + if(${FILESYSTEM_FOUND}) + target_compile_definitions(gnss_block_test PRIVATE -DHAS_STD_FILESYSTEM=1) + target_link_libraries(gnss_block_test PRIVATE std::filesystem) + else() + target_link_libraries(gnss_block_test PRIVATE Boost::filesystem Boost::system) + endif() target_link_libraries(gnss_block_test PUBLIC - Boost::filesystem - Boost::system Boost::thread Gflags::gflags Glog::glog @@ -659,11 +679,14 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/sources/unpack_2bit_samples_test.cc ) - + if(${FILESYSTEM_FOUND}) + target_compile_definitions(gnuradio_block_test PRIVATE -DHAS_STD_FILESYSTEM=1) + target_link_libraries(gnuradio_block_test PRIVATE std::filesystem) + else() + target_link_libraries(gnuradio_block_test PRIVATE Boost::filesystem Boost::system) + endif() target_link_libraries(gnuradio_block_test PUBLIC - Boost::filesystem - Boost::system Boost::thread Gflags::gflags Glog::glog @@ -715,11 +738,14 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) ${CMAKE_CURRENT_SOURCE_DIR}/single_test_main.cc ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc ) - + if(${FILESYSTEM_FOUND}) + target_compile_definitions(acq_test PRIVATE -DHAS_STD_FILESYSTEM=1) + target_link_libraries(acq_test PRIVATE std::filesystem) + else() + target_link_libraries(acq_test PRIVATE Boost::filesystem Boost::system) + endif() target_link_libraries(acq_test PUBLIC - Boost::filesystem - Boost::system Boost::thread Gflags::gflags Glog::glog @@ -756,11 +782,15 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/tracking/cpu_multicorrelator_real_codes_test.cc ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/signal-processing-blocks/tracking/bayesian_estimation_test.cc ) + if(${FILESYSTEM_FOUND}) + target_compile_definitions(trk_test PRIVATE -DHAS_STD_FILESYSTEM=1) + target_link_libraries(trk_test PRIVATE std::filesystem) + else() + target_link_libraries(trk_test PRIVATE Boost::filesystem Boost::system) + endif() target_link_libraries(trk_test PUBLIC - Boost::filesystem - Boost::system Boost::thread Gflags::gflags Glog::glog @@ -793,11 +823,15 @@ if(NOT ENABLE_PACKAGING AND NOT ENABLE_FPGA) ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/control-plane/control_message_factory_test.cc ${CMAKE_CURRENT_SOURCE_DIR}/unit-tests/control-plane/control_thread_test.cc ) + if(${FILESYSTEM_FOUND}) + target_compile_definitions(control_thread_test PRIVATE -DHAS_STD_FILESYSTEM=1) + target_link_libraries(control_thread_test PRIVATE std::filesystem) + else() + target_link_libraries(control_thread_test PRIVATE Boost::filesystem Boost::system) + endif() target_link_libraries(control_thread_test PUBLIC - Boost::filesystem - Boost::system Boost::thread Gflags::gflags Glog::glog diff --git a/src/tests/system-tests/position_test.cc b/src/tests/system-tests/position_test.cc index 1365b4302..364553dab 100644 --- a/src/tests/system-tests/position_test.cc +++ b/src/tests/system-tests/position_test.cc @@ -48,7 +48,6 @@ #include "test_flags.h" #include "tracking_tests_flags.h" //acquisition resampler #include -#include #include #include #include @@ -59,6 +58,14 @@ #include #include +#if HAS_STD_FILESYSTEM +#include +namespace fs = std::filesystem; +#else +#include +namespace fs = boost::filesystem; +#endif + // For GPS NAVIGATION (L1) Concurrent_Queue global_gps_acq_assist_queue; Concurrent_Map global_gps_acq_assist_map; @@ -843,8 +850,8 @@ void PositionSystemTest::print_results(const arma::mat& R_eb_enu) try { - boost::filesystem::path p(gnuplot_executable); - boost::filesystem::path dir = p.parent_path(); + fs::path p(gnuplot_executable); + fs::path dir = p.parent_path(); const std::string& gnuplot_path = dir.native(); Gnuplot::set_GNUPlotPath(gnuplot_path); diff --git a/src/tests/unit-tests/arithmetic/fft_length_test.cc b/src/tests/unit-tests/arithmetic/fft_length_test.cc index c8eb8354d..5b2583758 100644 --- a/src/tests/unit-tests/arithmetic/fft_length_test.cc +++ b/src/tests/unit-tests/arithmetic/fft_length_test.cc @@ -31,13 +31,19 @@ #include "gnuplot_i.h" #include "test_flags.h" -#include #include #include #include #include #include +#if HAS_STD_FILESYSTEM +#include +namespace fs = std::filesystem; +#else +#include +namespace fs = boost::filesystem; +#endif DEFINE_int32(fft_iterations_test, 1000, "Number of averaged iterations in FFT length timing test"); DEFINE_bool(plot_fft_length_test, false, "Plots results of FFTLengthTest with gnuplot"); @@ -110,8 +116,8 @@ TEST(FFTLengthTest, MeasureExecutionTime) { try { - boost::filesystem::path p(gnuplot_executable); - boost::filesystem::path dir = p.parent_path(); + fs::path p(gnuplot_executable); + fs::path dir = p.parent_path(); const std::string& gnuplot_path = dir.native(); Gnuplot::set_GNUPlotPath(gnuplot_path); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc index e30e4fe5b..82b0fdcfd 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/acq_performance_test.cc @@ -47,7 +47,6 @@ #include "test_flags.h" #include "tracking_true_obs_reader.h" #include "true_observables_reader.h" -#include #include #include #include @@ -55,6 +54,17 @@ #include #include +#if HAS_STD_FILESYSTEM +#include +#include +namespace fs = std::filesystem; +namespace errorlib = std; +#else +#include +#include +namespace fs = boost::filesystem; +namespace errorlib = boost::system; +#endif DEFINE_string(config_file_ptest, std::string(""), "File containing alternative configuration parameters for the acquisition performance test."); DEFINE_string(acq_test_input_file, std::string(""), "File containing raw signal data, must be in int8_t format. The signal generator will not be used."); @@ -692,8 +702,8 @@ void AcquisitionPerformanceTest::plot_results() { try { - boost::filesystem::path p(gnuplot_executable); - boost::filesystem::path dir = p.parent_path(); + fs::path p(gnuplot_executable); + fs::path dir = p.parent_path(); const std::string& gnuplot_path = dir.native(); Gnuplot::set_GNUPlotPath(gnuplot_path); @@ -782,12 +792,12 @@ TEST_F(AcquisitionPerformanceTest, ROC) { Tracking_True_Obs_Reader true_trk_data; - if (boost::filesystem::exists(path_str)) + if (fs::exists(path_str)) { - boost::filesystem::remove_all(path_str); + fs::remove_all(path_str); } - boost::system::error_code ec; - ASSERT_TRUE(boost::filesystem::create_directory(path_str, ec)) << "Could not create the " << path_str << " folder."; + errorlib::error_code ec; + ASSERT_TRUE(fs::create_directory(path_str, ec)) << "Could not create the " << path_str << " folder."; unsigned int cn0_index = 0; for (double it : cn0_vector) diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/beidou_b1i_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/beidou_b1i_pcps_acquisition_test.cc index be0214766..efb923137 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/beidou_b1i_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/beidou_b1i_pcps_acquisition_test.cc @@ -41,7 +41,6 @@ #include "gnuplot_i.h" #include "in_memory_configuration.h" #include "test_flags.h" -#include #include #include #include @@ -52,12 +51,20 @@ #include #include #include + #ifdef GR_GREATER_38 #include #else #include #endif +#if HAS_STD_FILESYSTEM +#include +namespace fs = std::filesystem; +#else +#include +namespace fs = boost::filesystem; +#endif // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class BeidouB1iPcpsAcquisitionTest_msg_rx; @@ -200,8 +207,8 @@ void BeidouB1iPcpsAcquisitionTest::plot_grid() std::cout << "Plotting the acquisition grid. This can take a while..." << std::endl; try { - boost::filesystem::path p(gnuplot_executable); - boost::filesystem::path dir = p.parent_path(); + fs::path p(gnuplot_executable); + fs::path dir = p.parent_path(); const std::string &gnuplot_path = dir.native(); Gnuplot::set_GNUPlotPath(gnuplot_path); @@ -229,9 +236,9 @@ void BeidouB1iPcpsAcquisitionTest::plot_grid() } } std::string data_str = "./tmp-acq-bds-b1i"; - if (boost::filesystem::exists(data_str)) + if (fs::exists(data_str)) { - boost::filesystem::remove_all(data_str); + fs::remove_all(data_str); } } @@ -290,11 +297,11 @@ TEST_F(BeidouB1iPcpsAcquisitionTest, ValidationOfResults) if (FLAGS_plot_acq_grid == true) { std::string data_str = "./tmp-acq-bds-b1i"; - if (boost::filesystem::exists(data_str)) + if (fs::exists(data_str)) { - boost::filesystem::remove_all(data_str); + fs::remove_all(data_str); } - boost::filesystem::create_directory(data_str); + fs::create_directory(data_str); } std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition_B1", 1, 0); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/beidou_b3i_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/beidou_b3i_pcps_acquisition_test.cc index d80ca6e66..8d39ac2ff 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/beidou_b3i_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/beidou_b3i_pcps_acquisition_test.cc @@ -33,15 +33,14 @@ #include "Beidou_B3I.h" #include "acquisition_dump_reader.h" +#include "beidou_b3i_pcps_acquisition.h" #include "gnss_block_factory.h" #include "gnss_block_interface.h" #include "gnss_sdr_valve.h" #include "gnss_synchro.h" #include "gnuplot_i.h" -#include "beidou_b3i_pcps_acquisition.h" #include "in_memory_configuration.h" #include "test_flags.h" -#include #include #include #include @@ -52,12 +51,20 @@ #include #include #include + #ifdef GR_GREATER_38 #include #else #include #endif +#if HAS_STD_FILESYSTEM +#include +namespace fs = std::filesystem; +#else +#include +namespace fs = boost::filesystem; +#endif // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class BeidouB3iPcpsAcquisitionTest_msg_rx; @@ -199,8 +206,8 @@ void BeidouB3iPcpsAcquisitionTest::plot_grid() std::cout << "Plotting the acquisition grid. This can take a while..." << std::endl; try { - boost::filesystem::path p(gnuplot_executable); - boost::filesystem::path dir = p.parent_path(); + fs::path p(gnuplot_executable); + fs::path dir = p.parent_path(); const std::string &gnuplot_path = dir.native(); Gnuplot::set_GNUPlotPath(gnuplot_path); @@ -228,9 +235,9 @@ void BeidouB3iPcpsAcquisitionTest::plot_grid() } } std::string data_str = "./tmp-acq-bds-b3i"; - if (boost::filesystem::exists(data_str)) + if (fs::exists(data_str)) { - boost::filesystem::remove_all(data_str); + fs::remove_all(data_str); } } @@ -289,11 +296,11 @@ TEST_F(BeidouB3iPcpsAcquisitionTest, ValidationOfResults) if (FLAGS_plot_acq_grid == true) { std::string data_str = "./tmp-acq-bds-b3i"; - if (boost::filesystem::exists(data_str)) + if (fs::exists(data_str)) { - boost::filesystem::remove_all(data_str); + fs::remove_all(data_str); } - boost::filesystem::create_directory(data_str); + fs::create_directory(data_str); } std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition_B3", 1, 0); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test.cc index c31937d37..204acbb14 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/galileo_e1_pcps_ambiguous_acquisition_test.cc @@ -52,12 +52,21 @@ #include #include #include + #ifdef GR_GREATER_38 #include #else #include #endif +#if HAS_STD_FILESYSTEM +#include +namespace fs = std::filesystem; +#else +#include +namespace fs = boost::filesystem; +#endif + // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GalileoE1PcpsAmbiguousAcquisitionTest_msg_rx; @@ -199,8 +208,8 @@ void GalileoE1PcpsAmbiguousAcquisitionTest::plot_grid() std::cout << "Plotting the acquisition grid. This can take a while..." << std::endl; try { - boost::filesystem::path p(gnuplot_executable); - boost::filesystem::path dir = p.parent_path(); + fs::path p(gnuplot_executable); + fs::path dir = p.parent_path(); const std::string& gnuplot_path = dir.native(); Gnuplot::set_GNUPlotPath(gnuplot_path); @@ -228,9 +237,9 @@ void GalileoE1PcpsAmbiguousAcquisitionTest::plot_grid() } } std::string data_str = "./tmp-acq-gal1"; - if (boost::filesystem::exists(data_str)) + if (fs::exists(data_str)) { - boost::filesystem::remove_all(data_str); + fs::remove_all(data_str); } } @@ -283,11 +292,11 @@ TEST_F(GalileoE1PcpsAmbiguousAcquisitionTest, ValidationOfResults) if (FLAGS_plot_acq_grid == true) { std::string data_str = "./tmp-acq-gal1"; - if (boost::filesystem::exists(data_str)) + if (fs::exists(data_str)) { - boost::filesystem::remove_all(data_str); + fs::remove_all(data_str); } - boost::filesystem::create_directory(data_str); + fs::create_directory(data_str); } double expected_delay_samples = 2920; //18250; diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc index 8e6876aa9..42fe90a6b 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l1_ca_pcps_acquisition_test.cc @@ -41,7 +41,6 @@ #include "gps_l1_ca_pcps_acquisition.h" #include "in_memory_configuration.h" #include "test_flags.h" -#include #include #include #include @@ -52,12 +51,21 @@ #include #include #include + #ifdef GR_GREATER_38 #include #else #include #endif +#if HAS_STD_FILESYSTEM +#include +namespace fs = std::filesystem; +#else +#include +namespace fs = boost::filesystem; +#endif + // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GpsL1CaPcpsAcquisitionTest_msg_rx; @@ -200,8 +208,8 @@ void GpsL1CaPcpsAcquisitionTest::plot_grid() std::cout << "Plotting the acquisition grid. This can take a while..." << std::endl; try { - boost::filesystem::path p(gnuplot_executable); - boost::filesystem::path dir = p.parent_path(); + fs::path p(gnuplot_executable); + fs::path dir = p.parent_path(); const std::string &gnuplot_path = dir.native(); Gnuplot::set_GNUPlotPath(gnuplot_path); @@ -229,9 +237,9 @@ void GpsL1CaPcpsAcquisitionTest::plot_grid() } } std::string data_str = "./tmp-acq-gps1"; - if (boost::filesystem::exists(data_str)) + if (fs::exists(data_str)) { - boost::filesystem::remove_all(data_str); + fs::remove_all(data_str); } } @@ -290,11 +298,11 @@ TEST_F(GpsL1CaPcpsAcquisitionTest, ValidationOfResults) if (FLAGS_plot_acq_grid == true) { std::string data_str = "./tmp-acq-gps1"; - if (boost::filesystem::exists(data_str)) + if (fs::exists(data_str)) { - boost::filesystem::remove_all(data_str); + fs::remove_all(data_str); } - boost::filesystem::create_directory(data_str); + fs::create_directory(data_str); } std::shared_ptr acquisition = std::make_shared(config.get(), "Acquisition_1C", 1, 0); diff --git a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc index 0ade6eb89..ae50d3bb0 100644 --- a/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/acquisition/gps_l2_m_pcps_acquisition_test.cc @@ -41,7 +41,6 @@ #include "gps_l2_m_pcps_acquisition.h" #include "in_memory_configuration.h" #include "test_flags.h" -#include #include #include #include @@ -53,12 +52,21 @@ #include #include #include + #ifdef GR_GREATER_38 #include #else #include #endif +#if HAS_STD_FILESYSTEM +#include +namespace fs = std::filesystem; +#else +#include +namespace fs = boost::filesystem; +#endif + // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GpsL2MPcpsAcquisitionTest_msg_rx; @@ -203,8 +211,8 @@ void GpsL2MPcpsAcquisitionTest::plot_grid() std::cout << "Plotting the acquisition grid. This can take a while..." << std::endl; try { - boost::filesystem::path p(gnuplot_executable); - boost::filesystem::path dir = p.parent_path(); + fs::path p(gnuplot_executable); + fs::path dir = p.parent_path(); const std::string &gnuplot_path = dir.native(); Gnuplot::set_GNUPlotPath(gnuplot_path); @@ -232,9 +240,9 @@ void GpsL2MPcpsAcquisitionTest::plot_grid() } } std::string data_str = "./tmp-acq-gps2"; - if (boost::filesystem::exists(data_str)) + if (fs::exists(data_str)) { - boost::filesystem::remove_all(data_str); + fs::remove_all(data_str); } } @@ -289,11 +297,11 @@ TEST_F(GpsL2MPcpsAcquisitionTest, ValidationOfResults) if (FLAGS_plot_acq_grid == true) { std::string data_str = "./tmp-acq-gps2"; - if (boost::filesystem::exists(data_str)) + if (fs::exists(data_str)) { - boost::filesystem::remove_all(data_str); + fs::remove_all(data_str); } - boost::filesystem::create_directory(data_str); + fs::create_directory(data_str); } init(); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc index 1bce1e6b8..88a03f1a3 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_dll_pll_tracking_test.cc @@ -41,7 +41,6 @@ #include "tracking_tests_flags.h" #include "tracking_true_obs_reader.h" #include -#include #include #include #include @@ -54,12 +53,21 @@ #include #include #include + #ifdef GR_GREATER_38 #include #else #include #endif +#if HAS_STD_FILESYSTEM +#include +namespace fs = std::filesystem; +#else +#include +namespace fs = boost::filesystem; +#endif + // ######## GNURADIO BLOCK MESSAGE RECEVER ######### class GpsL1CADllPllTrackingTest_msg_rx; @@ -807,8 +815,8 @@ TEST_F(GpsL1CADllPllTrackingTest, ValidationOfResults) { try { - boost::filesystem::path p(gnuplot_executable); - boost::filesystem::path dir = p.parent_path(); + fs::path p(gnuplot_executable); + fs::path dir = p.parent_path(); const std::string& gnuplot_path = dir.native(); Gnuplot::set_GNUPlotPath(gnuplot_path); auto decimate = static_cast(FLAGS_plot_decimate); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc index 7422aa286..0b16279f7 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/gps_l1_ca_kf_tracking_test.cc @@ -41,7 +41,6 @@ #include "tracking_interface.h" #include "tracking_true_obs_reader.h" #include -#include #include #include #include @@ -53,12 +52,21 @@ #include #include #include + #ifdef GR_GREATER_38 #include #else #include #endif +#if HAS_STD_FILESYSTEM +#include +namespace fs = std::filesystem; +#else +#include +namespace fs = boost::filesystem; +#endif + DEFINE_bool(plot_gps_l1_kf_tracking_test, false, "Plots results of GpsL1CAKfTrackingTest with gnuplot"); @@ -525,8 +533,8 @@ TEST_F(GpsL1CAKfTrackingTest, ValidationOfResults) { try { - boost::filesystem::path p(gnuplot_executable); - boost::filesystem::path dir = p.parent_path(); + fs::path p(gnuplot_executable); + fs::path dir = p.parent_path(); const std::string& gnuplot_path = dir.native(); Gnuplot::set_GNUPlotPath(gnuplot_path); diff --git a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc index 05787d5bd..21567e373 100644 --- a/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc +++ b/src/tests/unit-tests/signal-processing-blocks/tracking/tracking_pull-in_test.cc @@ -55,7 +55,6 @@ #include "tracking_tests_flags.h" #include "tracking_true_obs_reader.h" #include -#include #include #include #include @@ -69,12 +68,21 @@ #include #include #include + #ifdef GR_GREATER_38 #include #else #include #endif +#if HAS_STD_FILESYSTEM +#include +namespace fs = std::filesystem; +#else +#include +namespace fs = boost::filesystem; +#endif + // ######## GNURADIO TRACKING BLOCK MESSAGE RECEVER ######### class TrackingPullInTest_msg_rx; @@ -965,8 +973,8 @@ TEST_F(TrackingPullInTest, ValidationOfResults) { try { - boost::filesystem::path p(gnuplot_executable); - boost::filesystem::path dir = p.parent_path(); + fs::path p(gnuplot_executable); + fs::path dir = p.parent_path(); const std::string& gnuplot_path = dir.native(); Gnuplot::set_GNUPlotPath(gnuplot_path); auto decimate = static_cast(FLAGS_plot_decimate); diff --git a/src/utils/front-end-cal/CMakeLists.txt b/src/utils/front-end-cal/CMakeLists.txt index a8d0e244e..80f05cc2b 100644 --- a/src/utils/front-end-cal/CMakeLists.txt +++ b/src/utils/front-end-cal/CMakeLists.txt @@ -56,6 +56,13 @@ endif() add_executable(front-end-cal ${CMAKE_CURRENT_SOURCE_DIR}/main.cc) +if(${FILESYSTEM_FOUND}) + target_compile_definitions(front-end-cal PRIVATE -DHAS_STD_FILESYSTEM=1) + target_link_libraries(front-end-cal PRIVATE std::filesystem) +else() + target_link_libraries(front-end-cal PRIVATE Boost::filesystem Boost::system) +endif() + target_link_libraries(front-end-cal PUBLIC Volkgnsssdr::volkgnsssdr ${ORC_LIBRARIES} @@ -64,7 +71,6 @@ target_link_libraries(front-end-cal front_end_cal_lib gnss_sdr_flags PRIVATE - Boost::filesystem Gflags::gflags Glog::glog ) diff --git a/src/utils/front-end-cal/main.cc b/src/utils/front-end-cal/main.cc index 989ba2348..83b664362 100644 --- a/src/utils/front-end-cal/main.cc +++ b/src/utils/front-end-cal/main.cc @@ -51,7 +51,6 @@ #include // for bad_any_cast #include #include -#include #include #include #include @@ -83,6 +82,14 @@ #include #include +#if HAS_STD_FILESYSTEM +#include +namespace fs = std::filesystem; +#else +#include +namespace fs = boost::filesystem; +#endif + DECLARE_string(log_dir); Concurrent_Map global_gps_ephemeris_map; @@ -284,14 +291,14 @@ int main(int argc, char** argv) } else { - const boost::filesystem::path p(FLAGS_log_dir); - if (!boost::filesystem::exists(p)) + const fs::path p(FLAGS_log_dir); + if (!fs::exists(p)) { std::cout << "The path " << FLAGS_log_dir << " does not exist, attempting to create it" << std::endl; - boost::filesystem::create_directory(p); + fs::create_directory(p); } std::cout << "Logging with be done at " << FLAGS_log_dir << std::endl; diff --git a/src/utils/rinex2assist/CMakeLists.txt b/src/utils/rinex2assist/CMakeLists.txt index d42b379b5..312462ea1 100644 --- a/src/utils/rinex2assist/CMakeLists.txt +++ b/src/utils/rinex2assist/CMakeLists.txt @@ -55,8 +55,8 @@ find_program(UNCOMPRESS_EXECUTABLE uncompress ) if(Boost_FOUND) + set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-deprecated") - add_executable(rinex2assist ${CMAKE_CURRENT_SOURCE_DIR}/main.cc) target_link_libraries(rinex2assist