Skip to content

Commit ad194d5

Browse files
committed
Detect toolchains that don't support co_await in Boost.Asio
1 parent 5164d88 commit ad194d5

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

cmake/test_boost_beast.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// This is a dummy program that just needs to compile to tell us if Boost.Asio
2+
// supports co_await and Boost.Beast is installed.
3+
4+
#include <boost/asio/use_awaitable.hpp>
5+
6+
#include <boost/beast.hpp>
7+
8+
int main()
9+
{
10+
#ifdef BOOST_ASIO_HAS_CO_AWAIT
11+
return 0;
12+
#else
13+
#error BOOST_ASIO_HAS_CO_AWAIT is undefined
14+
#endif
15+
}

samples/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@ if(GRAPHQL_BUILD_HTTP_SAMPLE)
1212
find_package(Boost QUIET)
1313
if(Boost_FOUND)
1414
if(Boost_VERSION VERSION_GREATER_EQUAL "1.81.0")
15-
if(EXISTS "${Boost_INCLUDE_DIR}/boost/beast.hpp")
15+
try_compile(TEST_RESULT
16+
${CMAKE_CURRENT_BINARY_DIR}
17+
${CMAKE_CURRENT_SOURCE_DIR}/../cmake/test_boost_beast.cpp
18+
CMAKE_FLAGS -DINCLUDE_DIRECTORIES:STRING=${Boost_INCLUDE_DIR}
19+
CXX_STANDARD 20)
20+
21+
if(TEST_RESULT)
1622
message(STATUS "Using Boost.Beast ${Boost_VERSION}")
1723
add_subdirectory(proxy)
1824
else()
19-
message(WARNING "GRAPHQL_BUILD_HTTP_SAMPLE requires the Boost.Beast header-only library, but it was not found in ${Boost_INCLUDE_DIR}.")
25+
message(WARNING "GRAPHQL_BUILD_HTTP_SAMPLE requires the Boost.Beast header-only library and a toolchain that supports co_await in Boost.Asio.")
2026
endif()
2127
else()
2228
message(WARNING "GRAPHQL_BUILD_HTTP_SAMPLE requires the Boost.Beast header-only library >= 1.81.0, but only ${Boost_VERSION} was found in ${Boost_INCLUDE_DIR}.")

0 commit comments

Comments
 (0)