forked from love2d/lua-https
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCMakeLists.txt
More file actions
162 lines (132 loc) · 4.72 KB
/
CMakeLists.txt
File metadata and controls
162 lines (132 loc) · 4.72 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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
cmake_minimum_required (VERSION 3.13)
### Basic compilation settings
set (CMAKE_POSITION_INDEPENDENT_CODE TRUE)
include_directories (
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
### Compiler-specific flags
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU|Clang")
add_compile_options ("-fvisibility=hidden")
add_link_options ("-fvisibility=hidden")
endif ()
### Dependencies
find_package (LuaJIT)
if (LUAJIT_INCLUDE_DIR)
set(LUA_INCLUDE_DIR ${LUAJIT_INCLUDE_DIR})
set(LUA_LIBRARIES ${LUAJIT_LIBRARIES})
else ()
find_package (Lua 5.1 REQUIRED)
endif ()
include_directories (${LUA_INCLUDE_DIR})
### "Libraries"
add_library (https MODULE
lua/main.cpp
)
add_library (https-common STATIC
common/HTTPS.cpp
common/HTTPRequest.cpp
common/HTTPSClient.cpp
common/PlaintextConnection.cpp
)
add_library (https-curl STATIC EXCLUDE_FROM_ALL
generic/CurlClient.cpp
)
add_library (https-openssl STATIC EXCLUDE_FROM_ALL
generic/OpenSSLConnection.cpp
)
add_library (https-schannel STATIC EXCLUDE_FROM_ALL
windows/SChannelConnection.cpp
)
add_library (https-nsurl STATIC EXCLUDE_FROM_ALL
apple/NSURLClient.mm
)
add_library (https-android STATIC EXCLUDE_FROM_ALL
android/AndroidClient.cpp
)
### Flags
if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
option (USE_CURL_BACKEND "Use the libcurl backend" ON)
option (USE_OPENSSL_BACKEND "Use the openssl backend" ON)
option (USE_SCHANNEL_BACKEND "Use the schannel backend (windows-only)" OFF)
option (USE_NSURL_BACKEND "Use the NSUrl backend (apple-only)" OFF)
option (USE_ANDROID_BACKEND "Use the Android Java backend (Android-only)" OFF)
option (USE_WINSOCK "Use winsock instead of BSD sockets (windows-only)" OFF)
elseif (WIN32)
option (USE_CURL_BACKEND "Use the libcurl backend" OFF)
option (USE_OPENSSL_BACKEND "Use the openssl backend" OFF)
option (USE_SCHANNEL_BACKEND "Use the schannel backend (windows-only)" ON)
option (USE_NSURL_BACKEND "Use the NSUrl backend (apple-only)" OFF)
option (USE_ANDROID_BACKEND "Use the Android Java backend (Android-only)" OFF)
option (USE_WINSOCK "Use winsock instead of BSD sockets (windows-only)" ON)
# Windows needs to link with Lua libraries
target_link_libraries(https ${LUA_LIBRARIES})
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
option (USE_CURL_BACKEND "Use the libcurl backend" OFF)
option (USE_OPENSSL_BACKEND "Use the openssl backend" OFF)
option (USE_SCHANNEL_BACKEND "Use the schannel backend (windows-only)" OFF)
option (USE_NSURL_BACKEND "Use the NSUrl backend (apple-only)" ON)
option (USE_ANDROID_BACKEND "Use the Android Java backend (Android-only)" OFF)
option (USE_WINSOCK "Use winsock instead of BSD sockets (windows-only)" OFF)
if (NOT IOS)
# macOS needs -undefined dynamic_lookup
target_link_options(https PRIVATE -undefined dynamic_lookup)
else ()
target_link_libraries(https ${LUA_LIBRARIES})
endif ()
elseif (ANDROID)
option (USE_CURL_BACKEND "Use the libcurl backend" OFF)
option (USE_OPENSSL_BACKEND "Use the openssl backend" OFF)
option (USE_SCHANNEL_BACKEND "Use the schannel backend (windows-only)" OFF)
option (USE_NSURL_BACKEND "Use the NSUrl backend (apple-only)" OFF)
option (USE_ANDROID_BACKEND "Use the Android Java backend (Android-only)" ON)
option (USE_WINSOCK "Use winsock instead of BSD sockets (windows-only)" OFF)
# Android needs to link with Lua libraries
target_link_libraries(https ${LUA_LIBRARIES})
endif ()
option (DEBUG_SCHANNEL "Enable debug output in schannel backend" OFF)
set_target_properties(https PROPERTIES PREFIX "")
target_link_libraries (https https-common)
if (USE_CURL_BACKEND)
set(HTTPS_BACKEND_CURL ON)
find_package (CURL REQUIRED)
include_directories (${CURL_INCLUDE_DIR})
target_link_libraries (https https-curl ${CURL_LIBRARIES})
endif ()
if (USE_OPENSSL_BACKEND)
set(HTTPS_BACKEND_OPENSSL ON)
find_package (OpenSSL REQUIRED)
include_directories (${OPENSSL_INCLUDE_DIR})
target_link_libraries (https https-openssl ${OPENSSL_LIBRARIES})
endif ()
if (USE_SCHANNEL_BACKEND)
set(HTTPS_BACKEND_SCHANNEL ON)
target_link_libraries (https https-schannel ws2_32 secur32)
endif ()
if (USE_NSURL_BACKEND)
set(HTTPS_BACKEND_NSURL ON)
set_target_properties(
https-nsurl
PROPERTIES
MACOSX_BUNDLE YES
XCODE_ATTRIBUTE_CLANG_ENABLE_OBJC_ARC YES
)
target_link_libraries (https "-framework Foundation")
target_link_libraries (https https-nsurl)
endif ()
if (USE_ANDROID_BACKEND)
set(HTTPS_BACKEND_ANDROID ON)
target_link_libraries (https https-android)
message(STATUS "Ensure to add the Java files to your project too!")
endif ()
if (USE_WINSOCK)
set(HTTPS_USE_WINSOCK ON)
endif ()
### Generate config-generated.h
add_compile_definitions(HTTPS_HAVE_CONFIG_GENERATED_H)
configure_file (
common/config-generated.h.in
common/config-generated.h
)
### Install target
install(TARGETS https DESTINATION .)