Fix for gcc < 5.0

This commit is contained in:
Carles Fernandez 2019-03-16 20:30:38 +01:00
parent ba73da0081
commit 4c71864319
No known key found for this signature in database
GPG Key ID: 4C583C52B0C3877D
2 changed files with 16 additions and 0 deletions

View File

@ -58,6 +58,18 @@ if(Boost_VERSION LESS 105800)
target_compile_definitions(pvt_gr_blocks PRIVATE -DOLD_BOOST=1)
endif()
# Check if we have std::put_time (Workaround for gcc < 5.0)
include(CheckCXXSourceCompiles)
check_cxx_source_compiles("
#include <iomanip>
int main()
{ std::put_time(nullptr, \"\"); }"
HAS_PUT_TIME
)
if(${HAS_PUT_TIME})
target_compile_definitions(pvt_gr_blocks PRIVATE -DHAS_PUT_TIME=1)
endif()
set_property(TARGET pvt_gr_blocks
APPEND PROPERTY INTERFACE_INCLUDE_DIRECTORIES
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>

View File

@ -369,7 +369,9 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels,
time_t when = std::time(nullptr);
auto const tm = *std::localtime(&when);
std::ostringstream os;
#ifdef HAS_PUT_TIME
os << std::put_time(&tm, "%z");
#endif
std::string utc_diff_str = os.str(); // in ISO 8601 format: "+HHMM" or "-HHMM"
if (utc_diff_str.empty())
{
@ -379,7 +381,9 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels,
int m = std::stoi(utc_diff_str[0] + utc_diff_str.substr(3), nullptr, 10);
d_utc_diff_time = boost::posix_time::hours(h) + boost::posix_time::minutes(m);
std::ostringstream os2;
#ifdef HAS_PUT_TIME
os2 << std::put_time(&tm, "%Z");
#endif
std::string time_zone_abrv = os2.str();
if (time_zone_abrv.empty())
{