diff --git a/CMakeLists.txt b/CMakeLists.txt index 7d6f0139..e76ee03c 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() @@ -20,10 +21,10 @@ 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/FindCppcoroCoroutines.cmake +install(FILES cmake/FindCoroutines.cmake DESTINATION ${config_package_location} COMPONENT Devel) install(EXPORT cppcoroTargets 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/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") 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 )