From 394fa90d0d5e479b347905932180467cc02f5e14 Mon Sep 17 00:00:00 2001 From: Selim Mustafaev Date: Mon, 16 May 2022 18:22:55 +0300 Subject: [PATCH] Fix for macOS build (building folly in place) --- CMakeLists.txt | 23 ++++++++++++++++++++--- coro/Coro.h | 15 +++++++++++---- 2 files changed, 31 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3b2d572..b680514 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,16 +2,33 @@ cmake_minimum_required(VERSION 3.0) project(autocat_gnome) set(CMAKE_CXX_STANDARD 20) -#set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines") +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +if(APPLE) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fcoroutines-ts") +endif() + #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=undefined -g -Og") if(APPLE) set(ENV{PKG_CONFIG_PATH} "$ENV{PKG_CONFIG_PATH}:/usr/local/opt/libsoup@2/lib/pkgconfig:/usr/local/opt/icu4c/lib/pkgconfig") + set(OPENSSL_ROOT_DIR /usr/local/opt/openssl) + set(OPENSSL_LIBRARIES /usr/local/opt/openssl/lib) + set(FOLLY_DEP folly) + include(FetchContent) + FetchContent_Declare( + folly + GIT_REPOSITORY https://github.com/facebook/folly.git + GIT_TAG v2022.05.16.00 + ) + FetchContent_MakeAvailable(folly) +else() + find_package(folly REQUIRED) + set(FOLLY_DEP Folly::folly) endif() find_package(PkgConfig REQUIRED) find_package(nlohmann_json REQUIRED) -find_package(folly REQUIRED) pkg_check_modules(GTK REQUIRED gtk4) pkg_check_modules(GLIB REQUIRED glib-2.0) @@ -72,7 +89,7 @@ target_link_libraries(autocat_gnome ${GTK_LIBRARIES} ${LIBADWAITA_LIBRARIES} ${LIBSIGCPP_LIBRARIES} nlohmann_json::nlohmann_json - Folly::folly) + ${FOLLY_DEP}) set(XML gui/MainWindow.xml) diff --git a/coro/Coro.h b/coro/Coro.h index 48922c7..cc66e86 100644 --- a/coro/Coro.h +++ b/coro/Coro.h @@ -5,19 +5,26 @@ #ifndef AUTOCAT_GNOME_CORO_H #define AUTOCAT_GNOME_CORO_H -#include #include #include +#if __cpp_lib_coroutine + #include + namespace corons = std; +#else + #include + namespace corons = std::experimental; +#endif + template -struct std::coroutine_traits { +struct corons::coroutine_traits { struct promise_type { void get_return_object() noexcept {} - std::suspend_never initial_suspend() const noexcept { + corons::suspend_never initial_suspend() const noexcept { return {}; } - std::suspend_never final_suspend() const noexcept { + corons::suspend_never final_suspend() const noexcept { return {}; }