Use canonical cmakelogic for cross compilation, (#768)

Fix clang c++20 build
This commit is contained in:
interfector18 2021-03-24 21:27:52 +01:00 committed by GitHub
parent 5f60c9fc6c
commit 49181a22b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View File

@ -3,10 +3,10 @@ cmake_minimum_required(VERSION 3.5)
project(drogon)
message(STATUS "compiler: " ${CMAKE_CXX_COMPILER_ID})
include(CheckCXXSourceRuns)
check_cxx_source_runs("int main(){return 0;}" not_cross_compiling)
if (not_cross_compiling)
# If your cross compile is failing, you should set
# CMAKE_SYSTEM_NAME in your toolchain file
if (NOT CMAKE_CROSSCOMPILING)
set(BUILD_PROGRAMS ON)
else ()
set(BUILD_PROGRAMS OFF)

View File

@ -18,12 +18,12 @@ set(simple_example_sources
simple_example/DigestAuthFilter.cc
simple_example/main.cc)
if(DROGON_CXX_STANDARD GREATER_EQUAL 20)
if(DROGON_CXX_STANDARD GREATER_EQUAL 20 AND HAS_COROUTINE)
set(simple_example_sources ${simple_example_sources}
simple_example/api_v1_CoroTest.cc)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED TRUE)
endif(DROGON_CXX_STANDARD GREATER_EQUAL 20)
endif(DROGON_CXX_STANDARD GREATER_EQUAL 20 AND HAS_COROUTINE)
add_executable(webapp ${simple_example_sources})
drogon_create_views(webapp ${CMAKE_CURRENT_SOURCE_DIR}/simple_example
@ -68,10 +68,10 @@ set(example_targets
pipelining_test
websocket_test
multiple_ws_test)
if(DROGON_CXX_STANDARD GREATER_EQUAL 20)
if(DROGON_CXX_STANDARD GREATER_EQUAL 20 AND HAS_COROUTINE)
add_executable(websocket_coro_test simple_example_test/WebSocketCoroTest.cc)
set(simple_example ${simple_example} websocket_coro_test)
endif(DROGON_CXX_STANDARD GREATER_EQUAL 20)
endif(DROGON_CXX_STANDARD GREATER_EQUAL 20 AND HAS_COROUTINE)
set_property(TARGET ${example_targets}
PROPERTY CXX_STANDARD ${DROGON_CXX_STANDARD})

View File

@ -22,10 +22,10 @@ set(test_targets
url_codec_test
main_loop_test
main_loop_test2)
if(DROGON_CXX_STANDARD GREATER_EQUAL 20)
if(DROGON_CXX_STANDARD GREATER_EQUAL 20 AND HAS_COROUTINE)
add_executable(coroutine_test CoroutineTest.cc)
set(test_targets ${test_targets} coroutine_test)
endif(DROGON_CXX_STANDARD GREATER_EQUAL 20)
endif(DROGON_CXX_STANDARD GREATER_EQUAL 20 AND HAS_COROUTINE)
set_property(TARGET ${test_targets}
PROPERTY CXX_STANDARD ${DROGON_CXX_STANDARD})