Skip to content

Commit e29ba1d

Browse files
authored
Merge pull request #23 from andreasbuhr/fix_msvc_cpp17
Fix msvc cpp17
2 parents 52009b9 + 26959a6 commit e29ba1d

File tree

3 files changed

+25
-1
lines changed

3 files changed

+25
-1
lines changed

cmake/FindCoroutines.cmake

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,10 +150,19 @@ endif()
150150

151151
if(find_final)
152152
check_include_file_cxx("coroutine" _CXX_COROUTINES_HAVE_HEADER)
153+
if(_CXX_COROUTINES_HAVE_HEADER)
154+
check_cxx_source_compiles("#include <coroutine> \n typedef std::suspend_never blub; \nint main() {} " _CXX_COROUTINES_FINAL_HEADER_COMPILES)
155+
set(_CXX_COROUTINES_HAVE_HEADER ${}_CXX_COROUTINES_FINAL_HEADER_COMPILES})
156+
endif()
157+
153158
if(NOT _CXX_COROUTINES_HAVE_HEADER)
154159
cmake_push_check_state()
155160
set(CMAKE_REQUIRED_FLAGS "${_CXX_COROUTINES_EXTRA_FLAGS}")
156161
check_include_file_cxx("coroutine" _CXX_COROUTINES_HAVE_HEADER_WITH_FLAG)
162+
if(_CXX_COROUTINES_HAVE_HEADER_WITH_FLAG)
163+
check_cxx_source_compiles("#include <coroutine> \n typedef std::suspend_never blub; \nint main() {} " _CXX_COROUTINES_FINAL_HEADER_COMPILES_WITH_FLAG)
164+
set(_CXX_COROUTINES_HAVE_HEADER_WITH_FLAG ${_CXX_COROUTINES_FINAL_HEADER_COMPILES_WITH_FLAG})
165+
endif()
157166
set(_CXX_COROUTINES_HAVE_HEADER ${_CXX_COROUTINES_HAVE_HEADER_WITH_FLAG})
158167
cmake_pop_check_state()
159168
endif()

include/cppcoro/config.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,4 +150,17 @@
150150
# define CPPCORO_CPU_CACHE_LINE 64
151151
#endif
152152

153+
#if CPPCORO_COMPILER_MSVC
154+
#if __has_include(<coroutine>)
155+
#include <yvals_core.h>
156+
#ifdef __cpp_lib_coroutine
157+
#define CPPCORO_COROHEADER_FOUND_AND_USABLE
158+
#endif
159+
#endif
160+
#else
161+
#if __has_include(<coroutine>)
162+
#define CPPCORO_COROHEADER_FOUND_AND_USABLE
163+
#endif
164+
#endif
165+
153166
#endif

include/cppcoro/coroutine.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
#ifndef CPPCORO_COROUTINE_HPP_INCLUDED
22
#define CPPCORO_COROUTINE_HPP_INCLUDED
33

4-
#if __has_include(<coroutine>)
4+
#include <cppcoro/config.hpp>
5+
6+
#ifdef CPPCORO_COROHEADER_FOUND_AND_USABLE
57

68
#include <coroutine>
79

0 commit comments

Comments
 (0)