From 59494034d872208b6b7a8e3a993e394d28a8f8d7 Mon Sep 17 00:00:00 2001 From: Carles Fernandez Date: Sun, 26 May 2019 02:09:53 +0200 Subject: [PATCH] Better fix for Boost Asio and string_view issue in macOS --- CMakeLists.txt | 11 +++++++++++ src/algorithms/PVT/libs/CMakeLists.txt | 18 +++++++++++++----- .../gnuradio_blocks/CMakeLists.txt | 18 +++++++++++++----- src/algorithms/tracking/libs/CMakeLists.txt | 18 +++++++++++++----- src/core/monitor/CMakeLists.txt | 18 +++++++++++++----- src/core/receiver/CMakeLists.txt | 18 +++++++++++++----- 6 files changed, 76 insertions(+), 25 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4beca52e6..8b1a1cdc5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -690,6 +690,17 @@ if(CMAKE_VERSION VERSION_LESS 3.5) 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() ################################################################################ diff --git a/src/algorithms/PVT/libs/CMakeLists.txt b/src/algorithms/PVT/libs/CMakeLists.txt index 23eacf787..bf66966a0 100644 --- a/src/algorithms/PVT/libs/CMakeLists.txt +++ b/src/algorithms/PVT/libs/CMakeLists.txt @@ -94,12 +94,20 @@ if(Boost_VERSION VERSION_GREATER "106599") ) endif() +# Fix for Boost Asio < 1.70 if(OS_IS_MACOSX) - if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - target_compile_definitions(pvt_libs - PUBLIC - -DBOOST_ASIO_HAS_STD_STRING_VIEW - ) + if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND (${Boost_VERSION} VERSION_LESS 107000)) + if(${has_string_view}) + target_compile_definitions(pvt_libs + PUBLIC + -DBOOST_ASIO_HAS_STD_STRING_VIEW=1 + ) + else() + target_compile_definitions(pvt_libs + PUBLIC + -DBOOST_ASIO_HAS_STD_STRING_VIEW=0 + ) + endif() endif() endif() diff --git a/src/algorithms/signal_source/gnuradio_blocks/CMakeLists.txt b/src/algorithms/signal_source/gnuradio_blocks/CMakeLists.txt index ca38c48a7..4f05f3169 100644 --- a/src/algorithms/signal_source/gnuradio_blocks/CMakeLists.txt +++ b/src/algorithms/signal_source/gnuradio_blocks/CMakeLists.txt @@ -76,12 +76,20 @@ if(ENABLE_RAW_UDP AND PCAP_FOUND) ) endif() +# Fix for Boost Asio < 1.70 if(OS_IS_MACOSX) - if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - target_compile_definitions(signal_source_gr_blocks - PUBLIC - -DBOOST_ASIO_HAS_STD_STRING_VIEW - ) + if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND (${Boost_VERSION} VERSION_LESS 107000)) + if(${has_string_view}) + target_compile_definitions(signal_source_gr_blocks + PUBLIC + -DBOOST_ASIO_HAS_STD_STRING_VIEW=1 + ) + else() + target_compile_definitions(signal_source_gr_blocks + PUBLIC + -DBOOST_ASIO_HAS_STD_STRING_VIEW=0 + ) + endif() endif() endif() diff --git a/src/algorithms/tracking/libs/CMakeLists.txt b/src/algorithms/tracking/libs/CMakeLists.txt index d30feeaa5..3f772f149 100644 --- a/src/algorithms/tracking/libs/CMakeLists.txt +++ b/src/algorithms/tracking/libs/CMakeLists.txt @@ -100,12 +100,20 @@ if(Boost_VERSION VERSION_GREATER "106599") ) endif() +# Fix for Boost Asio < 1.70 if(OS_IS_MACOSX) - if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - target_compile_definitions(tracking_libs - PUBLIC - -DBOOST_ASIO_HAS_STD_STRING_VIEW - ) + if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND (${Boost_VERSION} VERSION_LESS 107000)) + if(${has_string_view}) + target_compile_definitions(tracking_libs + PUBLIC + -DBOOST_ASIO_HAS_STD_STRING_VIEW=1 + ) + else() + target_compile_definitions(tracking_libs + PUBLIC + -DBOOST_ASIO_HAS_STD_STRING_VIEW=0 + ) + endif() endif() endif() diff --git a/src/core/monitor/CMakeLists.txt b/src/core/monitor/CMakeLists.txt index 0982685ad..d888dd918 100644 --- a/src/core/monitor/CMakeLists.txt +++ b/src/core/monitor/CMakeLists.txt @@ -69,14 +69,22 @@ endif() if(OS_IS_MACOSX) - if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - target_compile_definitions(core_monitor - PUBLIC - -DBOOST_ASIO_HAS_STD_STRING_VIEW - ) + if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND (${Boost_VERSION} VERSION_LESS 107000)) + if(${has_string_view}) + target_compile_definitions(core_monitor + PUBLIC + -DBOOST_ASIO_HAS_STD_STRING_VIEW=1 + ) + else() + target_compile_definitions(core_monitor + PUBLIC + -DBOOST_ASIO_HAS_STD_STRING_VIEW=0 + ) + endif() endif() endif() + if(ENABLE_CLANG_TIDY) if(CLANG_TIDY_EXE) set_target_properties(core_monitor diff --git a/src/core/receiver/CMakeLists.txt b/src/core/receiver/CMakeLists.txt index af0c4a2f2..121b4ab75 100644 --- a/src/core/receiver/CMakeLists.txt +++ b/src/core/receiver/CMakeLists.txt @@ -162,12 +162,20 @@ target_link_libraries(core_receiver pvt_adapters ) +# Fix for Boost Asio < 1.70 if(OS_IS_MACOSX) - if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - target_compile_definitions(core_receiver - PUBLIC - -DBOOST_ASIO_HAS_STD_STRING_VIEW - ) + if((CMAKE_CXX_COMPILER_ID MATCHES "Clang") AND (${Boost_VERSION} VERSION_LESS 107000)) + if(${has_string_view}) + target_compile_definitions(core_receiver + PUBLIC + -DBOOST_ASIO_HAS_STD_STRING_VIEW=1 + ) + else() + target_compile_definitions(core_receiver + PUBLIC + -DBOOST_ASIO_HAS_STD_STRING_VIEW=0 + ) + endif() endif() endif()