From 9c9a7b5bc657f4b6439e00a2b55db8866bd75666 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sat, 25 Apr 2020 22:17:15 +0200 Subject: [PATCH] Use lambda instead of boost::build when genenic lambdas are available in the compiler --- .../PVT/gnuradio_blocks/CMakeLists.txt | 15 +++++++++++++ .../PVT/gnuradio_blocks/rtklib_pvt_gs.cc | 14 ++++++++++--- src/algorithms/channel/libs/CMakeLists.txt | 15 +++++++++++++ .../channel/libs/channel_msg_receiver_cc.cc | 12 +++++++++-- .../gnuradio_blocks/CMakeLists.txt | 15 +++++++++++++ .../gnuradio_blocks/hybrid_observables_gs.cc | 13 ++++++++++-- .../tracking/gnuradio_blocks/CMakeLists.txt | 15 +++++++++++++ .../gnuradio_blocks/dll_pll_veml_tracking.cc | 13 +++++++++++- .../dll_pll_veml_tracking_fpga.cc | 13 ++++++++++-- ...glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc | 10 +++++++-- ...glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc | 10 ++++++++- ...glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc | 6 ++++-- ...glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc | 5 ++++- src/core/libs/CMakeLists.txt | 15 +++++++++++++ src/core/libs/channel_status_msg_receiver.cc | 7 ++++++- src/utils/front-end-cal/CMakeLists.txt | 21 ++++++++++++------- 16 files changed, 175 insertions(+), 24 deletions(-) diff --git a/src/algorithms/PVT/gnuradio_blocks/CMakeLists.txt b/src/algorithms/PVT/gnuradio_blocks/CMakeLists.txt index d7db9195d..9b20e490d 100644 --- a/src/algorithms/PVT/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/PVT/gnuradio_blocks/CMakeLists.txt @@ -49,6 +49,21 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() +if(CMAKE_VERSION VERSION_GREATER 3.1) + set(has_generic_lambdas HAS_GENERIC_LAMBDA=1) + set(no_has_generic_lambdas HAS_GENERIC_LAMBDA=0) + target_compile_definitions(pvt_gr_blocks + PRIVATE + "$<$:${has_generic_lambdas}>" + "$<$>:${no_has_generic_lambdas}>" + ) +else() + target_compile_definitions(pvt_gr_blocks + PRIVATE + -DHAS_GENERIC_LAMBDA=0 + ) +endif() + if(ENABLE_CLANG_TIDY) if(CLANG_TIDY_EXE) set_target_properties(pvt_gr_blocks diff --git a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc index 98c3fce8b..97d63bd73 100644 --- a/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc +++ b/src/algorithms/PVT/gnuradio_blocks/rtklib_pvt_gs.cc @@ -54,7 +54,6 @@ #include // for any_cast, any #include // for xml_iarchive #include // for xml_oarchive -#include // for bind_t, bind #include #include #include @@ -75,6 +74,11 @@ #include // for IPC_CREAT #include // for msgctl +#if HAS_GENERIC_LAMBDA +#else +#include +#endif + #if HAS_STD_FILESYSTEM #include namespace errorlib = std; @@ -186,8 +190,12 @@ rtklib_pvt_gs::rtklib_pvt_gs(uint32_t nchannels, // GPS Ephemeris data message port in this->message_port_register_in(pmt::mp("telemetry")); - this->set_msg_handler(pmt::mp("telemetry"), boost::bind(&rtklib_pvt_gs::msg_handler_telemetry, this, _1)); - + this->set_msg_handler(pmt::mp("telemetry"), +#if HAS_GENERIC_LAMBDA + [this](auto&& PH1) { msg_handler_telemetry(PH1); }); +#else + boost::bind(&rtklib_pvt_gs::msg_handler_telemetry, this, _1)); +#endif // initialize kml_printer std::string kml_dump_filename; kml_dump_filename = d_dump_filename; diff --git a/src/algorithms/channel/libs/CMakeLists.txt b/src/algorithms/channel/libs/CMakeLists.txt index dc48de63f..8adf4ee08 100644 --- a/src/algorithms/channel/libs/CMakeLists.txt +++ b/src/algorithms/channel/libs/CMakeLists.txt @@ -47,6 +47,21 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() +if(CMAKE_VERSION VERSION_GREATER 3.1) + set(has_generic_lambdas HAS_GENERIC_LAMBDA=1) + set(no_has_generic_lambdas HAS_GENERIC_LAMBDA=0) + target_compile_definitions(channel_libs + PRIVATE + "$<$:${has_generic_lambdas}>" + "$<$>:${no_has_generic_lambdas}>" + ) +else() + target_compile_definitions(channel_libs + PRIVATE + -DHAS_GENERIC_LAMBDA=0 + ) +endif() + if(ENABLE_CLANG_TIDY) if(CLANG_TIDY_EXE) set_target_properties(channel_libs diff --git a/src/algorithms/channel/libs/channel_msg_receiver_cc.cc b/src/algorithms/channel/libs/channel_msg_receiver_cc.cc index 834c4cea8..28caa67e7 100644 --- a/src/algorithms/channel/libs/channel_msg_receiver_cc.cc +++ b/src/algorithms/channel/libs/channel_msg_receiver_cc.cc @@ -20,13 +20,16 @@ #include "channel_msg_receiver_cc.h" #include -#include #include #include #include #include #include +#if HAS_GENERIC_LAMBDA +#else +#include +#endif channel_msg_receiver_cc_sptr channel_msg_receiver_make_cc(std::shared_ptr channel_fsm, bool repeat) { @@ -37,7 +40,12 @@ channel_msg_receiver_cc_sptr channel_msg_receiver_make_cc(std::shared_ptr channel_fsm, bool repeat) : gr::block("channel_msg_receiver_cc", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) { this->message_port_register_in(pmt::mp("events")); - this->set_msg_handler(pmt::mp("events"), boost::bind(&channel_msg_receiver_cc::msg_handler_events, this, _1)); + this->set_msg_handler(pmt::mp("events"), +#if HAS_GENERIC_LAMBDA + [this](auto&& PH1) { msg_handler_events(PH1); }); +#else + boost::bind(&channel_msg_receiver_cc::msg_handler_events, this, _1)); +#endif d_channel_fsm = std::move(channel_fsm); d_repeat = repeat; diff --git a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt index 50f018127..c14d39069 100644 --- a/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/observables/gnuradio_blocks/CMakeLists.txt @@ -53,6 +53,21 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() +if(CMAKE_VERSION VERSION_GREATER 3.1) + set(has_generic_lambdas HAS_GENERIC_LAMBDA=1) + set(no_has_generic_lambdas HAS_GENERIC_LAMBDA=0) + target_compile_definitions(obs_gr_blocks + PRIVATE + "$<$:${has_generic_lambdas}>" + "$<$>:${no_has_generic_lambdas}>" + ) +else() + target_compile_definitions(obs_gr_blocks + PRIVATE + -DHAS_GENERIC_LAMBDA=0 + ) +endif() + if(ENABLE_CLANG_TIDY) if(CLANG_TIDY_EXE) set_target_properties(obs_gr_blocks diff --git a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc index 5113fb592..0d40b7928 100644 --- a/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc +++ b/src/algorithms/observables/gnuradio_blocks/hybrid_observables_gs.cc @@ -35,6 +35,11 @@ #include // for numeric_limits #include // for move +#if HAS_GENERIC_LAMBDA +#else +#include +#endif + #if HAS_STD_FILESYSTEM #include namespace errorlib = std; @@ -67,8 +72,12 @@ hybrid_observables_gs::hybrid_observables_gs(const Obs_Conf &conf_) : gr::block( { // PVT input message port this->message_port_register_in(pmt::mp("pvt_to_observables")); - this->set_msg_handler(pmt::mp("pvt_to_observables"), boost::bind(&hybrid_observables_gs::msg_handler_pvt_to_observables, this, _1)); - + this->set_msg_handler(pmt::mp("pvt_to_observables"), +#if HAS_GENERIC_LAMBDA + [this](auto &&PH1) { msg_handler_pvt_to_observables(PH1); }); +#else + boost::bind(&hybrid_observables_gs::msg_handler_pvt_to_observables, this, _1)); +#endif // Send Channel status to gnss_flowgraph this->message_port_register_out(pmt::mp("status")); d_conf = conf_; diff --git a/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt b/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt index e0c36df7c..354172560 100644 --- a/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/tracking/gnuradio_blocks/CMakeLists.txt @@ -115,6 +115,21 @@ if(ENABLE_ARMA_NO_DEBUG) ) endif() +if(CMAKE_VERSION VERSION_GREATER 3.1) + set(has_generic_lambdas HAS_GENERIC_LAMBDA=1) + set(no_has_generic_lambdas HAS_GENERIC_LAMBDA=0) + target_compile_definitions(tracking_gr_blocks + PRIVATE + "$<$:${has_generic_lambdas}>" + "$<$>:${no_has_generic_lambdas}>" + ) +else() + target_compile_definitions(tracking_gr_blocks + PRIVATE + -DHAS_GENERIC_LAMBDA=0 + ) +endif() + if(ENABLE_CLANG_TIDY) if(CLANG_TIDY_EXE) set_target_properties(tracking_gr_blocks 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 c4617f694..886c5882e 100644 --- a/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc +++ b/src/algorithms/tracking/gnuradio_blocks/dll_pll_veml_tracking.cc @@ -60,6 +60,11 @@ #include #include +#if HAS_GENERIC_LAMBDA +#else +#include +#endif + #if HAS_STD_FILESYSTEM #if HAS_STD_FILESYSTEM_EXPERIMENTAL #include @@ -92,7 +97,13 @@ dll_pll_veml_tracking::dll_pll_veml_tracking(const Dll_Pll_Conf &conf_) : gr::bl // Telemetry message port input this->message_port_register_in(pmt::mp("telemetry_to_trk")); - this->set_msg_handler(pmt::mp("telemetry_to_trk"), boost::bind(&dll_pll_veml_tracking::msg_handler_telemetry_to_trk, this, _1)); + this->set_msg_handler( + pmt::mp("telemetry_to_trk"), +#if HAS_GENERIC_LAMBDA + [this](auto &&PH1) { msg_handler_telemetry_to_trk(PH1); }); +#else + boost::bind(&dll_pll_veml_tracking::msg_handler_telemetry_to_trk, this, _1)); +#endif // initialize internal vars d_dll_filt_history.set_capacity(1000); 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 d43fabc68..031c23fa9 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 @@ -51,6 +51,11 @@ #include #include +#if HAS_GENERIC_LAMBDA +#else +#include +#endif + #if HAS_STD_FILESYSTEM #if HAS_STD_FILESYSTEM_EXPERIMENTAL #include @@ -83,8 +88,12 @@ dll_pll_veml_tracking_fpga::dll_pll_veml_tracking_fpga(const Dll_Pll_Conf_Fpga & // Telemetry message port input this->message_port_register_in(pmt::mp("telemetry_to_trk")); - this->set_msg_handler(pmt::mp("telemetry_to_trk"), boost::bind(&dll_pll_veml_tracking_fpga::msg_handler_telemetry_to_trk, this, _1)); - + this->set_msg_handler(pmt::mp("telemetry_to_trk"), +#if HAS_GENERIC_LAMBDA + [this](auto &&PH1) { msg_handler_telemetry_to_trk(PH1); }); +#else + boost::bind(&dll_pll_veml_tracking_fpga::msg_handler_telemetry_to_trk, this, _1)); +#endif // initialize internal vars d_dll_filt_history.set_capacity(1000); d_veml = false; diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc index 6bf6fc144..38ba2aeeb 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_cc.cc @@ -32,7 +32,6 @@ #include "gnss_sdr_flags.h" #include "lock_detectors.h" #include "tracking_discriminators.h" -#include #include #include #include @@ -48,6 +47,10 @@ #include #include +#if HAS_GENERIC_LAMBDA +#else +#include +#endif #define CN0_ESTIMATION_SAMPLES 10 @@ -109,8 +112,11 @@ glonass_l1_ca_dll_pll_c_aid_tracking_cc::glonass_l1_ca_dll_pll_c_aid_tracking_cc this->message_port_register_in(pmt::mp("preamble_timestamp_s")); this->set_msg_handler(pmt::mp("preamble_timestamp_s"), +#if HAS_GENERIC_LAMBDA + [this](auto &&PH1) { msg_handler_preamble_index(PH1); }); +#else boost::bind(&glonass_l1_ca_dll_pll_c_aid_tracking_cc::msg_handler_preamble_index, this, _1)); - +#endif this->message_port_register_out(pmt::mp("events")); this->message_port_register_in(pmt::mp("telemetry_to_trk")); // initialize internal vars diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc index a8bf0d150..3fafe53b3 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l1_ca_dll_pll_c_aid_tracking_sc.cc @@ -32,7 +32,6 @@ #include "gnss_sdr_flags.h" #include "lock_detectors.h" #include "tracking_discriminators.h" -#include #include #include #include @@ -46,6 +45,11 @@ #include #include +#if HAS_GENERIC_LAMBDA +#else +#include +#endif + #define CN0_ESTIMATION_SAMPLES 10 @@ -105,7 +109,11 @@ glonass_l1_ca_dll_pll_c_aid_tracking_sc::glonass_l1_ca_dll_pll_c_aid_tracking_sc // Telemetry bit synchronization message port input this->message_port_register_in(pmt::mp("preamble_timestamp_s")); this->set_msg_handler(pmt::mp("preamble_timestamp_s"), +#if HAS_GENERIC_LAMBDA + [this](auto &&PH1) { msg_handler_preamble_index(PH1); }); +#else boost::bind(&glonass_l1_ca_dll_pll_c_aid_tracking_sc::msg_handler_preamble_index, this, _1)); +#endif this->message_port_register_out(pmt::mp("events")); this->message_port_register_in(pmt::mp("telemetry_to_trk")); // initialize internal vars diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc index 95fd1acde..c36d4aa07 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_cc.cc @@ -30,7 +30,6 @@ #include "gnss_sdr_flags.h" #include "lock_detectors.h" #include "tracking_discriminators.h" -#include #include #include #include @@ -105,8 +104,11 @@ glonass_l2_ca_dll_pll_c_aid_tracking_cc::glonass_l2_ca_dll_pll_c_aid_tracking_cc this->message_port_register_in(pmt::mp("preamble_timestamp_s")); this->set_msg_handler(pmt::mp("preamble_timestamp_s"), +#if HAS_GENERIC_LAMBDA + [this](auto &&PH1) { msg_handler_preamble_index(PH1); }); +#else boost::bind(&glonass_l2_ca_dll_pll_c_aid_tracking_cc::msg_handler_preamble_index, this, _1)); - +#endif this->message_port_register_out(pmt::mp("events")); this->message_port_register_in(pmt::mp("telemetry_to_trk")); // initialize internal vars diff --git a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc index 1352923c0..92070be23 100644 --- a/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc +++ b/src/algorithms/tracking/gnuradio_blocks/glonass_l2_ca_dll_pll_c_aid_tracking_sc.cc @@ -30,7 +30,6 @@ #include "gnss_sdr_flags.h" #include "lock_detectors.h" #include "tracking_discriminators.h" -#include #include #include #include @@ -103,7 +102,11 @@ glonass_l2_ca_dll_pll_c_aid_tracking_sc::glonass_l2_ca_dll_pll_c_aid_tracking_sc // Telemetry bit synchronization message port input this->message_port_register_in(pmt::mp("preamble_timestamp_s")); this->set_msg_handler(pmt::mp("preamble_timestamp_s"), +#if HAS_GENERIC_LAMBDA + [this](auto &&PH1) { msg_handler_preamble_index(PH1); }); +#else boost::bind(&glonass_l2_ca_dll_pll_c_aid_tracking_sc::msg_handler_preamble_index, this, _1)); +#endif this->message_port_register_out(pmt::mp("events")); this->message_port_register_in(pmt::mp("telemetry_to_trk")); // initialize internal vars diff --git a/src/core/libs/CMakeLists.txt b/src/core/libs/CMakeLists.txt index 5b783df85..fec647a75 100644 --- a/src/core/libs/CMakeLists.txt +++ b/src/core/libs/CMakeLists.txt @@ -71,6 +71,21 @@ if(GNURADIO_USES_STD_POINTERS) ) endif() +if(CMAKE_VERSION VERSION_GREATER 3.1) + set(has_generic_lambdas HAS_GENERIC_LAMBDA=1) + set(no_has_generic_lambdas HAS_GENERIC_LAMBDA=0) + target_compile_definitions(core_libs + PRIVATE + "$<$:${has_generic_lambdas}>" + "$<$>:${no_has_generic_lambdas}>" + ) +else() + target_compile_definitions(core_libs + PRIVATE + -DHAS_GENERIC_LAMBDA=0 + ) +endif() + if(ENABLE_CLANG_TIDY) if(CLANG_TIDY_EXE) set_target_properties(core_libs diff --git a/src/core/libs/channel_status_msg_receiver.cc b/src/core/libs/channel_status_msg_receiver.cc index 4622aa726..6bbc1e766 100644 --- a/src/core/libs/channel_status_msg_receiver.cc +++ b/src/core/libs/channel_status_msg_receiver.cc @@ -37,7 +37,12 @@ channel_status_msg_receiver_sptr channel_status_msg_receiver_make() channel_status_msg_receiver::channel_status_msg_receiver() : gr::block("channel_status_msg_receiver", gr::io_signature::make(0, 0, 0), gr::io_signature::make(0, 0, 0)) { this->message_port_register_in(pmt::mp("status")); - this->set_msg_handler(pmt::mp("status"), boost::bind(&channel_status_msg_receiver::msg_handler_events, this, _1)); + this->set_msg_handler(pmt::mp("status"), +#if HAS_GENERIC_LAMBDA + [this](auto&& PH1) { msg_handler_events(PH1); }); +#else + boost::bind(&channel_status_msg_receiver::msg_handler_events, this, _1)); +#endif d_pvt_status.RX_time = -1; // to indicate that the PVT is not available } diff --git a/src/utils/front-end-cal/CMakeLists.txt b/src/utils/front-end-cal/CMakeLists.txt index 04653d5e6..14d2ce987 100644 --- a/src/utils/front-end-cal/CMakeLists.txt +++ b/src/utils/front-end-cal/CMakeLists.txt @@ -76,13 +76,20 @@ target_compile_definitions(front-end-cal PUBLIC -DGNSSSDR_INSTALL_DIR="${CMAKE_INSTALL_PREFIX}" ) -set(has_generic_lambdas HAS_GENERIC_LAMBDA=1) -set(no_has_generic_lambdas HAS_GENERIC_LAMBDA=0) -target_compile_definitions(front-end-cal - PRIVATE - "$<$:${has_generic_lambdas}>" - "$<$>:${no_has_generic_lambdas}>" -) +if(CMAKE_VERSION VERSION_GREATER 3.1) + set(has_generic_lambdas HAS_GENERIC_LAMBDA=1) + set(no_has_generic_lambdas HAS_GENERIC_LAMBDA=0) + target_compile_definitions(front-end-cal + PRIVATE + "$<$:${has_generic_lambdas}>" + "$<$>:${no_has_generic_lambdas}>" + ) +else() + target_compile_definitions(front-end-cal + PRIVATE + -DHAS_GENERIC_LAMBDA=0 + ) +endif() if(ENABLE_CLANG_TIDY) if(CLANG_TIDY_EXE)