File: CMakeLists.txt

package info (click to toggle)
myodbc 5.1.10-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd, sid
  • size: 2,984 kB
  • ctags: 2,099
  • sloc: ansic: 33,649; cpp: 1,360; xml: 1,261; sh: 353; makefile: 264; perl: 43
file content (298 lines) | stat: -rw-r--r-- 11,423 bytes parent folder | download | duplicates (2)
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
#
# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
#
# The MySQL Connector/ODBC is licensed under the terms of the GPLv2
# <http://www.gnu.org/licenses/old-licenses/gpl-2.0.html>, like most 
# MySQL Connectors. There are special exceptions to the terms and 
# conditions of the GPLv2 as it is applied to this software, see the 
# FLOSS License Exception
# <http://www.mysql.com/about/legal/licensing/foss-exception.html>.
#
# This program is free software; you can redistribute it and/or modify 
# it under the terms of the GNU General Public License as published 
# by the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful, but 
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
# for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA

##########################################################################

PROJECT(MySQL_Connector_ODBC)

SET(CONNECTOR_MAJOR "5")
SET(CONNECTOR_MINOR "1")
SET(CONNECTOR_PATCH "10")
SET(CONNECTOR_LEVEL "")

CMAKE_MINIMUM_REQUIRED(VERSION 2.6.2 FATAL_ERROR)

if(COMMAND cmake_policy)
	cmake_policy(SET CMP0003 NEW)
endif(COMMAND cmake_policy)

#SET(CMAKE_VERBOSE_MAKEFILE ON)

IF(NOT WIN32)
        SET(DISABLE_GUI 1)
ENDIF(NOT WIN32)

#-------------- find  mysql --------------------
INCLUDE(${CMAKE_SOURCE_DIR}/cmake/FindMySQL.cmake)
#-----------------------------------------------------

#-------------- unixodbc/iodbc/win -------------------
IF(WIN32)
        SET(ODBCLIB odbc32)
        SET(ODBCINSTLIB odbccp32)
ELSE(WIN32)
        IF(WITH_UNIXODBC)
                SET(ODBCLIB odbc)
                SET(ODBCINSTLIB odbcinst)
        ELSE(WITH_UNIXODBC)
                SET(ODBCLIB iodbc)
                SET(ODBCINSTLIB iodbcinst)
        ENDIF(WITH_UNIXODBC)

        # FindODBC uses ODBCLIB and ODBCINSTLIB in some cases
        INCLUDE(cmake/FindODBC.cmake)

        IF(WITH_UNIXODBC)
                TRY_COMPILE(COMPILE_RESULT ${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR}/cmake/havelpcwstr.c
                        CMAKE_FLAGS "-DINCLUDE_DIRECTORIES='${ODBC_INCLUDES} ${ODBC_INCLUDE_DIR}'")
                MESSAGE(STATUS "Checking if LPCWSTR type is present - ${COMPILE_RESULT}")

                IF(COMPILE_RESULT)
                        ADD_DEFINITIONS(-DHAVE_LPCWSTR)
                        ADD_DEFINITIONS(-DUSE_UNIXODBC)
                ENDIF(COMPILE_RESULT)

	ELSE(WITH_UNIXODBC)
		ADD_DEFINITIONS(-DHAVE_SQLGETPRIVATEPROFILESTRINGW)
        ENDIF(WITH_UNIXODBC)

	INCLUDE(CheckFunctionExists)
	CHECK_FUNCTION_EXISTS(dlopen DLOPEN_IN_LIBC)
        SET(DL_INCLUDES)
        SET(DL_LFLAGS)
        SET(DL_LIBS)
        IF(NOT DLOPEN_IN_LIBC)
          FIND_LIBRARY(DL_LIBS dl)
        ENDIF(NOT DLOPEN_IN_LIBC)
ENDIF(WIN32)
#-----------------------------------------------------

