From 68306be89ee8cdd88f96d798565204e55da0b81d Mon Sep 17 00:00:00 2001 From: Rodrigo Reichert Date: Thu, 9 May 2024 19:19:05 -0300 Subject: [PATCH] ASIO gRPC boost container fix (#174) # Changes Moved a number of changes made manually into one of our repositories to the `find_package` code where it can be used globally. --- FindAsioGrpc.cmake | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/FindAsioGrpc.cmake b/FindAsioGrpc.cmake index 504993e..05a8bef 100644 --- a/FindAsioGrpc.cmake +++ b/FindAsioGrpc.cmake @@ -12,8 +12,39 @@ include("GenericFindDependency") +# asio-grpc has some logic to conditionally enable boost containers, this +# should just be defaulted to false since the standard library offers the same +# functionality. +option(ASIO_GRPC_USE_BOOST_CONTAINER "(deprecated) Use Boost.Container instead of " false) + GenericFindDependency( TARGET asio-grpc::asio-grpc-standalone-asio SOURCE_DIR asio-grpc SYSTEM_INCLUDES ) + +# Older libc++ versions like the one that ships with clang < v16 doesn't offer +# the "memory_resource" standard header which is used by the library, instead +# we conditionally select it to use "experimental/memory_resource" which is +# available. The conditional selection is done via a customer preprocessor +# which we've (Swift Navigation) introduced. +include(CheckExperimentalMemoryResource) +check_experimental_memory_resource(IS_EXPERIMENTAL_MEMORY_RESOURCE) +if (IS_EXPERIMENTAL_MEMORY_RESOURCE) + target_compile_definitions(asio-grpc-standalone-asio + INTERFACE + SWIFTNAV_EXPERIMENTAL_MEMORY_RESOURCE + ) +endif() + +# asio-grpc uses language features that are removed in c++20, the libc++ +# implementation actually removed these features unless you set a special +# macro. +include(CheckLibcpp) +check_libcpp(IS_LIBCPP) +if (IS_LIBCPP) + target_compile_definitions(asio-grpc-standalone-asio + INTERFACE + _LIBCPP_ENABLE_CXX20_REMOVED_FEATURES + ) +endif()