forked from snowflakedb/libsnowflakeclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
345 lines (320 loc) · 12.2 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
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
# Copyright (c) 2018-2019 Snowflake Computing, Inc. All rights reserved.
#
# CMakeList for Snowflake Client
#
cmake_minimum_required(VERSION 2.8)
project(snowflakeclient)
# Enabling tests by Ctest. Don't use INCLUDE(Ctest) as
# we don't need Dart and other tools.
enable_testing()
add_definitions(-DLOG_USE_COLOR)
option(BUILD_TESTS "True if build tests" on)
option(MOCK "True if mock should be used" off)
set(OPENSSL_VERSION_NUMBER 0x11100000L)
# Developers can uncomment this to enable mock builds on their local VMs
#set(MOCK TRUE)
if (MOCK)
set(MOCK_OBJECT_WRAPPER_FLAGS -Wl,--wrap=http_perform)
add_definitions(-DMOCK_ENABLED)
else()
set(MOCK_OBJECT_WRAPPER_FLAGS )
endif ()
if (UNIX AND NOT APPLE)
set(LINUX TRUE)
endif ()
if (LINUX)
set(PLATFORM linux)
message("Platform: Linux")
endif ()
if (APPLE)
set(PLATFORM darwin)
set(CMAKE_OSX_DEPLOYMENT_TARGET "10.12" CACHE STRING "Minimum OS X deployment version")
message("Platform: Apple OSX")
endif ()
if ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "x64")
set(PLATFORM win64)
message("Platform: Windows 64bit")
endif ()
if ("${CMAKE_VS_PLATFORM_NAME}" STREQUAL "Win32")
set(PLATFORM win32)
message("Platform: Windows 32bit")
endif ()
set(CMAKE_VERBOSE_MAKEFILE ON)
if (UNIX)
# Linux and OSX
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -std=gnu99 -g -fPIC -Werror ${MOCK_OBJECT_WRAPPER_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -std=gnu++11 -fPIC -Werror ${MOCK_OBJECT_WRAPPER_FLAGS}")
endif ()
if (LINUX)
# Linux. MacOS doesn't require pthread option
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread")
endif ()
if (LINUX)
# Profiler for Linux
if (NOT "$ENV{BUILD_WITH_PROFILE_OPTION}" STREQUAL "")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pg")
endif ()
# Code coverage for Linux
if (NOT "$ENV{BUILD_WITH_GCOV_OPTION}" STREQUAL "")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fprofile-arcs -ftest-coverage")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -gp -fprofile-arcs -ftest-coverage")
endif ()
endif ()
set(SOURCE_FILES
include/snowflake/basic_types.h
include/snowflake/client.h
include/snowflake/logger.h
include/snowflake/version.h
include/snowflake/platform.h
lib/client.c
lib/constants.h
lib/cJSON.h
lib/cJSON.c
lib/logger.c
lib/lib_common.h
lib/paramstore.c
lib/paramstore.h
lib/arraylist.h
lib/arraylist.c
lib/treemap.h
lib/treemap.c
lib/rbtree.h
lib/rbtree.c
lib/memory.h
lib/memory.c
lib/connection.h
lib/connection.c
lib/constants.h
lib/results.h
lib/results.c
lib/platform.c
lib/uuid4.c
lib/basic_types.c
lib/error.h
lib/error.c
lib/client_int.h
lib/chunk_downloader.h
lib/chunk_downloader.c
lib/mock_http_perform.h
lib/http_perform.c)
set (SOURCE_FILES_PUT_GET
cpp/EncryptionProvider.cpp
cpp/FileCompressionType.cpp
cpp/FileCompressionType.hpp
cpp/FileMetadata.hpp
cpp/FileMetadataInitializer.cpp
cpp/FileMetadataInitializer.hpp
cpp/FileTransferAgent.cpp
cpp/FileTransferAgent.hpp
cpp/FileTransferExecutionResult.cpp
cpp/FileTransferExecutionResult.hpp
cpp/IFileTransferAgent.cpp
cpp/IStorageClient.hpp
cpp/SnowflakeS3Client.hpp
cpp/SnowflakeS3Client.cpp
cpp/SnowflakeAzureClient.hpp
cpp/SnowflakeAzureClient.cpp
cpp/SnowflakeTransferException.cpp
cpp/StatementPutGet.hpp
cpp/StatementPutGet.cpp
cpp/StorageClientFactory.hpp
cpp/StorageClientFactory.cpp
cpp/RemoteStorageRequestOutcome.hpp
cpp/util/Base64.hpp
cpp/util/Base64.cpp
cpp/util/ByteArrayStreamBuf.cpp
cpp/util/ByteArrayStreamBuf.hpp
cpp/util/CompressionUtil.cpp
cpp/util/CompressionUtil.hpp
cpp/util/Proxy.hpp
cpp/util/Proxy.cpp
cpp/util/ThreadPool.hpp
cpp/util/SnowflakeCommon.hpp
cpp/crypto/CryptoTypes.hpp
cpp/crypto/Cryptor.hpp
cpp/crypto/CipherContext.hpp
cpp/crypto/CipherContext.cpp
cpp/crypto/Cryptor.cpp
cpp/crypto/CipherStreamBuf.cpp
cpp/crypto/CipherStreamBuf.hpp
cpp/crypto/HashContext.cpp
cpp/crypto/HashContext.hpp
cpp/jwt/Jwt.cpp
cpp/jwt/Jwt.hpp
cpp/jwt/Signer.cpp
cpp/jwt/Signer.hpp
cpp/jwt/Util.cpp
cpp/jwt/Util.hpp
cpp/jwt/ClaimSet.hpp
cpp/jwt/ClaimSet.cpp
cpp/jwt/Header.cpp
cpp/jwt/Header.hpp
cpp/logger/ISFLogger.cpp
cpp/logger/SFAwsLogger.cpp
cpp/logger/SFAwsLogger.hpp
cpp/logger/SFLogger.cpp
cpp/logger/SFLogger.hpp
include/snowflake/IFileTransferAgent.hpp
include/snowflake/ISFLogger.hpp
include/snowflake/IStatementPutGet.hpp
include/snowflake/ITransferResult.hpp
include/snowflake/PutGetParseResponse.hpp
include/snowflake/SnowflakeTransferException.hpp
include/snowflake/IJwt.hpp
include/snowflake/IBase64.hpp
)
set(SOURCE_FILES_CPP_WRAPPER
include/snowflake/Connection.hpp
include/snowflake/Statement.hpp
include/snowflake/Column.hpp
include/snowflake/Param.hpp
include/snowflake/Exceptions.hpp
include/snowflake/jwtWrapper.h
cpp/lib/Exceptions.cpp
cpp/lib/Connection.cpp
cpp/lib/Statement.cpp
cpp/lib/Column.cpp
cpp/jwt/jwtWrapper.cpp)
if (LINUX)
# Linux
find_library(CURL_LIB libcurl.a PATHS deps-build/${PLATFORM}/curl/lib/ REQUIRED)
find_library(SSL_LIB libssl.a PATHS deps-build/${PLATFORM}/openssl/lib/ REQUIRED)
find_library(CRYPTO_LIB libcrypto.a PATHS deps-build/${PLATFORM}/openssl/lib/ REQUIRED)
find_library(AWS_CORE_LIB libaws-cpp-sdk-core.a PATHS deps-build/${PLATFORM}/aws/lib64/ REQUIRED)
find_library(AWS_S3_LIB libaws-cpp-sdk-s3.a PATHS deps-build/${PLATFORM}/aws/lib64/ REQUIRED)
find_library(AZURE_STORAGE_LITE_LIB libazure-storage-lite.a PATHS deps-build/${PLATFORM}/azure/lib/ REQUIRED)
find_library(UUID_LIB libuuid.a PATHS deps-build/${PLATFORM}/uuid/lib/ REQUIRED)
if(MOCK)
find_library(CMOCKA_LIB libcmocka.a PATHS deps-build/${PLATFORM}/cmocka/lib/ REQUIRED)
endif()
endif ()
if (APPLE)
find_library(CURL_LIB libcurl.a PATHS deps-build/${PLATFORM}/curl/lib/ REQUIRED)
find_library(SSL_LIB libssl.a PATHS deps-build/${PLATFORM}/openssl/lib/ REQUIRED)
find_library(CRYPTO_LIB libcrypto.a PATHS deps-build/${PLATFORM}/openssl/lib/ REQUIRED)
find_library(AWS_CORE_LIB libaws-cpp-sdk-core.a PATHS deps-build/${PLATFORM}/aws/lib/ REQUIRED)
find_library(AWS_S3_LIB libaws-cpp-sdk-s3.a PATHS deps-build/${PLATFORM}/aws/lib/ REQUIRED)
find_library(AZURE_STORAGE_LITE_LIB libazure-storage-lite.a PATHS deps-build/${PLATFORM}/azure/lib/ REQUIRED)
if(MOCK)
find_library(CMOCKA_LIB libcmocka.a PATHS deps-build/${PLATFORM}/cmocka/lib/ REQUIRED)
endif()
endif()
if (WIN32)
# Windows
option(DYNAMIC_RUNTIME "Dynamic runtime" ON)
set(VSDIR "vs15" CACHE STRING "Used to specify visual studio version of libsnowflakeclient dependecies")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
find_library(CURL_LIB libcurl_a.lib PATHS deps-build/${PLATFORM}/${VSDIR}/curl/lib/ REQUIRED)
find_library(SSL_LIB libssl_a.lib PATHS deps-build/${PLATFORM}/${VSDIR}/openssl/lib/ REQUIRED)
find_library(CRYPTO_LIB libcrypto_a.lib PATHS deps-build/${PLATFORM}/${VSDIR}/openssl/lib/ REQUIRED)
find_library(ZLIB_LIB zlib_a.lib PATHS deps-build/${PLATFORM}/${VSDIR}/zlib/lib/ REQUIRED)
find_library(AWS_CORE_LIB aws-cpp-sdk-core.lib PATHS deps-build/${PLATFORM}/${VSDIR}/aws/lib/ REQUIRED)
find_library(AWS_S3_LIB aws-cpp-sdk-s3.lib PATHS deps-build/${PLATFORM}/${VSDIR}/aws/lib/ REQUIRED)
find_library(AZURE_STORAGE_LITE_LIB azure-storage-lite.lib PATHS deps-build/${PLATFORM}/${VSDIR}/azure/lib/ REQUIRED)
if(MOCK)
find_library(CMOCKA_LIB cmocka_a.lib PATHS deps-build/${PLATFORM}/${VSDIR}/cmocka/lib/ REQUIRED)
endif()
endif ()
if (LINUX)
include_directories(
deps-build/${PLATFORM}/curl/include
deps-build/${PLATFORM}/openssl/include
deps-build/${PLATFORM}/zlib/include
deps-build/${PLATFORM}/aws/include
deps-build/${PLATFORM}/azure/include
deps-build/${PLATFORM}/uuid/include
deps-build/${PLATFORM}/cmocka/include
include
lib)
endif()
if (APPLE)
include_directories(
deps-build/${PLATFORM}/curl/include
deps-build/${PLATFORM}/openssl/include
deps-build/${PLATFORM}/zlib/include
deps-build/${PLATFORM}/aws/include
deps-build/${PLATFORM}/azure/include
deps-build/${PLATFORM}/cmocka/include
include
lib)
endif()
if (WIN32)
include_directories(
deps-build/${PLATFORM}/${VSDIR}/curl/include
deps-build/${PLATFORM}/${VSDIR}/openssl/include
deps-build/${PLATFORM}/${VSDIR}/zlib/include
deps-build/${PLATFORM}/${VSDIR}/aws/include
deps-build/${PLATFORM}/${VSDIR}/cmocka/include
deps-build/${PLATFORM}/${VSDIR}/azure/include
include
lib)
endif()
message("libcurl is located at " ${CURL_LIB})
message("libssl is located at " ${SSL_LIB})
message("libcrypto is located at " ${CRYPTO_LIB})
message("libaws-cpp-sdk-core is located at " ${AWS_CORE_LIB})
message("libaws-cpp-sdk-s3 is located at " ${AWS_S3_LIB})
message("libazure-storage-lite.a is located at " ${AZURE_STORAGE_LITE_LIB})
message("libuuid is located at " ${UUID_LIB})
if (MOCK)
message("libcmocka is located at " ${CMOCKA_LIB})
endif ()
add_library(snowflakeclient STATIC ${SOURCE_FILES} ${SOURCE_FILES_PUT_GET} ${SOURCE_FILES_CPP_WRAPPER})
set_target_properties(snowflakeclient PROPERTIES LINKER_LANGUAGE CXX)
set_property(TARGET snowflakeclient PROPERTY C_STANDARD 99)
#set (CMAKE_CXX_STANDARD 11)
if(LINUX)
link_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/deps-build/${PLATFORM}/curl/lib"
"${CMAKE_CURRENT_SOURCE_DIR}/deps-build/${PLATFORM}/openssl/lib"
"${CMAKE_CURRENT_SOURCE_DIR}/deps-build/${PLATFORM}/zlib/lib"
"${CMAKE_CURRENT_SOURCE_DIR}/deps-build/${PLATFORM}/aws/lib64"
"${CMAKE_CURRENT_SOURCE_DIR}/deps-build/${PLATFORM}/azure/lib"
"${CMAKE_CURRENT_SOURCE_DIR}/deps-build/${PLATFORM}/uuid/lib"
)
if(MOCK)
link_directories("${CMAKE_CURRENT_SOURCE_DIR}/deps-build/${PLATFORM}/cmocka/lib")
endif()
elseif(WIN32)
link_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/deps-build/${PLATFORM}/${VSDIR}/curl/lib"
"${CMAKE_CURRENT_SOURCE_DIR}/deps-build/${PLATFORM}/${VSDIR}/openssl/lib"
"${CMAKE_CURRENT_SOURCE_DIR}/deps-build/${PLATFORM}/${VSDIR}/aws/lib"
)
if(MOCK)
link_directories("${CMAKE_CURRENT_SOURCE_DIR}/deps-build/${PLATFORM}/${VSDIR}/cmocka/lib")
endif()
elseif()
link_directories(
"${CMAKE_CURRENT_SOURCE_DIR}/deps-build/${PLATFORM}/curl/lib"
"${CMAKE_CURRENT_SOURCE_DIR}/deps-build/${PLATFORM}/openssl/lib"
"${CMAKE_CURRENT_SOURCE_DIR}/deps-build/${PLATFORM}/aws/lib"
"${CMAKE_CURRENT_SOURCE_DIR}/deps-build/${PLATFORM}/azure/lib"
)
if(MOCK)
link_directories("${CMAKE_CURRENT_SOURCE_DIR}/deps-build/${PLATFORM}/cmocka/lib")
endif()
endif()
if (LINUX)
# Linux
target_link_libraries(snowflakeclient rt dl z)
endif ()
if (APPLE)
# OSX. no librt is required.
target_link_libraries(snowflakeclient dl z)
endif ()
if (WIN32)
# Windows
target_link_libraries(snowflakeclient)
if (DYNAMIC_RUNTIME)
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MD")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MDd")
else()
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /MT")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd")
endif()
endif ()
add_subdirectory(examples)
if (BUILD_TESTS)
add_subdirectory(tests)
endif()