File: CMakeLists.txt

package info (click to toggle)
mariadb-connector-c 2.3.2-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 2,856 kB
  • ctags: 6,144
  • sloc: ansic: 38,893; cpp: 316; xml: 95; makefile: 25
file content (322 lines) | stat: -rw-r--r-- 10,350 bytes parent folder | download
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
# CMakeLists.txt


# This is the LGPL libmariadb project.
PROJECT(mariadb-connector-c C)

SET(CPACK_PACKAGE_VERSION_MAJOR 2)
SET(CPACK_PACKAGE_VERSION_MINOR 3)
SET(CPACK_PACKAGE_VERSION_PATCH 2)
SET(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")

#Minimum required version is Cmake 2.8.8, since we need to build object libraries
IF(WIN32)
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
ELSE()
CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
ENDIF()
IF(COMMAND CMAKE_POLICY)
  CMAKE_POLICY(SET CMP0003 NEW)
ENDIF()

#Allow access to non existing targets  
IF(CMAKE_VERSION VERSION_GREATER "2.9.9")
 CMAKE_POLICY(SET CMP0026 OLD)
 CMAKE_POLICY(SET CMP0045 OLD)
 CMAKE_POLICY(SET CMP0042 OLD)
ENDIF()

### Options ###
IF(NOT WIN32)
  OPTION(WITH_MYSQLCOMPAT "creates libmysql* symbolic links" ON)
  OPTION(WITH_OPENSSL "enables SSL support" ON)
ELSE()
  OPTION(WITH_OPENSSL "enables SSL support" OFF)
  OPTION(WITH_SIGNCODE "digitally sign files" OFF)
  OPTION(WITH_RTC "enables run time checks for debug builds" OFF)
ENDIF()

OPTION(WITH_EXTERNAL_ZLIB "Enables use of external zlib" OFF)
###############

IF(WITH_RTC)
  SET(RTC_OPTIONS "/RTC1 /RTCc")
ENDIF()

IF(MSVC)
  # Speedup system tests
  INCLUDE(${CMAKE_SOURCE_DIR}/cmake/WindowsCache.cmake)
  IF (MSVC)
    SET(CONFIG_TYPES "DEBUG" "RELEASE" "RELWITHDEBINFO")
    FOREACH(BUILD_TYPE ${CONFIG_TYPES})
      FOREACH(COMPILER CXX C)
        SET(COMPILER_FLAGS "${CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE}}")
        IF (NOT COMPILER_FLAGS STREQUAL "")
          STRING(REPLACE "/MD" "/MT" COMPILER_FLAGS ${COMPILER_FLAGS})
          IF (CMAKE_BUILD_TYPE STREQUAL "Debug")
            SET(COMPILER_FLAGS "${COMPILER_FLAGS} ${RTC_OPTIONS}")
            STRING(REPLACE "/Zi" "/ZI" COMPILER_FLAGS ${COMPILER_FLAGS})
          ENDIF()
          MESSAGE (STATUS "CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE}= ${COMPILER_FLAGS}") 
          SET(CMAKE_${COMPILER}_FLAGS_${BUILD_TYPE} ${COMPILER_FLAGS} CACHE 
               STRING "overwritten by libmariadb" FORCE)
        ENDIF()
      ENDFOREACH()
    ENDFOREACH()
  ENDIF()
ENDIF()

# Disable dbug information for release builds 
SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DDBUG_OFF")
SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDBUG_OFF")
SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DDBUG_OFF")
SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF")

IF(CMAKE_COMPILER_IS_GNUCC)
  SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wunused -Wno-uninitialized")
ENDIF()

# If the build type isn't specified, set to Relwithdebinfo as default.
IF(NOT CMAKE_BUILD_TYPE)
  SET(CMAKE_BUILD_TYPE "Relwithdebinfo")
ENDIF()

# various defines for generating include/mysql_version.h

SET(PROTOCOL_VERSION 10) # we adapted new password option from PHP's mysqlnd !
SET(MYSQL_CLIENT_VERSION_MAJOR "5")
SET(MYSQL_CLIENT_VERSION_MINOR "5")
SET(MYSQL_CLIENT_VERSION_PATCH "1")
SET(MYSQL_CLIENT_VERSION "${MYSQL_CLIENT_VERSION_MAJOR}.${MYSQL_CLIENT_VERSION_MINOR}.${MYSQL_CLIENT_VERSION_PATCH}")
MATH(EXPR MYSQL_VERSION_ID "${MYSQL_CLIENT_VERSION_MAJOR} * 10000 +
                            ${MYSQL_CLIENT_VERSION_MINOR} * 100   +
                            ${MYSQL_CLIENT_VERSION_PATCH}")
IF (NOT MYSQL_PORT)
  SET(MYSQL_PORT 3306)
ENDIF ()
IF(NOT MYSQL_UNIX_ADDR)
  SET(MYSQL_UNIX_ADDR "/tmp/mysql.sock")
ENDIF()

INCLUDE(${CMAKE_SOURCE_DIR}/cmake/version_info.cmake)
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/sign.cmake)
INCLUDE("${CMAKE_SOURCE_DIR}/cmake/install.cmake")

SET(DEFAULT_CHARSET_HOME "${CMAKE_INSTALL_PREFIX}")
SET(PLUGINDIR "${CMAKE_INSTALL_PREFIX}/lib/plugin")

INCLUDE(${CMAKE_SOURCE_DIR}/cmake/SearchLibrary.cmake)

IF(WITH_EXTERNAL_ZLIB)
  FIND_PACKAGE(ZLIB QUIET)
  IF(${ZLIB_FOUND})
    SET(LIBZ "-z")
  ENDIF()
ENDIF()

INCLUDE(TestBigEndian)
TEST_BIG_ENDIAN(HAVE_BIGENDIAN)

IF(UNIX)
  SEARCH_LIBRARY(DEFAULT_LIB inet_ntoa "c")
  IF(NOT DEFAULT_LIB)
    SEARCH_LIBRARY(LIBNSL inet_ntoa "nsl_r;nsl")
  ENDIF()
  SEARCH_LIBRARY(DEFAULT_LIB bind "c")
  IF(NOT DEFAULT_LIB)
    SEARCH_LIBRARY(LIBBIND bind "bind;socket")
  ENDIF()
  SEARCH_LIBRARY(DEFAULT_LIB setsockopt "c")
  IF(NOT DEFAULT_LIB)
    SEARCH_LIBRARY(LIBSOCKET setsockopt "socket")
  ENDIF()
  SEARCH_LIBRARY(LIBDL dlopen "dl")
  SEARCH_LIBRARY(LIBM floor m)
  SEARCH_LIBRARY(LIBPTHREAD pthread_getspecific "pthread;pthreads")
  SET(EXTRA_LIBS "${LIBNSL}" "${LIBBIND}" "${LIBSOCKET}" "${LIBDL}" "${LIBM}" "${LIBPTHREAD}")
  FIND_PACKAGE(Threads)
  #remove possible dups from required libraries
  LIST(LENGTH SYS_LIBS rllength)
  IF(${rllength} GREATER 0)
    LIST(REMOVE_DUPLICATES SYS_LIBS)
  ENDIF()
  SET(CMAKE_REQUIRED_LIBRARIES ${SYS_LIBS})
ENDIF()


IF(CMAKE_HAVE_PTHREAD_H)
  SET(CMAKE_REQUIRED_INCLUDES pthread.h)
ENDIF()

IF(WIN32)
  SET(HAVE_THREADS 1)
  ADD_DEFINITIONS(-DHAVE_DLOPEN)
  ADD_DEFINITIONS(-D_CRT_SECURE_NO_WARNINGS)
  IF(MSVC)
     SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4996" )
  ENDIF()
ELSEIF()
  SET(HAVE_THREADS ${CMAKE_USE_PTHREADS})
ENDIF()

# check for various include files
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/CheckIncludeFiles.cmake)
# check for various functions
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/CheckFunctions.cmake)
# check for various types
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/CheckTypes.cmake)

