From 30ee3dcb899ea066cacb831bff1a1f005bd3f1fc Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 9 Jun 2019 02:33:17 +0200 Subject: [PATCH 1/2] Build volk-gnssdr without Boost if std::filesystem is available --- docs/changelog | 10 +- .../volk_gnsssdr/CMakeLists.txt | 132 ++++++++++++------ .../volk_gnsssdr/README.md | 14 +- .../volk_gnsssdr/apps/CMakeLists.txt | 30 ++-- .../volk_gnsssdr/apps/volk_gnsssdr_profile.cc | 29 ++-- 5 files changed, 145 insertions(+), 70 deletions(-) diff --git a/docs/changelog b/docs/changelog index 7abd99d06..5cfa4faee 100644 --- a/docs/changelog +++ b/docs/changelog @@ -1,9 +1,14 @@ ## [Unreleased](https://github.com/gnss-sdr/gnss-sdr/tree/next) +### Improvements in Accuracy + +- Local clock correction based on PVT solution (error kept below 1 ms). + + ### Improvements in Availability - Fixed bug that caused a random deadlock in the Observables block, preventing the computation of PVT fixes. -- Fixed bug in Galileo INAV message decoding when PLL is locked at 180 degrees, which prevented from correct navigation message decoding in some situations. +- Fixed bug in Galileo INAV/FNAV message decoding when PLL is locked at 180 degrees, which prevented from correct navigation message decoding in some situations. - Fixed PVT computation continuity through the TOW rollover. @@ -27,7 +32,7 @@ - Fix bug in GLONASS dual frequency receiver. - Added a custom UDP/IP output for PVT data streaming. - Improved Monitor block with UDP/IP output for internal receiver's data streaming. -- Custom output formats described with .proto files, making easier to other applications reading them in a forward and backward-compatible fashion upon future format changes. +- Custom output formats described with .proto files, making easier to other applications reading them in a forward and backward-compatible fashion upon future format changes. New dependency: Protocol Buffers >= 3.0.0 - Fixes in RINEX generation: week rollover, annotations are not repeated anymore in navigation files. Parameter rinexnav_rate_ms has been removed, annotations are made as new ephemeris arrive. - Fixes in RTCM messages generation: week rollover. @@ -45,6 +50,7 @@ - Added interfaces for FPGA off-loading. - CMake scripts now follow a modern approach (targets and properties) but still work with 2.8.12. - Improvements for macOS users using Homebrew. +- The volk_gnsssdr library can now be built without requiring Boost if the compiler supports C++17. ### Improvements in Reliability diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt index 79e64245e..45a10d062 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -59,42 +59,83 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") endif() endif() -# Enable C++17 support in GCC >= 8.0.0 -# Enable C++14 support in 8.0.0 > GCC >= 6.1.1 -# Fallback to C++11 when using GCC < 6.1.1 +#### Set C++ standard +set(CMAKE_CXX_EXTENSIONS OFF) -if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1") - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11") - else() - if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0") - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14") - else() - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++17") +# Check if we have std::filesystem +if(POLICY CMP0075) + cmake_policy(SET CMP0075 NEW) +endif() +if(CMAKE_VERSION VERSION_LESS 3.8) + set(has_std_filesystem FALSE) +else() + set(CMAKE_REQUIRED_FLAGS "-std=c++17") + if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0.0")) + set(CMAKE_REQUIRED_LIBRARIES -lstdc++fs) + endif() + if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + set(CMAKE_REQUIRED_LIBRARIES -lc++) endif() endif() - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -Wall -Wextra") #Add warning flags: For "-Wall" see http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html + include(CheckCXXSymbolExists) + check_cxx_symbol_exists(std::filesystem::path::preferred_separator filesystem has_std_filesystem) +endif() + +set(USE_CXX17 FALSE) +if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1") + set(CMAKE_CXX_STANDARD 11) + else() + if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0") + set(CMAKE_CXX_STANDARD 14) + else() + if(${has_std_filesystem}) + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(USE_CXX17 TRUE) + else() + set(CMAKE_CXX_STANDARD 14) + endif() + endif() + endif() + set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -Wall -Wextra") # Add warning flags: For "-Wall" see http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html endif() -# Enable C++17 support in Clang >= 6.0.0 -# Enable C++14 support in 6.0.0 > Clang >= 3.5.0 or AppleClang >= 600 -# Fallback to C++11 if older version if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - if(CMAKE_SYSTEM_NAME MATCHES "Darwin") + if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") # See https://trac.macports.org/wiki/XcodeVersionInfo for Apple Clang version equivalences if(CLANG_VERSION VERSION_LESS "600") - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11") + set(CMAKE_CXX_STANDARD 11) else() - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14") + if(CLANG_VERSION VERSION_LESS "1000") + set(CMAKE_CXX_STANDARD 14) + else() + if(${has_std_filesystem}) + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(USE_CXX17 TRUE) + else() + set(CMAKE_CXX_STANDARD 14) + endif() + endif() endif() else() if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "3.5.0") - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11") + set(CMAKE_CXX_STANDARD 11) else() if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.0.0") - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++14") + set(CMAKE_CXX_STANDARD 14) else() - set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++17") + if(${has_std_filesystem}) + set(CMAKE_CXX_STANDARD 17) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + if(NOT (${CMAKE_SYSTEM_NAME} MATCHES "Darwin") AND NOT WIN32) + set(USE_CXX17 TRUE) + endif() + else() + set(CMAKE_CXX_STANDARD 14) + endif() endif() endif() endif() @@ -110,21 +151,21 @@ endif() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${MY_CXX_FLAGS} -Wall") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall") -if(CMAKE_VERSION VERSION_GREATER "3.0") +if(POLICY CMP0042) cmake_policy(SET CMP0042 NEW) - if(CMAKE_VERSION VERSION_GREATER "3.9") - cmake_policy(SET CMP0068 NEW) - endif() +endif() +if(POLICY CMP0068) + cmake_policy(SET CMP0068 NEW) endif() option(ENABLE_STRIP "Create a stripped volk_gnsssdr_profile binary (without shared libraries)" OFF) -set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) #allows this to be a sub-project -set(PROJECT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) #allows this to be a sub-project -list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) #location for custom "Modules" +set(PROJECT_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) # allows this to be a sub-project +set(PROJECT_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) # allows this to be a sub-project +list(INSERT CMAKE_MODULE_PATH 0 ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules) # location for custom "Modules" include(VolkBuildTypes) -#select the release build type by default to get optimization flags +# select the release build type by default to get optimization flags if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "Release") message(STATUS "Build type not specified: defaulting to release.") @@ -136,7 +177,7 @@ message(STATUS "Build type set to ${CMAKE_BUILD_TYPE}.") set(VERSION_INFO_MAJOR_VERSION 0) set(VERSION_INFO_MINOR_VERSION 0) set(VERSION_INFO_MAINT_VERSION 10.git) -include(VolkVersion) #setup version info +include(VolkVersion) # setup version info @@ -154,8 +195,8 @@ endif() set(CROSSCOMPILE_MULTILIB ${CROSSCOMPILE_MULTILIB} CACHE STRING "Define \"true\" if you have and want to use multiple C development libs installed for cross compile") if(MSVC) - add_definitions(-D_USE_MATH_DEFINES) #enables math constants on all supported versions of MSVC - add_compile_options(/W1) #reduce warnings + add_definitions(-D_USE_MATH_DEFINES) # enables math constants on all supported versions of MSVC + add_compile_options(/W1) # reduce warnings add_compile_options(/wo4309) add_compile_options(/wd4752) add_compile_options(/wo4273) @@ -177,7 +218,7 @@ endif() ######################################################################## # Python -include(VolkPython) #sets PYTHON_EXECUTABLE and PYTHON_DASH_B +include(VolkPython) # sets PYTHON_EXECUTABLE and PYTHON_DASH_B volk_python_check_module("python >= 2.7" sys "sys.version.split()[0] >= '2.7'" PYTHON_MIN_VER_FOUND) volk_python_check_module("mako >= 0.4.2" mako "mako.__version__ >= '0.4.2'" MAKO_FOUND) volk_python_check_module("six - python 2 and 3 compatibility library" six "True" SIX_FOUND) @@ -204,20 +245,24 @@ if(MSVC) endif() set(BOOST_ALL_DYN_LINK "${BOOST_ALL_DYN_LINK}" CACHE BOOL "boost enable dynamic linking") if(BOOST_ALL_DYN_LINK) - add_definitions(-DBOOST_ALL_DYN_LINK) #setup boost auto-linking in msvc + add_definitions(-DBOOST_ALL_DYN_LINK) # setup boost auto-linking in msvc else() - unset(BOOST_REQUIRED_COMPONENTS) #empty components list for static link + unset(BOOST_REQUIRED_COMPONENTS) # empty components list for static link + endif() +endif() +if(${USE_CXX17}) + set(Boost_LIBRARIES "") + set(Boost_INCLUDE_DIRS "") + set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH}) +else() + include(VolkBoost) + if(NOT Boost_FOUND) + message(FATAL_ERROR "VOLK-GNSSSDR requires Boost to build") endif() endif() -include(VolkBoost) - -if(NOT Boost_FOUND) - message(FATAL_ERROR "VOLK_GNSSSDR Requires boost to build") -endif() - # Orc -option(ENABLE_ORC "Enable Orc" True) +option(ENABLE_ORC "Enable Orc" TRUE) if(ENABLE_ORC) find_package(ORC) else() @@ -246,7 +291,7 @@ endif() ######################################################################## # Setup the package config file ######################################################################## -#set variables found in the pc.in file +# set variables found in the pc.in file set(prefix ${CMAKE_INSTALL_PREFIX}) set(exec_prefix "\${prefix}") set(libdir "\${exec_prefix}/lib${LIB_SUFFIX}") @@ -335,7 +380,6 @@ endif() - ######################################################################## # Install our Cmake modules into $prefix/lib/cmake/volk_gnsssdr # See "Package Configuration Files" on page: diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/README.md b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/README.md index f37cc5b35..a88977385 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/README.md +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/README.md @@ -6,7 +6,7 @@ VOLK's. Please see http://libvolk.org for documentation, source code, and contact information about the original VOLK library. The boilerplate of this code was initially generated with -```volk_modtool```, an application provided by VOLK that creates the +`volk_modtool`, an application provided by VOLK that creates the skeleton that can then be filled with custom kernels. Some modifications were added to accommodate the specificities of Global Navigation Satellite Systems (GNSS) signal processing. Those changes are clearly @@ -16,7 +16,7 @@ This library contains kernels of hand-written SIMD code for different mathematical operations, mainly with 8-bit and 16-bit real and complex data types, offering a platform/architecture agnostic version that will run in all machines, plus other versions for different SIMD instruction -sets. Then, the application ```volk_gnsssdr_profile``` runs some +sets. Then, the application `volk_gnsssdr_profile` runs some iterations of all versions that your machine can execute and annotates which is the fastest, which will then be selected at runtime when executing GNSS-SDR. In this way, we can address at the same time @@ -49,6 +49,12 @@ $ sudo apt-get install cmake python-mako python-six libboost-dev \ libboost-filesystem-dev libboost-system-dev ~~~~~~ +Please note that if you are using a compiler supporting the C++17 standard +(for instance, gcc >= 8.0), specifically the std::filesystem library, packages +`libboost-dev`, `libboost-filesystem-dev` and `libboost-system-dev` are no +longer required dependencies. The CMake script will detect that availability for +you. + In order to build and install the library, go to the base folder of the source code and do: @@ -62,7 +68,7 @@ $ sudo make install That's it! -Before its first use, please execute ```volk_gnsssdr_profile``` to let +Before its first use, please execute `volk_gnsssdr_profile` to let your system know which is the fastest available implementation. This only has to be done once: @@ -74,7 +80,7 @@ From now on, GNSS-SDR (and any other program of your own that makes use of VOLK_GNSSSDR) will benefit from the acceleration provided by SIMD instructions available in your processor. -The execution of ```volk_gnsssdr_profile``` can be set automatically +The execution of `volk_gnsssdr_profile` can be set automatically after building, leaving your system ready to use: ~~~~~~ diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt index b1afa4ed0..a4be9907e 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/CMakeLists.txt @@ -35,13 +35,21 @@ include_directories( ) -set(Clang_required_link "") -if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") - if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") - set(Clang_required_link "c++") +set(CXX_REQUIRED_LINK "") +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") + if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin") + set(CXX_REQUIRED_LINK "c++") + else() + if(${USE_CXX17} AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0.0")) + set(CXX_REQUIRED_LINK "stdc++fs") + endif() + endif() +endif() +if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND (CMAKE_CXX_COMPILER_VERSION VERSION_LESS "9.0.0")) + if(${USE_CXX17}) + set(CXX_REQUIRED_LINK "stdc++fs") endif() endif() - if(ORC_FOUND) set(orc_lib ${ORC_LIBRARIES}) @@ -66,10 +74,14 @@ add_executable(volk_gnsssdr_profile ${CMAKE_CURRENT_SOURCE_DIR}/volk_gnsssdr_option_helpers.cc ) +if(${USE_CXX17}) + add_definitions(-DHAS_STD_FILESYSTEM=1) +endif() + if(ENABLE_STATIC_LIBS) - target_link_libraries(volk_gnsssdr_profile volk_gnsssdr_static ${Boost_LIBRARIES} ${Clang_required_link} ${orc_lib}) + target_link_libraries(volk_gnsssdr_profile ${CXX_REQUIRED_LINK} volk_gnsssdr_static ${Boost_LIBRARIES} ${orc_lib}) else() - target_link_libraries(volk_gnsssdr_profile volk_gnsssdr ${Boost_LIBRARIES} ${Clang_required_link} ${orc_lib}) + target_link_libraries(volk_gnsssdr_profile ${CXX_REQUIRED_LINK} volk_gnsssdr ${Boost_LIBRARIES} ${orc_lib}) add_dependencies(volk_gnsssdr_profile volk_gnsssdr) endif() @@ -92,9 +104,9 @@ install( # MAKE volk_gnsssdr-config-info add_executable(volk_gnsssdr-config-info volk_gnsssdr-config-info.cc ${CMAKE_CURRENT_SOURCE_DIR}/volk_gnsssdr_option_helpers.cc) if(ENABLE_STATIC_LIBS) - target_link_libraries(volk_gnsssdr-config-info volk_gnsssdr_static ${Clang_required_link} ${orc_lib}) + target_link_libraries(volk_gnsssdr-config-info ${CXX_REQUIRED_LINK} volk_gnsssdr_static ${orc_lib}) else() - target_link_libraries(volk_gnsssdr-config-info volk_gnsssdr ${Clang_required_link} ${orc_lib}) + target_link_libraries(volk_gnsssdr-config-info ${CXX_REQUIRED_LINK} volk_gnsssdr ${orc_lib}) add_dependencies(volk_gnsssdr-config-info volk_gnsssdr) endif() diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc index 140a64ba3..f0e75dc22 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/apps/volk_gnsssdr_profile.cc @@ -22,19 +22,26 @@ #include "volk_gnsssdr/volk_gnsssdr_complex.h" // for lv_32fc_t #include "volk_gnsssdr/volk_gnsssdr_prefs.h" // for volk_gnsssdr_get_config_path #include "volk_gnsssdr_option_helpers.h" // for option_list, option_t -#include // for create_directories, exists -#include // for path, operator<< -#include // for filesystem -#include // for size_t -#include // IWYU pragma: keep -#include // for operator<<, basic_ostream -#include // for map, map<>::iterator -#include // for stat -#include // for pair -#include // for vector, vector<>::const_.. - +#if HAS_STD_FILESYSTEM +#include +#else +#include // for create_directories, exists +#include // for path, operator<< +#include // for filesystem +#endif +#include // for size_t +#include // IWYU pragma: keep +#include // for operator<<, basic_ostream +#include // for map, map<>::iterator +#include // for stat +#include // for pair +#include // for vector, vector<>::const_.. +#if HAS_STD_FILESYSTEM +namespace fs = std::filesystem; +#else namespace fs = boost::filesystem; +#endif volk_gnsssdr_test_params_t test_params(1e-6f, 327.f, 8111, 1987, false, ""); From 72a640cab83c34ca0e7694b4a2dd2663d2144813 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 9 Jun 2019 03:00:38 +0200 Subject: [PATCH 2/2] Build volk-gnssdr without Boost if std::filesystem is available --- .../libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt index 45a10d062..9ce5743ec 100644 --- a/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt +++ b/src/algorithms/libs/volk_gnsssdr_module/volk_gnsssdr/CMakeLists.txt @@ -85,7 +85,11 @@ endif() set(USE_CXX17 FALSE) if((CMAKE_CXX_COMPILER_ID STREQUAL "GNU") AND NOT WIN32) if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "6.1.1") - set(CMAKE_CXX_STANDARD 11) + if(CMAKE_VERSION VERSION_LESS "3.1") + set(MY_CXX_FLAGS "${MY_CXX_FLAGS} -std=c++11") + else() + set(CMAKE_CXX_STANDARD 11) + endif() else() if(CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0") set(CMAKE_CXX_STANDARD 14)