forked from luncliff/coroutine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwindows.cmake
More file actions
84 lines (75 loc) · 2.19 KB
/
windows.cmake
File metadata and controls
84 lines (75 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# ---------------------------------------------------------------------------
#
# Author : github.com/luncliff (luncliff@gmail.com)
#
# ---------------------------------------------------------------------------
add_library(${PROJECT_NAME}
windows/dllmain.cpp
windows/concrt.cpp
windows/net.cpp
net/resolver.cpp
)
target_compile_definitions(${PROJECT_NAME}
PRIVATE
WIN32_LEAN_AND_MEAN
PUBLIC
NOMINMAX
)
# CMake variable MSVC follows windows.
# So we have to check clang first to be correct
if(${CMAKE_CXX_COMPILER_ID} MATCHES Clang)
# Additional source code for clang
target_sources(${PROJECT_NAME}
PRIVATE
windows/clang.cpp
)
# Need additional macro because this is not vcxproj
target_compile_definitions(${PROJECT_NAME}
PUBLIC
_RESUMABLE_FUNCTIONS_SUPPORTED
)
if(BUILD_SHARED_LIBS)
message(FATAL_ERROR "clang-cl build need to use static linking for current version")
endif()
# clang-cl build failes for this condition.
# finding a solution, but can't sure about it...
target_compile_definitions(${PROJECT_NAME}
PUBLIC
USE_STATIC_LINK_MACRO
)
# Argument for `clang-cl`
#
# `target_compile_options` removes duplicated -Xclang argument
# which must be protected. An alternative is to use CMAKE_CXX_FLAGS,
# but the method will be used only when there is no way but to use it
#
# set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Xclang -fcoroutines-ts")
target_compile_options(${PROJECT_NAME}
PUBLIC
/std:c++latest
-fms-compatibility
-Xclang -fcoroutines-ts
PRIVATE
-Wno-unused-private-field
-Wno-unused-function
-Wno-c++98-compat
-Wno-reserved-id-macro
-Wno-missing-prototypes
)
elseif(MSVC)
target_compile_options(${PROJECT_NAME}
PUBLIC
/std:c++latest /await
/W4
)
endif()
if(${CMAKE_BUILD_TYPE} MATCHES Debug)
target_compile_options(${PROJECT_NAME}
PRIVATE
/Od
)
endif()
set_target_properties(${PROJECT_NAME}
PROPERTIES
LINK_FLAGS "${LINK_FLAGS} /errorReport:send"
)