diff --git a/cmake/FindCppcoroCoroutines.cmake b/cmake/FindCppcoroCoroutines.cmake index 7f01ddb2..e6657bde 100644 --- a/cmake/FindCppcoroCoroutines.cmake +++ b/cmake/FindCppcoroCoroutines.cmake @@ -3,19 +3,24 @@ include(CheckIncludeFileCXX) include(FindPackageHandleStandardArgs) check_cxx_compiler_flag(/await Coroutines_SUPPORTS_MS_FLAG) -check_cxx_compiler_flag(-fcoroutines-ts Coroutines_SUPPORTS_GNU_FLAG) -if(Coroutines_SUPPORTS_MS_FLAG OR Coroutines_SUPPORTS_GNU_FLAG) +check_cxx_compiler_flag(-fcoroutines-ts Coroutines_SUPPORTS_CLANG_FLAG) +check_cxx_compiler_flag(-fcoroutines Coroutines_SUPPORTS_GCC_FLAG) +if(Coroutines_SUPPORTS_MS_FLAG OR Coroutines_SUPPORTS_CLANG_FLAG OR Coroutines_SUPPORTS_GCC_FLAG) set(Coroutines_COMPILER_SUPPORT ON) endif() +set(Coroutines_ADDITIONAL_FLAG "") if(Coroutines_SUPPORTS_MS_FLAG) - check_include_file_cxx("coroutine" Coroutines_STANDARD_LIBRARY_SUPPORT "/await") - check_include_file_cxx("experimental/coroutine" Coroutines_EXPERIMENTAL_LIBRARY_SUPPORT "/await") -elseif(Coroutines_SUPPORTS_GNU_FLAG) - check_include_file_cxx("coroutine" Coroutines_STANDARD_LIBRARY_SUPPORT "-fcoroutines-ts") - check_include_file_cxx("experimental/coroutine" Coroutines_EXPERIMENTAL_LIBRARY_SUPPORT "-fcoroutines-ts") + set(Coroutines_ADDITIONAL_FLAG "/await") +elseif(Coroutines_SUPPORTS_CLANG_FLAG) + set(Coroutines_ADDITIONAL_FLAG "-fcoroutines-ts") +elseif(Coroutines_SUPPORTS_GCC_FLAG) + set(Coroutines_ADDITIONAL_FLAG "-fcoroutines") endif() +check_include_file_cxx("coroutine" Coroutines_STANDARD_LIBRARY_SUPPORT ${Coroutines_ADDITIONAL_FLAG}) +check_include_file_cxx("experimental/coroutine" Coroutines_EXPERIMENTAL_LIBRARY_SUPPORT ${Coroutines_ADDITIONAL_FLAG}) + if(Coroutines_EXPERIMENTAL_LIBRARY_SUPPORT OR Coroutines_STANDARD_LIBRARY_SUPPORT) set(Coroutines_LIBRARY_SUPPORT ON) endif() @@ -29,8 +34,4 @@ if(NOT CppcoroCoroutines_FOUND OR TARGET cppcoro::coroutines) endif() add_library(cppcoro::coroutines INTERFACE IMPORTED) -if(Coroutines_SUPPORTS_MS_FLAG) - target_compile_options(cppcoro::coroutines INTERFACE /await) -elseif(Coroutines_SUPPORTS_GNU_FLAG) - target_compile_options(cppcoro::coroutines INTERFACE -fcoroutines-ts) -endif() +target_compile_options(cppcoro::coroutines INTERFACE ${Coroutines_ADDITIONAL_FLAG})