#-------- configuring paths to odbc heders for compatibility checks ---------
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/sqlcolattrib1.c.cmake ${CMAKE_BINARY_DIR}/cmake/sqlcolattrib1.c @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/sqlcolattrib2.c.cmake ${CMAKE_BINARY_DIR}/cmake/sqlcolattrib2.c @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/sqlparamopt1.c.cmake ${CMAKE_BINARY_DIR}/cmake/sqlparamopt1.c @ONLY)
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/sqlparamopt2.c.cmake ${CMAKE_BINARY_DIR}/cmake/sqlparamopt2.c @ONLY)
#-----------------------------------------------------

#------------------ check compatibility---------------
TRY_COMPILE(COMPILE_RESULT ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/cmake/sqlcolattrib1.c)
MESSAGE(STATUS "Checking if SQLColAttribute last arg is compatible with SQLLEN* - ${COMPILE_RESULT}")

IF(COMPILE_RESULT)
        ADD_DEFINITIONS(-DUSE_SQLCOLATTRIBUTE_SQLLEN_PTR)
ELSE(COMPILE_RESULT)
        TRY_COMPILE(COMPILE_RESULT1 ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/cmake/sqlcolattrib2.c)
        MESSAGE(STATUS "Checking if SQLColAttribute last arg is compatible with SQLPOINTER - ${COMPILE_RESULT1}")

        IF(COMPILE_RESULT1)
                ADD_DEFINITIONS(-DUSE_SQLCOLATTRIBUTE_SQLPOINTER)
        ELSE(COMPILE_RESULT1)
                # By default using SQLLEN parameter
                ADD_DEFINITIONS(-DUSE_SQLCOLATTRIBUTE_SQLLEN_PTR)
        ENDIF(COMPILE_RESULT1)
ENDIF(COMPILE_RESULT)

TRY_COMPILE(COMPILE_RESULT ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/cmake/sqlparamopt1.c)
MESSAGE(STATUS "Checking if SQLParamOptions() 2nd and 3rd arg is compatible with SQLULEN - ${COMPILE_RESULT}")

IF(COMPILE_RESULT)
        ADD_DEFINITIONS(-DUSE_SQLPARAMOPTIONS_SQLULEN_PTR)
ELSE(COMPILE_RESULT)
        TRY_COMPILE(COMPILE_RESULT1 ${CMAKE_BINARY_DIR} ${CMAKE_BINARY_DIR}/cmake/sqlparamopt2.c)
        MESSAGE(STATUS "Checking if SQLParamOptions() 2nd and 3rd arg is compatible with SQLUINTEGER - ${COMPILE_RESULT1}")

        IF(COMPILE_RESULT1)
                ADD_DEFINITIONS(-DUSE_SQLPARAMOPTIONS_SQLUINTEGER_PTR)
        ELSE(COMPILE_RESULT1)
                # SQLULEN is a default
		MESSAGE(STATUS "Apparently odbc headers could not be found. 2nd and 3rd parameters assumed to be (*)SQLULEN by default")
                ADD_DEFINITIONS(-DUSE_SQLPARAMOPTIONS_SQLULEN_PTR)
        ENDIF(COMPILE_RESULT1)

ENDIF(COMPILE_RESULT)
#-----------------------------------------------------

	IF(NOT NO_THREADS)
		MESSAGE(STATUS "Enabling threads support")
		ADD_DEFINITIONS(-DTHREAD)
	ENDIF(NOT NO_THREADS)

