Skip to content

Commit e01e4e8

Browse files
Sylvain GarciaGarcia6l20
authored andcommitted
add missing stuff for MSVC
- tests-main library changed to STATIC - MSVC dlls would require to do extra import/export effort
1 parent 00d4366 commit e01e4e8

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

cmake/FindCoroutines.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,9 @@ check_cxx_compiler_flag(-fcoroutines _CXX_COROUTINES_SUPPORTS_CORO_FLAG)
115115

116116
if(_CXX_COROUTINES_SUPPORTS_MS_FLAG)
117117
set(_CXX_COROUTINES_EXTRA_FLAGS "/await")
118+
if(CMAKE_CL_64)
119+
list(APPEND _CXX_COROUTINES_EXTRA_FLAGS "/await:heapelide")
120+
endif()
118121
elseif(_CXX_COROUTINES_SUPPORTS_TS_FLAG)
119122
set(_CXX_COROUTINES_EXTRA_FLAGS "-fcoroutines-ts")
120123
elseif(_CXX_COROUTINES_SUPPORTS_CORO_FLAG)

lib/CMakeLists.txt

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,14 @@ if(WIN32)
144144
socket_recv_from_operation.cpp
145145
)
146146
list(APPEND sources ${win32Sources})
147+
148+
list(APPEND libraries Ws2_32 Mswsock Synchronization)
149+
list(APPEND compile_options /EHsc)
150+
151+
if("${MSVC_VERSION}" VERSION_GREATER_EQUAL 1900)
152+
# TODO remove this when experimental/non-experimental include are fixed
153+
list(APPEND compile_definition _SILENCE_EXPERIMENTAL_FILESYSTEM_DEPRECATION_WARNING=1)
154+
endif()
147155
endif()
148156

149157
add_library(cppcoro
@@ -158,9 +166,11 @@ target_include_directories(cppcoro PUBLIC
158166
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include>
159167
$<INSTALL_INTERFACE:include>)
160168
target_compile_features(cppcoro PUBLIC cxx_std_20)
169+
target_compile_definitions(cppcoro PUBLIC ${compile_definition})
170+
target_compile_options(cppcoro PUBLIC ${compile_options})
161171

162172
find_package(Coroutines COMPONENTS Experimental Final REQUIRED)
163-
target_link_libraries(cppcoro PUBLIC std::coroutines)
173+
target_link_libraries(cppcoro PUBLIC std::coroutines ${libraries})
164174

165175
install(TARGETS cppcoro EXPORT cppcoroTargets
166176
LIBRARY DESTINATION lib

test/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ include(${CMAKE_CURRENT_LIST_DIR}/doctest/doctest.cmake)
55

66
find_package(Threads REQUIRED)
77

8-
add_library(tests-main SHARED
8+
add_library(tests-main STATIC
99
main.cpp
1010
counted.cpp
1111
)

0 commit comments

Comments
 (0)