-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathCMakeLists.txt
111 lines (83 loc) · 2.62 KB
/
CMakeLists.txt
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
cmake_minimum_required (VERSION 3.1)
project (CppAsyncSolution CXX)
#
# modules
#
set (CMAKE_MODULE_PATH ${CppAsyncSolution_SOURCE_DIR}/cmake_modules ${CMAKE_MODULE_PATH})
include (precompiled_header)
include (enable_max_warning_level)
#
# Boost
#
set (Boost_USE_STATIC_LIBS ON)
set (Boost_USE_STATIC_RUNTIME OFF)
set (_boost_deps context thread chrono system)
message ("Looking for Boost libraries: ${_boost_deps}")
find_package (Boost 1.61.0 COMPONENTS ${_boost_deps})
if (Boost_FOUND)
message ("Using Boost ${Boost_LIB_VERSION} from ${Boost_INCLUDE_DIRS}")
set (BoostContext_FOUND YES)
else()
list(REMOVE_ITEM _boost_deps context)
message ("Fall back, looking for: ${_boost_deps}")
find_package (Boost 1.61.0 COMPONENTS ${_boost_deps})
if (Boost_FOUND)
message ("Using Boost ${Boost_LIB_VERSION} from ${Boost_INCLUDE_DIRS}")
message ("Boost.Context not found, stackful examples will be skipped.")
else()
message ("Boost not found, some examples will be skipped.")
endif()
endif()
if (Boost_FOUND)
include_directories (${Boost_INCLUDE_DIRS})
# disable Boost autolinking
add_definitions (-DBOOST_ALL_NO_LIB)
add_definitions (-DHAVE_BOOST)
if (BoostContext_FOUND)
add_definitions (-DHAVE_BOOST_CONTEXT)
endif()
#
# OpenSSL
#
find_package (OpenSSL)
if (OPENSSL_FOUND)
message ("Using OpenSSL ${OPENSSL_VERSION} from ${OPENSSL_INCLUDE_DIR}")
include_directories (${OPENSSL_INCLUDE_DIR})
# enable OpenSSL examples
add_definitions (-DHAVE_OPENSSL)
else()
message ("OpenSSL not found, some examples will be skipped.")
endif()
endif()
#
# defs
#
if (CMAKE_COMPILER_IS_GNUCXX)
add_definitions (-std=c++11 -fstrict-aliasing -Wstrict-aliasing)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_definitions (-std=c++11 -fstrict-aliasing -Wstrict-aliasing)
elseif (MSVC)
add_definitions (/wd4100 /wd4127 /wd4457 /wd4913)
if (NOT (MSVC_VERSION LESS 1900))
# enable support for resumable functions (N4402, N4403)
add_definitions (/await)
# run-time error checks don't work yet in combination with /await
STRING (REPLACE "/RTC1" "" CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
endif()
endif()
if (MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 4)
add_definitions (-march=i686)
endif()
if (MSVC AND BoostContext_FOUND)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /SAFESEH:NO")
endif()
#
# paths
#
set (CMAKE_INCLUDE_CURRENT_DIR TRUE)
#
# subprojects
#
add_subdirectory (CppAsync)
add_subdirectory (Examples)
add_subdirectory (ExamplesNoExceptions)