Skip to content

Commit 5f20152

Browse files
committed
cleanup FindCppcoroCoroutines.cmake
1 parent 0112bd8 commit 5f20152

File tree

2 files changed

+13
-21
lines changed

2 files changed

+13
-21
lines changed

README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -2954,8 +2954,8 @@ $ cmake . -Dcppcoro_ROOT=$HOME/.local
29542954
# ...
29552955
-- Performing Test Coroutines_SUPPORTS_MS_FLAG
29562956
-- Performing Test Coroutines_SUPPORTS_MS_FLAG - Failed
2957-
-- Performing Test Coroutines_SUPPORTS_GNU_FLAG
2958-
-- Performing Test Coroutines_SUPPORTS_GNU_FLAG - Success
2957+
-- Performing Test Coroutines_SUPPORTS_COROUTINES_FLAG
2958+
-- Performing Test Coroutines_SUPPORTS_COROUTINES_FLAG - Success
29592959
-- Looking for C++ include coroutine
29602960
-- Looking for C++ include coroutine - not found
29612961
-- Looking for C++ include experimental/coroutine

cmake/FindCppcoroCoroutines.cmake

+11-19
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,23 @@ include(CheckIncludeFileCXX)
33
include(FindPackageHandleStandardArgs)
44

55
check_cxx_compiler_flag(/await Coroutines_SUPPORTS_MS_FLAG)
6-
check_cxx_compiler_flag(-fcoroutines-ts Coroutines_ts_SUPPORTS_GNU_FLAG)
7-
check_cxx_compiler_flag(-fcoroutines Coroutines_SUPPORTS_GNU_FLAG)
8-
if(Coroutines_SUPPORTS_MS_FLAG OR Coroutines_ts_SUPPORTS_GNU_FLAG OR Coroutines_SUPPORTS_GNU_FLAG)
6+
check_cxx_compiler_flag(-fcoroutines-ts Coroutines_SUPPORTS_COROUTINES_TS_FLAG)
7+
check_cxx_compiler_flag(-fcoroutines Coroutines_SUPPORTS_COROUTINES_FLAG)
8+
if(Coroutines_SUPPORTS_MS_FLAG OR Coroutines_SUPPORTS_COROUTINES_TS_FLAG OR Coroutines_SUPPORTS_COROUTINES_FLAG)
99
set(Coroutines_COMPILER_SUPPORT ON)
1010
endif()
1111

1212
if(Coroutines_SUPPORTS_MS_FLAG)
13-
check_include_file_cxx("coroutine" Coroutines_STANDARD_LIBRARY_SUPPORT "/await")
14-
check_include_file_cxx("experimental/coroutine" Coroutines_EXPERIMENTAL_LIBRARY_SUPPORT "/await")
15-
elseif(Coroutines_ts_SUPPORTS_GNU_FLAG)
16-
check_include_file_cxx("coroutine" Coroutines_STANDARD_LIBRARY_SUPPORT "-fcoroutines-ts")
17-
check_include_file_cxx("experimental/coroutine" Coroutines_EXPERIMENTAL_LIBRARY_SUPPORT "-fcoroutines-ts")
18-
elseif(Coroutines_SUPPORTS_GNU_FLAG)
19-
check_include_file_cxx("coroutine" Coroutines_STANDARD_LIBRARY_SUPPORT "-fcoroutines")
20-
check_include_file_cxx("experimental/coroutine" Coroutines_EXPERIMENTAL_LIBRARY_SUPPORT "-fcoroutines")
13+
set(Coroutines_EXTRA_FLAGS "/await")
14+
elseif(Coroutines_SUPPORTS_COROUTINES_TS_FLAG)
15+
set(Coroutines_EXTRA_FLAGS "-fcoroutines-ts")
16+
elseif(Coroutines_SUPPORTS_COROUTINES_FLAG)
17+
set(Coroutines_EXTRA_FLAGS "-fcoroutines")
2118
endif()
2219

20+
check_include_file_cxx("coroutine" Coroutines_STANDARD_LIBRARY_SUPPORT ${Coroutines_EXTRA_FLAGS})
21+
check_include_file_cxx("experimental/coroutine" Coroutines_EXPERIMENTAL_LIBRARY_SUPPORT ${Coroutines_EXTRA_FLAGS})
22+
2323
if(Coroutines_EXPERIMENTAL_LIBRARY_SUPPORT OR Coroutines_STANDARD_LIBRARY_SUPPORT)
2424
set(Coroutines_LIBRARY_SUPPORT ON)
2525
endif()
@@ -33,12 +33,4 @@ if(NOT CppcoroCoroutines_FOUND OR TARGET cppcoro::coroutines)
3333
endif()
3434

3535
add_library(cppcoro::coroutines INTERFACE IMPORTED)
36-
if(Coroutines_SUPPORTS_MS_FLAG)
37-
target_compile_options(cppcoro::coroutines INTERFACE /await)
38-
elseif(Coroutines_ts_SUPPORTS_GNU_FLAG)
39-
target_compile_options(cppcoro::coroutines INTERFACE -fcoroutines-ts)
40-
elseif(Coroutines_SUPPORTS_GNU_FLAG)
41-
target_compile_options(cppcoro::coroutines INTERFACE -fcoroutines)
42-
endif()
43-
4436
target_compile_options(cppcoro::coroutines INTERFACE ${Coroutines_EXTRA_FLAGS})

0 commit comments

Comments
 (0)