-
Notifications
You must be signed in to change notification settings - Fork 141
/
CMakeLists.txt
186 lines (166 loc) · 6.28 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
# SPDX-License-Identifier: Apache-2.0
#
# The OpenSearch Contributors require contributions made to
# this file be licensed under the Apache-2.0 license or a
# compatible open source license.
#
# Modifications Copyright OpenSearch Contributors. See
# GitHub history for details.
#
# Copyright 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License").
# You may not use this file except in compliance with the License.
# A copy of the License is located at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# or in the "license" file accompanying this file. This file is distributed
# on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
# express or implied. See the License for the specific language governing
# permissions and limitations under the License.
#
# Pre 3.16 versions of Windows set MD/MT incorrectly and cause linker 'warnings' which are actually serious issues
if(WIN32)
cmake_minimum_required(VERSION 3.16)
else()
cmake_minimum_required(VERSION 3.13)
endif()
project(global_make_list)
include("${CMAKE_CURRENT_SOURCE_DIR}/modules/code-coverage.cmake")
add_code_coverage_all_targets(EXCLUDE libraries aws-cpp-sdk googletest IntegrationTests)
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(BITNESS 64)
set(BITNESS_NAME "x64")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../build/odbc/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../build/odbc/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../build/odbc/bin")
elseif(CMAKE_SIZEOF_VOID_P EQUAL 4)
set(BITNESS 32)
set(BITNESS_NAME "x86")
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../build/odbc/lib")
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../build/odbc/lib")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/../build/odbc/bin")
endif()
# This wasn't being picked up on mac, causes some symbol errors
if(APPLE)
set(CMAKE_CXX_STANDARD 17)
add_definitions(-DHAVE_STRLCAT)
# Do not use shared libraries for AWS SDK.
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
# Set BUILD_WITH_TESTS to OFF before building installer package for size optimization.
option(BUILD_WITH_TESTS "Enable testing" ON)
else()
set(CMAKE_CXX_STANDARD 17)
# Use shared libraries for AWS SDK.
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
# Set BUILD_WITH_TESTS to OFF before building installer package for size optimization.
option(BUILD_WITH_TESTS "Enable testing" ON)
endif()
if(MSVC)
add_compile_options(/W4 /WX)
else()
add_compile_options(-Wall -Wextra -pedantic -Werror)
endif()
if(NOT WIN32)
# Unix builds require autoconf
option(AUTOCONF_ENABLE "Enable autoconf" ON)
configure_file(autoconf.h.in generated/autoconf.h @ONLY)
endif()
# Base directories
set(PROJECT_ROOT "${CMAKE_CURRENT_SOURCE_DIR}/..")
set(OPENSEARCHODBC_SRC "${CMAKE_CURRENT_SOURCE_DIR}/sqlodbc")
set(OPENSEARCHENLIST_SRC "${CMAKE_CURRENT_SOURCE_DIR}/opensearchenlist")
set(INTEGRATION_TESTS "${CMAKE_CURRENT_SOURCE_DIR}/IntegrationTests")
set(UNIT_TESTS "${CMAKE_CURRENT_SOURCE_DIR}/UnitTests")
set(LIBRARY_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/../libraries)
set(INSTALL_SRC "${CMAKE_CURRENT_SOURCE_DIR}/installer")
set(DSN_INSTALLER_SRC "${CMAKE_CURRENT_SOURCE_DIR}/DSNInstaller")
# ODBC Driver version
set(DRIVER_PACKAGE_VERSION "1.0.0.0")
set(DRIVER_PACKAGE_VERSION_COMMA_SEPARATED "1,0,0,0")
add_compile_definitions( OPENSEARCH_ODBC_VERSION="${DRIVER_PACKAGE_VERSION}"
# Comma separated version is required for odbc administrator's driver file.
OPENSEARCH_ODBC_DRVFILE_VERSION=${DRIVER_PACKAGE_VERSION_COMMA_SEPARATED} )
# Extensions of base directories
set(PERFORMANCE_TESTS "${CMAKE_CURRENT_SOURCE_DIR}/PerformanceTests")
set(UT_HELPER "${UNIT_TESTS}/UTHelper")
set(IT_HELPER "${INTEGRATION_TESTS}/ITODBCHelper")
set(RABBIT_SRC ${LIBRARY_DIRECTORY}/rabbit/include)
set(RAPIDJSON_SRC ${LIBRARY_DIRECTORY}/rapidjson/include)
set(VLD_SRC ${LIBRARY_DIRECTORY}/VisualLeakDetector/include)
# Without this symbols will be exporting to Unix but not Windows
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
# Set path for AWS SDK
set(aws-cpp-sdk-base "${CMAKE_CURRENT_SOURCE_DIR}/aws-sdk-cpp")
set(aws-cpp-sdk-core_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/cmake/aws-cpp-sdk-core")
set(aws-c-event-stream_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/aws-c-event-stream/cmake")
set(aws-c-common_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/aws-c-common/cmake")
set(aws-checksums_DIR "${PROJECT_ROOT}/sdk-build${BITNESS}/AWSSDK/lib/aws-checksums/cmake")
if (WIN32)
find_package(AWSSDK REQUIRED core)
endif()
# General compiler definitions
add_compile_definitions ( _SILENCE_TR1_NAMESPACE_DEPRECATION_WARNING
UNICODE_SUPPORT
DYNAMIC_LOAD
_MBCS
_CRT_SECURE_NO_DEPRECATE
_USRDLL
_SILENCE_CXX17_ITERATOR_BASE_CLASS_DEPRECATION_WARNING
_SILENCE_CXX17_CODECVT_HEADER_DEPRECATION_WARNING
# USE_SSL
)
# Platform specific compiler definitions
if (WIN32 AND BITNESS EQUAL 64)
# Windows specific
add_compile_definitions ( _WINDLL
_WIN64
_WINDOWS
WIN_EXPORT
)
elseif (WIN32 AND BITNESS EQUAL 32)
# Windows specific
add_compile_definitions ( _WINDLL
_WIN32
_WINDOWS
WIN_EXPORT
)
elseif(APPLE)
# macOS specific
add_compile_definitions ( WITH_IODBC
SQLCOLATTRIBUTE_SQLLEN
)
# iODBC includes
include_directories(/usr/local/include)
elseif(UNIX)
# Unix specific
add_compile_definitions ( WITH_UNIXODBC
SQLCOLATTRIBUTE_SQLLEN
)
endif()
if(BUILD_WITH_TESTS)
# GTest import
include(gtest/googletest.cmake)
fetch_googletest(
${PROJECT_SOURCE_DIR}/gtest
${PROJECT_BINARY_DIR}/googletest
)
enable_testing()
endif()
# Projects to build
if (APPLE)
add_subdirectory(${aws-cpp-sdk-base})
endif()
add_subdirectory(${OPENSEARCHODBC_SRC})
add_subdirectory(${OPENSEARCHENLIST_SRC})
add_subdirectory(${INSTALL_SRC})
# Only build & package DSN installer for Mac platforms
if(APPLE)
add_subdirectory(${DSN_INSTALLER_SRC})
endif()
if(BUILD_WITH_TESTS)
add_subdirectory(${INTEGRATION_TESTS})
add_subdirectory(${UNIT_TESTS})
add_subdirectory(${PERFORMANCE_TESTS})
endif()