From 8deaf1cd3d20d19fa2acf608eb7fede2eb77663e Mon Sep 17 00:00:00 2001 From: Indy Ray Date: Sat, 19 Mar 2022 04:32:46 +0000 Subject: [PATCH 1/3] Initial cmake build support. --- CMakeLists.txt | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..6ea8b51 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,20 @@ +cmake_minimum_required(VERSION 3.15) + +project(SquidTasks) + +add_library(${PROJECT_NAME} INTERFACE) + +# There doesn't seem to be a coroutines feature in CMAKE_CXX_KNOWN_FEATURES +target_compile_features(${PROJECT_NAME} INTERFACE "cxx_std_20") +target_compile_options(${PROJECT_NAME} INTERFACE "-fcoroutines") + +target_include_directories(${PROJECT_NAME} INTERFACE include) + +target_sources(${PROJECT_NAME} INTERFACE + include/Task.h + include/TaskManager.h + include/TasksConfig.h + include/TokenList.h + include/TaskFSM.h + include/FunctionGuard.h + ) From 9b573c34223c4584f9010b1a42c802ed8cb99c3d Mon Sep 17 00:00:00 2001 From: Indy Ray Date: Mon, 21 Mar 2022 12:15:45 -0700 Subject: [PATCH 2/3] CMake:Only use -fcoroutines for Clang builds. --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6ea8b51..26a39ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -6,7 +6,9 @@ add_library(${PROJECT_NAME} INTERFACE) # There doesn't seem to be a coroutines feature in CMAKE_CXX_KNOWN_FEATURES target_compile_features(${PROJECT_NAME} INTERFACE "cxx_std_20") -target_compile_options(${PROJECT_NAME} INTERFACE "-fcoroutines") +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_compile_options(${PROJECT_NAME} INTERFACE "-fcoroutines") +endif() target_include_directories(${PROJECT_NAME} INTERFACE include) From 1d6bcbb0669c4cdf1ae851dc0044ada5658d3abd Mon Sep 17 00:00:00 2001 From: Indy Ray Date: Tue, 22 Mar 2022 15:05:32 -0700 Subject: [PATCH 3/3] Additional cmake work, adding MSVC option arguments, and adding build samples. --- CMakeLists.txt | 30 +++++++++++++++++++++++--- samples/Sample_Template/CMakeLists.txt | 10 +++++++++ samples/Sample_Tests/CMakeLists.txt | 10 +++++++++ samples/Sample_TextGame/CMakeLists.txt | 12 +++++++++++ 4 files changed, 59 insertions(+), 3 deletions(-) create mode 100644 samples/Sample_Template/CMakeLists.txt create mode 100644 samples/Sample_Tests/CMakeLists.txt create mode 100644 samples/Sample_TextGame/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 26a39ae..cc48558 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,9 +5,20 @@ project(SquidTasks) add_library(${PROJECT_NAME} INTERFACE) # There doesn't seem to be a coroutines feature in CMAKE_CXX_KNOWN_FEATURES -target_compile_features(${PROJECT_NAME} INTERFACE "cxx_std_20") -if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - target_compile_options(${PROJECT_NAME} INTERFACE "-fcoroutines") + +# Some errors in Sample_TextGame with std_20 +#target_compile_features(${PROJECT_NAME} INTERFACE "cxx_std_20") + +if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + target_compile_options(${PROJECT_NAME} INTERFACE "-fcoroutines-ts") +elseif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC") + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 16.10) + # Seems like we should use /await:strict here, but seems to fail. + #target_compile_options(${PROJECT_NAME} INTERFACE "/await:strict") + target_compile_options(${PROJECT_NAME} INTERFACE "/await") + else() + target_compile_options(${PROJECT_NAME} INTERFACE "/await") + endif() endif() target_include_directories(${PROJECT_NAME} INTERFACE include) @@ -19,4 +30,17 @@ target_sources(${PROJECT_NAME} INTERFACE include/TokenList.h include/TaskFSM.h include/FunctionGuard.h + # Private + include/Private/TaskPrivate.h + include/Private/TaskFSMPrivate.h + include/Private/TasksCommonPrivate.h + include/Private/tl/optional.hpp ) + +option(SQUIDTASKS_BUILD_SAMPLES "Enable building with samples." OFF) + +if(SQUIDTASKS_BUILD_SAMPLES) + add_subdirectory(samples/Sample_Tests) + add_subdirectory(samples/Sample_Template) + add_subdirectory(samples/Sample_TextGame) +endif() \ No newline at end of file diff --git a/samples/Sample_Template/CMakeLists.txt b/samples/Sample_Template/CMakeLists.txt new file mode 100644 index 0000000..6e6f0f0 --- /dev/null +++ b/samples/Sample_Template/CMakeLists.txt @@ -0,0 +1,10 @@ +add_executable(Sample_Template) + +target_link_libraries(Sample_Template SquidTasks) + +target_include_directories(Sample_Template PRIVATE ../Common) + +target_sources(Sample_Template PRIVATE + ../Common/TimeSystem.h + Main.cpp +) \ No newline at end of file diff --git a/samples/Sample_Tests/CMakeLists.txt b/samples/Sample_Tests/CMakeLists.txt new file mode 100644 index 0000000..899439f --- /dev/null +++ b/samples/Sample_Tests/CMakeLists.txt @@ -0,0 +1,10 @@ +add_executable(Sample_Tests) + +target_link_libraries(Sample_Tests SquidTasks) + +target_include_directories(Sample_Tests PRIVATE ../Common) + +target_sources(Sample_Tests PRIVATE + ../Common/TimeSystem.h + Main.cpp +) \ No newline at end of file diff --git a/samples/Sample_TextGame/CMakeLists.txt b/samples/Sample_TextGame/CMakeLists.txt new file mode 100644 index 0000000..6d3ffad --- /dev/null +++ b/samples/Sample_TextGame/CMakeLists.txt @@ -0,0 +1,12 @@ +add_executable(Sample_TextGame) + +target_link_libraries(Sample_TextGame SquidTasks) + +target_include_directories(Sample_TextGame PRIVATE ../Common) + +target_sources(Sample_TextGame PRIVATE + ../Common/TimeSystem.h + TextGame.h + TextInput.h + Main.cpp +) \ No newline at end of file