# Check for OpenSSL
IF(WITH_OPENSSL)
  FIND_PACKAGE(OpenSSL)
  IF(OPENSSL_FOUND)
    ADD_DEFINITIONS(-DHAVE_OPENSSL)
    INCLUDE_DIRECTORIES(${OPENSSL_INCLUDE_DIR})
    SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES})
    IF(OPENSSL_CRYPTO_LIBRARIES)
      SET(SSL_LIBRARIES ${SSL_LIBRARIES} ${OPENSSL_CRYPTO_LIBRARIES})
    ENDIF()
  ELSE()
    MESSAGE(FATAL_ERROR "OpenSSL not found. Please install OpenSSL or disable SSL support via option -DWITH_OPENSSL=Off")
  ENDIF()
ENDIF()

IF(WITH_SQLITE)
  ADD_DEFINITIONS(-DHAVE_SQLITE)
ENDIF()

IF(NOT WIN32)
  INCLUDE(${CMAKE_SOURCE_DIR}/cmake/FindIconv.cmake)
ENDIF()

CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/mysql_version.h.in
  ${CMAKE_CURRENT_BINARY_DIR}/include/mysql_version.h)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/my_config.h.in
               ${CMAKE_CURRENT_BINARY_DIR}/include/my_config.h)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/mysql_version.h.in
               ${CMAKE_CURRENT_SOURCE_DIR}/include/mysql_version.h)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/include/my_config.h.in
               ${CMAKE_CURRENT_SOURCE_DIR}/include/my_config.h)

INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include)

IF(WIN32)
  SET(SYSTEM_LIBS ws2_32 advapi32 kernel32)
ELSE()
  SET(SYSTEM_LIBS ${LIBPTHREAD} ${LIBDL} ${LIBM})
  IF(ICONV_EXTERNAL)
    SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${ICONV_LIBRARIES})
  ENDIF()
ENDIF()
IF(OPENSSL_FOUND)
  SET(SYSTEM_LIBS ${SYSTEM_LIBS} ${SSL_LIBRARIES})
ENDIF()

ADD_SUBDIRECTORY(include)
ADD_SUBDIRECTORY(libmariadb)
ADD_SUBDIRECTORY(plugins)
IF(NOT WIN32)
  ADD_SUBDIRECTORY(mariadb_config)
