From 00d4366afe766a652a5eec0c5d821936ec608837 Mon Sep 17 00:00:00 2001 From: Sylvain Garcia Date: Thu, 15 Oct 2020 09:00:15 +0200 Subject: [PATCH 1/4] remove CTest --- CMakeLists.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d6f0139..d35a8abc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,9 +5,10 @@ set(CMAKE_CXX_EXTENSIONS OFF) set(CMAKE_EXPORT_COMPILE_COMMANDS ON) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") -include(CTest) add_subdirectory(lib) + +enable_testing() if(BUILD_TESTING) add_subdirectory(test) endif() From a363b479bc8f87e4370c8b155bc6fa857c018cbe Mon Sep 17 00:00:00 2001 From: Sylvain Garcia Date: Thu, 22 Oct 2020 13:06:12 +0200 Subject: [PATCH 2/4] add missing stuff for MSVC - tests-main library changed to STATIC - MSVC dlls would require to do extra import/export effort --- cmake/FindCoroutines.cmake | 4 ++++ lib/CMakeLists.txt | 12 +++++++++++- test/CMakeLists.txt | 2 +- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/cmake/FindCoroutines.cmake b/cmake/FindCoroutines.cmake index be410f12..e2592759 100644 --- a/cmake/FindCoroutines.cmake +++ b/cmake/FindCoroutines.cmake @@ -110,11 +110,15 @@ cmake_push_check_state() set(CMAKE_REQUIRED_QUIET ${Coroutines_FIND_QUIETLY}) check_cxx_compiler_flag(/await _CXX_COROUTINES_SUPPORTS_MS_FLAG) +check_cxx_compiler_flag(/await:heapelide _CXX_COROUTINES_SUPPORTS_MS_HEAPELIDE_FLAG) check_cxx_compiler_flag(-fcoroutines-ts _CXX_COROUTINES_SUPPORTS_TS_FLAG) check_cxx_compiler_flag(-fcoroutines _CXX_COROUTINES_SUPPORTS_CORO_FLAG) if(_CXX_COROUTINES_SUPPORTS_MS_FLAG) set(_CXX_COROUTINES_EXTRA_FLAGS "/await") + if(_CXX_COROUTINES_SUPPORTS_MS_HEAPELIDE_FLAG AND CMAKE_SIZEOF_VOID_P GREATER_EQUAL 8) + list(APPEND _CXX_COROUTINES_EXTRA_FLAGS "/await:heapelide") + endif() elseif(_CXX_COROUTINES_SUPPORTS_TS_FLAG) set(_CXX_COROUTINES_EXTRA_FLAGS "-fcoroutines-ts") elseif(_CXX_COROUTINES_SUPPORTS_CORO_FLAG) diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt index 8fec0beb..1d2149e9 100644 --- a/lib/CMakeLists.txt +++ b/lib/CMakeLists.txt @@ -144,6 +144,14 @@ if(WIN32) socket_recv_from_operation.cpp ) list(APPEND sources ${win32Sources}) + + list(APPEND libraries Ws2_32 Mswsock Synchronization) + list(APPEND compile_options /EHsc) + + if("${MSVC_VERSION}" VERSION_GREATER_EQUAL 1900) + # TODO remove this when experimental/non-experimental include are fixed + list(APPEND compile_definition _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING=1) + endif() endif() add_library(cppcoro @@ -158,9 +166,11 @@ target_include_directories(cppcoro PUBLIC $ $) target_compile_features(cppcoro PUBLIC cxx_std_20) +target_compile_definitions(cppcoro PUBLIC ${compile_definition}) +target_compile_options(cppcoro PUBLIC ${compile_options}) find_package(Coroutines COMPONENTS Experimental Final REQUIRED) -target_link_libraries(cppcoro PUBLIC std::coroutines) +target_link_libraries(cppcoro PUBLIC std::coroutines ${libraries}) install(TARGETS cppcoro EXPORT cppcoroTargets LIBRARY DESTINATION lib diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fb2a2386..f5afecd1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -5,7 +5,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/doctest/doctest.cmake) find_package(Threads REQUIRED) -add_library(tests-main SHARED +add_library(tests-main STATIC main.cpp counted.cpp ) From cd490775b5eb27e0870d3090b3d4021c8f4063ba Mon Sep 17 00:00:00 2001 From: Sylvain Garcia Date: Fri, 23 Oct 2020 08:02:45 +0200 Subject: [PATCH 3/4] fix install FindCoroutines.cmake --- CMakeLists.txt | 2 +- cmake/cppcoroConfig.cmake | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d35a8abc..1f41ade8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -24,7 +24,7 @@ set(config_package_location lib/cmake/cppcoro) install(DIRECTORY include DESTINATION . COMPONENT Devel) -install(FILES cmake/FindCppcoroCoroutines.cmake +install(FILES cmake/FindCoroutines.cmake DESTINATION ${config_package_location} COMPONENT Devel) install(EXPORT cppcoroTargets diff --git a/cmake/cppcoroConfig.cmake b/cmake/cppcoroConfig.cmake index b2c01e83..0b9f9c0b 100644 --- a/cmake/cppcoroConfig.cmake +++ b/cmake/cppcoroConfig.cmake @@ -1,6 +1,6 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}) include(CMakeFindDependencyMacro) -find_dependency(CppcoroCoroutines QUIET REQUIRED) +find_dependency(Coroutines QUIET REQUIRED) include("${CMAKE_CURRENT_LIST_DIR}/cppcoroTargets.cmake") From e0cd46a606327cd0f618bbdd46047de76b572504 Mon Sep 17 00:00:00 2001 From: Sylvain Garcia Date: Fri, 23 Oct 2020 08:03:03 +0200 Subject: [PATCH 4/4] fix install target on Windows --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f41ade8..e76ee03c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,8 +21,8 @@ configure_file(cmake/cppcoroConfig.cmake COPYONLY) set(config_package_location lib/cmake/cppcoro) -install(DIRECTORY include - DESTINATION . +install(DIRECTORY include/cppcoro + DESTINATION include COMPONENT Devel) install(FILES cmake/FindCoroutines.cmake DESTINATION ${config_package_location}