[cppcoro] add new port (#10693)

* [cppcoro] add new port

* [cppcoro] update with PR review

* update reference to tag and hash value
* ${PORT} for destination

Linux build support should marked unavailable?

* [cppcoro] embed CMakeLists.txt file

* copy the CMakeLists.txt file and start build with it
* change version to 2020.2

For now the repo doesn't have any tags.
Therefore its version followed the latest commit,
which is made in 2020 Feb.

* [cppcoro] 2020-02-28

* [cppcoro] port install failure on platforms

* vcpkg_fail_port_install on uwp/linux

mention PR #10693 so linux/clang users can see the port issues

* [cppcoro] force static linkage

* report error for clang-cl

build with VC++ in VS 2019 will fail by the header file.

* [cppcoro] register ci.baseline failure

* [cppcoro] Simplify CMakeLists.txt to ease future maintenance. Fix VS 2019 builds.

Co-authored-by: Robert Schumacher <roschuma@microsoft.com>
This commit is contained in:
Robert Schumacher 2020-04-24 14:01:38 -07:00 committed by GitHub
commit 84f94fb6fd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 247 additions and 0 deletions

View File

@ -0,0 +1,202 @@
cmake_minimum_required(VERSION 3.8)
project(cppcoro VERSION 2020.2 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
add_library(cppcoro
lib/async_mutex.cpp
lib/lightweight_manual_reset_event.cpp
lib/async_auto_reset_event.cpp
lib/async_manual_reset_event.cpp
lib/auto_reset_event.cpp
lib/auto_reset_event.hpp
lib/cancellation_registration.cpp
lib/cancellation_source.cpp
lib/cancellation_state.cpp
lib/cancellation_state.hpp
lib/cancellation_token.cpp
lib/spin_mutex.cpp
lib/spin_mutex.hpp
lib/spin_wait.cpp
lib/spin_wait.hpp
lib/static_thread_pool.cpp
lib/ip_address.cpp
lib/ip_endpoint.cpp
lib/ipv4_address.cpp
lib/ipv4_endpoint.cpp
lib/ipv6_address.cpp
lib/ipv6_endpoint.cpp
)
if(APPLE)
message(STATUS "using sysroot: ${CMAKE_OSX_SYSROOT}")
elseif(WIN32)
message(STATUS "using platform: ${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}")
# for now, build in single target
target_sources(cppcoro
PRIVATE
lib/win32.cpp
lib/file.cpp
lib/file_read_operation.cpp
lib/file_write_operation.cpp
lib/read_only_file.cpp
lib/read_write_file.cpp
lib/readable_file.cpp
lib/writable_file.cpp
lib/write_only_file.cpp
lib/socket.cpp
lib/socket_accept_operation.cpp
lib/socket_connect_operation.cpp
lib/socket_send_operation.cpp
lib/socket_send_to_operation.cpp
lib/socket_disconnect_operation.cpp
lib/socket_helpers.cpp
lib/socket_helpers.hpp
lib/socket_recv_from_operation.cpp
lib/socket_recv_operation.cpp
lib/io_service.cpp
)
elseif(CMAKE_SYSTEM_NAME MATCHES "Linux")
message(STATUS "using system: ${CMAKE_HOST_SYSTEM_VERSION}")
endif()
target_include_directories(cppcoro
PUBLIC
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
if(WIN32)
message(FATAL_ERROR "<experimental/resumable> doesn't support clang-cl compiler")
else()
target_compile_options(cppcoro
PUBLIC
-std=c++1z -fcoroutines-ts
-stdlib=libc++
)
target_link_libraries(cppcoro
PUBLIC
c++ pthread
)
endif()
elseif(MSVC)
target_compile_options(cppcoro
PUBLIC
/await
PRIVATE
"/analyze:max_paths 512"
-D_SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING=1
)
if(CMAKE_GENERATOR_PLATFORM STREQUAL x64)
target_compile_options(cppcoro
PUBLIC
/await:heapelide
)
endif()
endif()
if(WIN32)
target_link_libraries(cppcoro
PUBLIC
kernel32 synchronization ws2_32 mswsock
# msvcrt[d] msvcprt[d] vcruntime ucrt
)
elseif(APPLE)
elseif(CMAKE_SYSTEM_NAME MATCHES Linux)
target_link_libraries(cppcoro
PUBLIC
c++ # stdc++ # expect libc++ instead of libstdc++
)
endif()
install(DIRECTORY include/cppcoro
DESTINATION include
)
install(TARGETS cppcoro
EXPORT ${PROJECT_NAME}-config
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
install(EXPORT ${PROJECT_NAME}-config
DESTINATION share/${PROJECT_NAME}
)
include(CMakePackageConfigHelpers)
set(VERSION_FILE_PATH ${CMAKE_BINARY_DIR}/cmake/${PROJECT_NAME}-config-version.cmake)
write_basic_package_version_file(${VERSION_FILE_PATH}
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion
)
install(FILES ${VERSION_FILE_PATH}
DESTINATION share/${PROJECT_NAME}
)
if(NOT BUILD_TESTING)
return()
endif()
enable_testing()
find_package(Threads REQUIRED)
add_executable(cppcoro_test
test/main.cpp test/counted.cpp
test/generator_tests.cpp
# test/recursive_generator_tests.cpp # clang crash
test/async_generator_tests.cpp
test/async_auto_reset_event_tests.cpp
test/async_manual_reset_event_tests.cpp
test/async_mutex_tests.cpp
test/async_latch_tests.cpp
test/cancellation_token_tests.cpp
test/task_tests.cpp
test/sequence_barrier_tests.cpp
test/shared_task_tests.cpp
test/sync_wait_tests.cpp
test/single_consumer_async_auto_reset_event_tests.cpp
test/single_producer_sequencer_tests.cpp
test/multi_producer_sequencer_tests.cpp
test/when_all_tests.cpp
test/when_all_ready_tests.cpp
test/ip_address_tests.cpp
test/ip_endpoint_tests.cpp
test/ipv4_address_tests.cpp
test/ipv4_endpoint_tests.cpp
test/ipv6_address_tests.cpp
test/ipv6_endpoint_tests.cpp
test/static_thread_pool_tests.cpp
)
target_link_libraries(cppcoro_test
PRIVATE
cppcoro
Threads::Threads
)
find_package(doctest CONFIG REQUIRED)
get_target_property(DOCTEST_INCLUDE_DIR doctest::doctest
INTERFACE_INCLUDE_DIRECTORIES
)
message(STATUS "using doctest: ${DOCTEST_INCLUDE_DIR}")
target_link_libraries(cppcoro_test
PRIVATE
doctest::doctest
)
if(WIN32)
target_sources(cppcoro_test
PRIVATE
test/scheduling_operator_tests.cpp
test/io_service_tests.cpp
test/file_tests.cpp
test/socket_tests.cpp
)
endif()
add_test(NAME test_all COMMAND cppcoro_test --duration=true )

5
ports/cppcoro/CONTROL Normal file
View File

@ -0,0 +1,5 @@
Source: cppcoro
Homepage: https://github.com/lewissbaker/cppcoro
Version: 2020-2-28-1
Description: A library of C++ coroutine abstractions for the Coroutines TS
Supports: !uwp

View File

@ -0,0 +1,37 @@
vcpkg_fail_port_install(ON_TARGET "uwp")
vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
if(VCPKG_TARGET_IS_LINUX)
message("Warning: cppcoro requires libc++ and Clang on Linux. See https://github.com/microsoft/vcpkg/pull/10693#issuecomment-610394650.")
endif()
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO lewissbaker/cppcoro
REF 92892f31d0c41b8e34e6292d7c9d99228da5c501
SHA512 d1997b7449f1c5c0790575d0755ffbb5f9eef13a7610f3ec666a585bdbb93bb1553f79214c1023a1ef23aaeef64078ca6ee3784107645d7a75c7bba943c10b84
HEAD_REF master
)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt
DESTINATION ${SOURCE_PATH}
)
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS
-DBUILD_TESTING=False
)
vcpkg_install_cmake()
vcpkg_fixup_cmake_targets()
file(INSTALL ${SOURCE_PATH}/LICENSE.txt
DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT}
RENAME copyright
)
vcpkg_copy_pdbs()
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/include)
file(REMOVE_RECURSE ${CURRENT_PACKAGES_DIR}/debug/share)

View File

@ -283,6 +283,9 @@ cpp-netlib:arm-uwp=fail
cpp-netlib:x64-uwp=fail
cpp-netlib:x64-linux=ignore
cpp-taskflow:x64-osx=fail
cppcoro:x64-linux=fail
cppcoro:arm-uwp=fail
cppcoro:x64-uwp=fail
cppunit:arm64-windows=fail
cppunit:arm-uwp=fail
cppunit:x64-linux=fail