~ubuntu-branches/ubuntu/trusty/mysql-5.6/trusty

« back to all changes in this revision

Viewing changes to storage/innobase/CMakeLists.txt

  • Committer: Package Import Robot
  • Author(s): James Page
  • Date: 2014-02-12 11:54:27 UTC
  • Revision ID: package-import@ubuntu.com-20140212115427-oq6tfsqxl1wuwehi
Tags: upstream-5.6.15
ImportĀ upstreamĀ versionĀ 5.6.15

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved.
 
2
#
 
3
# This program is free software; you can redistribute it and/or modify
 
4
# it under the terms of the GNU General Public License as published by
 
5
# the Free Software Foundation; version 2 of the License.
 
6
#
 
7
# This program is distributed in the hope that it will be useful,
 
8
# but WITHOUT ANY WARRANTY; without even the implied warranty of
 
9
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
10
# GNU General Public License for more details.
 
11
#
 
12
# You should have received a copy of the GNU General Public License
 
13
# along with this program; if not, write to the Free Software
 
14
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 
15
 
 
16
# This is the CMakeLists for InnoDB
 
17
 
 
18
INCLUDE(CheckFunctionExists)
 
19
INCLUDE(CheckCSourceCompiles)
 
20
INCLUDE(CheckCSourceRuns)
 
21
 
 
22
# OS tests
 
23
IF(UNIX)
 
24
  IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
 
25
    CHECK_INCLUDE_FILES (libaio.h HAVE_LIBAIO_H)
 
26
    CHECK_LIBRARY_EXISTS(aio io_queue_init "" HAVE_LIBAIO)
 
27
    ADD_DEFINITIONS("-DUNIV_LINUX -D_GNU_SOURCE=1")
 
28
    IF(HAVE_LIBAIO_H AND HAVE_LIBAIO)
 
29
      ADD_DEFINITIONS(-DLINUX_NATIVE_AIO=1)
 
30
      LINK_LIBRARIES(aio)
 
31
    ENDIF()
 
32
  ELSEIF(CMAKE_SYSTEM_NAME MATCHES "HP*")
 
33
    ADD_DEFINITIONS("-DUNIV_HPUX")
 
34
  ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "AIX")
 
35
    ADD_DEFINITIONS("-DUNIV_AIX")
 
36
  ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
 
37
    ADD_DEFINITIONS("-DUNIV_SOLARIS")
 
38
  ENDIF()
 
39
ENDIF()
 
40
 
 
41
IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
 
42
# After: WL#5825 Using C++ Standard Library with MySQL code
 
43
#       we no longer use -fno-exceptions
 
44
#       SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-exceptions")
 
45
ENDIF()
 
46
 
 
47
# Enable InnoDB's UNIV_DEBUG and UNIV_SYNC_DEBUG in debug builds
 
48
SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DUNIV_DEBUG -DUNIV_SYNC_DEBUG")
 
49
 
 
50
# Add -Wconversion if compiling with GCC
 
51
## As of Mar 15 2011 this flag causes 3573+ warnings. If you are reading this
 
52
## please fix them and enable the following code:
 
53
#IF(CMAKE_CXX_COMPILER_ID MATCHES "GNU")
 
54
#SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wconversion")
 
55
#ENDIF()
 
56
 
 
57
CHECK_FUNCTION_EXISTS(sched_getcpu  HAVE_SCHED_GETCPU)
 
58
 
 
59
IF(NOT MSVC)
 
60
# either define HAVE_IB_GCC_ATOMIC_BUILTINS or not
 
61
IF(NOT CMAKE_CROSSCOMPILING)
 
62
  CHECK_C_SOURCE_RUNS(
 
63
  "
 
64
  int main()
 
65
  {
 
66
    long        x;
 
67
    long        y;
 
68
    long        res;
 
69
    char        c;
 
70
 
 
71
    x = 10;
 
72
    y = 123;
 
73
    res = __sync_bool_compare_and_swap(&x, x, y);
 
74
    if (!res || x != y) {
 
75
      return(1);
 
76
    }
 
77
 
 
78
    x = 10;
 
79
    y = 123;
 
80
    res = __sync_bool_compare_and_swap(&x, x + 1, y);
 
81
    if (res || x != 10) {
 
82
      return(1);
 
83
    }
 
84
    x = 10;
 
85
    y = 123;
 
86
    res = __sync_add_and_fetch(&x, y);
 
87
    if (res != 123 + 10 || x != 123 + 10) {
 
88
      return(1);
 
89
    }
 
90
 
 
91
    c = 10;
 
92
    res = __sync_lock_test_and_set(&c, 123);
 
93
    if (res != 10 || c != 123) {
 
94
      return(1);
 
95
    }
 
96
    return(0);
 
97
  }"
 
98
  HAVE_IB_GCC_ATOMIC_BUILTINS
 
99
  )
 
