You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

287 lines
7.9 KiB

15 years ago
15 years ago
15 years ago
15 years ago
16 years ago
15 years ago
16 years ago
15 years ago
16 years ago
15 years ago
16 years ago
15 years ago
16 years ago
15 years ago
16 years ago
15 years ago
16 years ago
15 years ago
16 years ago
15 years ago
16 years ago
15 years ago
16 years ago
15 years ago
16 years ago
16 years ago
15 years ago
16 years ago
15 years ago
16 years ago
15 years ago
  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. # This is the CMakeLists for InnoDB
  16. INCLUDE(CheckFunctionExists)
  17. INCLUDE(CheckCSourceCompiles)
  18. INCLUDE(CheckCSourceRuns)
  19. # OS tests
  20. IF(UNIX)
  21. IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  22. CHECK_INCLUDE_FILES (libaio.h HAVE_LIBAIO_H)
  23. CHECK_LIBRARY_EXISTS(aio io_queue_init "" HAVE_LIBAIO)
  24. ADD_DEFINITIONS("-DUNIV_LINUX -D_GNU_SOURCE=1")
  25. IF(HAVE_LIBAIO_H AND HAVE_LIBAIO)
  26. ADD_DEFINITIONS(-DLINUX_NATIVE_AIO=1)
  27. LINK_LIBRARIES(aio)
  28. ENDIF()
  29. ELSEIF(CMAKE_SYSTEM_NAME MATCHES "HP*")
  30. ADD_DEFINITIONS("-DUNIV_HPUX -DUNIV_MUST_NOT_INLINE")
  31. ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "AIX")
  32. ADD_DEFINITIONS("-DUNIV_AIX -DUNIX_MUST_NOT_INLINE")
  33. ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
  34. ADD_DEFINITIONS("-DUNIV_SOLARIS")
  35. ELSE()
  36. ADD_DEFINITIONS("-DUNIV_MUST_NOT_INLINE")
  37. ENDIF()
  38. ENDIF()
  39. # Enable InnoDB's UNIV_DEBUG for debug builds
  40. SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DUNIV_DEBUG")
  41. SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DUNIV_DEBUG")
  42. IF(NOT MSVC)
  43. # either define HAVE_IB_GCC_ATOMIC_BUILTINS or not
  44. IF(NOT CMAKE_CROSSCOMPILING)
  45. CHECK_C_SOURCE_RUNS(
  46. "
  47. int main()
  48. {
  49. long x;
  50. long y;
  51. long res;
  52. char c;
  53. x = 10;
  54. y = 123;
  55. res = __sync_bool_compare_and_swap(&x, x, y);
  56. if (!res || x != y) {
  57. return(1);
  58. }
  59. x = 10;
  60. y = 123;
  61. res = __sync_bool_compare_and_swap(&x, x + 1, y);
  62. if (res || x != 10) {
  63. return(1);
  64. }
  65. x = 10;
  66. y = 123;
  67. res = __sync_add_and_fetch(&x, y);
  68. if (res != 123 + 10 || x != 123 + 10) {
  69. return(1);
  70. }
  71. c = 10;
  72. res = __sync_lock_test_and_set(&c, 123);
  73. if (res != 10 || c != 123) {
  74. return(1);
  75. }
  76. return(0);
  77. }"
  78. HAVE_IB_GCC_ATOMIC_BUILTINS
  79. )
  80. CHECK_C_SOURCE_RUNS(
  81. "
  82. #include <stdint.h>
  83. int main()
  84. {
  85. int64_t x, y, res;
  86. x = 10;
  87. y = 123;
  88. res = __sync_bool_compare_and_swap(&x, x, y);
  89. if (!res || x != y) {
  90. return(1);
  91. }
  92. x = 10;
  93. y = 123;
  94. res = __sync_add_and_fetch(&x, y);
  95. if (res != 123 + 10 || x != 123 + 10) {
  96. return(1);
  97. }
  98. return(0);
  99. }"
  100. HAVE_IB_GCC_ATOMIC_BUILTINS_64
  101. )
  102. ENDIF()
  103. IF(HAVE_IB_GCC_ATOMIC_BUILTINS)
  104. ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_BUILTINS=1)
  105. ENDIF()
  106. IF(HAVE_IB_GCC_ATOMIC_BUILTINS_64)
  107. ADD_DEFINITIONS(-DHAVE_IB_GCC_ATOMIC_BUILTINS_64=1)
  108. ENDIF()
  109. # either define HAVE_IB_ATOMIC_PTHREAD_T_GCC or not
  110. IF(NOT CMAKE_CROSSCOMPILING)
  111. CHECK_C_SOURCE_RUNS(
  112. "
  113. #include <pthread.h>
  114. #include <string.h>
  115. int main() {
  116. pthread_t x1;
  117. pthread_t x2;
  118. pthread_t x3;
  119. memset(&x1, 0x0, sizeof(x1));
  120. memset(&x2, 0x0, sizeof(x2));
  121. memset(&x3, 0x0, sizeof(x3));
  122. __sync_bool_compare_and_swap(&x1, x2, x3);
  123. return(0);
  124. }"
  125. HAVE_IB_ATOMIC_PTHREAD_T_GCC)
  126. ENDIF()
  127. IF(HAVE_IB_ATOMIC_PTHREAD_T_GCC)
  128. ADD_DEFINITIONS(-DHAVE_IB_ATOMIC_PTHREAD_T_GCC=1)
  129. ENDIF()
  130. ENDIF(NOT MSVC)
  131. # Solaris atomics
  132. IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
  133. CHECK_FUNCTION_EXISTS(atomic_cas_ulong HAVE_ATOMIC_CAS_ULONG)
  134. CHECK_FUNCTION_EXISTS(atomic_cas_32 HAVE_ATOMIC_CAS_32)
  135. CHECK_FUNCTION_EXISTS(atomic_cas_64 HAVE_ATOMIC_CAS_64)
  136. CHECK_FUNCTION_EXISTS(atomic_add_long_nv HAVE_ATOMIC_ADD_LONG_NV)
  137. CHECK_FUNCTION_EXISTS(atomic_swap_uchar HAVE_ATOMIC_SWAP_UCHAR)
  138. IF(HAVE_ATOMIC_CAS_ULONG AND
  139. HAVE_ATOMIC_CAS_32 AND
  140. HAVE_ATOMIC_CAS_64 AND
  141. HAVE_ATOMIC_ADD_LONG_NV AND
  142. HAVE_ATOMIC_SWAP_UCHAR)
  143. SET(HAVE_IB_SOLARIS_ATOMICS 1)
  144. ENDIF()
  145. IF(HAVE_IB_SOLARIS_ATOMICS)
  146. ADD_DEFINITIONS(-DHAVE_IB_SOLARIS_ATOMICS=1)
  147. ENDIF()
  148. IF(NOT CMAKE_CROSSCOMPILING)
  149. # either define HAVE_IB_ATOMIC_PTHREAD_T_SOLARIS or not
  150. CHECK_C_SOURCE_COMPILES(
  151. " #include <pthread.h>
  152. #include <string.h>
  153. int main(int argc, char** argv) {
  154. pthread_t x1;
  155. pthread_t x2;
  156. pthread_t x3;
  157. memset(&x1, 0x0, sizeof(x1));
  158. memset(&x2, 0x0, sizeof(x2));
  159. memset(&x3, 0x0, sizeof(x3));
  160. if (sizeof(pthread_t) == 4) {
  161. atomic_cas_32(&x1, x2, x3);
  162. } else if (sizeof(pthread_t) == 8) {
  163. atomic_cas_64(&x1, x2, x3);
  164. } else {
  165. return(1);
  166. }
  167. return(0);
  168. }
  169. " HAVE_IB_ATOMIC_PTHREAD_T_SOLARIS)
  170. ENDIF()
  171. IF(HAVE_IB_ATOMIC_PTHREAD_T_SOLARIS)
  172. ADD_DEFINITIONS(-DHAVE_IB_ATOMIC_PTHREAD_T_SOLARIS=1)
  173. ENDIF()
  174. ENDIF()
  175. IF(UNIX)
  176. # this is needed to know which one of atomic_cas_32() or atomic_cas_64()
  177. # to use in the source
  178. SET(CMAKE_EXTRA_INCLUDE_FILES pthread.h)
  179. CHECK_TYPE_SIZE(pthread_t SIZEOF_PTHREAD_T)
  180. SET(CMAKE_EXTRA_INCLUDE_FILES)
  181. ENDIF()
  182. IF(SIZEOF_PTHREAD_T)
  183. ADD_DEFINITIONS(-DSIZEOF_PTHREAD_T=${SIZEOF_PTHREAD_T})
  184. ENDIF()
  185. IF(MSVC)
  186. ADD_DEFINITIONS(-DHAVE_WINDOWS_ATOMICS)
  187. ENDIF()
  188. # Include directories under innobase
  189. INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/innobase/include
  190. ${CMAKE_SOURCE_DIR}/storage/innobase/handler)
  191. # Sun Studio bug with -xO2
  192. IF(CMAKE_C_COMPILER_ID MATCHES "SunPro"
  193. AND CMAKE_C_FLAGS_RELEASE MATCHES "O2"
  194. AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
  195. # Sun Studio 12 crashes with -xO2 flag, but not with higher optimization
  196. # -xO3
  197. SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/rem/rem0rec.c
  198. PROPERTIES COMPILE_FLAGS -xO3)
  199. ENDIF()
  200. # Removing compiler optimizations for innodb/mem/* files on 64-bit Windows
  201. # due to 64-bit compiler error, See MySQL Bug #19424, #36366, #34297
  202. IF (MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8)
  203. SET_SOURCE_FILES_PROPERTIES(mem/mem0mem.c mem/mem0pool.c
  204. PROPERTIES COMPILE_FLAGS -Od)
  205. ENDIF()
  206. SET(INNOBASE_SOURCES btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c
  207. buf/buf0buddy.c buf/buf0buf.c buf/buf0flu.c buf/buf0lru.c buf/buf0rea.c
  208. data/data0data.c data/data0type.c
  209. dict/dict0boot.c dict/dict0crea.c dict/dict0dict.c dict/dict0load.c dict/dict0mem.c
  210. dyn/dyn0dyn.c
  211. eval/eval0eval.c eval/eval0proc.c
  212. fil/fil0fil.c
  213. fsp/fsp0fsp.c
  214. fut/fut0fut.c fut/fut0lst.c
  215. ha/ha0ha.c ha/hash0hash.c ha/ha0storage.c
  216. ibuf/ibuf0ibuf.c
  217. pars/lexyy.c pars/pars0grm.c pars/pars0opt.c pars/pars0pars.c pars/pars0sym.c
  218. lock/lock0lock.c lock/lock0iter.c
  219. log/log0log.c log/log0recv.c log/log0online.c
  220. mach/mach0data.c
  221. mem/mem0mem.c mem/mem0pool.c
  222. mtr/mtr0log.c mtr/mtr0mtr.c
  223. os/os0file.c os/os0proc.c os/os0sync.c os/os0thread.c
  224. page/page0cur.c page/page0page.c page/page0zip.c
  225. que/que0que.c
  226. handler/ha_innodb.cc handler/handler0alter.cc handler/i_s.cc
  227. read/read0read.c
  228. rem/rem0cmp.c rem/rem0rec.c
  229. row/row0ext.c row/row0ins.c row/row0merge.c row/row0mysql.c row/row0purge.c row/row0row.c
  230. row/row0sel.c row/row0uins.c row/row0umod.c row/row0undo.c row/row0upd.c row/row0vers.c
  231. srv/srv0srv.c srv/srv0start.c
  232. sync/sync0arr.c sync/sync0rw.c sync/sync0sync.c
  233. trx/trx0i_s.c trx/trx0purge.c trx/trx0rec.c trx/trx0roll.c trx/trx0rseg.c
  234. trx/trx0sys.c trx/trx0trx.c trx/trx0undo.c
  235. usr/usr0sess.c
  236. ut/ut0byte.c ut/ut0dbg.c ut/ut0list.c ut/ut0mem.c ut/ut0rbt.c ut/ut0rnd.c
  237. ut/ut0ut.c ut/ut0vec.c ut/ut0wqueue.c ut/ut0bh.c)
  238. IF(WITH_INNODB)
  239. # Legacy option
  240. SET(WITH_INNOBASE_STORAGE_ENGINE TRUE)
  241. ENDIF()
  242. MYSQL_ADD_PLUGIN(innobase ${INNOBASE_SOURCES} STORAGE_ENGINE
  243. DEFAULT
  244. MODULE_OUTPUT_NAME ha_innodb
  245. LINK_LIBRARIES ${ZLIB_LIBRARY})