diff options
author | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2017-09-10 02:44:03 +0300 |
---|---|---|
committer | Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com> | 2017-09-10 02:44:03 +0300 |
commit | afa177fe7e944a5adc015d5237a5bed2c9cc5e2e (patch) | |
tree | bc19526da1c294771b0c23859acb5f2aec1ad661 /CMakeLists.txt | |
parent | fa4497d76545b0543ac9818b87c2fb1b0dbfe0f8 (diff) |
Now clang 5.0 with its Coroutines TS is out, added Coroutines TS detection to cmake.
mapped_file_handle is compiling on POSIX, but I very much doubt is working. Moving over to my FreeBSD box for debugging.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e435b2e0..37a29431 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,6 +36,32 @@ include(QuickCppLibMakeHeaderOnlyLibrary) include(QuickCppLibMakeDoxygen) # Set the standard definitions for these libraries and bring in the all_* helper functions include(QuickCppLibApplyDefaultDefinitions) +# Do we have the Coroutines TS? +function(CheckCXXHasCoroutines iter flags) + set(CMAKE_REQUIRED_FLAGS "${flags}") + check_cxx_source_compiles(" +#include <future> +std::future<int> g() { co_return 0; } +int main() { return g().get(); } +" CXX_HAS_COROUTINES${iter}) + set(CXX_HAS_COROUTINES${iter} ${CXX_HAS_COROUTINES${iter}} PARENT_SCOPE) +endfunction() +include(CheckCXXSourceCompiles) +if(MSVC) + CheckCXXHasCoroutines(_MSVC "/await") + if(CXX_HAS_COROUTINES_MSVC) + all_compile_options(PUBLIC "/await") + all_compile_definitions(PUBLIC "__cpp_coroutines") + endif() +endif() +if(CLANG OR GCC) + CheckCXXHasCoroutines(_CLANG_GCC "-std=c++14 -fcoroutines-ts") + if(CXX_HAS_COROUTINES_CLANG_GCC) + all_compile_options(PUBLIC "-fcoroutines-ts") + all_compile_definitions(PUBLIC "__cpp_coroutines") + endif() +endif() + # Set the C++ features this library requires all_compile_features(PUBLIC # cxx_exceptions ## Annoyingly not supported by cmake 3.6 |