100
  CHECK_C_SOURCE_RUNS(
 
101
  "#include<stdint.h>
 
102
  int main()
 
103
  {
 
104
    int64_t     x,y,res;
 
105
 
 
106
    x = 10;
 
107
    y = 123;
 
108
    res = __sync_sub_and_fetch(&y, x);
 
109
    if (res != y || y != 113) {
 
110
      return(1);
 
111
    }
 
112
    res = __sync_add_and_fetch(&y, x);
 
113
    if (res != y || y != 123) {
 
114
      return(1);
 
115
    }
 
116
    return(0);
 
117
  }"
 
118
  HAVE_IB_GCC_ATOMIC_BUILTINS_64
 
119
  )
 
120
ENDIF()
 
121
 
 
122
IF(HAVE_IB_GCC_ATOMIC_BUILTINS)
 
123
 ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_BUILTINS=1)
 
124
ENDIF()
 
125
 
 
126
IF(HAVE_IB_GCC_ATOMIC_BUILTINS_64)
 
127
 ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_BUILTINS_64=1)
 
128
ENDIF()
 
129
 
 
130
 # either define HAVE_IB_ATOMIC_PTHREAD_T_GCC or not
 
131
IF(NOT CMAKE_CROSSCOMPILING)
 
132
  CHECK_C_SOURCE_RUNS(
 
133
  "
 
134
  #include <pthread.h>
 
135
  #include <string.h>
 
136
 
 
137
  int main() {
 
138
    pthread_t       x1;
 
139
    pthread_t       x2;
 
140
    pthread_t       x3;
 
141
 
 
142
    memset(&x1, 0x0, sizeof(x1));
 
143
    memset(&x2, 0x0, sizeof(x2));
 
144
    memset(&x3, 0x0, sizeof(x3));
 
145
 
 
146
    __sync_bool_compare_and_swap(&x1, x2, x3);
 
147
 
 
148
    return(0);
 
149
  }"
 
150
  HAVE_IB_ATOMIC_PTHREAD_T_GCC)
 
151
ENDIF()
 
152
IF(HAVE_IB_ATOMIC_PTHREAD_T_GCC)
 
153
  ADD_DEFINITIONS(-DHAVE_IB_ATOMIC_PTHREAD_T_GCC=1)
 
154
ENDIF()
 
155
 
 
156
ENDIF(NOT MSVC)
 
157
 
 
158
CHECK_FUNCTION_EXISTS(asprintf  HAVE_ASPRINTF)
 
159
CHECK_FUNCTION_EXISTS(vasprintf  HAVE_VASPRINTF)
 
160
 
 
161
# Solaris atomics
 
162
IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
 
163
  CHECK_FUNCTION_EXISTS(atomic_cas_ulong  HAVE_ATOMIC_CAS_ULONG)
 
164
  CHECK_FUNCTION_EXISTS(atomic_cas_32 HAVE_ATOMIC_CAS_32)
 
165
  CHECK_FUNCTION_EXISTS(atomic_cas_64 HAVE_ATOMIC_CAS_64)
 
166
  CHECK_FUNCTION_EXISTS(atomic_add_long_nv HAVE_ATOMIC_ADD_LONG_NV)
 
167
  CHECK_FUNCTION_EXISTS(atomic_swap_uchar HAVE_ATOMIC_SWAP_UCHAR)
 
168
  IF(HAVE_ATOMIC_CAS_ULONG AND
 
169
     HAVE_ATOMIC_CAS_32 AND
 
170
     HAVE_ATOMIC_CAS_64 AND
 
171
     HAVE_ATOMIC_ADD_LONG_NV AND
 
172
     HAVE_ATOMIC_SWAP_UCHAR)
 
173
    SET(HAVE_IB_SOLARIS_ATOMICS 1)
 
174
  ENDIF()
 
175
 
 
176
  IF(HAVE_IB_SOLARIS_ATOMICS)
 
177
    ADD_DEFINITIONS(-DHAVE_IB_SOLARIS_ATOMICS=1)
 
178
  ENDIF()
 
