Reputation: 305
I am trying to compile a program with #include <coroutine>
header file included in it. But gcc10 throws an error
/usr/include/c++/10/coroutine:295:2: error: #error "the coroutine header requires -fcoroutines"
295 | #error "the coroutine header requires -fcoroutines"
I set all the necessary flags in cmake
cmake_minimum_required(VERSION 3.17)
project(cortest1)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_FLAGS "-fcoroutines")
set(CMAKE_CXX_FLAGS "-pthread")
add_executable(cortest1 main.cpp)
But the compiler doesn't see the -fcoroutines flag. I am using g ++ 10.2.0
Upvotes: 4
Views: 3177
Reputation: 238401
set(CMAKE_CXX_FLAGS "-pthread")
After you set the flags to -pthread, it no longer has the previous value that had the coroutine flag.
P.S. Use target specific configuration i.e. don't set CMAKE_CXX_FLAGS. Use target_compile_options instead. And use target_compile_features instead of setting CMAKE_CXX_STANDARD.
Upvotes: 4