#------------ build options for windows --------------
IF(WIN32)
        REMOVE_DEFINITIONS(-DUNICODE)
        ADD_DEFINITIONS(-D_CRT_SECURE_NO_DEPRECATE -D_CRT_NONSTDC_NO_DEPRECATE)
        ADD_DEFINITIONS(-DENGLISH -DMYODBC_EXPORTS -D_USERDLL)
        ADD_DEFINITIONS(-D_WIN32 -DWIN32 -D_WINDOWS -D__WIN__)

	#Since 5.5.13 libmysql introduces dependency on Secur32.lib
	FILE(STRINGS "${MYSQL_INCLUDE_DIR}\\mysql_version.h" mysql_version REGEX "^\#define[ \t]+MYSQL_VERSION_ID")

	STRING(REGEX REPLACE "^\#define[ \t]+MYSQL_VERSION_ID[ \t]+([0-9]+)" "\\1" MYSQL_CLIENT_VERSION "${mysql_version}")

	IF(MYSQL_CLIENT_VERSION GREATER 50512)
		MESSAGE(STATUS "MySQL client lib(version ${MYSQL_CLIENT_VERSION}) requires Secure32.lib - TRUE")
		SET(SECURE32_LIB Secur32)
	ENDIF(MYSQL_CLIENT_VERSION GREATER 50512)

        # edits for all config build flags
        FOREACH(TYPE C CXX)
                # makefiles use blank configuration
                FOREACH(CFG "_DEBUG" "_MINSIZEREL" "_RELEASE" "_RELWITHDEBINFO")

                        SET(NEW_FLAGS "${CMAKE_${TYPE}_FLAGS${CFG}}")

                        # fix up static libc flags
                        STRING(REPLACE "/MD" "/MT" NEW_FLAGS "${NEW_FLAGS}")

                        # Add some additional help for debug builds
                        IF(CMAKE_BUILD_TYPE STREQUAL "Debug")
                                STRING(REPLACE "/Zi" "/ZI" NEW_FLAGS "${NEW_FLAGS}")
                                SET(NEW_FLAGS "${NEW_FLAGS} /RTC1 /RTCc")
                        ENDIF(CMAKE_BUILD_TYPE STREQUAL "Debug")

                        # *FORCE* to override whats already placed into the cache
                        SET(CMAKE_${TYPE}_FLAGS${CFG} "${NEW_FLAGS}" CACHE STRING
                                "CMAKE_${TYPE}_FLAGS${CFG} (overwritten for odbc)" FORCE)

                ENDFOREACH(CFG)
        ENDFOREACH(TYPE)
ELSE(WIN32)
  ADD_DEFINITIONS(-D_UNIX_)
ENDIF(WIN32)
#-----------------------------------------------------

SET(EXECUTABLE_OUTPUT_PATH "${CMAKE_BINARY_DIR}/bin")
SET(LIBRARY_OUTPUT_PATH "${CMAKE_BINARY_DIR}/lib")

SET(LIB_SUBDIR "lib")
IF(RPM_BUILD AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
  SET(LIB_SUBDIR "lib64")
ENDIF()

INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR})

ADD_SUBDIRECTORY(util)
ADD_SUBDIRECTORY(driver)

IF(NOT DISABLE_GUI)
        ADD_SUBDIRECTORY(setupgui)
ENDIF(NOT DISABLE_GUI)

ADD_SUBDIRECTORY(dltest)
ADD_SUBDIRECTORY(installer)

ADD_SUBDIRECTORY(test)

##############################################################################
#
#  Packaging
#
##############################################################################

SET(CONNECTOR_NUMERIC_VERSION "${CONNECTOR_MAJOR}.${CONNECTOR_MINOR}.${CONNECTOR_PATCH}")
SET(CONNECTOR_VERSION         "${CONNECTOR_NUMERIC_VERSION}${EXTRA_VERSION_SUFFIX}${CONNECTOR_LEVEL}")