179
 
 
180
  IF(NOT CMAKE_CROSSCOMPILING)
 
181
  # either define HAVE_IB_ATOMIC_PTHREAD_T_SOLARIS or not
 
182
  CHECK_C_SOURCE_COMPILES(
 
183
  "   #include <pthread.h>
 
184
      #include <string.h>
 
185
 
 
186
      int main(int argc, char** argv) {
 
187
        pthread_t       x1;
 
188
        pthread_t       x2;
 
189
        pthread_t       x3;
 
190
 
 
191
        memset(&x1, 0x0, sizeof(x1));
 
192
        memset(&x2, 0x0, sizeof(x2));
 
193
        memset(&x3, 0x0, sizeof(x3));
 
194
 
 
195
        if (sizeof(pthread_t) == 4) {
 
196
 
 
197
          atomic_cas_32(&x1, x2, x3);
 
198
 
 
199
        } else if (sizeof(pthread_t) == 8) {
 
200
 
 
201
          atomic_cas_64(&x1, x2, x3);
 
202
 
 
203
        } else {
 
204
 
 
205
          return(1);
 
206
        }
 
207
 
 
208
      return(0);
 
209
    }
 
210
  " HAVE_IB_ATOMIC_PTHREAD_T_SOLARIS)
 
211
  ENDIF()
 
212
  IF(HAVE_IB_ATOMIC_PTHREAD_T_SOLARIS)
 
213
    ADD_DEFINITIONS(-DHAVE_IB_ATOMIC_PTHREAD_T_SOLARIS=1)
 
214
  ENDIF()
 
215
ENDIF()
 
216
 
 
217
 
 
218
IF(UNIX)
 
219
# this is needed to know which one of atomic_cas_32() or atomic_cas_64()
 
220
# to use in the source
 
221
SET(CMAKE_EXTRA_INCLUDE_FILES pthread.h)
 
222
CHECK_TYPE_SIZE(pthread_t SIZEOF_PTHREAD_T)
 
223
SET(CMAKE_EXTRA_INCLUDE_FILES)
 
224
ENDIF()
 
225
 
 
226
IF(SIZEOF_PTHREAD_T)
 
227
  ADD_DEFINITIONS(-DSIZEOF_PTHREAD_T=${SIZEOF_PTHREAD_T})
 
228
ENDIF()
 
229
 
 
230
IF(MSVC)
 
231
  ADD_DEFINITIONS(-DHAVE_WINDOWS_ATOMICS)
 
232
ENDIF()
 
233
 
 
234
 
 
235
# Include directories under innobase
 
236
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/innobase/include
 
237
                    ${CMAKE_SOURCE_DIR}/storage/innobase/handler)
 
238
 
 
239
# Sun Studio bug with -xO2
 
240
IF(CMAKE_CXX_COMPILER_ID MATCHES "SunPro"
 
241
        AND CMAKE_CXX_FLAGS_RELEASE MATCHES "O2"
 
242
        AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
 
243
        # Sun Studio 12 crashes with -xO2 flag, but not with higher optimization
 
244
        # -xO3
 
245
        SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/rem/rem0rec.cc
 
246
    PROPERTIES COMPILE_FLAGS -xO3)
 
247
ENDIF()
 
248
 
 
249
# Removing compiler optimizations for innodb/mem/* files on 64-bit Windows
 
250
# due to 64-bit compiler error, See MySQL Bug #19424, #36366, #34297
 
251
IF (MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8)
 
252
        SET_SOURCE_FILES_PROPERTIES(mem/mem0mem.cc mem/mem0pool.cc
 
253
                                    PROPERTIES COMPILE_FLAGS -Od)
 
254
ENDIF()
 