ENDIF()

IF(IS_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/unittest)
  ADD_SUBDIRECTORY(unittest/mytap)
  ADD_SUBDIRECTORY(unittest/libmariadb)
ENDIF()

IF(CLIENT_DOCS)
  INSTALL(DIRECTORY ${CLIENT_DOCS}
          DESTINATION ${DOCS_INSTALL_DIR_${INSTALL_LAYOUT}})
ENDIF()


IF(WIN32 AND CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
  ADD_SUBDIRECTORY(win/packaging)
ENDIF()

SET(CPACK_PACKAGE_VENDOR "MariaDB Corporation Ab")
SET(CPACK_PACKAGE_DESCRIPTION "MariaDB Connector/C. A library for connecting to MariaDB and MySQL servers")
SET(CPACK_PACKAGE_NAME "mariadb_connector_c")
STRING(TOLOWER ${CMAKE_SYSTEM_NAME} system_name)
SET(CPACK_PACKAGE_FILE_NAME "mariadb-connector-c-${CPACK_PACKAGE_VERSION}-${system_name}-${CMAKE_SYSTEM_PROCESSOR}")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING.LIB")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
INCLUDE(cmake/ConnectorName.cmake)
SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mariadb-connector-c-${CPACK_PACKAGE_VERSION}-src")

# Build source packages
IF(GIT_BUILD_SRCPKG)
  # get branch name
  EXECUTE_PROCESS(COMMAND git show-branch OUTPUT_VARIABLE git_branch)
  STRING(REGEX MATCH "\\[([^]]+)\\]" git_branch ${git_branch})
  STRING(REGEX REPLACE "\\[|\\]" "" GIT_BRANCH ${git_branch})
  MESSAGE(STATUS "${GIT_BRANCH}")
  IF(WIN32)
    EXECUTE_PROCESS(COMMAND git archive ${GIT_BRANCH} --format=zip --prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ --output=${CPACK_SOURCE_PACKAGE_FILE_NAME}.zip)
  ELSE()
    EXECUTE_PROCESS(COMMAND git archive ${GIT_BRANCH} --format=zip --prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ --output=${CPACK_SOURCE_PACKAGE_FILE_NAME}.zip)
    EXECUTE_PROCESS(COMMAND git archive ${GIT_BRANCH} --format=tar --prefix=${CPACK_SOURCE_PACKAGE_FILE_NAME}/ --output=${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar)
    EXECUTE_PROCESS(COMMAND gzip -9 -f ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar)
  ENDIF()
ENDIF()

SET(CPACK_SOURCE_IGNORE_FILES
\\\\.git/
\\\\.gitignore
\\\\.gitattributes
CMakeCache.txt
cmake_dist.cmake
CPackSourceConfig.cmake
CPackConfig.cmake
mariadb_config/mariadb_config.c$
.build/
html/
unittest
/cmake_install.cmake
/CTestTestfile.cmake
/CMakeFiles/
/version_resources/
/_CPack_Packages/
.*gz$
.*zip$
.*so$
.*so.*$
.*dll$
.*a$
.*pdb$
/CMakeFiles/
/version_resources/
/_CPack_Packages/
Makefile$
include/my_config.h$
/autom4te.cache/
errmsg.sys$
)

IF(WIN32)
  SET(CPACK_GENERATOR "ZIP")
  SET(CPACK_SOURCE_GENERATOR "ZIP")
ELSE()
  SET(CPACK_GENERATOR "TGZ")
  SET(CPACK_SOURCE_GENERATOR "TGZ")
ENDIF()
INCLUDE(CPack)

MESSAGE(STATUS "MariaDB Connector/c configuration:")
MESSAGE(STATUS "CPack generation: ${CPACK_GENERATOR}")
IF(CLIENT_DOCS)
  MESSAGE(STATUS "Documentation included from ${CLIENT_DOCS}")
ENDIF()
MESSAGE(STATUS "SSL support: ${WITH_OPENSSL}")
MESSAGE(STATUS "Experimental Sqlite support: ${WITH_SQLITE}")
IF(WITH_EXTERNAL_ZLIB)
  MESSAGE(STATUS "Zlib support: ${WITH_EXTERNAL_ZLIB}")
ELSE()
  MESSAGE(STATUS "Zlib support: yes (using bundled zlib)")
ENDIF()
MESSAGE(STATUS "Installation layout: ${INSTALL_LAYOUT}")
MESSAGE(STATUS "Include files will be installed in ${PREFIX_INSTALL_DIR}/${INCLUDE_INSTALL_DIR}/${SUFFIX_INSTALL_DIR}")
MESSAGE(STATUS "Libraries will be installed in ${PREFIX_INSTALL_DIR}/${LIB_INSTALL_DIR}/${LIBSUFFIX_INSTALL_DIR}")
MESSAGE(STATUS "Binaries will be installed in ${PREFIX_INSTALL_DIR}/${BIN_INSTALL_DIR}")

MESSAGE(STATUS "Required: ${CMAKE_REQUIRED_LIBRARIES}")