Issue
I'm trying to integrate a boost project using asio and coroutines on android. I use set(CMAKE_CXX_FLAGS "-fcoroutines-ts")
on the CMakeLists.txt file (c++17 is used). When i set this flag the ANDROID macro becomes undefined. If i add -DANDROID then the coroutines get disabled. Are this two flags incompatible? Can i use c++ coroutines on Android with NDK?
Solution
By setting CMAKE_CXX_FLAGS
you're overwriting the original value, which likely was set to include -DANDROID
by the toolchain file you're using or CMake directly. There are two possibilities here:
- You can use
add_compile_options("-fcoroutines-ts")
instead, this will add the flag to all targets defined afterwards - If only a single target makes use of coroutines you can also set it via
target_compile_options(<target> PUBLIC "-fcoroutines-ts")
ortarget_compile_options(<target> PRIVATE "-fcoroutines-ts")
depending on whether you're using coroutines in public headers of that target (choose PUBLIC) or only in the implementation (choose PRIVATE).
Answered By - Corristo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.