255
 
 
256
SET(INNOBASE_SOURCES
 
257
        api/api0api.cc
 
258
        api/api0misc.cc
 
259
        btr/btr0btr.cc
 
260
        btr/btr0cur.cc
 
261
        btr/btr0pcur.cc
 
262
        btr/btr0sea.cc
 
263
        buf/buf0buddy.cc
 
264
        buf/buf0buf.cc
 
265
        buf/buf0dblwr.cc
 
266
        buf/buf0checksum.cc
 
267
        buf/buf0dump.cc
 
268
        buf/buf0flu.cc
 
269
        buf/buf0lru.cc
 
270
        buf/buf0rea.cc
 
271
        data/data0data.cc
 
272
        data/data0type.cc
 
273
        dict/dict0boot.cc
 
274
        dict/dict0crea.cc
 
275
        dict/dict0dict.cc
 
276
        dict/dict0load.cc
 
277
        dict/dict0mem.cc
 
278
        dict/dict0stats.cc
 
279
        dict/dict0stats_bg.cc
 
280
        dyn/dyn0dyn.cc
 
281
        eval/eval0eval.cc
 
282
        eval/eval0proc.cc
 
283
        fil/fil0fil.cc
 
284
        fsp/fsp0fsp.cc
 
285
        fut/fut0fut.cc
 
286
        fut/fut0lst.cc
 
287
        ha/ha0ha.cc
 
288
        ha/ha0storage.cc
 
289
        ha/hash0hash.cc
 
290
        fts/fts0fts.cc
 
291
        fts/fts0ast.cc
 
292
        fts/fts0blex.cc
 
293
        fts/fts0config.cc
 
294
        fts/fts0opt.cc
 
295
        fts/fts0pars.cc
 
296
        fts/fts0que.cc
 
297
        fts/fts0sql.cc
 
298
        fts/fts0tlex.cc
 
299
        handler/ha_innodb.cc
 
300
        handler/handler0alter.cc
 
301
        handler/i_s.cc
 
302
        ibuf/ibuf0ibuf.cc
 
303
        lock/lock0iter.cc
 
304
        lock/lock0lock.cc
 
305
        lock/lock0wait.cc
 
306
        log/log0log.cc
 
307
        log/log0recv.cc
 
308
        mach/mach0data.cc
 
309
        mem/mem0mem.cc
 
310
        mem/mem0pool.cc
 
311
        mtr/mtr0log.cc
 
312
        mtr/mtr0mtr.cc
 
313
        os/os0file.cc
 
314
        os/os0proc.cc
 
315
        os/os0sync.cc
 
316
        os/os0thread.cc
 
317
        page/page0cur.cc
 
318
        page/page0page.cc
 
319
        page/page0zip.cc
 
320
        pars/lexyy.cc
 
321
        pars/pars0grm.cc
 
322
        pars/pars0opt.cc
 
323
        pars/pars0pars.cc
 
324
        pars/pars0sym.cc
 
325
        que/que0que.cc
 
326
        read/read0read.cc
 
327
        rem/rem0cmp.cc
 
328
        rem/rem0rec.cc
 
329
        row/row0ext.cc
 
330
        row/row0ftsort.cc
 
331
        row/row0import.cc
 
332
        row/row0ins.cc
 
333
        row/row0merge.cc
 
334
        row/row0mysql.cc
 
335
        row/row0log.cc
 
336
        row/row0purge.cc
 
337
        row/row0row.cc
 
338
        row/row0sel.cc
 
339
        row/row0uins.cc
 
340
        row/row0umod.cc
 
341
        row/row0undo.cc
 
342
        row/row0upd.cc
 
343
        row/row0quiesce.cc
 
344
        row/row0vers.cc
 
345
        srv/srv0conc.cc
 
346
        srv/srv0mon.cc
 
347
        srv/srv0srv.cc
 
348
        srv/srv0start.cc
 
349
        sync/sync0arr.cc
 
350
        sync/sync0rw.cc
 
351
        sync/sync0sync.cc
 
352
        trx/trx0i_s.cc
 
353
        trx/trx0purge.cc
 
354
        trx/trx0rec.cc
 
355
        trx/trx0roll.cc
 
356
        trx/trx0rseg.cc
 
357
        trx/trx0sys.cc
 
358
        trx/trx0trx.cc
 
359
        trx/trx0undo.cc
 
360
        usr/usr0sess.cc
 
361
        ut/ut0bh.cc
 
362
        ut/ut0byte.cc
 
363
        ut/ut0crc32.cc
 
364
        ut/ut0dbg.cc
 
365
        ut/ut0list.cc
 
366
        ut/ut0mem.cc
 
367
        ut/ut0rbt.cc
 
368
        ut/ut0rnd.cc
 
369
        ut/ut0ut.cc
 
370
        ut/ut0vec.cc
 
371
        ut/ut0wqueue.cc)
 
372
 
 
373
IF(WITH_INNODB)
 
374
  # Legacy option
 
375
  SET(WITH_INNOBASE_STORAGE_ENGINE TRUE)
 
376
ENDIF()
 
377
 
 
378
MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE
 
379
  DEFAULT
 
380
  MODULE_OUTPUT_NAME ha_innodb
 
381
  LINK_LIBRARIES ${ZLIB_LIBRARY})