forked from snowflakedb/azure-storage-cpplite
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
307 lines (266 loc) · 10.5 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
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
cmake_minimum_required(VERSION 2.8)
project(azurestoragelite)
option(BUILD_TESTS "Build test codes" OFF)
option(BUILD_SAMPLES "Build sample codes" ON)
option(BUILD_WITH_MD "If enabled, will unconditionally link the standard libraries in dynamically, otherwise the standard library will be linked in based on the BUILD_SHARED_LIBS setting" OFF)
option(BUILD_SHARED_LIBS "Request build of shared libraries" OFF)
set(OPENSSL_VERSION_NUMBER 0x11100000L)
set(AZURE_STORAGE_LITE_HEADER
include/storage_EXPORTS.h
include/logging.h
include/base64.h
include/common.h
include/compare.h
include/constants.h
include/constants.dat
include/executor.h
include/hash.h
include/retry.h
include/utility.h
include/tinyxml2.h
include/xml_parser_base.h
include/tinyxml2_parser.h
include/xml_writer.h
include/storage_account.h
include/storage_credential.h
include/storage_outcome.h
include/storage_stream.h
include/storage_url.h
include/storage_errno.h
include/storage_request_base.h
include/get_blob_request_base.h
include/put_blob_request_base.h
include/delete_blob_request_base.h
include/copy_blob_request_base.h
include/create_container_request_base.h
include/delete_container_request_base.h
include/list_containers_request_base.h
include/list_blobs_request_base.h
include/get_block_list_request_base.h
include/put_block_request_base.h
include/get_blob_property_request_base.h
include/get_container_property_request_base.h
include/put_block_list_request_base.h
include/get_container_property_request_base.h
include/append_block_request_base.h
include/put_page_request_base.h
include/get_page_ranges_request_base.h
include/http_base.h
include/http/libcurl_http_client.h
include/blob/blob_client.h
include/blob/download_blob_request.h
include/blob/create_block_blob_request.h
include/blob/delete_blob_request.h
include/blob/copy_blob_request.h
include/blob/create_container_request.h
include/blob/delete_container_request.h
include/blob/list_containers_request.h
include/blob/list_blobs_request.h
include/blob/get_blob_property_request.h
include/blob/get_container_property_request.h
include/blob/get_block_list_request.h
include/blob/put_block_request.h
include/blob/put_block_list_request.h
include/blob/append_block_request.h
include/blob/put_page_request.h
include/blob/get_page_ranges_request.h
)
set(AZURE_STORAGE_LITE_SOURCE
src/logging.cpp
src/base64.cpp
src/constants.cpp
src/hash.cpp
src/utility.cpp
src/tinyxml2.cpp
src/tinyxml2_parser.cpp
src/storage_account.cpp
src/storage_credential.cpp
src/storage_url.cpp
src/get_blob_request_base.cpp
src/put_blob_request_base.cpp
src/delete_blob_request_base.cpp
src/copy_blob_request_base.cpp
src/create_container_request_base.cpp
src/delete_container_request_base.cpp
src/list_containers_request_base.cpp
src/list_blobs_request_base.cpp
src/get_blob_property_request_base.cpp
src/get_block_list_request_base.cpp
src/get_container_property_request_base.cpp
src/put_block_request_base.cpp
src/put_block_list_request_base.cpp
src/append_block_request_base.cpp
src/put_page_request_base.cpp
src/get_page_ranges_request_base.cpp
src/http/libcurl_http_client.cpp
src/blob/blob_client.cpp
src/blob/blob_client_wrapper.cpp
)
if(APPLE)
option(USE_OPENSSL "Use OpenSSL instead of GnuTLS" ON)
add_definitions(-DUSE_OPENSSL)
find_package(Threads REQUIRED)
include_directories(${PROJECT_SOURCE_DIR}/include ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} ${EXTRA_INCLUDE})
set(EXTRA_LIBRARIES ${EXTRA_LIBRARIES} system)
set(CMAKE_MACOSX_RPATH ON)
elseif (UNIX)
option(USE_OPENSSL "Use OpenSSL instead of GnuTLS" ON)
find_package(Threads REQUIRED)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC")
if (NOT ${USE_OPENSSL})
find_package(GnuTLS REQUIRED)
set(EXTRA_INCLUDE ${GNUTLS_INCLUDE_DIR})
set(EXTRA_LIBRARIES ${GNUTLS_LIBRARIES})
include_directories(${PROJECT_SOURCE_DIR}/include ${CURL_INCLUDE_DIRS} ${UUID_INCLUDE_DIR} ${EXTRA_INCLUDE})
else()
add_definitions(-DUSE_OPENSSL)
include_directories(${PROJECT_SOURCE_DIR}/include ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} ${UUID_INCLUDE_DIR} ${EXTRA_INCLUDE})
endif()
else()
# Add the parameter/definition specifically for Windows.
option(USE_OPENSSL "Use OpenSSL instead of GnuTLS" ON)
option(CMAKE_BUILD_TYPE "The default build type" "Debug")
option(CMAKE_GENERATOR_PLATFORM "The Generator platform used for CMake" "x86")
#Construct the libcurl folder path
#This is because the cmake's FindCurl.cmake not being compatible with libcurl's buildscript on Windows.
#e.g. libcurl-vc15-x64-debug-static-ssl-static-ipv6-sspi
if((DEFINED CURL_ROOT_DIR) AND (NOT (CURL_ROOT_DIR STREQUAL "")))
if(CMAKE_CL_64)
set(INHERIT_ENV "x64")
else()
set(INHERIT_ENV "x86")
endif()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(LIBRARY_BUILD_TYPE "debug")
else()
set(LIBRARY_BUILD_TYPE "release")
endif()
if(CURL_LINK_TYPE STREQUAL "static")
add_definitions(-DCURL_STATICLIB)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CURL_LIBRARY_NAME "lib\\libcurl_a_debug.lib")
else()
set(CURL_LIBRARY_NAME "lib\\libcurl_a.lib")
endif()
else()
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CURL_LIBRARY_NAME "bin\\libcurl_debug.dll")
else()
set(CURL_LIBRARY_NAME "bin\\libcurl.dll")
endif()
endif()
set(CURL_LIBRARIES "${CURL_ROOT_DIR}\\builds\\libcurl-vc15-${INHERIT_ENV}-${LIBRARY_BUILD_TYPE}-${CURL_LINK_TYPE}-ssl-${OPENSSL_LINK_TYPE}-ipv6-sspi\\${CURL_LIBRARY_NAME}")
set(CURL_INCLUDE_DIRS "${CURL_ROOT_DIR}\\builds\\libcurl-vc15-${INHERIT_ENV}-${LIBRARY_BUILD_TYPE}-${CURL_LINK_TYPE}-ssl-${OPENSSL_LINK_TYPE}-ipv6-sspi\\include\\")
message (STATUS "Constructed curl library path: ${CURL_LIBRARIES}")
message (STATUS "Constructed curl include path: ${CURL_INCLUDE_DIRS}")
unset(INHERIT_ENV)
unset(LIBRARY_BUILD_TYPE)
unset(CURL_LIBRARY_NAME)
else()
if(CURL_LINK_TYPE STREQUAL "static")
add_definitions(-DCURL_STATICLIB)
endif()
#if there isn't a customized openssl library and include, then use FindOpenSSL.cmake to find Openssl on Windows
if(NOT((DEFINED CURL_INCLUDE_DIRS) OR (DEFINED CURL_LIBRARIES)))
find_package(CURL REQUIRED)
endif()
endif()
#Constructing OPENSSL path on windows.
if((DEFINED OPENSSL_ROOT_DIR) AND (NOT (OPENSSL_ROOT_DIR STREQUAL "")))
if(CMAKE_CL_64)
set(INHERIT_ENV "x64")
else()
set(INHERIT_ENV "x86")
endif()
if(OPENSSL_LINK_TYPE STREQUAL "static")
add_definitions(-DOPENSSL_STATICLIB)
set(OPENSSL_LIBRARY_NAME "ssleay32.lib")
set(OPENSSL_CRYPTO_LIBRARY_NAME "libeay32.lib")
else()
set(OPENSSL_LIBRARY_NAME "ssleay32.dll")
set(OPENSSL_CRYPTO_LIBRARY_NAME "libeay32.dll")
endif()
set(OPENSSL_SSL_LIBRARY "${OPENSSL_ROOT_DIR}\\lib\\${CMAKE_BUILD_TYPE}\\${OPENSSL_LIBRARY_NAME}")
set(OPENSSL_CRYPTO_LIBRARY "${OPENSSL_ROOT_DIR}\\lib\\${CMAKE_BUILD_TYPE}\\${OPENSSL_CRYPTO_LIBRARY_NAME}")
set(OPENSSL_INCLUDE_DIR "${OPENSSL_ROOT_DIR}\\include\\openssl\\")
message (STATUS "Constructed openssl library path: ${OPENSSL_SSL_LIBRARY}")
message (STATUS "Constructed openssl include path: ${OPENSSL_INCLUDE_DIR}")
message (STATUS "Constructed openssl crypto library path: ${OPENSSL_CRYPTO_LIBRARY}")
unset(INHERIT_ENV)
unset(OPENSSL_LIBRARY_NAME)
unset(OPENSSL_CRYPTO_LIBRARY_NAME)
else()
if(OPENSSL_LINK_TYPE STREQUAL "static")
add_definitions(-DOPENSSL_STATICLIB)
endif()
#if there isn't a customized openssl library and include, then use FindOpenSSL.cmake to find Openssl on Windows
if(NOT((DEFINED OPENSSL_INCLUDE_DIR) AND (DEFINED OPENSSL_CRYPTO_LIBRARY) AND (DEFINED OPENSSL_SSL_LIBRARY)))
message(STATUS "OpenSSL folder is not specified, need to find it automatically.")
find_package(OpenSSL REQUIRED)
endif()
endif()
if(OPENSSL_LINK_TYPE STREQUAL "static")
add_definitions(-DOPENSSL_STATICLIB)
endif()
add_definitions(-DUSE_OPENSSL)
set(OPENSSL_MSVC_STATIC_RT "true")
if (BUILD_WITH_MD)
set(CMAKE_CXX_FLAGS_RELEASE "/MD")
set(CMAKE_CXX_FLAGS_DEBUG "/MDd")
else()
# If BUILD_WITH_MD is off then we build with /MT option
set(CMAKE_CXX_FLAGS_RELEASE "/MT")
set(CMAKE_CXX_FLAGS_DEBUG "/MTd")
endif()
#adding extra dependency libraries for windows
set(EXTRA_LIBRARIES ${EXTRA_LIBRARIES} rpcrt4 ws2_32 wldap32 crypt32 normaliz)
include_directories(${PROJECT_SOURCE_DIR}/include ${CURL_INCLUDE_DIRS} ${OPENSSL_INCLUDE_DIR} ${EXTRA_INCLUDE})
endif()
if (("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang") OR ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU"))
add_definitions(-std=c++11)
set(WARNING "-Wall -Wextra -Werror -pedantic -pedantic-errors")
set(CMAKE_CXX_FLAGS "${CMAKE_THREAD_LIBS_INIT} ${WARNING} ${CMAKE_CXX_FLAGS}")
endif()
if (BUILD_SHARED_LIBS)
add_library(azure-storage-lite SHARED ${AZURE_STORAGE_LITE_HEADER} ${AZURE_STORAGE_LITE_SOURCE})
else ()
add_library(azure-storage-lite STATIC ${AZURE_STORAGE_LITE_HEADER} ${AZURE_STORAGE_LITE_SOURCE})
endif()
if (NOT ${USE_OPENSSL})
target_link_libraries(azure-storage-lite ${CURL_LIBRARIES} ${UUID_LIBRARIES} ${EXTRA_LIBRARIES})
else()
target_link_libraries(azure-storage-lite ${CURL_LIBRARIES} ${OPENSSL_SSL_LIBRARY} ${OPENSSL_CRYPTO_LIBRARY} ${UUID_LIBRARIES} ${EXTRA_LIBRARIES})
endif()
if(BUILD_TESTS)
add_subdirectory(test)
endif()
if(BUILD_SAMPLES)
add_subdirectory(sample)
endif()
if (WIN32 OR UNIX)
file(GLOB BLOB_HEADERS includes/blob/*.h)
install(FILES ${BLOB_HEADERS} DESTINATION include/blob)
file(GLOB HTTP_HEADERS includes/http/*.h)
install(FILES ${HTTP_HEADERS} DESTINATION include/http)
file(GLOB TODO_HEADERS includes/todo/*.h)
install(FILES ${HTTP_HEADERS} DESTINATION todo/http)
file(GLOB GENERAL_HEADERS includes/*.h)
install(FILES ${GENERAL_HEADERS} DESTINATION include)
file(GLOB GENERAL_DATA includes/*.dat)
install(FILES ${GENERAL_DATA} DESTINATION include)
endif()
# Reconfigure final output directory
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/Binaries)
# Set version numbers centralized
set (AZURE_STORAGE_LITE_VERSION_MAJOR 0)
set (AZURE_STORAGE_LITE_VERSION_MINOR 1)
set (AZURE_STORAGE_LITE_VERSION_REVISION 0)
# Set output directories.
if(NOT DEFINED CMAKE_INSTALL_BINDIR)
set(CMAKE_INSTALL_BINDIR bin)
endif()
if(NOT DEFINED CMAKE_INSTALL_LIBDIR)
set(CMAKE_INSTALL_LIBDIR lib)
endif()