SET(CPACK_PACKAGE_VERSION_MAJOR ${CONNECTOR_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${CONNECTOR_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${CONNECTOR_PATCH})

IF(NOT EXTRA_NAME_SUFFIX)
  SET(EXTRA_NAME_SUFFIX "")
ENDIF(NOT EXTRA_NAME_SUFFIX)

SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Connector/ODBC 5.1, a library for connecting to MySQL servers.")
SET(CPACK_PACKAGE_NAME                "mysql-connector-odbc${EXTRA_NAME_SUFFIX}")
IF(EXISTS "${CMAKE_SOURCE_DIR}/COPYING")
  SET(CPACK_RESOURCE_FILE_LICENSE     "${CMAKE_SOURCE_DIR}/COPYING")
ELSE(EXISTS "${CMAKE_SOURCE_DIR}/COPYING")
  SET(CPACK_RESOURCE_FILE_LICENSE     "${CMAKE_SOURCE_DIR}/LICENSE.mysql")
ENDIF(EXISTS "${CMAKE_SOURCE_DIR}/COPYING")
SET(CPACK_PACKAGE_DESCRIPTION_FILE    "${CMAKE_SOURCE_DIR}/README")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME    "${CPACK_PACKAGE_NAME}-${CONNECTOR_VERSION}-src")
SET(CPACK_PACKAGE_INSTALL_DIRECTORY   "${CPACK_PACKAGE_NAME}-${CONNECTOR_VERSION}-${CONNECTOR_PLATFORM}")
IF(WIN32)
  SET(CPACK_GENERATOR                 "ZIP")
  SET(CPACK_PACKAGE_FILE_NAME         "${CPACK_PACKAGE_NAME}-noinstall-${CONNECTOR_VERSION}-${CONNECTOR_PLATFORM}")
ELSE(WIN32)
  SET(CPACK_GENERATOR                 "TGZ")
  SET(CPACK_PACKAGE_FILE_NAME         "${CPACK_PACKAGE_INSTALL_DIRECTORY}")
ENDIF(WIN32)

SET(CPACK_SOURCE_IGNORE_FILES
\\\\.bzr/
\\\\.bzr-mysql
\\\\.bzrignore
CMakeCache\\\\.txt
CPackSourceConfig\\\\.cmake
CPackConfig\\\\.cmake
/cmake_install\\\\.cmake
/CTestTestfile\\\\.cmake
/CMakeFiles/
/_CPack_Packages/
Makefile$
cmake/sql.*\\\\.c$
)

#------------ Installation ---------------------------

IF(WIN32)

# For conveninence copy (un)install.bat scripts to the build
# directory to ease testing.

  CONFIGURE_FILE(Install.bat ${CMAKE_BINARY_DIR}/Install.bat COPYONLY)
  CONFIGURE_FILE(Uninstall.bat ${CMAKE_BINARY_DIR}/Uninstall.bat COPYONLY)

# TODO: line-ending conversions unix->dos

  INSTALL(FILES ChangeLog     DESTINATION . RENAME ChangeLog.txt)
  INSTALL(FILES README        DESTINATION . RENAME README.txt)
  INSTALL(FILES README.debug  DESTINATION . RENAME README.debug.txt)
  INSTALL(FILES INSTALL       DESTINATION . RENAME INSTALL.txt)
  INSTALL(FILES INSTALL.win   DESTINATION . RENAME INSTALL.win.txt)
  IF(EXISTS "${CMAKE_SOURCE_DIR}/COPYING")
    INSTALL(FILES COPYING       DESTINATION . RENAME COPYING.txt)
  ELSE()
    INSTALL(FILES LICENSE.mysql DESTINATION . RENAME LICENSE.mysql.txt)
  ENDIF()

  INSTALL(FILES Install.bat   DESTINATION .)
  INSTALL(FILES Uninstall.bat DESTINATION .)

ELSE(WIN32)

  INSTALL(FILES ChangeLog    DESTINATION .)
  INSTALL(FILES README       DESTINATION .)
  INSTALL(FILES README.debug DESTINATION .)
  INSTALL(FILES INSTALL      DESTINATION .)
  IF(EXISTS "${CMAKE_SOURCE_DIR}/COPYING")
    INSTALL(FILES COPYING       DESTINATION .)
  ELSE()
    INSTALL(FILES LICENSE.mysql DESTINATION .)
  ENDIF()

ENDIF(WIN32)

INSTALL(FILES Licenses_for_Third-Party_Components.txt DESTINATION .)

INCLUDE(CPack)