summaryrefslogtreecommitdiff
path: root/cmake
diff options
context:
space:
mode:
Diffstat (limited to 'cmake')
-rw-r--r--cmake/abi_check.cmake68
-rw-r--r--cmake/bison.cmake81
-rw-r--r--cmake/build_configurations/mysql_release.cmake237
-rw-r--r--cmake/cat.cmake28
-rw-r--r--cmake/character_sets.cmake61
-rw-r--r--cmake/check_minimal_version.cmake20
-rw-r--r--cmake/cmake_parse_arguments.cmake47
-rw-r--r--cmake/configurable_file_content.in17
-rw-r--r--cmake/configure.pl223
-rw-r--r--cmake/cpack_source_ignore_files.cmake55
-rw-r--r--cmake/create_initial_db.cmake.in83
-rw-r--r--cmake/do_abi_check.cmake83
-rw-r--r--cmake/dtrace.cmake187
-rw-r--r--cmake/dtrace_prelink.cmake84
-rw-r--r--cmake/info_bin.cmake30
-rw-r--r--cmake/info_macros.cmake.in132
-rw-r--r--cmake/info_src.cmake31
-rw-r--r--cmake/install_layout.cmake234
-rw-r--r--cmake/install_macros.cmake329
-rw-r--r--cmake/libutils.cmake302
-rw-r--r--cmake/maintainer.cmake54
-rw-r--r--cmake/make_dist.cmake.in183
-rw-r--r--cmake/merge_archives_unix.cmake.in63
-rw-r--r--cmake/mysql_add_executable.cmake56
-rw-r--r--cmake/mysql_version.cmake141
-rw-r--r--cmake/os/AIX.cmake33
-rw-r--r--cmake/os/Cygwin.cmake18
-rw-r--r--cmake/os/Darwin.cmake35
-rw-r--r--cmake/os/FreeBSD.cmake24
-rw-r--r--cmake/os/HP-UX.cmake48
-rw-r--r--cmake/os/Linux.cmake47
-rw-r--r--cmake/os/OS400.cmake18
-rw-r--r--cmake/os/SunOS.cmake95
-rw-r--r--cmake/os/Windows.cmake195
-rw-r--r--cmake/os/WindowsCache.cmake358
-rw-r--r--cmake/package_name.cmake127
-rw-r--r--cmake/plugin.cmake237
-rw-r--r--cmake/readline.cmake230
-rw-r--r--cmake/ssl.cmake90
-rw-r--r--cmake/stack_direction.c33
-rw-r--r--cmake/tags.cmake26
-rw-r--r--cmake/versioninfo.rc.in38
-rw-r--r--cmake/zlib.cmake74
43 files changed, 4555 insertions, 0 deletions
diff --git a/cmake/abi_check.cmake b/cmake/abi_check.cmake
new file mode 100644
index 00000000000..9948f526b7a
--- /dev/null
+++ b/cmake/abi_check.cmake
@@ -0,0 +1,68 @@
+# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+#
+# Headers which need to be checked for abi/api compatibility are in
+# API_PREPROCESSOR_HEADER. plugin.h is tested implicitly via
+# plugin_audit.h and plugin_ftparser.h.
+#
+# We use gcc specific preprocessing command and sed/diff, so it will
+# only be run on Unix and only if gcc is used. On some Unixes,
+# (Solaris) sed or diff might act differently from GNU, so we run only
+# on systems we can trust.
+IF(APPLE OR CMAKE_SYSTEM_NAME MATCHES "Linux")
+ SET(RUN_ABI_CHECK 1)
+ELSE()
+ SET(RUN_ABI_CHECK 0)
+ENDIF()
+
+IF(CMAKE_COMPILER_IS_GNUCC AND RUN_ABI_CHECK)
+ IF(CMAKE_C_COMPILER MATCHES "ccache$")
+ SET(COMPILER ${CMAKE_C_COMPILER_ARG1})
+ STRING(REGEX REPLACE "^ " "" COMPILER ${COMPILER})
+ ELSE()
+ SET(COMPILER ${CMAKE_C_COMPILER})
+ ENDIF()
+ SET(API_PREPROCESSOR_HEADER
+ ${CMAKE_SOURCE_DIR}/include/mysql/plugin_audit.h
+ ${CMAKE_SOURCE_DIR}/include/mysql/plugin_ftparser.h
+ ${CMAKE_SOURCE_DIR}/include/mysql.h
+ ${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_v1.h
+ ${CMAKE_SOURCE_DIR}/include/mysql/psi/psi_abi_v2.h
+ ${CMAKE_SOURCE_DIR}/include/mysql/client_plugin.h
+ ${CMAKE_SOURCE_DIR}/include/mysql/plugin_auth.h
+ )
+
+ ADD_CUSTOM_TARGET(abi_check ALL
+ COMMAND ${CMAKE_COMMAND}
+ -DCOMPILER=${COMPILER}
+ -DSOURCE_DIR=${CMAKE_SOURCE_DIR}
+ -DBINARY_DIR=${CMAKE_BINARY_DIR}
+ "-DABI_HEADERS=${API_PREPROCESSOR_HEADER}"
+ -P ${CMAKE_SOURCE_DIR}/cmake/do_abi_check.cmake
+ VERBATIM
+ )
+
+ ADD_CUSTOM_TARGET(abi_check_all
+ COMMAND ${CMAKE_COMMAND}
+ -DCOMPILER=${COMPILER}
+ -DSOURCE_DIR=${CMAKE_SOURCE_DIR}
+ -DBINARY_DIR=${CMAKE_BINARY_DIR}
+ "-DABI_HEADERS=${API_PREPROCESSOR_HEADER}"
+ -P ${CMAKE_SOURCE_DIR}/cmake/do_abi_check.cmake
+ VERBATIM
+ )
+ENDIF()
+
diff --git a/cmake/bison.cmake b/cmake/bison.cmake
new file mode 100644
index 00000000000..d5c725fbbde
--- /dev/null
+++ b/cmake/bison.cmake
@@ -0,0 +1,81 @@
+# Copyright (c) 2009 Sun Microsystems, Inc.
+# Use is subject to license terms.
+#
+# 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
+
+IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
+ # On Solaris, /opt/csw often contains a newer bison
+ IF(NOT BISON_EXECUTABLE AND EXISTS /opt/csw/bin/bison)
+ SET(BISON_EXECUTABLE /opt/csw/bin/bison)
+ ENDIF()
+ENDIF()
+FIND_PROGRAM(BISON_EXECUTABLE bison DOC "path to the bison executable")
+MARK_AS_ADVANCED(BISON_EXECUTABLE "")
+IF(NOT BISON_EXECUTABLE)
+ MESSAGE("Warning: Bison executable not found in PATH")
+ELSEIF(BISON_EXECUTABLE AND NOT BISON_USABLE)
+ # Check version as well
+ EXEC_PROGRAM(${BISON_EXECUTABLE} ARGS --version OUTPUT_VARIABLE BISON_VERSION_STR)
+ # Get first line in case it's multiline
+ STRING(REGEX REPLACE "([^\n]+).*" "\\1" FIRST_LINE "${BISON_VERSION_STR}")
+ # get version information
+ STRING(REGEX REPLACE ".* ([0-9]+)\\.([0-9]+)" "\\1" BISON_VERSION_MAJOR "${FIRST_LINE}")
+ STRING(REGEX REPLACE ".* ([0-9]+)\\.([0-9]+)" "\\2" BISON_VERSION_MINOR "${FIRST_LINE}")
+ IF (BISON_VERSION_MAJOR LESS 2)
+ MESSAGE("Warning: bison version is old. please update to version 2")
+ ELSE()
+ SET(BISON_USABLE 1 CACHE INTERNAL "Bison version 2 or higher")
+ ENDIF()
+ENDIF()
+
+# Use bison to generate C++ and header file
+MACRO (RUN_BISON input_yy output_cc output_h)
+ IF(BISON_TOO_OLD)
+ IF(EXISTS ${output_cc} AND EXISTS ${output_h})
+ SET(BISON_USABLE FALSE)
+ ENDIF()
+ ENDIF()
+ IF(BISON_USABLE)
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${output_cc}
+ ${output_h}
+ COMMAND ${BISON_EXECUTABLE} -y -p MYSQL
+ --output=${output_cc}
+ --defines=${output_h}
+ ${input_yy}
+ DEPENDS ${input_yy}
+ )
+ ELSE()
+ # Bison is missing or not usable, e.g too old
+ IF(EXISTS ${output_cc} AND EXISTS ${output_h})
+ IF(${input_yy} IS_NEWER_THAN ${output_cc} OR ${input_yy} IS_NEWER_THAN ${output_h})
+ # Possibly timestamps are messed up in source distribution.
+ MESSAGE("Warning: no usable bison found, ${input_yy} will not be rebuilt.")
+ ENDIF()
+ ELSE()
+ # Output files are missing, bail out.
+ SET(ERRMSG
+ "Bison (GNU parser generator) is required to build MySQL."
+ "Please install bison."
+ )
+ IF(WIN32)
+ SET(ERRMSG ${ERRMSG}
+ "You can download bison from http://gnuwin32.sourceforge.net/packages/bison.htm "
+ "Choose 'Complete package, except sources' installation. We recommend to "
+ "install bison into a directory without spaces, e.g C:\\GnuWin32.")
+ ENDIF()
+ MESSAGE(FATAL_ERROR ${ERRMSG})
+ ENDIF()
+ ENDIF()
+ENDMACRO()
diff --git a/cmake/build_configurations/mysql_release.cmake b/cmake/build_configurations/mysql_release.cmake
new file mode 100644
index 00000000000..d780e9e2dd1
--- /dev/null
+++ b/cmake/build_configurations/mysql_release.cmake
@@ -0,0 +1,237 @@
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+# This file includes build settings used for MySQL release
+
+INCLUDE(CheckIncludeFiles)
+INCLUDE(CheckLibraryExists)
+INCLUDE(CheckTypeSize)
+
+# XXX package_name.cmake uses this too, move it somewhere global
+CHECK_TYPE_SIZE("void *" SIZEOF_VOIDP)
+IF(SIZEOF_VOIDP EQUAL 4)
+ SET(32BIT 1)
+ENDIF()
+IF(SIZEOF_VOIDP EQUAL 8)
+ SET(64BIT 1)
+ENDIF()
+
+SET(FEATURE_SET "community" CACHE STRING
+" Selection of features. Options are
+ - xsmall :
+ - small: embedded
+ - classic: embedded + archive + federated + blackhole
+ - large : embedded + archive + federated + blackhole + innodb
+ - xlarge: embedded + archive + federated + blackhole + innodb + partition
+ - community: all features (currently == xlarge)
+"
+)
+
+SET(FEATURE_SET_xsmall 1)
+SET(FEATURE_SET_small 2)
+SET(FEATURE_SET_classic 3)
+SET(FEATURE_SET_large 5)
+SET(FEATURE_SET_xlarge 6)
+SET(FEATURE_SET_community 7)
+
+IF(FEATURE_SET)
+ STRING(TOLOWER ${FEATURE_SET} feature_set)
+ SET(num ${FEATURE_SET_${feature_set}})
+ IF(NOT num)
+ MESSAGE(FATAL_ERROR "Invalid FEATURE_SET option '${feature_set}'.
+ Should be xsmall, small, classic, large, or community
+ ")
+ ENDIF()
+ SET(WITH_PARTITION_STORAGE_ENGINE OFF)
+ IF(num EQUAL FEATURE_SET_xsmall)
+ SET(WITH_NONE ON)
+ ENDIF()
+
+ IF(num GREATER FEATURE_SET_xsmall)
+ SET(WITH_EMBEDDED_SERVER ON CACHE BOOL "")
+ ENDIF()
+ IF(num GREATER FEATURE_SET_small)
+ SET(WITH_ARCHIVE_STORAGE_ENGINE ON)
+ SET(WITH_BLACKHOLE_STORAGE_ENGINE ON)
+ SET(WITH_FEDERATED_STORAGE_ENGINE ON)
+ ENDIF()
+ IF(num GREATER FEATURE_SET_classic)
+ SET(WITH_INNOBASE_STORAGE_ENGINE ON)
+ ENDIF()
+ IF(num GREATER FEATURE_SET_large)
+ SET(WITH_PARTITION_STORAGE_ENGINE ON)
+ ENDIF()
+ IF(num GREATER FEATURE_SET_xlarge)
+ # OPTION(WITH_ALL ON)
+ # better no set this, otherwise server would be linked
+ # statically with experimental stuff like audit_null
+ ENDIF()
+
+ # Update cache with current values, remove engines we do not care about
+ # from build.
+ FOREACH(eng ARCHIVE BLACKHOLE FEDERATED INNOBASE PARTITION EXAMPLE)
+ IF(NOT WITH_${eng}_STORAGE_ENGINE)
+ SET(WITHOUT_${eng}_STORAGE_ENGINE ON CACHE BOOL "")
+ MARK_AS_ADVANCED(WITHOUT_${eng}_STORAGE_ENGINE)
+ SET(WITH_${eng}_STORAGE_ENGINE OFF CACHE BOOL "")
+ ELSE()
+ SET(WITH_${eng}_STORAGE_ENGINE ON CACHE BOOL "")
+ ENDIF()
+ ENDFOREACH()
+ENDIF()
+
+OPTION(ENABLED_LOCAL_INFILE "" ON)
+SET(WITH_SSL bundled CACHE STRING "")
+SET(WITH_ZLIB bundled CACHE STRING "")
+
+IF(NOT COMPILATION_COMMENT)
+ SET(COMPILATION_COMMENT "MySQL Community Server (GPL)")
+ENDIF()
+
+IF(WIN32)
+ IF(NOT CMAKE_USING_VC_FREE_TOOLS)
+ # Sign executables with authenticode certificate
+ SET(SIGNCODE 1 CACHE BOOL "")
+ ENDIF()
+ENDIF()
+
+IF(UNIX)
+ SET(WITH_EXTRA_CHARSETS all CACHE STRING "")
+ IF(EXISTS "${CMAKE_SOURCE_DIR}/COPYING")
+ OPTION(WITH_READLINE "" ON)
+ ELSE()
+ OPTION(WITH_LIBEDIT "" ON)
+ ENDIF()
+
+ OPTION(WITH_PIC "" ON) # Why?
+
+ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ IF(NOT IGNORE_AIO_CHECK)
+ # Ensure aio is available on Linux (required by InnoDB)
+ CHECK_INCLUDE_FILES(libaio.h HAVE_LIBAIO_H)
+ CHECK_LIBRARY_EXISTS(aio io_queue_init "" HAVE_LIBAIO)
+ IF(NOT HAVE_LIBAIO_H OR NOT HAVE_LIBAIO)
+ MESSAGE(FATAL_ERROR "
+ aio is required on Linux, you need to install the required library:
+
+ Debian/Ubuntu: apt-get install libaio-dev
+ RedHat/Fedora/Oracle Linux: yum install libaio-devel
+ SuSE: zypper install libaio-devel
+
+ If you really do not want it, pass -DIGNORE_AIO_CHECK to cmake.
+ ")
+ ENDIF()
+ ENDIF()
+
+ # Enable fast mutexes on Linux
+ OPTION(WITH_FAST_MUTEXES "" ON)
+ ENDIF()
+
+ENDIF()
+
+# Compiler options
+IF(UNIX)
+
+ # Default GCC flags
+ IF(CMAKE_COMPILER_IS_GNUCC)
+ SET(COMMON_C_FLAGS "-g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing")
+ SET(CMAKE_C_FLAGS_DEBUG "-O ${COMMON_C_FLAGS}")
+ SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_C_FLAGS}")
+ ENDIF()
+ IF(CMAKE_COMPILER_IS_GNUCXX)
+ SET(COMMON_CXX_FLAGS "-g -static-libgcc -fno-omit-frame-pointer -fno-strict-aliasing")
+ SET(CMAKE_CXX_FLAGS_DEBUG "-O ${COMMON_CXX_FLAGS}")
+ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 ${COMMON_CXX_FLAGS}")
+ ENDIF()
+
+ # HPUX flags
+ IF(CMAKE_SYSTEM_NAME MATCHES "HP-UX")
+ IF(CMAKE_C_COMPILER_ID MATCHES "HP")
+ IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ia64")
+ SET(COMMON_C_FLAGS "+DSitanium2 -mt -AC99")
+ SET(COMMON_CXX_FLAGS "+DSitanium2 -mt -Aa")
+ SET(CMAKE_C_FLAGS_DEBUG "+O0 -g ${COMMON_C_FLAGS}")
+ SET(CMAKE_CXX_FLAGS_DEBUG "+O0 -g ${COMMON_CXX_FLAGS}")
+ # We have seen compiler bugs with optimisation and -g, so disabled for now
+ SET(CMAKE_C_FLAGS_RELWITHDEBINFO "+O2 ${COMMON_C_FLAGS}")
+ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "+O2 ${COMMON_CXX_FLAGS}")
+ ENDIF()
+ ENDIF()
+ SET(WITH_SSL no)
+ ENDIF()
+
+ # Linux flags
+ IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ IF(CMAKE_C_COMPILER_ID MATCHES "Intel")
+ SET(COMMON_C_FLAGS "-static-intel -static-libgcc -g -mp -restrict")
+ SET(COMMON_CXX_FLAGS "-static-intel -static-libgcc -g -mp -restrict -fno-exceptions -fno-rtti")
+ IF(CMAKE_SYSTEM_PROCESSOR MATCHES "ia64")
+ SET(COMMON_C_FLAGS "${COMMON_C_FLAGS} -no-ftz -no-prefetch")
+ SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -no-ftz -no-prefetch")
+ ENDIF()
+ SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}")
+ SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}")
+ SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -unroll2 -ip ${COMMON_C_FLAGS}")
+ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -unroll2 -ip ${COMMON_CXX_FLAGS}")
+ SET(WITH_SSL no)
+ ENDIF()
+ ENDIF()
+
+ # OSX flags
+ IF(APPLE)
+ SET(COMMON_C_FLAGS "-g -fno-common -fno-strict-aliasing")
+ # XXX: why are we using -felide-constructors on OSX?
+ SET(COMMON_CXX_FLAGS "-g -fno-common -felide-constructors -fno-strict-aliasing")
+ SET(CMAKE_C_FLAGS_DEBUG "-O ${COMMON_C_FLAGS}")
+ SET(CMAKE_CXX_FLAGS_DEBUG "-O ${COMMON_CXX_FLAGS}")
+ SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-Os ${COMMON_C_FLAGS}")
+ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-Os ${COMMON_CXX_FLAGS}")
+ ENDIF()
+
+ # Solaris flags
+ IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
+ IF(CMAKE_SYSTEM_VERSION VERSION_GREATER "5.9")
+ # Link mysqld with mtmalloc on Solaris 10 and later
+ SET(WITH_MYSQLD_LDFLAGS "-lmtmalloc" CACHE STRING "")
+ ENDIF()
+ IF(CMAKE_C_COMPILER_ID MATCHES "SunPro")
+ IF(CMAKE_SYSTEM_PROCESSOR MATCHES "i386")
+ SET(COMMON_C_FLAGS "-g -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -xlibmil -xlibmopt -xtarget=generic")
+ SET(COMMON_CXX_FLAGS "-g0 -mt -fsimple=1 -ftrap=%none -nofstore -xbuiltin=%all -features=no%except -xlibmil -xlibmopt -xtarget=generic")
+ SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}")
+ SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}")
+ IF(32BIT)
+ SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-xO2 ${COMMON_C_FLAGS}")
+ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO2 ${COMMON_CXX_FLAGS}")
+ ELSEIF(64BIT)
+ SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_C_FLAGS}")
+ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_CXX_FLAGS}")
+ ENDIF()
+ ELSE()
+ # Assume !x86 is SPARC
+ SET(COMMON_C_FLAGS "-g -Xa -xstrconst -mt")
+ SET(COMMON_CXX_FLAGS "-g0 -noex -mt")
+ IF(32BIT)
+ SET(COMMON_C_FLAGS "${COMMON_C_FLAGS} -xarch=sparc")
+ SET(COMMON_CXX_FLAGS "${COMMON_CXX_FLAGS} -xarch=sparc")
+ ENDIF()
+ SET(CMAKE_C_FLAGS_DEBUG "${COMMON_C_FLAGS}")
+ SET(CMAKE_CXX_FLAGS_DEBUG "${COMMON_CXX_FLAGS}")
+ SET(CMAKE_C_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_C_FLAGS}")
+ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-xO3 ${COMMON_CXX_FLAGS}")
+ ENDIF()
+ ENDIF()
+ ENDIF()
+ENDIF()
diff --git a/cmake/cat.cmake b/cmake/cat.cmake
new file mode 100644
index 00000000000..1ffe2ecfa1d
--- /dev/null
+++ b/cmake/cat.cmake
@@ -0,0 +1,28 @@
+# Copyright (c) 2009 Sun Microsystems, Inc.
+# Use is subject to license terms.
+#
+# 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
+
+# Concatenate files
+#
+# Parameters :
+# IN - input files (list)
+# OUT - output file
+FILE(WRITE ${OUT} "")
+FOREACH(FILENAME ${IN})
+ FILE(READ ${FILENAME} CONTENTS)
+ FILE(APPEND ${OUT} "${CONTENTS}")
+ENDFOREACH()
+
+
diff --git a/cmake/character_sets.cmake b/cmake/character_sets.cmake
new file mode 100644
index 00000000000..1cf63ed1462
--- /dev/null
+++ b/cmake/character_sets.cmake
@@ -0,0 +1,61 @@
+# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+# Charsets and collations
+IF(NOT DEFAULT_CHARSET)
+ SET(DEFAULT_CHARSET "latin1")
+ENDIF()
+
+IF(NOT DEFAULT_COLLATION)
+ SET(DEFAULT_COLLATION "latin1_swedish_ci")
+ENDIF()
+
+SET(CHARSETS ${DEFAULT_CHARSET} latin1 utf8 utf8mb4)
+SET(CHARSETS_COMPLEX
+ big5 cp1250 cp932 eucjpms euckr gb2312 gbk latin1 latin2
+ sjis tis620 ucs2 ujis utf8 utf8mb4 utf16 utf32)
+
+SET(CHARSETS_AVAILABLE
+binary armscii8 ascii big5 cp1250 cp1251 cp1256 cp1257
+cp850 cp852 cp866 cp932 dec8 eucjpms euckr gb2312 gbk geostd8
+greek hebrew hp8 keybcs2 koi8r koi8u
+latin1 latin2 latin5 latin7 macce macroman
+sjis swe7 tis620 ucs2 ujis utf8 utf8mb4 utf16 utf32)
+
+
+SET (EXTRA_CHARSETS "all")
+SET(WITH_EXTRA_CHARSETS ${EXTRA_CHARSETS} CACHE
+ STRING "Options are: none, complex, all")
+
+
+IF(WITH_EXTRA_CHARSETS MATCHES "complex")
+ SET(CHARSETS ${CHARSETS} ${CHARSETS_COMPLEX})
+ELSEIF(WITH_EXTRA_CHARSETS MATCHES "all")
+ SET(CHARSETS ${CHARSETS} ${CHARSETS_AVAILABLE})
+ENDIF()
+
+SET(MYSQL_DEFAULT_CHARSET_NAME "${DEFAULT_CHARSET}")
+SET(MYSQL_DEFAULT_COLLATION_NAME "${DEFAULT_COLLATION}")
+
+FOREACH(cs in ${CHARSETS})
+ SET(HAVE_CHARSET_${cs} 1)
+ENDFOREACH()
+
+SET(HAVE_UCA_COLLATIONS 1)
+
+SET(HAVE_UTF8_GENERAL_CS 1)
+SET(USE_MB 1)
+SET(USE_MB_IDENT 1)
+
diff --git a/cmake/check_minimal_version.cmake b/cmake/check_minimal_version.cmake
new file mode 100644
index 00000000000..d96c6a93418
--- /dev/null
+++ b/cmake/check_minimal_version.cmake
@@ -0,0 +1,20 @@
+# Copyright (c) 2009 Sun Microsystems, Inc.
+# Use is subject to license terms.
+#
+# 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
+
+# This is a helper script is used to check for the minimal required version
+# It helps to decide whether to use autoconf based configure or cmake's
+# configure
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
diff --git a/cmake/cmake_parse_arguments.cmake b/cmake/cmake_parse_arguments.cmake
new file mode 100644
index 00000000000..487fe2bacd9
--- /dev/null
+++ b/cmake/cmake_parse_arguments.cmake
@@ -0,0 +1,47 @@
+
+# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+# Handy macro to parse macro arguments
+MACRO(MYSQL_PARSE_ARGUMENTS prefix arg_names option_names)
+ SET(DEFAULT_ARGS)
+ FOREACH(arg_name ${arg_names})
+ SET(${prefix}_${arg_name})
+ ENDFOREACH(arg_name)
+ FOREACH(option ${option_names})
+ SET(${prefix}_${option} FALSE)
+ ENDFOREACH(option)
+
+ SET(current_arg_name DEFAULT_ARGS)
+ SET(current_arg_list)
+ FOREACH(arg ${ARGN})
+ SET(larg_names ${arg_names})
+ LIST(FIND larg_names "${arg}" is_arg_name)
+ IF (is_arg_name GREATER -1)
+ SET(${prefix}_${current_arg_name} ${current_arg_list})
+ SET(current_arg_name ${arg})
+ SET(current_arg_list)
+ ELSE (is_arg_name GREATER -1)
+ SET(loption_names ${option_names})
+ LIST(FIND loption_names "${arg}" is_option)
+ IF (is_option GREATER -1)
+ SET(${prefix}_${arg} TRUE)
+ ELSE (is_option GREATER -1)
+ SET(current_arg_list ${current_arg_list} ${arg})
+ ENDIF (is_option GREATER -1)
+ ENDIF (is_arg_name GREATER -1)
+ ENDFOREACH(arg)
+ SET(${prefix}_${current_arg_name} ${current_arg_list})
+ENDMACRO() \ No newline at end of file
diff --git a/cmake/configurable_file_content.in b/cmake/configurable_file_content.in
new file mode 100644
index 00000000000..ac26b8c0b11
--- /dev/null
+++ b/cmake/configurable_file_content.in
@@ -0,0 +1,17 @@
+# Copyright (c) 2009 Sun Microsystems, Inc.
+# Use is subject to license terms.
+#
+# 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
+
+@CMAKE_CONFIGURABLE_FILE_CONTENT@
diff --git a/cmake/configure.pl b/cmake/configure.pl
new file mode 100644
index 00000000000..565de571452
--- /dev/null
+++ b/cmake/configure.pl
@@ -0,0 +1,223 @@
+#!/usr/bin/perl
+
+# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+use strict;
+use Cwd 'abs_path';
+use File::Basename;
+
+my $cmakeargs = "";
+
+# Find source root directory
+# Assume this script is in <srcroot>/cmake
+my $srcdir = dirname(dirname(abs_path($0)));
+my $cmake_install_prefix="";
+
+# Sets installation directory, bindir, libdir, libexecdir etc
+# the equivalent CMake variables are given without prefix
+# e.g if --prefix is /usr and --bindir is /usr/bin
+# then cmake variable (INSTALL_BINDIR) must be just "bin"
+
+sub set_installdir
+{
+ my($path, $varname) = @_;
+ my $prefix_length = length($cmake_install_prefix);
+ if (($prefix_length > 0) && (index($path,$cmake_install_prefix) == 0))
+ {
+ # path is under the prefix, so remove the prefix and maybe following "/"
+ $path = substr($path, $prefix_length);
+ if(length($path) > 0)
+ {
+ my $char = substr($path, 0, 1);
+ if($char eq "/")
+ {
+ $path= substr($path, 1);
+ }
+ }
+ if(length($path) > 0)
+ {
+ $cmakeargs = $cmakeargs." -D".$varname."=".$path;
+ }
+ }
+}
+
+# CMake understands CC and CXX env.variables correctly, if they contain 1 or 2 tokens
+# e.g CXX=gcc and CXX="ccache gcc" are ok. However it could have a problem if there
+# (recognizing gcc) with more tokens ,e.g CXX="ccache gcc --pipe".
+# The problem is simply fixed by splitting compiler and flags, e.g
+# CXX="ccache gcc --pipe" => CXX=ccache gcc CXXFLAGS=--pipe
+
+sub check_compiler
+{
+ my ($varname, $flagsvarname) = @_;
+ my @tokens = split(/ /,$ENV{$varname});
+ if($#tokens >= 2)
+ {
+ $ENV{$varname} = $tokens[0]." ".$tokens[1];
+ my $flags;
+
+ for(my $i=2; $i<=$#tokens; $i++)
+ {
+ $flags= $flags." ".$tokens[$i];
+ }
+ if(defined $ENV{$flagsvarname})
+ {
+ $flags = $flags." ".$ENV{$flagsvarname};
+ }
+ $ENV{$flagsvarname}=$flags;
+ print("$varname=$ENV{$varname}\n");
+ print("$flagsvarname=$ENV{$flagsvarname}\n");
+ }
+}
+
+check_compiler("CC", "CFLAGS");
+check_compiler("CXX", "CXXFLAGS");
+
+foreach my $option (@ARGV)
+{
+ if (substr ($option, 0, 2) eq "--")
+ {
+ $option = substr($option, 2);
+ }
+ else
+ {
+ # This must be environment variable
+ my @v = split('=', $option);
+ my $name = shift(@v);
+ if(@v)
+ {
+ $ENV{$name} = join('=', @v);
+ }
+ next;
+ }
+ if($option =~ /srcdir/)
+ {
+ $srcdir = substr($option,7);
+ next;
+ }
+ if($option =~ /help/)
+ {
+ system("cmake ${srcdir} -LH");
+ exit(0);
+ }
+ if($option =~ /with-plugins=/)
+ {
+ my @plugins= split(/,/, substr($option,13));
+ foreach my $p (@plugins)
+ {
+ $p =~ s/-/_/g;
+ $cmakeargs = $cmakeargs." -DWITH_".uc($p)."=1";
+ }
+ next;
+ }
+ if($option =~ /with-extra-charsets=/)
+ {
+ my $charsets= substr($option,20);
+ $cmakeargs = $cmakeargs." -DWITH_EXTRA_CHARSETS=".$charsets;
+ next;
+ }
+ if($option =~ /without-plugin=/)
+ {
+ $cmakeargs = $cmakeargs." -DWITHOUT_".uc(substr($option,15))."=1";
+ next;
+ }
+ if($option =~ /with-zlib-dir=bundled/)
+ {
+ $cmakeargs = $cmakeargs." -DWITH_ZLIB=bundled";
+ next;
+ }
+ if($option =~ /with-zlib-dir=/)
+ {
+ $cmakeargs = $cmakeargs." -DWITH_ZLIB=system";
+ next;
+ }
+ if($option =~ /with-ssl=/)
+ {
+ $cmakeargs = $cmakeargs." -DWITH_SSL=yes";
+ next;
+ }
+ if($option =~ /with-ssl/)
+ {
+ $cmakeargs = $cmakeargs." -DWITH_SSL=bundled";
+ next;
+ }
+ if($option =~ /prefix=/)
+ {
+ $cmake_install_prefix= substr($option, 7);
+ $cmakeargs = $cmakeargs." -DCMAKE_INSTALL_PREFIX=".$cmake_install_prefix;
+ next;
+ }
+ if($option =~/bindir=/)
+ {
+ set_installdir(substr($option,7), "INSTALL_BINDIR");
+ next;
+ }
+ if($option =~/libdir=/)
+ {
+ set_installdir(substr($option,7), "INSTALL_LIBDIR");
+ next;
+ }
+ if($option =~/libexecdir=/)
+ {
+ set_installdir(substr($option,11), "INSTALL_SBINDIR");
+ next;
+ }
+ if($option =~/includedir=/)
+ {
+ set_installdir(substr($option,11), "INSTALL_INCLUDEDIR");
+ next;
+ }
+ if ($option =~ /extra-charsets=all/)
+ {
+ $cmakeargs = $cmakeargs." -DWITH_CHARSETS=all";
+ next;
+ }
+ if ($option =~ /extra-charsets=complex/)
+ {
+ $cmakeargs = $cmakeargs." -DWITH_CHARSETS=complex";
+ next;
+ }
+ if ($option =~ /localstatedir=/)
+ {
+ $cmakeargs = $cmakeargs." -DMYSQL_DATADIR=".substr($option,14);
+ next;
+ }
+ if ($option =~ /mysql-maintainer-mode/)
+ {
+ $cmakeargs = $cmakeargs." -DMYSQL_MAINTAINER_MODE=" .
+ ($option =~ /enable/ ? "1" : "0");
+ next;
+ }
+ if ($option =~ /with-comment=/)
+ {
+ $cmakeargs = $cmakeargs." \"-DWITH_COMMENT=".substr($option,13)."\"";
+ next;
+ }
+ if ($option =~ /with-gcov/)
+ {
+ $cmakeargs = $cmakeargs." -DENABLE_GCOV=ON";
+ next;
+ }
+
+ $option = uc($option);
+ $option =~ s/-/_/g;
+ $cmakeargs = $cmakeargs." -D".$option."=1";
+}
+
+print("configure.pl : calling cmake $srcdir $cmakeargs\n");
+unlink("CMakeCache.txt");
+my $rc = system("cmake $srcdir $cmakeargs");
+exit($rc);
diff --git a/cmake/cpack_source_ignore_files.cmake b/cmake/cpack_source_ignore_files.cmake
new file mode 100644
index 00000000000..5db383ae73f
--- /dev/null
+++ b/cmake/cpack_source_ignore_files.cmake
@@ -0,0 +1,55 @@
+# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+SET(CPACK_SOURCE_IGNORE_FILES
+\\\\.bzr/
+\\\\.bzr-mysql
+\\\\.bzrignore
+CMakeCache\\\\.txt
+cmake_dist\\\\.cmake
+CPackSourceConfig\\\\.cmake
+CPackConfig.cmake
+/cmake_install\\\\.cmake
+/CTestTestfile\\\\.cmake
+/CMakeFiles/
+/version_resources/
+/_CPack_Packages/
+$\\\\.gz
+$\\\\.zip
+/CMakeFiles/
+/version_resources/
+/_CPack_Packages/
+scripts/make_binary_distribution$
+scripts/msql2mysql$
+scripts/mysql_config$
+scripts/mysql_convert_table_format$
+scripts/mysql_find_rows$
+scripts/mysql_fix_extensions$
+scripts/mysql_install_db$
+scripts/mysql_secure_installation$
+scripts/mysql_setpermission$
+scripts/mysql_zap$
+scripts/mysqlaccess$
+scripts/mysqld_multi$
+scripts/mysqld_safe$
+scripts/mysqldumpslow$
+scripts/mysqlhotcopy$
+Makefile$
+include/config\\\\.h$
+include/my_config\\\\.h$
+/autom4te\\\\.cache/
+errmsg\\\\.sys$
+#
+)
diff --git a/cmake/create_initial_db.cmake.in b/cmake/create_initial_db.cmake.in
new file mode 100644
index 00000000000..e37f41255e0
--- /dev/null
+++ b/cmake/create_initial_db.cmake.in
@@ -0,0 +1,83 @@
+# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+# This script creates initial database for packaging on Windows
+SET(CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@")
+SET(CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@")
+SET(MYSQLD_EXECUTABLE "@MYSQLD_EXECUTABLE@")
+SET(CMAKE_CFG_INTDIR "@CMAKE_CFG_INTDIR@")
+SET(WIN32 "@WIN32@")
+# Force Visual Studio to output to stdout
+IF(ENV{VS_UNICODE_OUTPUT})
+ SET ($ENV{VS_UNICODE_OUTPUT})
+ENDIF()
+IF(CMAKE_CFG_INTDIR AND CONFIG)
+ #Resolve build configuration variables
+ STRING(REPLACE "${CMAKE_CFG_INTDIR}" ${CONFIG} MYSQLD_EXECUTABLE
+ "${MYSQLD_EXECUTABLE}")
+ENDIF()
+
+# Create bootstrapper SQL script
+FILE(WRITE bootstrap.sql "use mysql;\n" )
+FOREACH(FILENAME mysql_system_tables.sql mysql_system_tables_data.sql)
+ FILE(STRINGS ${CMAKE_SOURCE_DIR}/scripts/${FILENAME} CONTENTS)
+ FOREACH(STR ${CONTENTS})
+ IF(NOT STR MATCHES "@current_hostname")
+ FILE(APPEND bootstrap.sql "${STR}\n")
+ ENDIF()
+ ENDFOREACH()
+ENDFOREACH()
+FILE(READ ${CMAKE_SOURCE_DIR}/scripts/fill_help_tables.sql CONTENTS)
+FILE(APPEND bootstrap.sql ${CONTENTS})
+
+
+FILE(REMOVE_RECURSE mysql)
+MAKE_DIRECTORY(mysql)
+IF(WIN32)
+ SET(CONSOLE --console)
+ENDIF()
+
+SET(BOOTSTRAP_COMMAND
+ ${MYSQLD_EXECUTABLE}
+ --no-defaults
+ ${CONSOLE}
+ --bootstrap
+ --lc-messages-dir=${CMAKE_CURRENT_BINARY_DIR}/share
+ --basedir=.
+ --datadir=.
+ --default-storage-engine=MyISAM
+ --loose-skip-innodb
+ --loose-skip-ndbcluster
+ --max_allowed_packet=8M
+ --net_buffer_length=16K
+)
+
+GET_FILENAME_COMPONENT(CWD . ABSOLUTE)
+EXECUTE_PROCESS(
+ COMMAND "@CMAKE_COMMAND@" -E echo Executing ${BOOTSTRAP_COMMAND}
+)
+EXECUTE_PROCESS (
+ COMMAND "@CMAKE_COMMAND@" -E echo input file bootstrap.sql, current directory ${CWD}
+)
+EXECUTE_PROCESS (
+ COMMAND ${BOOTSTRAP_COMMAND} INPUT_FILE bootstrap.sql OUTPUT_VARIABLE OUT
+ ERROR_VARIABLE ERR
+ RESULT_VARIABLE RESULT
+ )
+
+IF(NOT RESULT EQUAL 0)
+ MESSAGE(FATAL_ERROR "Could not create initial database \n ${OUT} \n ${ERR}")
+ENDIF()
+
diff --git a/cmake/do_abi_check.cmake b/cmake/do_abi_check.cmake
new file mode 100644
index 00000000000..e42f11abde2
--- /dev/null
+++ b/cmake/do_abi_check.cmake
@@ -0,0 +1,83 @@
+# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+#
+# Rules for checking that the abi/api has not changed.
+#
+# The following steps are followed in the do_abi_check rule below
+#
+# 1) Generate preprocessor output for the files that need to
+# be tested for abi/api changes. use -nostdinc to prevent
+# generation of preprocessor output for system headers. This
+# results in messages in stderr saying that these headers
+# were not found. Redirect the stderr output to /dev/null
+# to prevent seeing these messages.
+# 2) sed the output to
+# 2.1) remove blank lines and lines that begin with "# "
+# 2.2) When gcc -E is run on the Mac OS and solaris sparc platforms it
+# introduces a line of output that shows up as a difference between
+# the .pp and .out files. Remove these OS specific preprocessor text
+# inserted by the preprocessor.
+# 3) diff the generated file and the canons (.pp files already in
+# the repository).
+# 4) delete the .out file that is generated.
+#
+# If the diff fails, the generated file is not removed. This will
+# be useful for analysis of ABI differences (e.g. using a visual
+# diff tool).
+#
+# A ABI change that causes a build to fail will always be accompanied
+# by new canons (.out files). The .out files that are not removed will
+# be replaced as the new .pp files.
+#
+# e.g. If include/mysql/plugin.h has an ABI change then this rule would
+# leave a <build directory>/abi_check.out file.
+#
+# A developer with a justified API change will then do a
+# mv <build directory>/abi_check.out include/mysql/plugin.pp
+# to replace the old canons with the new ones.
+#
+
+SET(abi_check_out ${BINARY_DIR}/abi_check.out)
+
+FOREACH(file ${ABI_HEADERS})
+ GET_FILENAME_COMPONENT(header_basename ${file} NAME)
+ SET(tmpfile ${BINARY_DIR}/${header_basename}.pp.tmp)
+
+ EXECUTE_PROCESS(
+ COMMAND ${COMPILER}
+ -E -nostdinc -dI -DMYSQL_ABI_CHECK -I${SOURCE_DIR}/include
+ -I${BINARY_DIR}/include -I${SOURCE_DIR}/include/mysql -I${SOURCE_DIR}/sql
+ ${file}
+ ERROR_QUIET OUTPUT_FILE ${tmpfile})
+ EXECUTE_PROCESS(
+ COMMAND sed -e "/^# /d"
+ -e "/^[ ]*$/d"
+ -e "/^#pragma GCC set_debug_pwd/d"
+ -e "/^#ident/d"
+ RESULT_VARIABLE result OUTPUT_FILE ${abi_check_out} INPUT_FILE ${tmpfile})
+ IF(NOT ${result} EQUAL 0)
+ MESSAGE(FATAL_ERROR "sed returned error ${result}")
+ ENDIF()
+ FILE(REMOVE ${tmpfile})
+ EXECUTE_PROCESS(
+ COMMAND diff -w ${file}.pp ${abi_check_out} RESULT_VARIABLE result)
+ IF(NOT ${result} EQUAL 0)
+ MESSAGE(FATAL_ERROR
+ "ABI check found difference between ${file}.pp and ${abi_check_out}")
+ ENDIF()
+ FILE(REMOVE ${abi_check_out})
+ENDFOREACH()
+
diff --git a/cmake/dtrace.cmake b/cmake/dtrace.cmake
new file mode 100644
index 00000000000..882ea0de6aa
--- /dev/null
+++ b/cmake/dtrace.cmake
@@ -0,0 +1,187 @@
+# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+IF(CMAKE_SYSTEM_NAME MATCHES "SunOS" AND CMAKE_COMPILER_IS_GNUCXX
+ AND CMAKE_SIZEOF_VOID_P EQUAL 4)
+ IF(NOT DEFINED BUGGY_GCC_NO_DTRACE_MODULES)
+ EXECUTE_PROCESS(
+ COMMAND ${CMAKE_C_COMPILER} ${CMAKE_C_COMPILER_ARG1} --version
+ OUTPUT_VARIABLE out)
+ IF(out MATCHES "3.4.6")
+ # This gcc causes crashes in dlopen() for dtraced shared libs,
+ # while standard shipped with Solaris10 3.4.3 is ok
+ SET(BUGGY_GCC_NO_DTRACE_MODULES 1 CACHE INTERNAL "")
+ ELSE()
+ SET(BUGGY_GCC_NO_DTRACE_MODULES 0 CACHE INTERNAL "")
+ ENDIF()
+ ENDIF()
+ENDIF()
+
+# Check if OS supports DTrace
+MACRO(CHECK_DTRACE)
+ FIND_PROGRAM(DTRACE dtrace)
+ MARK_AS_ADVANCED(DTRACE)
+
+ # On FreeBSD, dtrace does not handle userland tracing yet
+ IF(DTRACE AND NOT CMAKE_SYSTEM_NAME MATCHES "FreeBSD"
+ AND NOT BUGGY_GCC_NO_DTRACE_MODULES)
+ SET(ENABLE_DTRACE ON CACHE BOOL "Enable dtrace")
+ ENDIF()
+ SET(HAVE_DTRACE ${ENABLE_DTRACE})
+ IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
+ IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ SET(DTRACE_FLAGS -32 CACHE INTERNAL "DTrace architecture flags")
+ ELSE()
+ SET(DTRACE_FLAGS -64 CACHE INTERNAL "DTrace architecture flags")
+ ENDIF()
+ ENDIF()
+ENDMACRO()
+
+CHECK_DTRACE()
+
+# Produce a header file with
+# DTrace macros
+MACRO (DTRACE_HEADER provider header header_no_dtrace)
+ IF(ENABLE_DTRACE)
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${header} ${header_no_dtrace}
+ COMMAND ${DTRACE} -h -s ${provider} -o ${header}
+ COMMAND perl ${CMAKE_SOURCE_DIR}/scripts/dheadgen.pl -f ${provider} > ${header_no_dtrace}
+ DEPENDS ${provider}
+ )
+ ENDIF()
+ENDMACRO()
+
+
+# Create provider headers
+IF(ENABLE_DTRACE)
+ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/probes_mysql.d.base
+ ${CMAKE_BINARY_DIR}/include/probes_mysql.d COPYONLY)
+ DTRACE_HEADER(
+ ${CMAKE_BINARY_DIR}/include/probes_mysql.d
+ ${CMAKE_BINARY_DIR}/include/probes_mysql_dtrace.h
+ ${CMAKE_BINARY_DIR}/include/probes_mysql_nodtrace.h
+ )
+ IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ # Systemtap object
+ EXECUTE_PROCESS(
+ COMMAND ${DTRACE} -G -s ${CMAKE_SOURCE_DIR}/include/probes_mysql.d.base
+ -o ${CMAKE_BINARY_DIR}/probes_mysql.o
+ )
+ ENDIF()
+ ADD_CUSTOM_TARGET(gen_dtrace_header
+ DEPENDS
+ ${CMAKE_BINARY_DIR}/include/probes_mysql.d
+ ${CMAKE_BINARY_DIR}/include/probes_mysql_dtrace.h
+ ${CMAKE_BINARY_DIR}/include/probes_mysql_nodtrace.h
+ )
+ENDIF()
+
+FUNCTION(DTRACE_INSTRUMENT target)
+ IF(BUGGY_GCC_NO_DTRACE_MODULES)
+ GET_TARGET_PROPERTY(target_type ${target} TYPE)
+ IF(target_type MATCHES "MODULE_LIBRARY")
+ RETURN()
+ ENDIF()
+ ENDIF()
+ IF(ENABLE_DTRACE)
+ ADD_DEPENDENCIES(${target} gen_dtrace_header)
+
+ IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ TARGET_LINK_LIBRARIES(${target} ${CMAKE_BINARY_DIR}/probes_mysql.o)
+ ENDIF()
+
+ # On Solaris, invoke dtrace -G to generate object file and
+ # link it together with target.
+ IF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
+ SET(objdir ${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${target}.dir)
+ SET(outfile ${objdir}/${target}_dtrace.o)
+ GET_TARGET_PROPERTY(target_type ${target} TYPE)
+ ADD_CUSTOM_COMMAND(
+ TARGET ${target} PRE_LINK
+ COMMAND ${CMAKE_COMMAND}
+ -DDTRACE=${DTRACE}
+ -DOUTFILE=${outfile}
+ -DDFILE=${CMAKE_BINARY_DIR}/include/probes_mysql.d
+ -DDTRACE_FLAGS=${DTRACE_FLAGS}
+ -DDIRS=.
+ -DTYPE=${target_type}
+ -P ${CMAKE_SOURCE_DIR}/cmake/dtrace_prelink.cmake
+ WORKING_DIRECTORY ${objdir}
+ )
+ # Add full object path to linker flags
+ GET_TARGET_PROPERTY(target_type ${target} TYPE)
+ IF(NOT target_type MATCHES "STATIC")
+ SET_TARGET_PROPERTIES(${target} PROPERTIES LINK_FLAGS "${outfile}")
+ ELSE()
+ # For static library flags, add the object to the library.
+ # Note: DTrace probes in static libraries are unusable currently
+ # (see explanation for DTRACE_INSTRUMENT_STATIC_LIBS below)
+ # but maybe one day this will be fixed.
+ GET_TARGET_PROPERTY(target_location ${target} LOCATION)
+ ADD_CUSTOM_COMMAND(
+ TARGET ${target} POST_BUILD
+ COMMAND ${CMAKE_AR} r ${target_location} ${outfile}
+ COMMAND ${CMAKE_RANLIB} ${target_location}
+ )
+ # Used in DTRACE_INSTRUMENT_WITH_STATIC_LIBS
+ SET(TARGET_OBJECT_DIRECTORY_${target} ${objdir} CACHE INTERNAL "")
+ ENDIF()
+ ENDIF()
+ ENDIF()
+ENDFUNCTION()
+
+
+# Ugly workaround for Solaris' DTrace inability to use probes
+# from static libraries, discussed e.g in this thread
+# (http://opensolaris.org/jive/thread.jspa?messageID=432454)
+# We have to collect all object files that may be instrumented
+# and go into the mysqld (also those that come from in static libs)
+# run them again through dtrace -G to generate an ELF file that links
+# to mysqld.
+MACRO (DTRACE_INSTRUMENT_STATIC_LIBS target libs)
+IF(CMAKE_SYSTEM_NAME MATCHES "SunOS" AND ENABLE_DTRACE)
+ # Filter out non-static libraries in the list, if any
+ SET(static_libs)
+ FOREACH(lib ${libs})
+ GET_TARGET_PROPERTY(libtype ${lib} TYPE)
+ IF(libtype MATCHES STATIC_LIBRARY)
+ SET(static_libs ${static_lics} ${lib})
+ ENDIF()
+ ENDFOREACH()
+
+ FOREACH(lib ${static_libs})
+ SET(dirs ${dirs} ${TARGET_OBJECT_DIRECTORY_${lib}})
+ ENDFOREACH()
+
+ SET (obj ${CMAKE_CURRENT_BINARY_DIR}/${target}_dtrace_all.o)
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${obj}
+ DEPENDS ${static_libs}
+ COMMAND ${CMAKE_COMMAND}
+ -DDTRACE=${DTRACE}
+ -DOUTFILE=${obj}
+ -DDFILE=${CMAKE_BINARY_DIR}/include/probes_mysql.d
+ -DDTRACE_FLAGS=${DTRACE_FLAGS}
+ "-DDIRS=${dirs}"
+ -DTYPE=MERGE
+ -P ${CMAKE_SOURCE_DIR}/cmake/dtrace_prelink.cmake
+ VERBATIM
+ )
+ ADD_CUSTOM_TARGET(${target}_dtrace_all DEPENDS ${obj})
+ ADD_DEPENDENCIES(${target} ${target}_dtrace_all)
+ TARGET_LINK_LIBRARIES(${target} ${obj})
+ENDIF()
+ENDMACRO()
diff --git a/cmake/dtrace_prelink.cmake b/cmake/dtrace_prelink.cmake
new file mode 100644
index 00000000000..0efc2bb64bb
--- /dev/null
+++ b/cmake/dtrace_prelink.cmake
@@ -0,0 +1,84 @@
+# Copyright (c) 2009 Sun Microsystems, Inc.
+# Use is subject to license terms.
+#
+# 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
+
+# Generates an ELF object file with dtrace entry points.
+# This object that must to be linked with together with
+# the target. This script needs to run on Solaris only
+
+# Do not follow symlinks in GLOB_RECURSE
+CMAKE_POLICY(SET CMP0009 NEW)
+FILE(REMOVE ${OUTFILE})
+
+MACRO(CONVERT_TO_RELATIVE_PATHS files rel_paths)
+ GET_FILENAME_COMPONENT(abs_dir . ABSOLUTE)
+ SET(${rel_paths})
+ FOREACH(file ${files})
+ FILE(RELATIVE_PATH rel ${abs_dir} ${file})
+ LIST(APPEND ${rel_paths} ${rel})
+ ENDFOREACH()
+ENDMACRO()
+
+IF(TYPE STREQUAL "MERGE")
+ # Rerun dtrace on objects that are already in static libraries.
+ # Object paths are stored in text files named 'dtrace_objects'
+ # in the input directores. We have to copy the objects into temp.
+ # directory, as running dtrace -G on original files will change
+ # timestamps and cause rebuilds or the libraries / excessive
+ # relink
+ FILE(REMOVE_RECURSE dtrace_objects_merge)
+ MAKE_DIRECTORY(dtrace_objects_merge)
+
+ FOREACH(dir ${DIRS})
+ FILE(STRINGS ${dir}/dtrace_objects OBJS)
+ FOREACH(obj ${OBJS})
+ IF(obj)
+ EXECUTE_PROCESS(COMMAND cp ${obj} dtrace_objects_merge)
+ ENDIF()
+ ENDFOREACH()
+ ENDFOREACH()
+ FILE(GLOB_RECURSE OBJECTS dtrace_objects_merge/*.o)
+ CONVERT_TO_RELATIVE_PATHS("${OBJECTS}" REL_OBJECTS)
+ EXECUTE_PROCESS(
+ COMMAND ${DTRACE} ${DTRACE_FLAGS} -o ${OUTFILE} -G -s ${DFILE} ${REL_OBJECTS}
+ )
+ RETURN()
+ENDIF()
+
+FOREACH(dir ${DIRS})
+ FILE(GLOB_RECURSE OBJECTS ${dir}/*.o)
+ CONVERT_TO_RELATIVE_PATHS("${OBJECTS}" REL)
+ LIST(APPEND REL_OBJECTS ${REL})
+ENDFOREACH()
+
+FILE(WRITE dtrace_timestamp "")
+EXECUTE_PROCESS(
+ COMMAND ${DTRACE} ${DTRACE_FLAGS} -o ${OUTFILE} -G -s ${DFILE} ${REL_OBJECTS}
+)
+
+# Save objects that contain dtrace probes in a file.
+# This file is used when script is called with -DTYPE=MERGE
+# to dtrace from static libs.
+# To find objects with probes, look at the timestamp, it was updated
+# by dtrace -G run
+IF(TYPE MATCHES "STATIC")
+ FILE(WRITE dtrace_objects "")
+ FOREACH(obj ${REL_OBJECTS})
+ IF(${obj} IS_NEWER_THAN dtrace_timestamp)
+ GET_FILENAME_COMPONENT(obj_absolute_path ${obj} ABSOLUTE)
+ FILE(APPEND dtrace_objects "${obj_absolute_path}\n" )
+ ENDIF()
+ ENDFOREACH()
+ENDIF()
diff --git a/cmake/info_bin.cmake b/cmake/info_bin.cmake
new file mode 100644
index 00000000000..9cec3de0e0f
--- /dev/null
+++ b/cmake/info_bin.cmake
@@ -0,0 +1,30 @@
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+
+# The sole purpose of this cmake control file is to create the "INFO_BIN" file.
+
+# By having a separate cmake file for this, it is ensured this happens
+# only in the build (Unix: "make") phase, not when cmake runs.
+# This, in turn, avoids creating stuff in the source directory -
+# it should get into the binary directory only.
+
+
+# Get the macros which the "INFO_*" files.
+INCLUDE(${CMAKE_BINARY_DIR}/info_macros.cmake)
+
+# Here is where the action is.
+CREATE_INFO_BIN()
+
diff --git a/cmake/info_macros.cmake.in b/cmake/info_macros.cmake.in
new file mode 100644
index 00000000000..9e08cffb2bf
--- /dev/null
+++ b/cmake/info_macros.cmake.in
@@ -0,0 +1,132 @@
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+
+# Handle/create the "INFO_*" files describing a MySQL (server) binary.
+# This is part of the fix for bug#42969.
+
+
+# Several of cmake's variables need to be translated from '@' notation
+# to '${}', this is done by the "configure" call in top level "CMakeLists.txt".
+# If further variables are used in this file, add them to this list.
+
+SET(VERSION "@VERSION@")
+SET(CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@")
+SET(CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@")
+SET(CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+SET(CMAKE_SIZEOF_VOID_P "@CMAKE_SIZEOF_VOID_P@")
+SET(BZR_EXECUTABLE "@BZR_EXECUTABLE@")
+SET(CMAKE_CROSSCOMPILING "@CMAKE_CROSSCOMPILING@")
+SET(CMAKE_HOST_SYSTEM "@CMAKE_HOST_SYSTEM@")
+SET(CMAKE_HOST_SYSTEM_PROCESSOR "@CMAKE_HOST_SYSTEM_PROCESSOR@")
+SET(CMAKE_SYSTEM "@CMAKE_SYSTEM@")
+SET(CMAKE_SYSTEM_PROCESSOR "@CMAKE_SYSTEM_PROCESSOR@")
+
+
+# Create an "INFO_SRC" file with information about the source (only).
+# We use "bzr version-info", if possible, and the "VERSION" contents.
+#
+# Outside development (BZR tree), the "INFO_SRC" file will not be modified
+# provided it exists (from "make dist" or a source tarball creation).
+
+MACRO(CREATE_INFO_SRC target_dir)
+ SET(INFO_SRC "${target_dir}/INFO_SRC")
+
+ IF(EXISTS ${CMAKE_SOURCE_DIR}/.bzr)
+ # Sources are in a BZR repository: Always update.
+ EXECUTE_PROCESS(
+ COMMAND ${BZR_EXECUTABLE} version-info ${CMAKE_SOURCE_DIR}
+ OUTPUT_VARIABLE VERSION_INFO
+ RESULT_VARIABLE RESULT
+ )
+ FILE(WRITE ${INFO_SRC} "${VERSION_INFO}\n")
+ # to debug, add: FILE(APPEND ${INFO_SRC} "\nResult ${RESULT}\n")
+ # For better readability ...
+ FILE(APPEND ${INFO_SRC} "\nMySQL source ${VERSION}\n")
+ ELSEIF(EXISTS ${INFO_SRC})
+ # Outside a BZR tree, there is no need to change an existing "INFO_SRC",
+ # it cannot be improved.
+ ELSEIF(EXISTS ${CMAKE_SOURCE_DIR}/Docs/INFO_SRC)
+ # If we are building from a source distribution, it also contains "INFO_SRC".
+ # Similar, the export used for a release build already has the file.
+ FILE(READ ${CMAKE_SOURCE_DIR}/Docs/INFO_SRC SOURCE_INFO)
+ FILE(WRITE ${INFO_SRC} "${SOURCE_INFO}\n")
+ ELSEIF(EXISTS ${CMAKE_SOURCE_DIR}/INFO_SRC)
+ # This is not the proper location, but who knows ...
+ FILE(READ ${CMAKE_SOURCE_DIR}/INFO_SRC SOURCE_INFO)
+ FILE(WRITE ${INFO_SRC} "${SOURCE_INFO}\n")
+ ELSE()
+ # This is a fall-back.
+ FILE(WRITE ${INFO_SRC} "\nMySQL source ${VERSION}\n")
+ ENDIF()
+ENDMACRO(CREATE_INFO_SRC)
+
+
+# This is for the "real" build, must be run again with each cmake run
+# to make sure we report the current flags (not those of some previous run).
+
+MACRO(CREATE_INFO_BIN)
+ SET(INFO_BIN "Docs/INFO_BIN")
+
+ FILE(WRITE ${INFO_BIN} "===== Information about the build process: =====\n")
+ IF (WIN32)
+ EXECUTE_PROCESS(COMMAND cmd /c date /T OUTPUT_VARIABLE TMP_DATE)
+ ELSEIF(UNIX)
+ EXECUTE_PROCESS(COMMAND date "+%Y-%m-%d %H:%M:%S" OUTPUT_VARIABLE TMP_DATE OUTPUT_STRIP_TRAILING_WHITESPACE)
+ ELSE()
+ SET(TMP_DATE "(no date command known for this platform)")
+ ENDIF()
+ SITE_NAME(HOSTNAME)
+ FILE(APPEND ${INFO_BIN} "Build was run at ${TMP_DATE} on host '${HOSTNAME}'\n\n")
+
+ # According to the cmake docs, these variables should always be set.
+ # However, they are empty in my tests, using cmake 2.6.4 on Linux, various Unix, and Windows.
+ # Still, include this code, so we will profit if a build environment does provide that info.
+ IF(CMAKE_HOST_SYSTEM)
+ FILE(APPEND ${INFO_BIN} "Build was done on ${CMAKE_HOST_SYSTEM} using ${CMAKE_HOST_SYSTEM_PROCESSOR}\n")
+ ENDIF()
+ IF(CMAKE_CROSSCOMPILING)
+ FILE(APPEND ${INFO_BIN} "Build was done for ${CMAKE_SYSTEM} using ${CMAKE_SYSTEM_PROCESSOR}\n")
+ ENDIF()
+
+ # ${CMAKE_VERSION} doesn't work in 2.6.0, use the separate components.
+ FILE(APPEND ${INFO_BIN} "Build was done using cmake ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}.${CMAKE_PATCH_VERSION} \n\n")
+
+ IF (WIN32)
+ FILE(APPEND ${INFO_BIN} "===== Compiler / generator used: =====\n")
+ FILE(APPEND ${INFO_BIN} ${CMAKE_GENERATOR} "\n\n")
+ ELSEIF(UNIX)
+ FILE(APPEND ${INFO_BIN} "===== Compiler flags used (from the 'sql/' subdirectory): =====\n")
+ IF(EXISTS sql/CMakeFiles/sql.dir/flags.make)
+ EXECUTE_PROCESS(COMMAND egrep "^# compile|^C_|^CXX_" sql/CMakeFiles/sql.dir/flags.make OUTPUT_VARIABLE COMPILE_FLAGS)
+ FILE(APPEND ${INFO_BIN} ${COMPILE_FLAGS} "\n")
+ ELSE()
+ FILE(APPEND ${INFO_BIN} "File 'sql/CMakeFiles/sql.dir/flags.make' is not yet found.\n\n")
+ ENDIF()
+ ENDIF()
+ FILE(APPEND ${INFO_BIN} "Pointer size: ${CMAKE_SIZEOF_VOID_P}\n\n")
+
+ FILE(APPEND ${INFO_BIN} "===== Feature flags used: =====\n")
+ IF(EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt)
+ # Attention: "-N" prevents cmake from entering a recursion, and it must be a separate flag from "-L".
+ EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -N -L ${CMAKE_BINARY_DIR} OUTPUT_VARIABLE FEATURE_FLAGS)
+ FILE(APPEND ${INFO_BIN} ${FEATURE_FLAGS} "\n")
+ ELSE()
+ FILE(APPEND ${INFO_BIN} "File 'CMakeCache.txt' is not yet found.\n\n")
+ ENDIF()
+
+ FILE(APPEND ${INFO_BIN} "===== EOF =====\n")
+ENDMACRO(CREATE_INFO_BIN)
+
diff --git a/cmake/info_src.cmake b/cmake/info_src.cmake
new file mode 100644
index 00000000000..97776b70901
--- /dev/null
+++ b/cmake/info_src.cmake
@@ -0,0 +1,31 @@
+# Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+
+# The sole purpose of this cmake control file is to create the "INFO_SRC" file.
+
+# As long as and "bzr pull" (or "bzr commit") is followed by a "cmake",
+# the call in top level "CMakeLists.txt" is sufficient.
+# This file is to provide a separate target for the "make" phase,
+# to ensure the BZR revision-id is correct even after a sequence
+# cmake ; make ; bzr pull ; make
+
+
+# Get the macros which handle the "INFO_*" files.
+INCLUDE(${CMAKE_BINARY_DIR}/info_macros.cmake)
+
+# Here is where the action is.
+CREATE_INFO_SRC(${CMAKE_BINARY_DIR}/Docs)
+
diff --git a/cmake/install_layout.cmake b/cmake/install_layout.cmake
new file mode 100644
index 00000000000..9f9dc7dc9a3
--- /dev/null
+++ b/cmake/install_layout.cmake
@@ -0,0 +1,234 @@
+# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+# The purpose of this file is to set the default installation layout.
+#
+# The current choices of installation layout are:
+#
+# STANDALONE
+# Build with prefix=/usr/local/mysql, create tarball with install prefix="."
+# and relative links. Windows zip uses the same tarball layout but without
+# the build prefix.
+#
+# RPM
+# Build as per default RPM layout, with prefix=/usr
+#
+# DEB
+# Build as per STANDALONE, prefix=/opt/mysql/server-$major.$minor
+#
+# SVR4
+# Solaris package layout suitable for pkg* tools, prefix=/opt/mysql/mysql
+#
+# To force a directory layout, use -DINSTALL_LAYOUT=<layout>.
+#
+# The default is STANDALONE.
+#
+# There is the possibility to further fine-tune installation directories.
+# Several variables can be overwritten:
+#
+# - INSTALL_BINDIR (directory with client executables and scripts)
+# - INSTALL_SBINDIR (directory with mysqld)
+# - INSTALL_SCRIPTDIR (several scripts, rarely used)
+#
+# - INSTALL_LIBDIR (directory with client end embedded libraries)
+# - INSTALL_PLUGINDIR (directory for plugins)
+#
+# - INSTALL_INCLUDEDIR (directory for MySQL headers)
+#
+# - INSTALL_DOCDIR (documentation)
+# - INSTALL_DOCREADMEDIR (readme and similar)
+# - INSTALL_MANDIR (man pages)
+# - INSTALL_INFODIR (info pages)
+#
+# - INSTALL_SHAREDIR (location of aclocal/mysql.m4)
+# - INSTALL_MYSQLSHAREDIR (MySQL character sets and localized error messages)
+# - INSTALL_MYSQLTESTDIR (mysql-test)
+# - INSTALL_SQLBENCHDIR (sql-bench)
+# - INSTALL_SUPPORTFILESDIR (various extra support files)
+#
+# - INSTALL_MYSQLDATADIR (data directory)
+#
+# When changing this page, _please_ do not forget to update public Wiki
+# http://forge.mysql.com/wiki/CMake#Fine-tuning_installation_paths
+
+IF(NOT INSTALL_LAYOUT)
+ SET(DEFAULT_INSTALL_LAYOUT "STANDALONE")
+ENDIF()
+
+SET(INSTALL_LAYOUT "${DEFAULT_INSTALL_LAYOUT}"
+CACHE STRING "Installation directory layout. Options are: STANDALONE (as in zip or tar.gz installer), RPM, DEB, SVR4")
+
+IF(UNIX)
+ IF(INSTALL_LAYOUT MATCHES "RPM")
+ SET(default_prefix "/usr")
+ ELSEIF(INSTALL_LAYOUT MATCHES "DEB")
+ SET(default_prefix "/opt/mysql/server-${MYSQL_BASE_VERSION}")
+ # This is required to avoid "cpack -GDEB" default of prefix=/usr
+ SET(CPACK_SET_DESTDIR ON)
+ ELSEIF(INSTALL_LAYOUT MATCHES "SVR4")
+ SET(default_prefix "/opt/mysql/mysql")
+ ELSE()
+ SET(default_prefix "/usr/local/mysql")
+ ENDIF()
+ IF(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
+ SET(CMAKE_INSTALL_PREFIX ${default_prefix}
+ CACHE PATH "install prefix" FORCE)
+ ENDIF()
+ SET(VALID_INSTALL_LAYOUTS "RPM" "STANDALONE" "DEB" "SVR4")
+ LIST(FIND VALID_INSTALL_LAYOUTS "${INSTALL_LAYOUT}" ind)
+ IF(ind EQUAL -1)
+ MESSAGE(FATAL_ERROR "Invalid INSTALL_LAYOUT parameter:${INSTALL_LAYOUT}."
+ " Choose between ${VALID_INSTALL_LAYOUTS}" )
+ ENDIF()
+
+ SET(SYSCONFDIR "${CMAKE_INSTALL_PREFIX}/etc"
+ CACHE PATH "config directory (for my.cnf)")
+ MARK_AS_ADVANCED(SYSCONFDIR)
+ENDIF()
+
+#
+# plugin_tests's value should not be used by imported plugins,
+# just use if(INSTALL_PLUGINTESTDIR).
+# The plugin must set its own install path for tests
+#
+FILE(GLOB plugin_tests ${CMAKE_SOURCE_DIR}/plugin/*/tests)
+
+#
+# STANDALONE layout
+#
+SET(INSTALL_BINDIR_STANDALONE "bin")
+SET(INSTALL_SBINDIR_STANDALONE "bin")
+SET(INSTALL_SCRIPTDIR_STANDALONE "scripts")
+#
+SET(INSTALL_LIBDIR_STANDALONE "lib")
+SET(INSTALL_PLUGINDIR_STANDALONE "lib/plugin")
+#
+SET(INSTALL_INCLUDEDIR_STANDALONE "include")
+#
+SET(INSTALL_DOCDIR_STANDALONE "docs")
+SET(INSTALL_DOCREADMEDIR_STANDALONE ".")
+SET(INSTALL_MANDIR_STANDALONE "man")
+SET(INSTALL_INFODIR_STANDALONE "docs")
+#
+SET(INSTALL_SHAREDIR_STANDALONE "share")
+SET(INSTALL_MYSQLSHAREDIR_STANDALONE "share")
+SET(INSTALL_MYSQLTESTDIR_STANDALONE "mysql-test")
+SET(INSTALL_SQLBENCHDIR_STANDALONE ".")
+SET(INSTALL_SUPPORTFILESDIR_STANDALONE "support-files")
+#
+SET(INSTALL_MYSQLDATADIR_STANDALONE "data")
+SET(INSTALL_PLUGINTESTDIR_STANDALONE ${plugin_tests})
+
+#
+# RPM layout
+#
+SET(INSTALL_BINDIR_RPM "bin")
+SET(INSTALL_SBINDIR_RPM "sbin")
+SET(INSTALL_SCRIPTDIR_RPM "bin")
+#
+IF(CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
+ SET(INSTALL_LIBDIR_RPM "lib64")
+ SET(INSTALL_PLUGINDIR_RPM "lib64/mysql/plugin")
+ELSE()
+ SET(INSTALL_LIBDIR_RPM "lib")
+ SET(INSTALL_PLUGINDIR_RPM "lib/mysql/plugin")
+ENDIF()
+#
+SET(INSTALL_INCLUDEDIR_RPM "include/mysql")
+#
+#SET(INSTALL_DOCDIR_RPM unset - installed directly by RPM)
+#SET(INSTALL_DOCREADMEDIR_RPM unset - installed directly by RPM)
+SET(INSTALL_INFODIR_RPM "share/info")
+SET(INSTALL_MANDIR_RPM "share/man")
+#
+SET(INSTALL_SHAREDIR_RPM "share")
+SET(INSTALL_MYSQLSHAREDIR_RPM "share/mysql")
+SET(INSTALL_MYSQLTESTDIR_RPM "share/mysql-test")
+SET(INSTALL_SQLBENCHDIR_RPM "")
+SET(INSTALL_SUPPORTFILESDIR_RPM "share/mysql")
+#
+SET(INSTALL_MYSQLDATADIR_RPM "/var/lib/mysql")
+SET(INSTALL_PLUGINTESTDIR_RPM ${plugin_tests})
+
+#
+# DEB layout
+#
+SET(INSTALL_BINDIR_DEB "bin")
+SET(INSTALL_SBINDIR_DEB "bin")
+SET(INSTALL_SCRIPTDIR_DEB "scripts")
+#
+SET(INSTALL_LIBDIR_DEB "lib")
+SET(INSTALL_PLUGINDIR_DEB "lib/plugin")
+#
+SET(INSTALL_INCLUDEDIR_DEB "include")
+#
+SET(INSTALL_DOCDIR_DEB "docs")
+SET(INSTALL_DOCREADMEDIR_DEB ".")
+SET(INSTALL_MANDIR_DEB "man")
+SET(INSTALL_INFODIR_DEB "docs")
+#
+SET(INSTALL_SHAREDIR_DEB "share")
+SET(INSTALL_MYSQLSHAREDIR_DEB "share")
+SET(INSTALL_MYSQLTESTDIR_DEB "mysql-test")
+SET(INSTALL_SQLBENCHDIR_DEB ".")
+SET(INSTALL_SUPPORTFILESDIR_DEB "support-files")
+#
+SET(INSTALL_MYSQLDATADIR_DEB "data")
+SET(INSTALL_PLUGINTESTDIR_DEB ${plugin_tests})
+
+#
+# SVR4 layout
+#
+SET(INSTALL_BINDIR_SVR4 "bin")
+SET(INSTALL_SBINDIR_SVR4 "bin")
+SET(INSTALL_SCRIPTDIR_SVR4 "scripts")
+#
+SET(INSTALL_LIBDIR_SVR4 "lib")
+SET(INSTALL_PLUGINDIR_SVR4 "lib/plugin")
+#
+SET(INSTALL_INCLUDEDIR_SVR4 "include")
+#
+SET(INSTALL_DOCDIR_SVR4 "docs")
+SET(INSTALL_DOCREADMEDIR_SVR4 ".")
+SET(INSTALL_MANDIR_SVR4 "man")
+SET(INSTALL_INFODIR_SVR4 "docs")
+#
+SET(INSTALL_SHAREDIR_SVR4 "share")
+SET(INSTALL_MYSQLSHAREDIR_SVR4 "share")
+SET(INSTALL_MYSQLTESTDIR_SVR4 "mysql-test")
+SET(INSTALL_SQLBENCHDIR_SVR4 ".")
+SET(INSTALL_SUPPORTFILESDIR_SVR4 "support-files")
+#
+SET(INSTALL_MYSQLDATADIR_SVR4 "/var/lib/mysql")
+SET(INSTALL_PLUGINTESTDIR_SVR4 ${plugin_tests})
+
+
+# Clear cached variables if install layout was changed
+IF(OLD_INSTALL_LAYOUT)
+ IF(NOT OLD_INSTALL_LAYOUT STREQUAL INSTALL_LAYOUT)
+ SET(FORCE FORCE)
+ ENDIF()
+ENDIF()
+SET(OLD_INSTALL_LAYOUT ${INSTALL_LAYOUT} CACHE INTERNAL "")
+
+# Set INSTALL_FOODIR variables for chosen layout (for example, INSTALL_BINDIR
+# will be defined as ${INSTALL_BINDIR_STANDALONE} by default if STANDALONE
+# layout is chosen)
+FOREACH(var BIN SBIN LIB MYSQLSHARE SHARE PLUGIN INCLUDE SCRIPT DOC MAN
+ INFO MYSQLTEST SQLBENCH DOCREADME SUPPORTFILES MYSQLDATA PLUGINTEST)
+ SET(INSTALL_${var}DIR ${INSTALL_${var}DIR_${INSTALL_LAYOUT}}
+ CACHE STRING "${var} installation directory" ${FORCE})
+ MARK_AS_ADVANCED(INSTALL_${var}DIR)
+ENDFOREACH()
diff --git a/cmake/install_macros.cmake b/cmake/install_macros.cmake
new file mode 100644
index 00000000000..a8a84e48455
--- /dev/null
+++ b/cmake/install_macros.cmake
@@ -0,0 +1,329 @@
+# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
+INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake)
+MACRO (INSTALL_DEBUG_SYMBOLS targets)
+ IF(MSVC)
+ FOREACH(target ${targets})
+ GET_TARGET_PROPERTY(location ${target} LOCATION)
+ GET_TARGET_PROPERTY(type ${target} TYPE)
+ IF(NOT INSTALL_LOCATION)
+ IF(type MATCHES "STATIC_LIBRARY" OR type MATCHES "MODULE_LIBRARY" OR type MATCHES "SHARED_LIBRARY")
+ SET(INSTALL_LOCATION "lib")
+ ELSEIF(type MATCHES "EXECUTABLE")
+ SET(INSTALL_LOCATION "bin")
+ ELSE()
+ MESSAGE(FATAL_ERROR "cannot determine type of ${target}. Don't now where to install")
+ ENDIF()
+ ENDIF()
+ STRING(REPLACE ".exe" ".pdb" pdb_location ${location})
+ STRING(REPLACE ".dll" ".pdb" pdb_location ${pdb_location})
+ STRING(REPLACE ".lib" ".pdb" pdb_location ${pdb_location})
+ IF(CMAKE_GENERATOR MATCHES "Visual Studio")
+ STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CMAKE_INSTALL_CONFIG_NAME}" pdb_location ${pdb_location})
+ ENDIF()
+ IF(target STREQUAL "mysqld")
+ SET(comp Server)
+ ELSE()
+ SET(comp Debuginfo)
+ ENDIF()
+ INSTALL(FILES ${pdb_location} DESTINATION ${INSTALL_LOCATION} COMPONENT ${comp})
+ ENDFOREACH()
+ ENDIF()
+ENDMACRO()
+
+# Installs manpage for given file (either script or executable)
+#
+FUNCTION(INSTALL_MANPAGE file)
+ IF(NOT UNIX)
+ RETURN()
+ ENDIF()
+ GET_FILENAME_COMPONENT(file_name "${file}" NAME)
+ SET(GLOB_EXPR
+ ${CMAKE_SOURCE_DIR}/man/*${file}man.1*
+ ${CMAKE_SOURCE_DIR}/man/*${file}man.8*
+ ${CMAKE_BINARY_DIR}/man/*${file}man.1*
+ ${CMAKE_BINARY_DIR}/man/*${file}man.8*
+ )
+ IF(MYSQL_DOC_DIR)
+ SET(GLOB_EXPR
+ ${MYSQL_DOC_DIR}/man/*${file}man.1*
+ ${MYSQL_DOC_DIR}/man/*${file}man.8*
+ ${MYSQL_DOC_DIR}/man/*${file}.1*
+ ${MYSQL_DOC_DIR}/man/*${file}.8*
+ ${GLOB_EXPR}
+ )
+ ENDIF()
+
+ FILE(GLOB_RECURSE MANPAGES ${GLOB_EXPR})
+ IF(MANPAGES)
+ LIST(GET MANPAGES 0 MANPAGE)
+ STRING(REPLACE "${file}man.1" "${file}.1" MANPAGE "${MANPAGE}")
+ STRING(REPLACE "${file}man.8" "${file}.8" MANPAGE "${MANPAGE}")
+ IF(MANPAGE MATCHES "${file}.1")
+ SET(SECTION man1)
+ ELSE()
+ SET(SECTION man8)
+ ENDIF()
+ MESSAGE("huj!")
+ INSTALL(FILES "${MANPAGE}" DESTINATION "${INSTALL_MANDIR}/${SECTION}"
+ COMPONENT ManPages)
+ ENDIF()
+ENDFUNCTION()
+
+FUNCTION(INSTALL_SCRIPT)
+ MYSQL_PARSE_ARGUMENTS(ARG
+ "DESTINATION;COMPONENT"
+ ""
+ ${ARGN}
+ )
+
+ SET(script ${ARG_DEFAULT_ARGS})
+ IF(NOT ARG_DESTINATION)
+ SET(ARG_DESTINATION ${INSTALL_BINDIR})
+ ENDIF()
+ IF(ARG_COMPONENT)
+ SET(COMP COMPONENT ${ARG_COMPONENT})
+ ELSE()
+ SET(COMP)
+ ENDIF()
+
+ INSTALL(FILES
+ ${script}
+ DESTINATION ${ARG_DESTINATION}
+ PERMISSIONS OWNER_READ OWNER_WRITE
+ OWNER_EXECUTE GROUP_READ GROUP_EXECUTE
+ WORLD_READ WORLD_EXECUTE ${COMP}
+ )
+ INSTALL_MANPAGE(${script})
+ENDFUNCTION()
+
+# Install symbolic link to CMake target.
+# the link is created in the same directory as target
+# and extension will be the same as for target file.
+MACRO(INSTALL_SYMLINK linkname target destination component)
+IF(UNIX)
+ GET_TARGET_PROPERTY(location ${target} LOCATION)
+ GET_FILENAME_COMPONENT(path ${location} PATH)
+ GET_FILENAME_COMPONENT(name ${location} NAME)
+ SET(output ${path}/${linkname})
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${output}
+ COMMAND ${CMAKE_COMMAND} ARGS -E remove -f ${output}
+ COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink
+ ${name}
+ ${linkname}
+ WORKING_DIRECTORY ${path}
+ DEPENDS ${target}
+ )
+
+ ADD_CUSTOM_TARGET(symlink_${linkname}
+ ALL
+ DEPENDS ${output})
+ SET_TARGET_PROPERTIES(symlink_${linkname} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+ IF(CMAKE_GENERATOR MATCHES "Xcode")
+ # For Xcode, replace project config with install config
+ STRING(REPLACE "${CMAKE_CFG_INTDIR}"
+ "\${CMAKE_INSTALL_CONFIG_NAME}" output ${output})
+ ENDIF()
+ INSTALL(FILES ${output} DESTINATION ${destination} COMPONENT ${component})
+ENDIF()
+ENDMACRO()
+
+IF(WIN32)
+ OPTION(SIGNCODE "Sign executables and dlls with digital certificate" OFF)
+ MARK_AS_ADVANCED(SIGNCODE)
+ IF(SIGNCODE)
+ SET(SIGNTOOL_PARAMETERS
+ /a /t http://timestamp.verisign.com/scripts/timstamp.dll
+ CACHE STRING "parameters for signtool (list)")
+ FIND_PROGRAM(SIGNTOOL_EXECUTABLE signtool)
+ IF(NOT SIGNTOOL_EXECUTABLE)
+ MESSAGE(FATAL_ERROR
+ "signtool is not found. Signing executables not possible")
+ ENDIF()
+ IF(NOT DEFINED SIGNCODE_ENABLED)
+ FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/testsign.c "int main(){return 0;}")
+ MAKE_DIRECTORY(${CMAKE_CURRENT_BINARY_DIR}/testsign)
+ TRY_COMPILE(RESULT ${CMAKE_CURRENT_BINARY_DIR}/testsign ${CMAKE_CURRENT_BINARY_DIR}/testsign.c
+ COPY_FILE ${CMAKE_CURRENT_BINARY_DIR}/testsign.exe
+ )
+
+ EXECUTE_PROCESS(COMMAND
+ ${SIGNTOOL_EXECUTABLE} sign ${SIGNTOOL_PARAMETERS} ${CMAKE_CURRENT_BINARY_DIR}/testsign.exe
+ RESULT_VARIABLE ERR ERROR_QUIET OUTPUT_QUIET
+ )
+ IF(ERR EQUAL 0)
+ SET(SIGNCODE_ENABLED 1 CACHE INTERNAL "Can sign executables")
+ ELSE()
+ MESSAGE(STATUS "Disable authenticode signing for executables")
+ SET(SIGNCODE_ENABLED 0 CACHE INTERNAL "Invalid or missing certificate")
+ ENDIF()
+ ENDIF()
+ MARK_AS_ADVANCED(SIGNTOOL_EXECUTABLE SIGNTOOL_PARAMETERS)
+ ENDIF()
+ENDIF()
+
+MACRO(SIGN_TARGET target)
+ GET_TARGET_PROPERTY(target_type ${target} TYPE)
+ IF(target_type AND NOT target_type MATCHES "STATIC")
+ GET_TARGET_PROPERTY(target_location ${target} LOCATION)
+ IF(CMAKE_GENERATOR MATCHES "Visual Studio")
+ STRING(REPLACE "${CMAKE_CFG_INTDIR}" "\${CMAKE_INSTALL_CONFIG_NAME}"
+ target_location ${target_location})
+ ENDIF()
+ INSTALL(CODE
+ "EXECUTE_PROCESS(COMMAND
+ ${SIGNTOOL_EXECUTABLE} sign ${SIGNTOOL_PARAMETERS} ${target_location}
+ RESULT_VARIABLE ERR)
+ IF(NOT \${ERR} EQUAL 0)
+ MESSAGE(FATAL_ERROR \"Error signing ${target_location}\")
+ ENDIF()
+ ")
+ ENDIF()
+ENDMACRO()
+
+
+# Installs targets, also installs pdbs on Windows.
+#
+#
+
+FUNCTION(MYSQL_INSTALL_TARGETS)
+ MYSQL_PARSE_ARGUMENTS(ARG
+ "DESTINATION;COMPONENT"
+ ""
+ ${ARGN}
+ )
+ SET(TARGETS ${ARG_DEFAULT_ARGS})
+ IF(NOT TARGETS)
+ MESSAGE(FATAL_ERROR "Need target list for MYSQL_INSTALL_TARGETS")
+ ENDIF()
+ IF(NOT ARG_DESTINATION)
+ MESSAGE(FATAL_ERROR "Need DESTINATION parameter for MYSQL_INSTALL_TARGETS")
+ ENDIF()
+
+
+ FOREACH(target ${TARGETS})
+ # If signing is required, sign executables before installing
+ IF(SIGNCODE AND SIGNCODE_ENABLED)
+ SIGN_TARGET(${target})
+ ENDIF()
+ # Install man pages on Unix
+ IF(UNIX)
+ GET_TARGET_PROPERTY(target_location ${target} LOCATION)
+ INSTALL_MANPAGE(${target_location})
+ ENDIF()
+ ENDFOREACH()
+ IF(ARG_COMPONENT)
+ SET(COMP COMPONENT ${ARG_COMPONENT})
+ ENDIF()
+ INSTALL(TARGETS ${TARGETS} DESTINATION ${ARG_DESTINATION} ${COMP})
+ SET(INSTALL_LOCATION ${ARG_DESTINATION} )
+ INSTALL_DEBUG_SYMBOLS("${TARGETS}")
+ SET(INSTALL_LOCATION)
+ENDFUNCTION()
+
+# Optionally install mysqld/client/embedded from debug build run. outside of the current build dir
+# (unless multi-config generator is used like Visual Studio or Xcode).
+# For Makefile generators we default Debug build directory to ${buildroot}/../debug.
+GET_FILENAME_COMPONENT(BINARY_PARENTDIR ${CMAKE_BINARY_DIR} PATH)
+SET(DEBUGBUILDDIR "${BINARY_PARENTDIR}/debug" CACHE INTERNAL "Directory of debug build")
+
+
+FUNCTION(INSTALL_DEBUG_TARGET target)
+ MYSQL_PARSE_ARGUMENTS(ARG
+ "DESTINATION;RENAME;PDB_DESTINATION;COMPONENT"
+ ""
+ ${ARGN}
+ )
+ GET_TARGET_PROPERTY(target_type ${target} TYPE)
+ IF(ARG_RENAME)
+ SET(RENAME_PARAM RENAME ${ARG_RENAME}${CMAKE_${target_type}_SUFFIX})
+ ELSE()
+ SET(RENAME_PARAM)
+ ENDIF()
+ IF(NOT ARG_DESTINATION)
+ MESSAGE(FATAL_ERROR "Need DESTINATION parameter for INSTALL_DEBUG_TARGET")
+ ENDIF()
+ GET_TARGET_PROPERTY(target_location ${target} LOCATION)
+ IF(CMAKE_GENERATOR MATCHES "Makefiles")
+ STRING(REPLACE "${CMAKE_BINARY_DIR}" "${DEBUGBUILDDIR}" debug_target_location "${target_location}")
+ ELSE()
+ STRING(REPLACE "${CMAKE_CFG_INTDIR}" "Debug" debug_target_location "${target_location}" )
+ ENDIF()
+ IF(NOT ARG_COMPONENT)
+ SET(ARG_COMPONENT DebugBinaries)
+ ENDIF()
+
+ # Define permissions
+ # For executable files
+ SET(PERMISSIONS_EXECUTABLE
+ PERMISSIONS
+ OWNER_READ OWNER_WRITE OWNER_EXECUTE
+ GROUP_READ GROUP_EXECUTE
+ WORLD_READ WORLD_EXECUTE)
+
+ # Permissions for shared library (honors CMAKE_INSTALL_NO_EXE which is
+ # typically set on Debian)
+ IF(CMAKE_INSTALL_SO_NO_EXE)
+ SET(PERMISSIONS_SHARED_LIBRARY
+ PERMISSIONS
+ OWNER_READ OWNER_WRITE
+ GROUP_READ
+ WORLD_READ)
+ ELSE()
+ SET(PERMISSIONS_SHARED_LIBRARY ${PERMISSIONS_EXECUTABLE})
+ ENDIF()
+
+ # Shared modules get the same permissions as shared libraries
+ SET(PERMISSIONS_MODULE_LIBRARY ${PERMISSIONS_SHARED_LIBRARY})
+
+ # Define permissions for static library
+ SET(PERMISSIONS_STATIC_LIBRARY
+ PERMISSIONS
+ OWNER_READ OWNER_WRITE
+ GROUP_READ
+ WORLD_READ)
+
+ INSTALL(FILES ${debug_target_location}
+ DESTINATION ${ARG_DESTINATION}
+ ${RENAME_PARAM}
+ ${PERMISSIONS_${target_type}}
+ CONFIGURATIONS Release RelWithDebInfo
+ COMPONENT ${ARG_COMPONENT}
+ OPTIONAL)
+
+ IF(MSVC)
+ GET_FILENAME_COMPONENT(ext ${debug_target_location} EXT)
+ STRING(REPLACE "${ext}" ".pdb" debug_pdb_target_location "${debug_target_location}" )
+ IF (RENAME_PARAM)
+ IF(NOT ARG_PDB_DESTINATION)
+ STRING(REPLACE "${ext}" ".pdb" "${ARG_RENAME}" pdb_rename)
+ SET(PDB_RENAME_PARAM RENAME "${pdb_rename}")
+ ENDIF()
+ ENDIF()
+ IF(NOT ARG_PDB_DESTINATION)
+ SET(ARG_PDB_DESTINATION "${ARG_DESTINATION}")
+ ENDIF()
+ INSTALL(FILES ${debug_pdb_target_location}
+ DESTINATION ${ARG_PDB_DESTINATION}
+ ${PDB_RENAME_PARAM}
+ CONFIGURATIONS Release RelWithDebInfo
+ COMPONENT ${ARG_COMPONENT}
+ OPTIONAL)
+ ENDIF()
+ENDFUNCTION()
+
diff --git a/cmake/libutils.cmake b/cmake/libutils.cmake
new file mode 100644
index 00000000000..89a9de9b322
--- /dev/null
+++ b/cmake/libutils.cmake
@@ -0,0 +1,302 @@
+# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+
+# This file exports macros that emulate some functionality found in GNU libtool
+# on Unix systems. One such feature is convenience libraries. In this context,
+# convenience library is a static library that can be linked to shared library
+# On systems that force position-independent code, linking into shared library
+# normally requires compilation with a special flag (often -fPIC). To enable
+# linking static libraries to shared, we compile source files that come into
+# static library with the PIC flag (${CMAKE_SHARED_LIBRARY_C_FLAGS} in CMake)
+# Some systems, like Windows or OSX do not need special compilation (Windows
+# never uses PIC and OSX always uses it).
+#
+# The intention behind convenience libraries is simplify the build and to reduce
+# excessive recompiles.
+
+# Except for convenience libraries, this file provides macros to merge static
+# libraries (we need it for mysqlclient) and to create shared library out of
+# convenience libraries(again, for mysqlclient)
+
+# Following macros are exported
+# - ADD_CONVENIENCE_LIBRARY(target source1...sourceN)
+# This macro creates convenience library. The functionality is similar to
+# ADD_LIBRARY(target STATIC source1...sourceN), the difference is that resulting
+# library can always be linked to shared library
+#
+# - MERGE_LIBRARIES(target [STATIC|SHARED|MODULE] [linklib1 .... linklibN]
+# [EXPORTS exported_func1 .... exported_func_N]
+# [OUTPUT_NAME output_name]
+# This macro merges several static libraries into a single one or creates a shared
+# library from several convenience libraries
+
+# Important global flags
+# - WITH_PIC : If set, it is assumed that everything is compiled as position
+# independent code (that is CFLAGS/CMAKE_C_FLAGS contain -fPIC or equivalent)
+# If defined, ADD_CONVENIENCE_LIBRARY does not add PIC flag to compile flags
+#
+# - DISABLE_SHARED: If set, it is assumed that shared libraries are not produced
+# during the build. ADD_CONVENIENCE_LIBRARY does not add anything to compile flags
+
+
+GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
+IF(WIN32 OR CYGWIN OR APPLE OR WITH_PIC OR DISABLE_SHARED OR NOT CMAKE_SHARED_LIBRARY_C_FLAGS)
+ SET(_SKIP_PIC 1)
+ENDIF()
+
+INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake)
+# CREATE_EXPORT_FILE (VAR target api_functions)
+# Internal macro, used to create source file for shared libraries that
+# otherwise consists entirely of "convenience" libraries. On Windows,
+# also exports API functions as dllexport. On unix, creates a dummy file
+# that references all exports and this prevents linker from creating an
+# empty library(there are unportable alternatives, --whole-archive)
+MACRO(CREATE_EXPORT_FILE VAR TARGET API_FUNCTIONS)
+ IF(WIN32)
+ SET(DUMMY ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_dummy.c)
+ SET(EXPORTS ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_exports.def)
+ CONFIGURE_FILE_CONTENT("" ${DUMMY})
+ SET(CONTENT "EXPORTS\n")
+ FOREACH(FUNC ${API_FUNCTIONS})
+ SET(CONTENT "${CONTENT} ${FUNC}\n")
+ ENDFOREACH()
+ CONFIGURE_FILE_CONTENT(${CONTENT} ${EXPORTS})
+ SET(${VAR} ${DUMMY} ${EXPORTS})
+ ELSE()
+ SET(EXPORTS ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_exports_file.cc)
+ SET(CONTENT)
+ FOREACH(FUNC ${API_FUNCTIONS})
+ SET(CONTENT "${CONTENT} extern void* ${FUNC}\;\n")
+ ENDFOREACH()
+ SET(CONTENT "${CONTENT} void *${TARGET}_api_funcs[] = {\n")
+ FOREACH(FUNC ${API_FUNCTIONS})
+ SET(CONTENT "${CONTENT} &${FUNC},\n")
+ ENDFOREACH()
+ SET(CONTENT "${CONTENT} (void *)0\n}\;")
+ CONFIGURE_FILE_CONTENT(${CONTENT} ${EXPORTS})
+ SET(${VAR} ${EXPORTS})
+ ENDIF()
+ENDMACRO()
+
+
+# MYSQL_ADD_CONVENIENCE_LIBRARY(name source1...sourceN)
+# Create static library that can be linked to shared library.
+# On systems that force position-independent code, adds -fPIC or
+# equivalent flag to compile flags.
+MACRO(ADD_CONVENIENCE_LIBRARY)
+ SET(TARGET ${ARGV0})
+ SET(SOURCES ${ARGN})
+ LIST(REMOVE_AT SOURCES 0)
+ ADD_LIBRARY(${TARGET} STATIC ${SOURCES})
+ IF(NOT _SKIP_PIC)
+ SET_TARGET_PROPERTIES(${TARGET} PROPERTIES COMPILE_FLAGS
+ "${CMAKE_SHARED_LIBRARY_C_FLAGS}")
+ ENDIF()
+ENDMACRO()
+
+
+# Write content to file, using CONFIGURE_FILE
+# The advantage compared to FILE(WRITE) is that timestamp
+# does not change if file already has the same content
+MACRO(CONFIGURE_FILE_CONTENT content file)
+ SET(CMAKE_CONFIGURABLE_FILE_CONTENT
+ "${content}\n")
+ CONFIGURE_FILE(
+ ${MYSQL_CMAKE_SCRIPT_DIR}/configurable_file_content.in
+ ${file}
+ @ONLY)
+ENDMACRO()
+
+# Merge static libraries into a big static lib. The resulting library
+# should not not have dependencies on other static libraries.
+# We use it in MySQL to merge mysys,dbug,vio etc into mysqlclient
+
+MACRO(MERGE_STATIC_LIBS TARGET OUTPUT_NAME LIBS_TO_MERGE)
+ # To produce a library we need at least one source file.
+ # It is created by ADD_CUSTOM_COMMAND below and will helps
+ # also help to track dependencies.
+ SET(SOURCE_FILE ${CMAKE_CURRENT_BINARY_DIR}/${TARGET}_depends.c)
+ ADD_LIBRARY(${TARGET} STATIC ${SOURCE_FILE})
+ SET_TARGET_PROPERTIES(${TARGET} PROPERTIES OUTPUT_NAME ${OUTPUT_NAME})
+
+ SET(OSLIBS)
+ FOREACH(LIB ${LIBS_TO_MERGE})
+ GET_TARGET_PROPERTY(LIB_LOCATION ${LIB} LOCATION)
+ GET_TARGET_PROPERTY(LIB_TYPE ${LIB} TYPE)
+ IF(NOT LIB_LOCATION)
+ # 3rd party library like libz.so. Make sure that everything
+ # that links to our library links to this one as well.
+ LIST(APPEND OSLIBS ${LIB})
+ ELSE()
+ # This is a target in current project
+ # (can be a static or shared lib)
+ IF(LIB_TYPE STREQUAL "STATIC_LIBRARY")
+ SET(STATIC_LIBS ${STATIC_LIBS} ${LIB_LOCATION})
+ ADD_DEPENDENCIES(${TARGET} ${LIB})
+ # Extract dependend OS libraries
+ GET_DEPENDEND_OS_LIBS(${LIB} LIB_OSLIBS)
+ LIST(APPEND OSLIBS ${LIB_OSLIBS})
+ ELSE()
+ # This is a shared library our static lib depends on.
+ LIST(APPEND OSLIBS ${LIB})
+ ENDIF()
+ ENDIF()
+ ENDFOREACH()
+ IF(OSLIBS)
+ LIST(REMOVE_DUPLICATES OSLIBS)
+ TARGET_LINK_LIBRARIES(${TARGET} ${OSLIBS})
+ ENDIF()
+
+ # Make the generated dummy source file depended on all static input
+ # libs. If input lib changes,the source file is touched
+ # which causes the desired effect (relink).
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${SOURCE_FILE}
+ COMMAND ${CMAKE_COMMAND} -E touch ${SOURCE_FILE}
+ DEPENDS ${STATIC_LIBS})
+
+ IF(MSVC)
+ # To merge libs, just pass them to lib.exe command line.
+ SET(LINKER_EXTRA_FLAGS "")
+ FOREACH(LIB ${STATIC_LIBS})
+ SET(LINKER_EXTRA_FLAGS "${LINKER_EXTRA_FLAGS} ${LIB}")
+ ENDFOREACH()
+ SET_TARGET_PROPERTIES(${TARGET} PROPERTIES STATIC_LIBRARY_FLAGS
+ "${LINKER_EXTRA_FLAGS}")
+ ELSE()
+ GET_TARGET_PROPERTY(TARGET_LOCATION ${TARGET} LOCATION)
+ IF(APPLE)
+ # Use OSX's libtool to merge archives (ihandles universal
+ # binaries properly)
+ ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD
+ COMMAND rm ${TARGET_LOCATION}
+ COMMAND /usr/bin/libtool -static -o ${TARGET_LOCATION}
+ ${STATIC_LIBS}
+ )
+ ELSE()
+ # Generic Unix, Cygwin or MinGW. In post-build step, call
+ # script, that extracts objects from archives with "ar x"
+ # and repacks them with "ar r"
+ SET(TARGET ${TARGET})
+ CONFIGURE_FILE(
+ ${MYSQL_CMAKE_SCRIPT_DIR}/merge_archives_unix.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET}.cmake
+ @ONLY
+ )
+ ADD_CUSTOM_COMMAND(TARGET ${TARGET} POST_BUILD
+ COMMAND rm ${TARGET_LOCATION}
+ COMMAND ${CMAKE_COMMAND} -P
+ ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET}.cmake
+ )
+ ENDIF()
+ ENDIF()
+ENDMACRO()
+
+# Create libs from libs.
+# Merges static libraries, creates shared libraries out of convenience libraries.
+# MERGE_LIBRARIES(target [STATIC|SHARED|MODULE]
+# [linklib1 .... linklibN]
+# [EXPORTS exported_func1 .... exportedFuncN]
+# [OUTPUT_NAME output_name]
+#)
+MACRO(MERGE_LIBRARIES)
+ MYSQL_PARSE_ARGUMENTS(ARG
+ "EXPORTS;OUTPUT_NAME;COMPONENT"
+ "STATIC;SHARED;MODULE;NOINSTALL"
+ ${ARGN}
+ )
+ LIST(GET ARG_DEFAULT_ARGS 0 TARGET)
+ SET(LIBS ${ARG_DEFAULT_ARGS})
+ LIST(REMOVE_AT LIBS 0)
+ IF(ARG_STATIC)
+ IF (NOT ARG_OUTPUT_NAME)
+ SET(ARG_OUTPUT_NAME ${TARGET})
+ ENDIF()
+ MERGE_STATIC_LIBS(${TARGET} ${ARG_OUTPUT_NAME} "${LIBS}")
+ ELSEIF(ARG_SHARED OR ARG_MODULE)
+ IF(ARG_SHARED)
+ SET(LIBTYPE SHARED)
+ ELSE()
+ SET(LIBTYPE MODULE)
+ ENDIF()
+ # check for non-PIC libraries
+ IF(NOT _SKIP_PIC)
+ FOREACH(LIB ${LIBS})
+ GET_TARGET_PROPERTY(${LIB} TYPE LIBTYPE)
+ IF(LIBTYPE STREQUAL "STATIC_LIBRARY")
+ GET_TARGET_PROPERTY(LIB COMPILE_FLAGS LIB_COMPILE_FLAGS)
+ STRING(REPLACE "${CMAKE_SHARED_LIBRARY_C_FLAGS}"
+ "<PIC_FLAG>" LIB_COMPILE_FLAGS ${LIB_COMPILE_FLAG})
+ IF(NOT LIB_COMPILE_FLAGS MATCHES "<PIC_FLAG>")
+ MESSAGE(FATAL_ERROR
+ "Attempted to link non-PIC static library ${LIB} to shared library ${TARGET}\n"
+ "Please use ADD_CONVENIENCE_LIBRARY, instead of ADD_LIBRARY for ${LIB}"
+ )
+ ENDIF()
+ ENDIF()
+ ENDFOREACH()
+ ENDIF()
+ CREATE_EXPORT_FILE(SRC ${TARGET} "${ARG_EXPORTS}")
+ IF(NOT ARG_NOINSTALL)
+ ADD_VERSION_INFO(${TARGET} SHARED SRC)
+ ENDIF()
+ ADD_LIBRARY(${TARGET} ${LIBTYPE} ${SRC})
+ TARGET_LINK_LIBRARIES(${TARGET} ${LIBS})
+ IF(ARG_OUTPUT_NAME)
+ SET_TARGET_PROPERTIES(${TARGET} PROPERTIES OUTPUT_NAME "${ARG_OUTPUT_NAME}")
+ ENDIF()
+ ELSE()
+ MESSAGE(FATAL_ERROR "Unknown library type")
+ ENDIF()
+ IF(NOT ARG_NOINSTALL)
+ IF(ARG_COMPONENT)
+ SET(COMP COMPONENT ${ARG_COMPONENT})
+ ENDIF()
+ MYSQL_INSTALL_TARGETS(${TARGET} DESTINATION "${INSTALL_LIBDIR}" ${COMP})
+ ENDIF()
+ SET_TARGET_PROPERTIES(${TARGET} PROPERTIES LINK_INTERFACE_LIBRARIES "")
+ENDMACRO()
+
+FUNCTION(GET_DEPENDEND_OS_LIBS target result)
+ SET(deps ${${target}_LIB_DEPENDS})
+ IF(deps)
+ FOREACH(lib ${deps})
+ # Filter out keywords for used for debug vs optimized builds
+ IF(NOT lib MATCHES "general" AND NOT lib MATCHES "debug" AND NOT lib MATCHES "optimized")
+ GET_TARGET_PROPERTY(lib_location ${lib} LOCATION)
+ IF(NOT lib_location)
+ SET(ret ${ret} ${lib})
+ ENDIF()
+ ENDIF()
+ ENDFOREACH()
+ ENDIF()
+ SET(${result} ${ret} PARENT_SCOPE)
+ENDFUNCTION()
+
+MACRO(RESTRICT_SYMBOL_EXPORTS target)
+ IF(CMAKE_COMPILER_IS_GNUCXX AND UNIX)
+ CHECK_C_COMPILER_FLAG("-fvisibility=hidden" HAVE_VISIBILITY_HIDDEN)
+ IF(HAVE_VISIBILITY_HIDDEN)
+ GET_TARGET_PROPERTY(COMPILE_FLAGS ${target} COMPILE_FLAGS)
+ IF(NOT COMPILE_FLAGS)
+ # Avoid COMPILE_FLAGS-NOTFOUND
+ SET(COMPILE_FLAGS)
+ ENDIF()
+ SET_TARGET_PROPERTIES(${target} PROPERTIES
+ COMPILE_FLAGS "${COMPILE_FLAGS} -fvisibility=hidden")
+ ENDIF()
+ ENDIF()
+ENDMACRO()
diff --git a/cmake/maintainer.cmake b/cmake/maintainer.cmake
new file mode 100644
index 00000000000..a91905a281b
--- /dev/null
+++ b/cmake/maintainer.cmake
@@ -0,0 +1,54 @@
+# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+INCLUDE(CheckCCompilerFlag)
+
+# Setup GCC (GNU C compiler) warning options.
+MACRO(SET_MYSQL_MAINTAINER_GNU_C_OPTIONS)
+ SET(MY_MAINTAINER_WARNINGS
+ "-Wall -Wextra -Wunused -Wwrite-strings -Wno-strict-aliasing -Werror")
+ CHECK_C_COMPILER_FLAG("-Wdeclaration-after-statement"
+ HAVE_DECLARATION_AFTER_STATEMENT)
+ IF(HAVE_DECLARATION_AFTER_STATEMENT)
+ SET(MY_MAINTAINER_DECLARATION_AFTER_STATEMENT
+ "-Wdeclaration-after-statement")
+ ENDIF()
+ SET(MY_MAINTAINER_C_WARNINGS
+ "${MY_MAINTAINER_WARNINGS} ${MY_MAINTAINER_DECLARATION_AFTER_STATEMENT}"
+ CACHE STRING "C warning options used in maintainer builds.")
+ # Do not make warnings in checks into errors.
+ SET(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} -Wno-error")
+ENDMACRO()
+
+# Setup G++ (GNU C++ compiler) warning options.
+MACRO(SET_MYSQL_MAINTAINER_GNU_CXX_OPTIONS)
+ SET(MY_MAINTAINER_CXX_WARNINGS
+ "${MY_MAINTAINER_WARNINGS} -Wno-unused-parameter -Woverloaded-virtual"
+ CACHE STRING "C++ warning options used in maintainer builds.")
+ENDMACRO()
+
+# Setup ICC (Intel C Compiler) warning options.
+MACRO(SET_MYSQL_MAINTAINER_INTEL_C_OPTIONS)
+ SET(MY_MAINTAINER_WARNINGS "-Wcheck")
+ SET(MY_MAINTAINER_C_WARNINGS "${MY_MAINTAINER_WARNINGS}"
+ CACHE STRING "C warning options used in maintainer builds.")
+ENDMACRO()
+
+# Setup ICPC (Intel C++ Compiler) warning options.
+MACRO(SET_MYSQL_MAINTAINER_INTEL_CXX_OPTIONS)
+ SET(MY_MAINTAINER_CXX_WARNINGS "${MY_MAINTAINER_WARNINGS}"
+ CACHE STRING "C++ warning options used in maintainer builds.")
+ENDMACRO()
+
diff --git a/cmake/make_dist.cmake.in b/cmake/make_dist.cmake.in
new file mode 100644
index 00000000000..5aa1fc8fd0e
--- /dev/null
+++ b/cmake/make_dist.cmake.in
@@ -0,0 +1,183 @@
+# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+# Make source distribution
+# If bzr is present, run bzr export.
+# Otherwise, just run cpack with source configuration.
+
+SET(CMAKE_SOURCE_DIR "@CMAKE_SOURCE_DIR@")
+SET(CMAKE_BINARY_DIR "@CMAKE_BINARY_DIR@")
+SET(CPACK_SOURCE_PACKAGE_FILE_NAME "@CPACK_SOURCE_PACKAGE_FILE_NAME@")
+SET(CMAKE_CPACK_COMMAND "@CMAKE_CPACK_COMMAND@")
+SET(CMAKE_COMMAND "@CMAKE_COMMAND@")
+SET(BZR_EXECUTABLE "@BZR_EXECUTABLE@")
+SET(GTAR_EXECUTABLE "@GTAR_EXECUTABLE@")
+SET(TAR_EXECUTABLE "@TAR_EXECUTABLE@")
+SET(CMAKE_GENERATOR "@CMAKE_GENERATOR@")
+SET(CMAKE_MAKE_PROGRAM "@CMAKE_MAKE_PROGRAM@")
+SET(CMAKE_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@")
+SET(PLUGIN_REPOS "@PLUGIN_REPOS@")
+
+SET(VERSION "@VERSION@")
+
+SET(MYSQL_DOCS_LOCATION "@MYSQL_DOCS_LOCATION@")
+
+
+SET(PACKAGE_DIR ${CMAKE_BINARY_DIR}/${CPACK_SOURCE_PACKAGE_FILE_NAME})
+
+FILE(REMOVE_RECURSE ${PACKAGE_DIR})
+FILE(REMOVE ${PACKAGE_DIR}.tar.gz )
+
+IF(BZR_EXECUTABLE)
+ MESSAGE(STATUS "Running bzr export")
+ EXECUTE_PROCESS(
+ COMMAND "${BZR_EXECUTABLE}" export
+ ${PACKAGE_DIR}
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ RESULT_VARIABLE RESULT
+ )
+
+ IF(NOT RESULT EQUAL 0)
+ SET(BZR_EXECUTABLE)
+ ENDIF()
+ENDIF()
+
+IF(BZR_EXECUTABLE)
+ FOREACH(REPO ${PLUGIN_REPOS})
+ GET_FILENAME_COMPONENT(PLUGIN_NAME ${REPO} NAME)
+ SET(DEST ${PACKAGE_DIR}/plugin/${PLUGIN_NAME})
+ MESSAGE(STATUS "Running bzr export for plugin/${PLUGIN_NAME}")
+ EXECUTE_PROCESS(
+ COMMAND "${BZR_EXECUTABLE}" export ${DEST}
+ WORKING_DIRECTORY ${REPO}
+ RESULT_VARIABLE RESULT
+ )
+ IF(NOT RESULT EQUAL 0)
+ MESSAGE(STATUS "bzr export failed")
+ ENDIF()
+ ENDFOREACH()
+ENDIF()
+
+IF(NOT BZR_EXECUTABLE)
+ MESSAGE(STATUS "bzr not found or source dir is not a repo, use CPack")
+
+ IF(CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
+ # In-source build is the worst option, we have to cleanup source tree.
+
+ # Save bison output first.
+ CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
+ ${CMAKE_BINARY_DIR}/sql_yacc.cc COPY_ONLY)
+ CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.h
+ ${CMAKE_BINARY_DIR}/sql_yacc.h COPY_ONLY)
+
+ IF(CMAKE_GENERATOR MATCHES "Makefiles")
+ # make clean
+ EXECUTE_PROCESS(
+ COMMAND ${CMAKE_MAKE_PROGRAM} clean
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ )
+ ENDIF()
+
+ # Restore bison output
+ CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql_yacc.cc
+ ${CMAKE_BINARY_DIR}/sql/sql_yacc.cc COPY_ONLY)
+ CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql_yacc.h
+ ${CMAKE_BINARY_DIR}/sql/sql_yacc.h COPY_ONLY)
+ FILE(REMOVE ${CMAKE_BINARY_DIR}/sql_yacc.cc)
+ FILE(REMOVE ${CMAKE_BINARY_DIR}/sql_yacc.h)
+ ENDIF()
+
+ EXECUTE_PROCESS(
+ COMMAND ${CMAKE_CPACK_COMMAND} -G TGZ --config ./CPackSourceConfig.cmake
+ ${CMAKE_BINARY_DIR}/CPackSourceConfig.cmake
+
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ )
+ EXECUTE_PROCESS(
+ COMMAND ${CMAKE_COMMAND} -E tar xzf
+ ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz
+ ${PACK_SOURCE_PACKAGE_FILE_NAME}
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ )
+ENDIF()
+
+# Copy bison output
+CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.h
+ ${PACKAGE_DIR}/sql/sql_yacc.h COPYONLY)
+CONFIGURE_FILE(${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
+ ${PACKAGE_DIR}/sql/sql_yacc.cc COPYONLY)
+
+# Copy spec files
+CONFIGURE_FILE(${CMAKE_BINARY_DIR}/support-files/mysql.${VERSION}.spec
+ ${PACKAGE_DIR}/support-files/mysql.${VERSION}.spec COPYONLY)
+
+# Add documentation, if user has specified where to find them
+IF(MYSQL_DOCS_LOCATION)
+ MESSAGE("Copying documentation files from " ${MYSQL_DOCS_LOCATION})
+ EXECUTE_PROCESS(COMMAND ${CMAKE_COMMAND} -E copy_directory "${MYSQL_DOCS_LOCATION}" "${PACKAGE_DIR}")
+ENDIF()
+
+# Ensure there is an "INFO_SRC" file.
+INCLUDE(${CMAKE_BINARY_DIR}/info_macros.cmake)
+IF(NOT EXISTS ${PACKAGE_DIR}/Docs/INFO_SRC)
+ CREATE_INFO_SRC(${PACKAGE_DIR}/Docs)
+ENDIF()
+
+# In case we used CPack, it could have copied some
+# extra files that are not usable on different machines.
+FILE(REMOVE ${PACKAGE_DIR}/CMakeCache.txt)
+
+# When packing source, prefer gnu tar to "cmake -P tar"
+# cmake does not preserve timestamps.gnuwin32 tar is broken, cygwin is ok
+
+IF(CMAKE_SYSTEM_NAME MATCHES "Windows")
+ IF (EXISTS C:/cygwin/bin/tar.exe)
+ SET(TAR_EXECUTABLE C:/cygwin/bin/tar.exe)
+ ENDIF()
+ENDIF()
+
+IF(GTAR_EXECUTABLE)
+ SET(GNUTAR ${GTAR_EXECUTABLE})
+ELSEIF(TAR_EXECUTABLE)
+ EXECUTE_PROCESS(
+ COMMAND "${TAR_EXECUTABLE}" --version
+ RESULT_VARIABLE RESULT OUTPUT_VARIABLE OUT ERROR_VARIABLE ERR
+ )
+ IF(RESULT EQUAL 0 AND OUT MATCHES "GNU")
+ SET(GNUTAR ${TAR_EXECUTABLE})
+ ENDIF()
+ENDIF()
+
+SET($ENV{GZIP} "--best")
+
+IF(GNUTAR)
+ SET(PACK_COMMAND
+ ${GNUTAR} cfz
+ ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz
+ ${CPACK_SOURCE_PACKAGE_FILE_NAME}
+ )
+ELSE()
+ SET(PACK_COMMAND ${CMAKE_COMMAND} -E tar cfz
+ ${CPACK_SOURCE_PACKAGE_FILE_NAME}.tar.gz
+ ${CPACK_SOURCE_PACKAGE_FILE_NAME}
+)
+ENDIF()
+
+MESSAGE(STATUS "Creating source package")
+
+EXECUTE_PROCESS(
+ COMMAND ${PACK_COMMAND}
+)
+MESSAGE(STATUS "Source package ${PACKAGE_DIR}.tar.gz created")
diff --git a/cmake/merge_archives_unix.cmake.in b/cmake/merge_archives_unix.cmake.in
new file mode 100644
index 00000000000..d05336d6c91
--- /dev/null
+++ b/cmake/merge_archives_unix.cmake.in
@@ -0,0 +1,63 @@
+# Copyright (c) 2009 Sun Microsystems, Inc.
+# Use is subject to license terms.
+#
+# 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
+
+# This script merges many static libraries into
+# one big library on Unix.
+SET(TARGET_LOCATION "@TARGET_LOCATION@")
+SET(TARGET "@TARGET@")
+SET(STATIC_LIBS "@STATIC_LIBS@")
+SET(CMAKE_CURRENT_BINARY_DIR "@CMAKE_CURRENT_BINARY_DIR@")
+SET(CMAKE_AR "@CMAKE_AR@")
+SET(CMAKE_RANLIB "@CMAKE_RANLIB@")
+
+
+SET(TEMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/merge_archives_${TARGET})
+MAKE_DIRECTORY(${TEMP_DIR})
+# Extract each archive to its own subdirectory(avoid object filename clashes)
+FOREACH(LIB ${STATIC_LIBS})
+ GET_FILENAME_COMPONENT(NAME_NO_EXT ${LIB} NAME_WE)
+ SET(TEMP_SUBDIR ${TEMP_DIR}/${NAME_NO_EXT})
+ MAKE_DIRECTORY(${TEMP_SUBDIR})
+ EXECUTE_PROCESS(
+ COMMAND ${CMAKE_AR} -x ${LIB}
+ WORKING_DIRECTORY ${TEMP_SUBDIR}
+ )
+
+ FILE(GLOB_RECURSE LIB_OBJECTS "${TEMP_SUBDIR}/*")
+ SET(OBJECTS ${OBJECTS} ${LIB_OBJECTS})
+ENDFOREACH()
+
+# Use relative paths, makes command line shorter.
+GET_FILENAME_COMPONENT(ABS_TEMP_DIR ${TEMP_DIR} ABSOLUTE)
+FOREACH(OBJ ${OBJECTS})
+ FILE(RELATIVE_PATH OBJ ${ABS_TEMP_DIR} ${OBJ})
+ FILE(TO_NATIVE_PATH ${OBJ} OBJ)
+ SET(ALL_OBJECTS ${ALL_OBJECTS} ${OBJ})
+ENDFOREACH()
+
+FILE(TO_NATIVE_PATH ${TARGET_LOCATION} ${TARGET_LOCATION})
+# Now pack the objects into library with ar.
+EXECUTE_PROCESS(
+ COMMAND ${CMAKE_AR} -r ${TARGET_LOCATION} ${ALL_OBJECTS}
+ WORKING_DIRECTORY ${TEMP_DIR}
+)
+EXECUTE_PROCESS(
+ COMMAND ${CMAKE_RANLIB} ${TARGET_LOCATION}
+ WORKING_DIRECTORY ${TEMP_DIR}
+)
+
+# Cleanup
+FILE(REMOVE_RECURSE ${TEMP_DIR})
diff --git a/cmake/mysql_add_executable.cmake b/cmake/mysql_add_executable.cmake
new file mode 100644
index 00000000000..b1e1d3129e6
--- /dev/null
+++ b/cmake/mysql_add_executable.cmake
@@ -0,0 +1,56 @@
+# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+# Add executable plus some additional MySQL specific stuff
+# Usage (same as for standard CMake's ADD_EXECUTABLE)
+#
+# MYSQL_ADD_EXECUTABLE(target source1...sourceN)
+#
+# MySQL specifics:
+# - instruct CPack to install executable under ${CMAKE_INSTALL_PREFIX}/bin directory
+# On Windows :
+# - add version resource
+# - instruct CPack to do autenticode signing if SIGNCODE is set
+
+INCLUDE(cmake_parse_arguments)
+
+FUNCTION (MYSQL_ADD_EXECUTABLE)
+ # Pass-through arguments for ADD_EXECUTABLE
+ MYSQL_PARSE_ARGUMENTS(ARG
+ "WIN32;MACOSX_BUNDLE;EXCLUDE_FROM_ALL;DESTINATION;COMPONENT"
+ ""
+ ${ARGN}
+ )
+ LIST(GET ARG_DEFAULT_ARGS 0 target)
+ LIST(REMOVE_AT ARG_DEFAULT_ARGS 0)
+
+ SET(sources ${ARG_DEFAULT_ARGS})
+ ADD_VERSION_INFO(${target} EXECUTABLE sources)
+ ADD_EXECUTABLE(${target} ${ARG_WIN32} ${ARG_MACOSX_BUNDLE} ${ARG_EXCLUDE_FROM_ALL} ${sources})
+ # tell CPack where to install
+ IF(NOT ARG_EXCLUDE_FROM_ALL)
+ IF(NOT ARG_DESTINATION)
+ SET(ARG_DESTINATION ${INSTALL_BINDIR})
+ ENDIF()
+ IF(ARG_COMPONENT)
+ SET(COMP COMPONENT ${ARG_COMPONENT})
+ ELSEIF(MYSQL_INSTALL_COMPONENT)
+ SET(COMP COMPONENT ${MYSQL_INSTALL_COMPONENT})
+ ELSE()
+ SET(COMP COMPONENT Client)
+ ENDIF()
+ MYSQL_INSTALL_TARGETS(${target} DESTINATION ${ARG_DESTINATION} ${COMP})
+ ENDIF()
+ENDFUNCTION()
diff --git a/cmake/mysql_version.cmake b/cmake/mysql_version.cmake
new file mode 100644
index 00000000000..122f0e63736
--- /dev/null
+++ b/cmake/mysql_version.cmake
@@ -0,0 +1,141 @@
+# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+#
+# Global constants, only to be changed between major releases.
+#
+
+SET(SHARED_LIB_MAJOR_VERSION "18")
+SET(PROTOCOL_VERSION "10")
+SET(DOT_FRM_VERSION "6")
+
+# Generate "something" to trigger cmake rerun when VERSION changes
+CONFIGURE_FILE(
+ ${CMAKE_SOURCE_DIR}/VERSION
+ ${CMAKE_BINARY_DIR}/VERSION.dep
+)
+
+# Read value for a variable from VERSION.
+
+MACRO(MYSQL_GET_CONFIG_VALUE keyword var)
+ IF(NOT ${var})
+ FILE (STRINGS ${CMAKE_SOURCE_DIR}/VERSION str REGEX "^[ ]*${keyword}=")
+ IF(str)
+ STRING(REPLACE "${keyword}=" "" str ${str})
+ STRING(REGEX REPLACE "[ ].*" "" str "${str}")
+ SET(${var} ${str})
+ ENDIF()
+ ENDIF()
+ENDMACRO()
+
+
+# Read mysql version for configure script
+
+MACRO(GET_MYSQL_VERSION)
+ MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_MAJOR" MAJOR_VERSION)
+ MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_MINOR" MINOR_VERSION)
+ MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_PATCH" PATCH_VERSION)
+ MYSQL_GET_CONFIG_VALUE("MYSQL_VERSION_EXTRA" EXTRA_VERSION)
+
+ IF(NOT MAJOR_VERSION OR NOT MINOR_VERSION OR NOT PATCH_VERSION)
+ MESSAGE(FATAL_ERROR "VERSION file cannot be parsed.")
+ ENDIF()
+
+ SET(VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}${EXTRA_VERSION}")
+ MESSAGE("-- MySQL ${VERSION}")
+ SET(MYSQL_BASE_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}" CACHE INTERNAL "MySQL Base version")
+ SET(MYSQL_NO_DASH_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}")
+ STRING(REPLACE "-" "_" MYSQL_RPM_VERSION "${VERSION}")
+ MATH(EXPR MYSQL_VERSION_ID "10000*${MAJOR_VERSION} + 100*${MINOR_VERSION} + ${PATCH_VERSION}")
+ MARK_AS_ADVANCED(VERSION MYSQL_VERSION_ID MYSQL_BASE_VERSION)
+ SET(CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION})
+ SET(CPACK_PACKAGE_VERSION_MINOR ${MINOR_VERSION})
+ SET(CPACK_PACKAGE_VERSION_PATCH ${PATCH_VERSION})
+ENDMACRO()
+
+# Get mysql version and other interesting variables
+GET_MYSQL_VERSION()
+
+SET(MYSQL_TCP_PORT_DEFAULT "3306")
+
+IF(NOT MYSQL_TCP_PORT)
+ SET(MYSQL_TCP_PORT ${MYSQL_TCP_PORT_DEFAULT})
+ SET(MYSQL_TCP_PORT_DEFAULT "0")
+ELSEIF(MYSQL_TCP_PORT EQUAL MYSQL_TCP_PORT_DEFAULT)
+ SET(MYSQL_TCP_PORT_DEFAULT "0")
+ENDIF()
+
+
+IF(NOT MYSQL_UNIX_ADDR)
+ SET(MYSQL_UNIX_ADDR "/tmp/mysql.sock")
+ENDIF()
+IF(NOT COMPILATION_COMMENT)
+ SET(COMPILATION_COMMENT "Source distribution")
+ENDIF()
+
+
+INCLUDE(package_name)
+IF(NOT CPACK_PACKAGE_FILE_NAME)
+ GET_PACKAGE_FILE_NAME(CPACK_PACKAGE_FILE_NAME)
+ENDIF()
+
+IF(NOT CPACK_SOURCE_PACKAGE_FILE_NAME)
+ SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mysql-${VERSION}")
+ENDIF()
+SET(CPACK_PACKAGE_CONTACT "MySQL Build Team <build@mysql.com>")
+SET(CPACK_PACKAGE_VENDOR "Sun Microsystems, Inc")
+SET(CPACK_SOURCE_GENERATOR "TGZ")
+INCLUDE(cpack_source_ignore_files)
+
+# Defintions for windows version resources
+SET(PRODUCTNAME "MySQL Server")
+SET(COMPANYNAME ${CPACK_PACKAGE_VENDOR})
+
+# Windows 'date' command has unpredictable output, so cannot rely on it to
+# set MYSQL_COPYRIGHT_YEAR - if someone finds a portable way to do so then
+# it might be useful
+#IF (WIN32)
+# EXECUTE_PROCESS(COMMAND "date" "/T" OUTPUT_VARIABLE TMP_DATE)
+# STRING(REGEX REPLACE "(..)/(..)/..(..).*" "\\3\\2\\1" MYSQL_COPYRIGHT_YEAR ${TMP_DATE})
+IF(UNIX)
+ EXECUTE_PROCESS(COMMAND "date" "+%Y" OUTPUT_VARIABLE MYSQL_COPYRIGHT_YEAR OUTPUT_STRIP_TRAILING_WHITESPACE)
+ENDIF()
+
+# Add version information to the exe and dll files
+# Refer to http://msdn.microsoft.com/en-us/library/aa381058(VS.85).aspx
+# for more info.
+IF(MSVC)
+ GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
+
+ SET(FILETYPE VFT_APP)
+ CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in
+ ${CMAKE_BINARY_DIR}/versioninfo_exe.rc)
+
+ SET(FILETYPE VFT_DLL)
+ CONFIGURE_FILE(${MYSQL_CMAKE_SCRIPT_DIR}/versioninfo.rc.in
+ ${CMAKE_BINARY_DIR}/versioninfo_dll.rc)
+
+ FUNCTION(ADD_VERSION_INFO target target_type sources_var)
+ IF("${target_type}" MATCHES "SHARED" OR "${target_type}" MATCHES "MODULE")
+ SET(rcfile ${CMAKE_BINARY_DIR}/versioninfo_dll.rc)
+ ELSEIF("${target_type}" MATCHES "EXE")
+ SET(rcfile ${CMAKE_BINARY_DIR}/versioninfo_exe.rc)
+ ENDIF()
+ SET(${sources_var} ${${sources_var}} ${rcfile} PARENT_SCOPE)
+ ENDFUNCTION()
+ELSE()
+ FUNCTION(ADD_VERSION_INFO)
+ ENDFUNCTION()
+ENDIF()
diff --git a/cmake/os/AIX.cmake b/cmake/os/AIX.cmake
new file mode 100644
index 00000000000..c86392f8bc4
--- /dev/null
+++ b/cmake/os/AIX.cmake
@@ -0,0 +1,33 @@
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+
+#Enable 64 bit file offsets
+SET(_LARGE_FILES 1)
+
+# Fix xlC oddity - it complains about same inline function defined multiple times
+# in different compilation units
+INCLUDE(CheckCXXCompilerFlag)
+ CHECK_CXX_COMPILER_FLAG("-qstaticinline" HAVE_QSTATICINLINE)
+ IF(HAVE_QSTATICINLINE)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -qstaticinline")
+ ENDIF()
+
+# The following is required to export all symbols
+# (also with leading underscore)
+STRING(REPLACE "-bexpall" "-bexpfull" CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS
+ "${CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS}")
+STRING(REPLACE "-bexpall" "-bexpfull" CMAKE_SHARED_LIBRARY_LINK_C_FLAGS
+ "${CMAKE_SHARED_LIBRARY_LINK_C_FLAGS}")
diff --git a/cmake/os/Cygwin.cmake b/cmake/os/Cygwin.cmake
new file mode 100644
index 00000000000..9c29277c626
--- /dev/null
+++ b/cmake/os/Cygwin.cmake
@@ -0,0 +1,18 @@
+# Copyright (c) 2010 Sun Microsystems, Inc.
+# Use is subject to license terms.
+#
+# 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
+
+# Cygwin is not Windows
+SET(WIN32 0) \ No newline at end of file
diff --git a/cmake/os/Darwin.cmake b/cmake/os/Darwin.cmake
new file mode 100644
index 00000000000..0d8bac106f0
--- /dev/null
+++ b/cmake/os/Darwin.cmake
@@ -0,0 +1,35 @@
+# Copyright (c) 2010 Sun Microsystems, Inc.
+# Use is subject to license terms.
+#
+# 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
+
+# This file includes OSX specific options and quirks, related to system checks
+
+# Workaround for CMake bug#9051
+# (CMake does not pass CMAKE_OSX_SYSROOT and CMAKE_OSX_DEPLOYMENT_TARGET when
+# running TRY_COMPILE)
+
+IF(CMAKE_OSX_SYSROOT)
+ SET(ENV{CMAKE_OSX_SYSROOT} ${CMAKE_OSX_SYSROOT})
+ENDIF()
+IF(CMAKE_OSX_SYSROOT)
+ SET(ENV{MACOSX_DEPLOYMENT_TARGET} ${OSX_DEPLOYMENT_TARGET})
+ENDIF()
+
+IF(CMAKE_OSX_DEPLOYMENT_TARGET)
+ # Workaround linker problems on OSX 10.4
+ IF(CMAKE_OSX_DEPLOYMENT_TARGET VERSION_LESS "10.5")
+ ADD_DEFINITIONS(-fno-common)
+ ENDIF()
+ENDIF()
diff --git a/cmake/os/FreeBSD.cmake b/cmake/os/FreeBSD.cmake
new file mode 100644
index 00000000000..e09592942c1
--- /dev/null
+++ b/cmake/os/FreeBSD.cmake
@@ -0,0 +1,24 @@
+
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+# This file includes FreeBSD specific options and quirks, related to system checks
+
+# Should not be needed any more, but kept for easy resurrection if needed
+# #Legacy option, maybe not needed anymore , taken as is from autotools build
+# ADD_DEFINITIONS(-DNET_RETRY_COUNT=1000000)
+
+# The below was used for really old versions of FreeBSD, roughly: before 5.1.9
+# ADD_DEFINITIONS(-DHAVE_BROKEN_REALPATH)
diff --git a/cmake/os/HP-UX.cmake b/cmake/os/HP-UX.cmake
new file mode 100644
index 00000000000..4cadddc7b18
--- /dev/null
+++ b/cmake/os/HP-UX.cmake
@@ -0,0 +1,48 @@
+# Copyright (c) 2010 Sun Microsystems, Inc.
+# Use is subject to license terms.
+#
+# 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
+
+INCLUDE(CheckCXXSourceCompiles)
+# Enable 64 bit file offsets
+SET(_LARGEFILE64_SOURCE 1)
+SET(_FILE_OFFSET_BITS 64)
+# If Itanium make shared library suffix .so
+# OS understands both .sl and .so. CMake would
+# use .sl, however MySQL prefers .so
+IF(NOT CMAKE_SYSTEM_PROCESSOR MATCHES "9000")
+ SET(CMAKE_SHARED_LIBRARY_SUFFIX ".so" CACHE INTERNAL "" FORCE)
+ SET(CMAKE_SHARED_MODULE_SUFFIX ".so" CACHE INTERNAL "" FORCE)
+ENDIF()
+IF(CMAKE_SYSTEM MATCHES "11")
+ ADD_DEFINITIONS(-DHPUX11)
+ENDIF()
+
+IF(CMAKE_CXX_COMPILER_ID MATCHES "HP")
+ # Enable standard C++ flags if required
+ # HP seems a bit traditional and "new" features like ANSI for-scope
+ # still require special flag to be set
+ CHECK_CXX_SOURCE_COMPILES(
+ "int main()
+ {
+ for(int i=0; i<1; i++);
+ for(int i=0; i<1; i++);
+ return 0;
+ }
+ " HAVE_ANSI_FOR_SCOPE)
+ IF(NOT HAVE_ANSI_FOR_SCOPE)
+ # Enable conformant behavior
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Aa")
+ ENDIF()
+ENDIF()
diff --git a/cmake/os/Linux.cmake b/cmake/os/Linux.cmake
new file mode 100644
index 00000000000..61361d1d48b
--- /dev/null
+++ b/cmake/os/Linux.cmake
@@ -0,0 +1,47 @@
+
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+# This file includes Linux specific options and quirks, related to system checks
+
+INCLUDE(CheckSymbolExists)
+
+# Something that needs to be set on legacy reasons
+SET(TARGET_OS_LINUX 1)
+SET(HAVE_NPTL 1)
+SET(_GNU_SOURCE 1)
+
+# Fix CMake (< 2.8) flags. -rdynamic exports too many symbols.
+FOREACH(LANG C CXX)
+ STRING(REPLACE "-rdynamic" ""
+ CMAKE_SHARED_LIBRARY_LINK_${LANG}_FLAGS
+ ${CMAKE_SHARED_LIBRARY_LINK_${LANG}_FLAGS}
+ )
+ENDFOREACH()
+
+# Ensure we have clean build for shared libraries
+# without unresolved symbols
+SET(LINK_FLAG_NO_UNDEFINED "-Wl,--no-undefined")
+
+# 64 bit file offset support flag
+SET(_FILE_OFFSET_BITS 64)
+
+# Linux specific HUGETLB /large page support
+CHECK_SYMBOL_EXISTS(SHM_HUGETLB sys/shm.h HAVE_DECL_SHM_HUGETLB)
+IF(HAVE_DECL_SHM_HUGETLB)
+ SET(HAVE_LARGE_PAGES 1)
+ SET(HUGETLB_USE_PROC_MEMINFO 1)
+ SET(HAVE_LARGE_PAGE_OPTION 1)
+ENDIF()
diff --git a/cmake/os/OS400.cmake b/cmake/os/OS400.cmake
new file mode 100644
index 00000000000..502eeccc30a
--- /dev/null
+++ b/cmake/os/OS400.cmake
@@ -0,0 +1,18 @@
+# Copyright (c) 2010 Sun Microsystems, Inc.
+# Use is subject to license terms.
+#
+# 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
+
+GET_FILENAME_COMPONENT(_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
+INCLUDE(${_SCRIPT_DIR}/AIX.cmake) \ No newline at end of file
diff --git a/cmake/os/SunOS.cmake b/cmake/os/SunOS.cmake
new file mode 100644
index 00000000000..3d2b4b8949a
--- /dev/null
+++ b/cmake/os/SunOS.cmake
@@ -0,0 +1,95 @@
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+INCLUDE(CheckSymbolExists)
+INCLUDE(CheckCSourceRuns)
+INCLUDE(CheckCSourceCompiles)
+
+# Enable 64 bit file offsets
+SET(_FILE_OFFSET_BITS 64)
+
+# Legacy option, without it my_pthread is having problems
+ADD_DEFINITIONS(-DHAVE_RWLOCK_T)
+
+# On Solaris, use of intrinsics will screw the lib search logic
+# Force using -lm, so rint etc are found.
+SET(LIBM m)
+
+# CMake defined -lthread as thread flag. This crashes in dlopen
+# when trying to load plugins workaround with -lpthread
+SET(CMAKE_THREADS_LIBS_INIT -lpthread CACHE INTERNAL "" FORCE)
+
+# Solaris specific large page support
+CHECK_SYMBOL_EXISTS(MHA_MAPSIZE_VA sys/mman.h HAVE_DECL_MHA_MAPSIZE_VA)
+IF(HAVE_DECL_MHA_MAPSIZE_VA)
+ SET(HAVE_SOLARIS_LARGE_PAGES 1)
+ SET(HAVE_LARGE_PAGE_OPTION 1)
+ENDIF()
+
+
+# Solaris atomics
+CHECK_C_SOURCE_RUNS(
+ "
+ #include <atomic.h>
+ int main()
+ {
+ int foo = -10; int bar = 10;
+ int64_t foo64 = -10; int64_t bar64 = 10;
+ if (atomic_add_int_nv((uint_t *)&foo, bar) || foo)
+ return -1;
+ bar = atomic_swap_uint((uint_t *)&foo, (uint_t)bar);
+ if (bar || foo != 10)
+ return -1;
+ bar = atomic_cas_uint((uint_t *)&bar, (uint_t)foo, 15);
+ if (bar)
+ return -1;
+ if (atomic_add_64_nv((volatile uint64_t *)&foo64, bar64) || foo64)
+ return -1;
+ bar64 = atomic_swap_64((volatile uint64_t *)&foo64, (uint64_t)bar64);
+ if (bar64 || foo64 != 10)
+ return -1;
+ bar64 = atomic_cas_64((volatile uint64_t *)&bar64, (uint_t)foo64, 15);
+ if (bar64)
+ return -1;
+ atomic_or_64((volatile uint64_t *)&bar64, 0);
+ return 0;
+ }
+" HAVE_SOLARIS_ATOMIC)
+
+
+# Check is special processor flag needs to be set on older GCC
+#that defaults to v8 sparc . Code here is taken from my_rdtsc.c
+IF(CMAKE_COMPILER_IS_GNUCC AND CMAKE_SIZEOF_VOID_P EQUAL 4
+ AND CMAKE_SYSTEM_PROCESSOR MATCHES "sparc")
+ SET(SOURCE
+ "
+ int main()
+ {
+ long high\;
+ long low\;
+ __asm __volatile__ (\"rd %%tick,%1\; srlx %1,32,%0\" : \"=r\" ( high), \"=r\" (low))\;
+ return 0\;
+ } ")
+ CHECK_C_SOURCE_COMPILES(${SOURCE} HAVE_SPARC32_TICK)
+ IF(NOT HAVE_SPARC32_TICK)
+ SET(CMAKE_REQUIRED_FLAGS "-mcpu=v9")
+ CHECK_C_SOURCE_COMPILES(${SOURCE} HAVE_SPARC32_TICK_WITH_V9)
+ SET(CMAKE_REQUIRED_FLAGS)
+ IF(HAVE_SPARC32_TICK_WITH_V9)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mcpu=v9")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=v9")
+ ENDIF()
+ ENDIF()
+ENDIF()
diff --git a/cmake/os/Windows.cmake b/cmake/os/Windows.cmake
new file mode 100644
index 00000000000..c3809d2e6c2
--- /dev/null
+++ b/cmake/os/Windows.cmake
@@ -0,0 +1,195 @@
+# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+# This file includes Windows specific hacks, mostly around compiler flags
+
+INCLUDE (CheckCSourceCompiles)
+INCLUDE (CheckCXXSourceCompiles)
+INCLUDE (CheckStructHasMember)
+INCLUDE (CheckLibraryExists)
+INCLUDE (CheckFunctionExists)
+INCLUDE (CheckCCompilerFlag)
+INCLUDE (CheckCSourceRuns)
+INCLUDE (CheckSymbolExists)
+INCLUDE (CheckTypeSize)
+
+# Optionally read user configuration, generated by configure.js.
+# This is left for backward compatibility reasons only.
+INCLUDE(${CMAKE_BINARY_DIR}/win/configure.data OPTIONAL)
+
+# avoid running system checks by using pre-cached check results
+# system checks are expensive on VS since every tiny program is to be compiled in
+# a VC solution.
+GET_FILENAME_COMPONENT(_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
+INCLUDE(${_SCRIPT_DIR}/WindowsCache.cmake)
+
+
+# OS display name (version_compile_os etc).
+# Used by the test suite to ignore bugs on some platforms,
+IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
+ SET(SYSTEM_TYPE "Win64")
+ELSE()
+ SET(SYSTEM_TYPE "Win32")
+ENDIF()
+
+# Intel compiler is almost Visual C++
+# (same compile flags etc). Set MSVC flag
+IF(CMAKE_C_COMPILER MATCHES "icl")
+ SET(MSVC TRUE)
+ENDIF()
+
+ADD_DEFINITIONS("-D_WINDOWS -D__WIN__ -D_CRT_SECURE_NO_DEPRECATE")
+ADD_DEFINITIONS("-D_WIN32_WINNT=0x0501")
+# Speed up build process excluding unused header files
+ADD_DEFINITIONS("-DWIN32_LEAN_AND_MEAN")
+
+# Adjust compiler and linker flags
+IF(MINGW AND CMAKE_SIZEOF_VOID_P EQUAL 4)
+ # mininal architecture flags, i486 enables GCC atomics
+ ADD_DEFINITIONS(-march=i486)
+ENDIF()
+
+IF(MSVC)
+ # Enable debug info also in Release build, and create PDB to be able to analyze
+ # crashes
+ FOREACH(lang C CXX)
+ SET(CMAKE_${lang}_FLAGS_RELEASE "${CMAKE_${lang}_FLAGS_RELEASE} /Zi")
+ ENDFOREACH()
+ FOREACH(type EXE SHARED MODULE)
+ SET(CMAKE_{type}_LINKER_FLAGS_RELEASE "${CMAKE_${type}_LINKER_FLAGS_RELEASE} /debug")
+ ENDFOREACH()
+
+ # Force static runtime libraries
+ FOREACH(flag
+ CMAKE_C_FLAGS_RELEASE CMAKE_C_FLAGS_RELWITHDEBINFO
+ CMAKE_C_FLAGS_DEBUG CMAKE_C_FLAGS_DEBUG_INIT
+ CMAKE_CXX_FLAGS_RELEASE CMAKE_CXX_FLAGS_RELWITHDEBINFO
+ CMAKE_CXX_FLAGS_DEBUG CMAKE_CXX_FLAGS_DEBUG_INIT)
+ STRING(REPLACE "/MD" "/MT" "${flag}" "${${flag}}")
+ ENDFOREACH()
+
+ # Remove support for exceptions
+ FOREACH(flag CMAKE_CXX_FLAGS CMAKE_CXX_FLAGS_INIT)
+ STRING(REPLACE "/EHsc" "" "${flag}" "${${flag}}")
+ ENDFOREACH()
+
+ # Fix CMake's predefined huge stack size
+ FOREACH(type EXE SHARED MODULE)
+ STRING(REGEX REPLACE "/STACK:([^ ]+)" "" CMAKE_${type}_LINKER_FLAGS "${CMAKE_${type}_LINKER_FLAGS}")
+ STRING(REGEX REPLACE "/INCREMENTAL:([^ ]+)" "" CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO "${CMAKE_${type}_LINKER_FLAGS_RELWITHDEBINFO}")
+ ENDFOREACH()
+
+ # Mark 32 bit executables large address aware so they can
+ # use > 2GB address space
+ IF(CMAKE_SIZEOF_VOID_P MATCHES 4)
+ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /LARGEADDRESSAWARE")
+ ENDIF()
+
+ # Speed up multiprocessor build
+ IF (MSVC_VERSION GREATER 1400)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /MP")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP")
+ ENDIF()
+
+ #TODO: update the code and remove the disabled warnings
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4800 /wd4805 /wd4996")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800 /wd4805 /wd4996 /we4099")
+
+
+ IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
+ # _WIN64 is defined by the compiler itself.
+ # Yet, we define it here again to work around a bug with Intellisense
+ # described here: http://tinyurl.com/2cb428.
+ # Syntax highlighting is important for proper debugger functionality.
+ ADD_DEFINITIONS("-D_WIN64")
+ ENDIF()
+ENDIF()
+
+# Always link with socket library
+LINK_LIBRARIES(ws2_32)
+# ..also for tests
+SET(CMAKE_REQUIRED_LIBRARIES ws2_32)
+
+# System checks
+SET(SIGNAL_WITH_VIO_CLOSE 1) # Something that runtime team needs
+
+# IPv6 constants appeared in Vista SDK first. We need to define them in any case if they are
+# not in headers, to handle dual mode sockets correctly.
+CHECK_SYMBOL_EXISTS(IPPROTO_IPV6 "winsock2.h" HAVE_IPPROTO_IPV6)
+IF(NOT HAVE_IPPROTO_IPV6)
+ SET(HAVE_IPPROTO_IPV6 41)
+ENDIF()
+CHECK_SYMBOL_EXISTS(IPV6_V6ONLY "winsock2.h;ws2ipdef.h" HAVE_IPV6_V6ONLY)
+IF(NOT HAVE_IPV6_V6ONLY)
+ SET(IPV6_V6ONLY 27)
+ENDIF()
+
+# Some standard functions exist there under different
+# names (e.g popen is _popen or strok_r is _strtok_s)
+# If a replacement function exists, HAVE_FUNCTION is
+# defined to 1. CMake variable <function_name> will also
+# be defined to the replacement name.
+# So for example, CHECK_FUNCTION_REPLACEMENT(popen _popen)
+# will define HAVE_POPEN to 1 and set variable named popen
+# to _popen. If the header template, one needs to have
+# cmakedefine popen @popen@ which will expand to
+# define popen _popen after CONFIGURE_FILE
+
+MACRO(CHECK_FUNCTION_REPLACEMENT function replacement)
+ STRING(TOUPPER ${function} function_upper)
+ CHECK_FUNCTION_EXISTS(${function} HAVE_${function_upper})
+ IF(NOT HAVE_${function_upper})
+ CHECK_FUNCTION_EXISTS(${replacement} HAVE_${replacement})
+ IF(HAVE_${replacement})
+ SET(HAVE_${function_upper} 1 )
+ SET(${function} ${replacement})
+ ENDIF()
+ ENDIF()
+ENDMACRO()
+MACRO(CHECK_SYMBOL_REPLACEMENT symbol replacement header)
+ STRING(TOUPPER ${symbol} symbol_upper)
+ CHECK_SYMBOL_EXISTS(${symbol} ${header} HAVE_${symbol_upper})
+ IF(NOT HAVE_${symbol_upper})
+ CHECK_SYMBOL_EXISTS(${replacement} ${header} HAVE_${replacement})
+ IF(HAVE_${replacement})
+ SET(HAVE_${symbol_upper} 1)
+ SET(${symbol} ${replacement})
+ ENDIF()
+ ENDIF()
+ENDMACRO()
+
+CHECK_SYMBOL_REPLACEMENT(S_IROTH _S_IREAD sys/stat.h)
+CHECK_SYMBOL_REPLACEMENT(S_IFIFO _S_IFIFO sys/stat.h)
+CHECK_SYMBOL_REPLACEMENT(SIGQUIT SIGTERM signal.h)
+CHECK_SYMBOL_REPLACEMENT(SIGPIPE SIGINT signal.h)
+CHECK_SYMBOL_REPLACEMENT(isnan _isnan float.h)
+CHECK_SYMBOL_REPLACEMENT(finite _finite float.h)
+CHECK_FUNCTION_REPLACEMENT(popen _popen)
+CHECK_FUNCTION_REPLACEMENT(pclose _pclose)
+CHECK_FUNCTION_REPLACEMENT(access _access)
+CHECK_FUNCTION_REPLACEMENT(strcasecmp _stricmp)
+CHECK_FUNCTION_REPLACEMENT(strncasecmp _strnicmp)
+CHECK_FUNCTION_REPLACEMENT(snprintf _snprintf)
+CHECK_FUNCTION_REPLACEMENT(strtok_r strtok_s)
+CHECK_FUNCTION_REPLACEMENT(strtoll _strtoi64)
+CHECK_FUNCTION_REPLACEMENT(strtoull _strtoui64)
+CHECK_FUNCTION_REPLACEMENT(vsnprintf _vsnprintf)
+CHECK_TYPE_SIZE(ssize_t SIZE_OF_SSIZE_T)
+IF(NOT HAVE_SIZE_OF_SSIZE_T)
+ SET(ssize_t SSIZE_T)
+ENDIF()
+
+SET(FN_NO_CASE_SENSE 1)
+SET(USE_SYMDIR 1)
diff --git a/cmake/os/WindowsCache.cmake b/cmake/os/WindowsCache.cmake
new file mode 100644
index 00000000000..897012896c8
--- /dev/null
+++ b/cmake/os/WindowsCache.cmake
@@ -0,0 +1,358 @@
+# Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+# Avoid system checks on Windows by pre-caching results. Most of the system checks
+# are not relevant for Windows anyway and it takes lot more time to run them,
+# since CMake to creates a Visual Studio project for each tiny test.
+# Note that only we cache values on VC++ only, MinGW would give slightly
+# different results.
+
+IF(MSVC)
+SET(HAVE_ACCESS 1 CACHE INTERNAL "")
+SET(HAVE_AIO_H CACHE INTERNAL "")
+SET(HAVE_AIO_READ CACHE INTERNAL "")
+SET(HAVE_ALARM CACHE INTERNAL "")
+SET(HAVE_ALLOCA_H CACHE INTERNAL "")
+SET(HAVE_ARPA_INET_H CACHE INTERNAL "")
+SET(HAVE_ASM_MSR_H CACHE INTERNAL "")
+SET(HAVE_BACKTRACE CACHE INTERNAL "")
+SET(HAVE_BACKTRACE_SYMBOLS CACHE INTERNAL "")
+SET(HAVE_BACKTRACE_SYMBOLS_FD CACHE INTERNAL "")
+SET(HAVE_BFILL CACHE INTERNAL "")
+SET(HAVE_BMOVE CACHE INTERNAL "")
+SET(HAVE_BSD_SIGNALS CACHE INTERNAL "")
+SET(HAVE_BSEARCH 1 CACHE INTERNAL "")
+SET(HAVE_BSS_START CACHE INTERNAL "")
+SET(HAVE_BZERO CACHE INTERNAL "")
+SET(HAVE_CHOWN CACHE INTERNAL "")
+SET(HAVE_CLOCK_GETTIME CACHE INTERNAL "")
+SET(HAVE_COMPRESS CACHE INTERNAL "")
+SET(HAVE_CRYPT CACHE INTERNAL "")
+SET(HAVE_CRYPT_H CACHE INTERNAL "")
+SET(HAVE_CUSERID CACHE INTERNAL "")
+SET(HAVE_CXX_NEW 1 CACHE INTERNAL "")
+SET(HAVE_DECL_MADVISE CACHE INTERNAL "")
+SET(HAVE_DIRECTIO CACHE INTERNAL "")
+SET(HAVE_DIRENT_H CACHE INTERNAL "")
+SET(HAVE_DLERROR CACHE INTERNAL "")
+SET(HAVE_DLFCN_H CACHE INTERNAL "")
+SET(HAVE_DLOPEN CACHE INTERNAL "")
+SET(HAVE_DOPRNT CACHE INTERNAL "")
+SET(HAVE_EXECINFO_H CACHE INTERNAL "")
+SET(HAVE_FCHMOD CACHE INTERNAL "")
+SET(HAVE_FCNTL CACHE INTERNAL "")
+SET(HAVE_FCNTL_H 1 CACHE INTERNAL "")
+SET(HAVE_FCNTL_NONBLOCK CACHE INTERNAL "")
+SET(HAVE_FCONVERT CACHE INTERNAL "")
+SET(HAVE_FDATASYNC CACHE INTERNAL "")
+SET(HAVE_DECL_FDATASYNC CACHE INTERNAL "")
+SET(HAVE_FENV_H CACHE INTERNAL "")
+SET(HAVE_FESETROUND CACHE INTERNAL "")
+SET(HAVE_FGETLN CACHE INTERNAL "")
+SET(HAVE_FINITE CACHE INTERNAL "")
+SET(HAVE_FINITE_IN_MATH_H CACHE INTERNAL "")
+SET(HAVE_FLOATINGPOINT_H CACHE INTERNAL "")
+SET(HAVE_FLOAT_H 1 CACHE INTERNAL "")
+SET(HAVE_FLOCKFILE CACHE INTERNAL "")
+SET(HAVE_FNMATCH_H CACHE INTERNAL "")
+SET(HAVE_FPSETMASK CACHE INTERNAL "")
+SET(HAVE_FPU_CONTROL_H CACHE INTERNAL "")
+SET(HAVE_FSEEKO CACHE INTERNAL "")
+SET(HAVE_FSYNC CACHE INTERNAL "")
+SET(HAVE_FTIME 1 CACHE INTERNAL "")
+SET(HAVE_FTRUNCATE CACHE INTERNAL "")
+SET(HAVE_GETADDRINFO 1 CACHE INTERNAL "")
+SET(HAVE_GETCWD 1 CACHE INTERNAL "")
+SET(HAVE_GETHOSTBYADDR_R CACHE INTERNAL "")
+SET(HAVE_GETHRTIME CACHE INTERNAL "")
+SET(HAVE_GETLINE CACHE INTERNAL "")
+SET(HAVE_GETNAMEINFO CACHE INTERNAL "")
+SET(HAVE_GETPAGESIZE CACHE INTERNAL "")
+SET(HAVE_GETPASS CACHE INTERNAL "")
+SET(HAVE_GETPASSPHRASE CACHE INTERNAL "")
+SET(HAVE_GETPWNAM CACHE INTERNAL "")
+SET(HAVE_GETPWUID CACHE INTERNAL "")
+SET(HAVE_GETRLIMIT CACHE INTERNAL "")
+SET(HAVE_GETRUSAGE CACHE INTERNAL "")
+SET(HAVE_GETTIMEOFDAY CACHE INTERNAL "")
+SET(HAVE_GETWD CACHE INTERNAL "")
+SET(HAVE_GMTIME_R CACHE INTERNAL "")
+SET(HAVE_GRP_H CACHE INTERNAL "")
+SET(HAVE_IA64INTRIN_H CACHE INTERNAL "")
+SET(HAVE_IEEEFP_H CACHE INTERNAL "")
+SET(HAVE_INDEX CACHE INTERNAL "")
+SET(HAVE_INITGROUPS CACHE INTERNAL "")
+SET(HAVE_INTTYPES_H CACHE INTERNAL "")
+SET(HAVE_IPPROTO_IPV6 CACHE INTERNAL "")
+SET(HAVE_IPV6 TRUE CACHE INTERNAL "")
+SET(HAVE_IPV6_V6ONLY 1 CACHE INTERNAL "")
+SET(HAVE_ISINF CACHE INTERNAL "")
+SET(HAVE_ISNAN CACHE INTERNAL "")
+SET(HAVE_ISSETUGID CACHE INTERNAL "")
+SET(HAVE_GETUID CACHE INTERNAL "")
+SET(HAVE_GETEUID CACHE INTERNAL "")
+SET(HAVE_GETGID CACHE INTERNAL "")
+SET(HAVE_GETEGID CACHE INTERNAL "")
+SET(HAVE_LANGINFO_H CACHE INTERNAL "")
+SET(HAVE_LDIV 1 CACHE INTERNAL "")
+SET(HAVE_LIMITS_H 1 CACHE INTERNAL "")
+SET(HAVE_LOCALE_H 1 CACHE INTERNAL "")
+SET(HAVE_LOCALTIME_R CACHE INTERNAL "")
+SET(HAVE_LOG2 CACHE INTERNAL "")
+SET(HAVE_LONGJMP 1 CACHE INTERNAL "")
+SET(HAVE_LRAND48 CACHE INTERNAL "")
+SET(HAVE_LSTAT CACHE INTERNAL "")
+SET(HAVE_MADVISE CACHE INTERNAL "")
+SET(HAVE_MALLINFO CACHE INTERNAL "")
+SET(HAVE_MALLOC_H 1 CACHE INTERNAL "")
+SET(HAVE_MEMALIGN CACHE INTERNAL "")
+SET(HAVE_MEMCPY 1 CACHE INTERNAL "")
+SET(HAVE_MEMMOVE 1 CACHE INTERNAL "")
+SET(HAVE_MEMORY_H 1 CACHE INTERNAL "")
+SET(HAVE_MKSTEMP CACHE INTERNAL "")
+SET(HAVE_MLOCK CACHE INTERNAL "")
+SET(HAVE_MLOCKALL CACHE INTERNAL "")
+SET(HAVE_MMAP CACHE INTERNAL "")
+SET(HAVE_MMAP64 CACHE INTERNAL "")
+SET(HAVE_NETINET_IN6_H CACHE INTERNAL "")
+SET(HAVE_NETINET_IN_H CACHE INTERNAL "")
+SET(HAVE_NL_LANGINFO CACHE INTERNAL "")
+SET(HAVE_PASE_ENVIRONMENT CACHE INTERNAL "")
+SET(HAVE_PATHS_H CACHE INTERNAL "")
+SET(HAVE_PCLOSE CACHE INTERNAL "")
+SET(HAVE_PERROR 1 CACHE INTERNAL "")
+SET(HAVE_PEERCRED CACHE INTERNAL "")
+SET(HAVE_POLL_H CACHE INTERNAL "")
+SET(HAVE_POPEN CACHE INTERNAL "")
+SET(HAVE_POLL CACHE INTERNAL "")
+SET(HAVE_PORT_CREATE CACHE INTERNAL "")
+SET(HAVE_PORT_H CACHE INTERNAL "")
+SET(HAVE_POSIX_FALLOCATE CACHE INTERNAL "")
+SET(HAVE_POSIX_SIGNALS CACHE INTERNAL "")
+SET(HAVE_PREAD CACHE INTERNAL "")
+SET(HAVE_PRINTSTACK CACHE INTERNAL "")
+SET(HAVE_PTHREAD_ATTR_CREATE CACHE INTERNAL "")
+SET(HAVE_PTHREAD_ATTR_GETSTACKSIZE CACHE INTERNAL "")
+SET(HAVE_PTHREAD_ATTR_SETSCOPE CACHE INTERNAL "")
+SET(HAVE_PTHREAD_ATTR_SETSTACKSIZE CACHE INTERNAL "")
+SET(HAVE_PTHREAD_CONDATTR_CREATE CACHE INTERNAL "")
+SET(HAVE_PTHREAD_CONDATTR_SETCLOCK CACHE INTERNAL "")
+SET(HAVE_PTHREAD_INIT CACHE INTERNAL "")
+SET(HAVE_PTHREAD_KEY_DELETE CACHE INTERNAL "")
+SET(HAVE_PTHREAD_RWLOCK_RDLOCK CACHE INTERNAL "")
+SET(HAVE_PTHREAD_SIGMASK CACHE INTERNAL "")
+SET(HAVE_PTHREAD_THREADMASK CACHE INTERNAL "")
+SET(HAVE_PTHREAD_YIELD_NP CACHE INTERNAL "")
+SET(HAVE_PTHREAD_YIELD_ZERO_ARG CACHE INTERNAL "")
+SET(HAVE_PUTENV 1 CACHE INTERNAL "")
+SET(HAVE_PWD_H CACHE INTERNAL "")
+SET(HAVE_RDTSCLL CACHE INTERNAL "")
+SET(HAVE_READDIR_R CACHE INTERNAL "")
+SET(HAVE_READLINK CACHE INTERNAL "")
+SET(HAVE_READ_REAL_TIME CACHE INTERNAL "")
+SET(HAVE_REALPATH CACHE INTERNAL "")
+SET(HAVE_REGCOMP CACHE INTERNAL "")
+SET(HAVE_RENAME 1 CACHE INTERNAL "")
+SET(HAVE_RE_COMP CACHE INTERNAL "")
+SET(HAVE_RINT CACHE INTERNAL "")
+SET(HAVE_RWLOCK_INIT CACHE INTERNAL "")
+SET(HAVE_SCHED_H CACHE INTERNAL "")
+SET(HAVE_SCHED_YIELD CACHE INTERNAL "")
+SET(HAVE_SELECT 1 CACHE INTERNAL "")
+SET(HAVE_SELECT_H CACHE INTERNAL "")
+SET(HAVE_SEMAPHORE_H CACHE INTERNAL "")
+SET(HAVE_SETENV CACHE INTERNAL "")
+SET(HAVE_SETFD CACHE INTERNAL "")
+SET(HAVE_SETLOCALE 1 CACHE INTERNAL "")
+SET(HAVE_SHMAT CACHE INTERNAL "")
+SET(HAVE_SHMCTL CACHE INTERNAL "")
+SET(HAVE_SHMDT CACHE INTERNAL "")
+SET(HAVE_SHMGET CACHE INTERNAL "")
+SET(HAVE_SIGACTION CACHE INTERNAL "")
+SET(HAVE_SIGADDSET CACHE INTERNAL "")
+SET(HAVE_SIGEMPTYSET CACHE INTERNAL "")
+SET(HAVE_SIGHOLD CACHE INTERNAL "")
+SET(HAVE_SIGINT 1 CACHE INTERNAL "")
+SET(HAVE_SIGPIPE CACHE INTERNAL "")
+SET(HAVE_SIGQUIT CACHE INTERNAL "")
+SET(HAVE_SIGSET CACHE INTERNAL "")
+SET(HAVE_SIGTERM 1 CACHE INTERNAL "")
+SET(HAVE_SIGTHREADMASK CACHE INTERNAL "")
+SET(HAVE_SIGWAIT CACHE INTERNAL "")
+SET(HAVE_SIZEOF_BOOL FALSE CACHE INTERNAL "")
+SET(HAVE_SIZEOF_CHAR TRUE CACHE INTERNAL "")
+SET(SIZEOF_CHAR 1 CACHE INTERNAL "")
+SET(HAVE_SIZEOF_CHARP TRUE CACHE INTERNAL "")
+SET(SIZEOF_CHARP ${CMAKE_SIZEOF_VOID_P} CACHE INTERNAL "")
+SET(HAVE_SIZEOF_IN6_ADDR TRUE CACHE INTERNAL "")
+SET(HAVE_SIZEOF_INT TRUE CACHE INTERNAL "")
+SET(SIZEOF_INT 4 CACHE INTERNAL "")
+SET(HAVE_SIZEOF_INT16 FALSE CACHE INTERNAL "")
+SET(HAVE_SIZEOF_INT32 FALSE CACHE INTERNAL "")
+SET(HAVE_SIZEOF_INT64 FALSE CACHE INTERNAL "")
+SET(HAVE_SIZEOF_INT8 FALSE CACHE INTERNAL "")
+SET(HAVE_SIZEOF_LONG TRUE CACHE INTERNAL "")
+SET(SIZEOF_LONG 4 CACHE INTERNAL "")
+SET(HAVE_SIZEOF_LONG_LONG TRUE CACHE INTERNAL "")
+SET(SIZEOF_LONG_LONG 8 CACHE INTERNAL "")
+SET(HAVE_SIZEOF_MODE_T FALSE CACHE INTERNAL "")
+SET(HAVE_SIZEOF_OFF_T TRUE CACHE INTERNAL "")
+SET(SIZEOF_OFF_T 4 CACHE INTERNAL "")
+SET(HAVE_SIZEOF_SHORT TRUE CACHE INTERNAL "")
+SET(SIZEOF_SHORT 2 CACHE INTERNAL "")
+SET(HAVE_SIZEOF_SIGSET_T FALSE CACHE INTERNAL "")
+SET(HAVE_SIZEOF_SIZE_T TRUE CACHE INTERNAL "")
+SET(SIZEOF_SIZE_T ${CMAKE_SIZEOF_VOID_P} CACHE INTERNAL "")
+SET(HAVE_SIZEOF_SOCKADDR_IN6 TRUE CACHE INTERNAL "")
+SET(HAVE_SIZEOF_SOCKLEN_T FALSE CACHE INTERNAL "")
+SET(HAVE_SIZEOF_UCHAR FALSE CACHE INTERNAL "")
+SET(HAVE_SIZEOF_UINT FALSE CACHE INTERNAL "")
+SET(HAVE_SIZEOF_UINT16 FALSE CACHE INTERNAL "")
+SET(HAVE_SIZEOF_UINT32 FALSE CACHE INTERNAL "")
+SET(HAVE_SIZEOF_UINT64 FALSE CACHE INTERNAL "")
+SET(HAVE_SIZEOF_UINT8 FALSE CACHE INTERNAL "")
+SET(HAVE_SIZEOF_ULONG FALSE CACHE INTERNAL "")
+SET(HAVE_SIZEOF_U_INT32_T FALSE CACHE INTERNAL "")
+SET(HAVE_SIZE_OF_SSIZE_T FALSE CACHE INTERNAL "")
+SET(HAVE_SLEEP CACHE INTERNAL "")
+SET(HAVE_SNPRINTF CACHE INTERNAL "")
+SET(HAVE_SOCKADDR_STORAGE_SS_FAMILY 1 CACHE INTERNAL "")
+SET(HAVE_SOLARIS_STYLE_GETHOST CACHE INTERNAL "")
+SET(STACK_DIRECTION -1 CACHE INTERNAL "")
+SET(HAVE_STDARG_H 1 CACHE INTERNAL "")
+SET(HAVE_STDDEF_H 1 CACHE INTERNAL "")
+SET(HAVE_STDINT_H CACHE INTERNAL "")
+SET(HAVE_STDLIB_H 1 CACHE INTERNAL "")
+SET(HAVE_STPCPY CACHE INTERNAL "")
+SET(HAVE_STRCASECMP CACHE INTERNAL "")
+SET(HAVE_STRCOLL 1 CACHE INTERNAL "")
+SET(HAVE_STRDUP 1 CACHE INTERNAL "")
+SET(HAVE_STRERROR 1 CACHE INTERNAL "")
+SET(HAVE_STRINGS_H CACHE INTERNAL "")
+SET(HAVE_STRING_H 1 CACHE INTERNAL "")
+SET(HAVE_STRLCAT CACHE INTERNAL "")
+SET(HAVE_STRLCPY CACHE INTERNAL "")
+SET(HAVE_STRNCASECMP CACHE INTERNAL "")
+IF(MSVC_VERSION GREATER 1310)
+SET(HAVE_STRNLEN 1 CACHE INTERNAL "")
+ENDIF()
+SET(HAVE_STRPBRK 1 CACHE INTERNAL "")
+SET(HAVE_STRSEP CACHE INTERNAL "")
+SET(HAVE_STRSIGNAL CACHE INTERNAL "")
+SET(HAVE_STRSTR 1 CACHE INTERNAL "")
+SET(HAVE_STRTOK_R CACHE INTERNAL "")
+SET(HAVE_STRTOL 1 CACHE INTERNAL "")
+SET(HAVE_STRTOLL CACHE INTERNAL "")
+SET(HAVE_STRTOUL 1 CACHE INTERNAL "")
+SET(HAVE_STRTOULL CACHE INTERNAL "")
+SET(HAVE_SVR3_SIGNALS CACHE INTERNAL "")
+SET(HAVE_SYNCH_H CACHE INTERNAL "")
+SET(HAVE_SYSENT_H CACHE INTERNAL "")
+SET(HAVE_SYS_CDEFS_H CACHE INTERNAL "")
+SET(HAVE_SYS_DIR_H CACHE INTERNAL "")
+SET(HAVE_SYS_ERRLIST CACHE INTERNAL "")
+SET(HAVE_SYS_FILE_H CACHE INTERNAL "")
+SET(HAVE_SYS_FPU_H CACHE INTERNAL "")
+SET(HAVE_SYS_IOCTL_H CACHE INTERNAL "")
+SET(HAVE_SYS_IPC_H CACHE INTERNAL "")
+SET(HAVE_SYS_MALLOC_H CACHE INTERNAL "")
+SET(HAVE_SYS_MMAN_H CACHE INTERNAL "")
+SET(HAVE_SYS_PARAM_H CACHE INTERNAL "")
+SET(HAVE_SYS_PRCTL_H CACHE INTERNAL "")
+SET(HAVE_SYS_PTEM_H CACHE INTERNAL "")
+SET(HAVE_SYS_PTE_H CACHE INTERNAL "")
+SET(HAVE_SYS_RESOURCE_H CACHE INTERNAL "")
+SET(HAVE_SYS_SELECT_H CACHE INTERNAL "")
+SET(HAVE_SYS_SHM_H CACHE INTERNAL "")
+SET(HAVE_SYS_SOCKET_H CACHE INTERNAL "")
+SET(HAVE_SYS_STAT_H 1 CACHE INTERNAL "")
+SET(HAVE_SYS_STREAM_H CACHE INTERNAL "")
+SET(HAVE_SYS_TERMCAP_H CACHE INTERNAL "")
+SET(HAVE_SYS_TIMEB_H 1 CACHE INTERNAL "")
+SET(HAVE_SYS_TIMES_H CACHE INTERNAL "")
+SET(HAVE_SYS_TIME_H CACHE INTERNAL "")
+SET(HAVE_SYS_TYPES_H 1 CACHE INTERNAL "")
+SET(HAVE_SYS_UN_H CACHE INTERNAL "")
+SET(HAVE_SYS_UTIME_H 1 CACHE INTERNAL "")
+SET(HAVE_SYS_VADVISE_H CACHE INTERNAL "")
+SET(HAVE_SYS_WAIT_H CACHE INTERNAL "")
+SET(HAVE_TCGETATTR CACHE INTERNAL "")
+SET(HAVE_TELL 1 CACHE INTERNAL "")
+SET(HAVE_TEMPNAM 1 CACHE INTERNAL "")
+SET(HAVE_TERMCAP_H CACHE INTERNAL "")
+SET(HAVE_TERMIOS_H CACHE INTERNAL "")
+SET(HAVE_TERMIO_H CACHE INTERNAL "")
+SET(HAVE_TERM_H CACHE INTERNAL "")
+SET(HAVE_THR_SETCONCURRENCY CACHE INTERNAL "")
+SET(HAVE_THR_YIELD CACHE INTERNAL "")
+SET(HAVE_TIME 1 CACHE INTERNAL "")
+SET(HAVE_TIMES CACHE INTERNAL "")
+SET(HAVE_TIMESPEC_TS_SEC CACHE INTERNAL "")
+SET(HAVE_TIME_H 1 CACHE INTERNAL "")
+SET(HAVE_TZNAME 1 CACHE INTERNAL "")
+SET(HAVE_UNISTD_H CACHE INTERNAL "")
+SET(HAVE_UTIME_H CACHE INTERNAL "")
+SET(HAVE_VALLOC CACHE INTERNAL "")
+SET(HAVE_VARARGS_H 1 CACHE INTERNAL "")
+SET(HAVE_VASPRINTF CACHE INTERNAL "")
+SET(HAVE_VPRINTF 1 CACHE INTERNAL "")
+IF(MSVC_VERSION GREATER 1310)
+SET(HAVE_VSNPRINTF 1 CACHE INTERNAL "")
+ENDIF()
+SET(HAVE_WEAK_SYMBOL CACHE INTERNAL "")
+SET(HAVE_WORDS_BIGENDIAN TRUE CACHE INTERNAL "")
+SET(WORDS_BIGENDIAN CACHE INTERNAL "")
+SET(HAVE__S_IFIFO 1 CACHE INTERNAL "")
+SET(HAVE__S_IREAD 1 CACHE INTERNAL "")
+SET(HAVE__finite 1 CACHE INTERNAL "")
+SET(HAVE__isnan 1 CACHE INTERNAL "")
+SET(HAVE__pclose 1 CACHE INTERNAL "")
+SET(HAVE__popen 1 CACHE INTERNAL "")
+SET(HAVE__snprintf 1 CACHE INTERNAL "")
+SET(HAVE__stricmp 1 CACHE INTERNAL "")
+SET(HAVE__strnicmp 1 CACHE INTERNAL "")
+SET(HAVE__strtoi64 1 CACHE INTERNAL "")
+SET(HAVE__strtoui64 1 CACHE INTERNAL "")
+IF(MSVC_VERSION GREATER 1310)
+ SET(HAVE_strtok_s 1 CACHE INTERNAL "")
+ENDIF()
+SET(STDC_HEADERS CACHE 1 INTERNAL "")
+SET(STRUCT_DIRENT_HAS_D_INO CACHE INTERNAL "")
+SET(STRUCT_DIRENT_HAS_D_INO CACHE INTERNAL "")
+SET(STRUCT_DIRENT_HAS_D_NAMLEN CACHE INTERNAL "")
+SET(TIME_WITH_SYS_TIME CACHE INTERNAL "")
+SET(TIOCSTAT_IN_SYS_IOCTL CACHE INTERNAL "")
+SET(HAVE_S_IROTH CACHE INTERNAL "")
+SET(HAVE_S_IFIFO CACHE INTERNAL "")
+SET(QSORT_TYPE_IS_VOID 1 CACHE INTERNAL "")
+SET(SIGNAL_RETURN_TYPE_IS_VOID 1 CACHE INTERNAL "")
+SET(C_HAS_inline CACHE INTERNAL "")
+SET(C_HAS___inline 1 CACHE INTERNAL "")
+SET(FIONREAD_IN_SYS_IOCTL CACHE INTERNAL "")
+SET(FIONREAD_IN_SYS_FILIO CACHE INTERNAL "")
+SET(GWINSZ_IN_SYS_IOCTL CACHE INTERNAL "")
+SET(HAVE_CXXABI_H CACHE INTERNAL "")
+SET(HAVE_NDIR_H CACHE INTERNAL "")
+SET(HAVE_SYS_NDIR_H CACHE INTERNAL "")
+SET(HAVE_SYS_NDIR_H CACHE INTERNAL "")
+SET(HAVE_ASM_TERMBITS_H CACHE INTERNAL "")
+SET(HAVE_TERMBITS_H CACHE INTERNAL "")
+SET(HAVE_VIS_H CACHE INTERNAL "")
+SET(HAVE_WCHAR_H 1 CACHE INTERNAL "")
+SET(HAVE_WCTYPE_H 1 CACHE INTERNAL "")
+SET(HAVE_PTHREAD_RWLOCKATTR_SETKIND_NP CACHE INTERNAL "")
+SET(HAVE_SOCKADDR_IN_SIN_LEN CACHE INTERNAL "")
+SET(HAVE_SOCKADDR_IN6_SIN6_LEN CACHE INTERNAL "")
+ENDIF()
diff --git a/cmake/package_name.cmake b/cmake/package_name.cmake
new file mode 100644
index 00000000000..fb75df563ec
--- /dev/null
+++ b/cmake/package_name.cmake
@@ -0,0 +1,127 @@
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+# Produce meaningful package name for the binary package
+# The logic is rather involved with special cases for different OSes
+INCLUDE(CheckTypeSize)
+CHECK_TYPE_SIZE("void *" SIZEOF_VOIDP)
+MACRO(GET_PACKAGE_FILE_NAME Var)
+IF(NOT VERSION)
+ MESSAGE(FATAL_ERROR
+ "Variable VERSION needs to be set prior to calling GET_PACKAGE_FILE_NAME")
+ ENDIF()
+ IF(NOT SYSTEM_NAME_AND_PROCESSOR)
+ SET(NEED_DASH_BETWEEN_PLATFORM_AND_MACHINE 1)
+ SET(DEFAULT_PLATFORM ${CMAKE_SYSTEM_NAME})
+ SET(DEFAULT_MACHINE ${CMAKE_SYSTEM_PROCESSOR})
+ IF(SIZEOF_VOIDP EQUAL 8)
+ SET(64BIT 1)
+ ENDIF()
+
+ IF(CMAKE_SYSTEM_NAME MATCHES "Windows")
+ SET(NEED_DASH_BETWEEN_PLATFORM_AND_MACHINE 0)
+ SET(DEFAULT_PLATFORM "win")
+ IF(64BIT)
+ SET(DEFAULT_MACHINE "x64")
+ ELSE()
+ SET(DEFAULT_MACHINE "32")
+ ENDIF()
+ ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ IF(NOT 64BIT AND CMAKE_SYSTEM_PROCESSOR MATCHES "x86_64")
+ SET(DEFAULT_MACHINE "i686")
+ ENDIF()
+ ELSEIF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
+ # SunOS 5.10=> solaris10
+ STRING(REPLACE "5." "" VER "${CMAKE_SYSTEM_VERSION}")
+ SET(DEFAULT_PLATFORM "solaris${VER}")
+ IF(64BIT)
+ IF(CMAKE_SYSTEM_PROCESSOR MATCHES "i386")
+ SET(DEFAULT_MACHINE "x86_64")
+ ELSE()
+ SET(DEFAULT_MACHINE "${CMAKE_SYSTEM_PROCESSOR}-64bit")
+ ENDIF()
+ ENDIF()
+ ELSEIF(CMAKE_SYSTEM_NAME MATCHES "HP-UX")
+ STRING(REPLACE "B." "" VER "${CMAKE_SYSTEM_VERSION}")
+ SET(DEFAULT_PLATFORM "hpux${VER}")
+ IF(64BIT)
+ SET(DEFAULT_MACHINE "${CMAKE_SYSTEM_PROCESSOR}-64bit")
+ ENDIF()
+ ELSEIF(CMAKE_SYSTEM_NAME MATCHES "AIX")
+ SET(DEFAULT_PLATFORM "${CMAKE_SYSTEM_NAME}5.${CMAKE_SYSTEM_VERSION}")
+ IF(64BIT)
+ SET(DEFAULT_MACHINE "${CMAKE_SYSTEM_PROCESSOR}-64bit")
+ ENDIF()
+ ELSEIF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ STRING(REGEX MATCH "[0-9]+\\.[0-9]+" VER "${CMAKE_SYSTEM_VERSION}")
+ SET(DEFAULT_PLATFORM "${CMAKE_SYSTEM_NAME}${VER}")
+ IF(CMAKE_SYSTEM_PROCESSOR MATCHES "amd64")
+ SET(DEFAULT_MACHINE "x86_64")
+ IF(NOT 64BIT)
+ SET(DEFAULT_MACHINE "i386")
+ ENDIF()
+ ENDIF()
+ ELSEIF(CMAKE_SYSTEM_NAME MATCHES "Darwin")
+ IF(CMAKE_OSX_DEPLOYMENT_TARGET)
+ SET(DEFAULT_PLATFORM "osx${CMAKE_OSX_DEPLOYMENT_TARGET}")
+ ELSE()
+ SET(VER "${CMAKE_SYSTEM_VERSION}")
+ STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+" "\\1" VER "${VER}")
+ # Subtract 4 from Darwin version to get correct osx10.X
+ MATH(EXPR VER "${VER} -4")
+ SET(DEFAULT_PLATFORM "osx10.${VER}")
+ ENDIF()
+ LIST(LENGTH CMAKE_OSX_ARCHITECTURES LEN)
+ IF(LEN GREATER 1)
+ SET(DEFAULT_MACHINE "universal")
+ ELSE()
+ SET(DEFAULT_MACHINE "${CMAKE_OSX_ARCHITECTURES}")
+ ENDIF()
+ IF(DEFAULT_MACHINE MATCHES "i386")
+ SET(DEFAULT_MACHINE "x86")
+ ENDIF()
+ ENDIF()
+
+ IF(NOT PLATFORM)
+ SET(PLATFORM ${DEFAULT_PLATFORM})
+ ENDIF()
+ IF(NOT MACHINE)
+ SET(MACHINE ${DEFAULT_MACHINE})
+ ENDIF()
+
+ IF(NEED_DASH_BETWEEN_PLATFORM_AND_MACHINE)
+ SET(SYSTEM_NAME_AND_PROCESSOR "${PLATFORM}-${MACHINE}")
+ ELSE()
+ SET(SYSTEM_NAME_AND_PROCESSOR "${PLATFORM}${MACHINE}")
+ ENDIF()
+ ENDIF()
+
+ IF(SHORT_PRODUCT_TAG)
+ SET(PRODUCT_TAG "-${SHORT_PRODUCT_TAG}")
+ ELSEIF(MYSQL_SERVER_SUFFIX)
+ SET(PRODUCT_TAG "${MYSQL_SERVER_SUFFIX}") # Already has a leading dash
+ ELSE()
+ SET(PRODUCT_TAG)
+ ENDIF()
+
+ SET(package_name "mysql${PRODUCT_TAG}-${VERSION}-${SYSTEM_NAME_AND_PROCESSOR}")
+
+ # Sometimes package suffix is added (something like "-icc-glibc23")
+ IF(PACKAGE_SUFFIX)
+ SET(package_name "${package_name}${PACKAGE_SUFFIX}")
+ ENDIF()
+ STRING(TOLOWER ${package_name} package_name)
+ SET(${Var} ${package_name})
+ENDMACRO()
diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake
new file mode 100644
index 00000000000..6f534568a2d
--- /dev/null
+++ b/cmake/plugin.cmake
@@ -0,0 +1,237 @@
+# Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+
+GET_FILENAME_COMPONENT(MYSQL_CMAKE_SCRIPT_DIR ${CMAKE_CURRENT_LIST_FILE} PATH)
+INCLUDE(${MYSQL_CMAKE_SCRIPT_DIR}/cmake_parse_arguments.cmake)
+
+# MYSQL_ADD_PLUGIN(plugin_name source1...sourceN
+# [STORAGE_ENGINE]
+# [MANDATORY|DEFAULT]
+# [STATIC_ONLY|DYNAMIC_ONLY]
+# [MODULE_OUTPUT_NAME module_name]
+# [STATIC_OUTPUT_NAME static_name]
+# [RECOMPILE_FOR_EMBEDDED]
+# [LINK_LIBRARIES lib1...libN]
+# [DEPENDENCIES target1...targetN]
+
+# Append collections files for the plugin to the common files
+# Make sure we don't copy twice if running cmake again
+
+MACRO(PLUGIN_APPEND_COLLECTIONS plugin)
+ SET(fcopied "${CMAKE_CURRENT_SOURCE_DIR}/tests/collections/FilesCopied")
+ IF(NOT EXISTS ${fcopied})
+ FILE(GLOB collections ${CMAKE_CURRENT_SOURCE_DIR}/tests/collections/*)
+ FOREACH(cfile ${collections})
+ FILE(READ ${cfile} contents)
+ GET_FILENAME_COMPONENT(fname ${cfile} NAME)
+ FILE(APPEND ${CMAKE_SOURCE_DIR}/mysql-test/collections/${fname} "${contents}")
+ FILE(APPEND ${fcopied} "${fname}\n")
+ ENDFOREACH()
+ ENDIF()
+ENDMACRO()
+
+MACRO(MYSQL_ADD_PLUGIN)
+ MYSQL_PARSE_ARGUMENTS(ARG
+ "LINK_LIBRARIES;DEPENDENCIES;MODULE_OUTPUT_NAME;STATIC_OUTPUT_NAME"
+ "STORAGE_ENGINE;STATIC_ONLY;MODULE_ONLY;MANDATORY;DEFAULT;DISABLED;RECOMPILE_FOR_EMBEDDED"
+ ${ARGN}
+ )
+
+ # Add common include directories
+ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_SOURCE_DIR}/sql
+ ${CMAKE_SOURCE_DIR}/regex
+ ${SSL_INCLUDE_DIRS}
+ ${ZLIB_INCLUDE_DIR})
+
+ LIST(GET ARG_DEFAULT_ARGS 0 plugin)
+ SET(SOURCES ${ARG_DEFAULT_ARGS})
+ LIST(REMOVE_AT SOURCES 0)
+ STRING(TOUPPER ${plugin} plugin)
+ STRING(TOLOWER ${plugin} target)
+
+ # Figure out whether to build plugin
+ IF(WITH_PLUGIN_${plugin})
+ SET(WITH_${plugin} 1)
+ ENDIF()
+
+ IF(WITH_MAX_NO_NDB)
+ SET(WITH_MAX 1)
+ SET(WITHOUT_NDBCLUSTER 1)
+ ENDIF()
+
+ IF(ARG_DEFAULT)
+ IF(NOT DEFINED WITH_${plugin} AND
+ NOT DEFINED WITH_${plugin}_STORAGE_ENGINE)
+ SET(WITH_${plugin} 1)
+ ENDIF()
+ ENDIF()
+
+ IF(WITH_${plugin}_STORAGE_ENGINE
+ OR WITH_{$plugin}
+ OR WITH_ALL
+ OR WITH_MAX
+ AND NOT WITHOUT_${plugin}_STORAGE_ENGINE
+ AND NOT WITHOUT_${plugin}
+ AND NOT ARG_MODULE_ONLY)
+
+ SET(WITH_${plugin} 1)
+ ELSEIF(WITHOUT_${plugin}_STORAGE_ENGINE OR WITH_NONE OR ${plugin}_DISABLED)
+ SET(WITHOUT_${plugin} 1)
+ SET(WITH_${plugin}_STORAGE_ENGINE 0)
+ SET(WITH_${plugin} 0)
+ ENDIF()
+
+
+ IF(ARG_MANDATORY)
+ SET(WITH_${plugin} 1)
+ ENDIF()
+
+
+ IF(ARG_STORAGE_ENGINE)
+ SET(with_var "WITH_${plugin}_STORAGE_ENGINE" )
+ ELSE()
+ SET(with_var "WITH_${plugin}")
+ ENDIF()
+
+ IF(NOT ARG_DEPENDENCIES)
+ SET(ARG_DEPENDENCIES)
+ ENDIF()
+ SET(BUILD_PLUGIN 1)
+ # Build either static library or module
+ IF (WITH_${plugin} AND NOT ARG_MODULE_ONLY)
+ ADD_LIBRARY(${target} STATIC ${SOURCES})
+ SET_TARGET_PROPERTIES(${target} PROPERTIES COMPILE_DEFINITONS "MYSQL_SERVER")
+ DTRACE_INSTRUMENT(${target})
+ ADD_DEPENDENCIES(${target} GenError ${ARG_DEPENDENCIES})
+ IF(WITH_EMBEDDED_SERVER)
+ # Embedded library should contain PIC code and be linkable
+ # to shared libraries (on systems that need PIC)
+ IF(ARG_RECOMPILE_FOR_EMBEDDED OR NOT _SKIP_PIC)
+ # Recompile some plugins for embedded
+ ADD_CONVENIENCE_LIBRARY(${target}_embedded ${SOURCES})
+ DTRACE_INSTRUMENT(${target}_embedded)
+ IF(ARG_RECOMPILE_FOR_EMBEDDED)
+ SET_TARGET_PROPERTIES(${target}_embedded
+ PROPERTIES COMPILE_DEFINITIONS "MYSQL_SERVER;EMBEDDED_LIBRARY")
+ ENDIF()
+ ADD_DEPENDENCIES(${target}_embedded GenError)
+ ENDIF()
+ ENDIF()
+
+ IF(ARG_STATIC_OUTPUT_NAME)
+ SET_TARGET_PROPERTIES(${target} PROPERTIES
+ OUTPUT_NAME ${ARG_STATIC_OUTPUT_NAME})
+ ENDIF()
+
+ # Update mysqld dependencies
+ SET (MYSQLD_STATIC_PLUGIN_LIBS ${MYSQLD_STATIC_PLUGIN_LIBS}
+ ${target} ${ARG_LINK_LIBRARIES} CACHE INTERNAL "" FORCE)
+
+ IF(ARG_MANDATORY)
+ SET(${with_var} ON CACHE INTERNAL "Link ${plugin} statically to the server"
+ FORCE)
+ ELSE()
+ SET(${with_var} ON CACHE BOOL "Link ${plugin} statically to the server"
+ FORCE)
+ ENDIF()
+
+ IF(ARG_MANDATORY)
+ SET (mysql_mandatory_plugins
+ "${mysql_mandatory_plugins} builtin_${target}_plugin,"
+ PARENT_SCOPE)
+ ELSE()
+ SET (mysql_optional_plugins
+ "${mysql_optional_plugins} builtin_${target}_plugin,"
+ PARENT_SCOPE)
+ ENDIF()
+ ELSEIF(NOT WITHOUT_${plugin} AND NOT ARG_STATIC_ONLY AND NOT WITHOUT_DYNAMIC_PLUGINS)
+ IF(NOT ARG_MODULE_OUTPUT_NAME)
+ IF(ARG_STORAGE_ENGINE)
+ SET(ARG_MODULE_OUTPUT_NAME "ha_${target}")
+ ELSE()
+ SET(ARG_MODULE_OUTPUT_NAME "${target}")
+ ENDIF()
+ ENDIF()
+
+ ADD_VERSION_INFO(${target} MODULE SOURCES)
+ ADD_LIBRARY(${target} MODULE ${SOURCES})
+ DTRACE_INSTRUMENT(${target})
+ SET_TARGET_PROPERTIES (${target} PROPERTIES PREFIX ""
+ COMPILE_DEFINITIONS "MYSQL_DYNAMIC_PLUGIN")
+ TARGET_LINK_LIBRARIES (${target} mysqlservices)
+
+ # Plugin uses symbols defined in mysqld executable.
+ # Some operating systems like Windows and OSX and are pretty strict about
+ # unresolved symbols. Others are less strict and allow unresolved symbols
+ # in shared libraries. On Linux for example, CMake does not even add
+ # executable to the linker command line (it would result into link error).
+ # Thus we skip TARGET_LINK_LIBRARIES on Linux, as it would only generate
+ # an additional dependency.
+ IF(NOT CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ TARGET_LINK_LIBRARIES (${target} mysqld ${ARG_LINK_LIBRARIES})
+ ENDIF()
+ ADD_DEPENDENCIES(${target} GenError ${ARG_DEPENDENCIES})
+
+ IF(NOT ARG_MODULE_ONLY)
+ # set cached variable, e.g with checkbox in GUI
+ SET(${with_var} OFF CACHE BOOL "Link ${plugin} statically to the server"
+ FORCE)
+ ENDIF()
+ SET_TARGET_PROPERTIES(${target} PROPERTIES
+ OUTPUT_NAME "${ARG_MODULE_OUTPUT_NAME}")
+ # Install dynamic library
+ MYSQL_INSTALL_TARGETS(${target} DESTINATION ${INSTALL_PLUGINDIR} COMPONENT Server)
+ INSTALL_DEBUG_TARGET(${target} DESTINATION ${INSTALL_PLUGINDIR}/debug)
+ # For internal testing in PB2, append collections files
+ IF(DEFINED ENV{PB2WORKDIR})
+ PLUGIN_APPEND_COLLECTIONS(${plugin})
+ ENDIF()
+ ELSE()
+ IF(WITHOUT_${plugin})
+ # Update cache variable
+ STRING(REPLACE "WITH_" "WITHOUT_" without_var ${with_var})
+ SET(${without_var} ON CACHE BOOL "Don't build ${plugin}"
+ FORCE)
+ ENDIF()
+ SET(BUILD_PLUGIN 0)
+ ENDIF()
+
+ IF(BUILD_PLUGIN AND ARG_LINK_LIBRARIES)
+ TARGET_LINK_LIBRARIES (${target} ${ARG_LINK_LIBRARIES})
+ ENDIF()
+
+ENDMACRO()
+
+
+# Add all CMake projects under storage and plugin
+# subdirectories, configure sql_builtins.cc
+MACRO(CONFIGURE_PLUGINS)
+ FILE(GLOB dirs_storage ${CMAKE_SOURCE_DIR}/storage/*)
+ FILE(GLOB dirs_plugin ${CMAKE_SOURCE_DIR}/plugin/*)
+ FOREACH(dir ${dirs_storage} ${dirs_plugin})
+ IF (EXISTS ${dir}/CMakeLists.txt)
+ ADD_SUBDIRECTORY(${dir})
+ ENDIF()
+ ENDFOREACH()
+ FOREACH(dir ${dirs_plugin})
+ IF (EXISTS ${dir}/.bzr)
+ MESSAGE(STATUS "Found repo ${dir}/.bzr")
+ LIST(APPEND PLUGIN_BZR_REPOS "${dir}")
+ ENDIF()
+ ENDFOREACH()
+ SET(PLUGIN_REPOS "${PLUGIN_BZR_REPOS}" CACHE INTERNAL "")
+ENDMACRO()
diff --git a/cmake/readline.cmake b/cmake/readline.cmake
new file mode 100644
index 00000000000..4840229a82e
--- /dev/null
+++ b/cmake/readline.cmake
@@ -0,0 +1,230 @@
+# Copyright (c) 2009, 2010 Sun Microsystems, Inc.
+# Use is subject to license terms.
+#
+# 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
+
+MACRO (MYSQL_CHECK_MULTIBYTE)
+ CHECK_INCLUDE_FILE(wctype.h HAVE_WCTYPE_H)
+ CHECK_INCLUDE_FILE(wchar.h HAVE_WCHAR_H)
+ IF(HAVE_WCHAR_H)
+ SET(CMAKE_EXTRA_INCLUDE_FILES wchar.h)
+ CHECK_TYPE_SIZE(mbstate_t SIZEOF_MBSTATE_T)
+ SET(CMAKE_EXTRA_INCLUDE_FILES)
+ IF(SIZEOF_MBSTATE_T)
+ SET(HAVE_MBSTATE_T 1)
+ ENDIF()
+ ENDIF()
+
+ CHECK_C_SOURCE_COMPILES("
+ #include <langinfo.h>
+ int main(int ac, char **av)
+ {
+ char *cs = nl_langinfo(CODESET);
+ return 0;
+ }"
+ HAVE_LANGINFO_CODESET)
+
+ CHECK_FUNCTION_EXISTS(mbrlen HAVE_MBRLEN)
+ CHECK_FUNCTION_EXISTS(mbscmp HAVE_MBSCMP)
+ CHECK_FUNCTION_EXISTS(mbsrtowcs HAVE_MBSRTOWCS)
+ CHECK_FUNCTION_EXISTS(wcrtomb HAVE_WCRTOMB)
+ CHECK_FUNCTION_EXISTS(mbrtowc HAVE_MBRTOWC)
+ CHECK_FUNCTION_EXISTS(wcscoll HAVE_WCSCOLL)
+ CHECK_FUNCTION_EXISTS(wcsdup HAVE_WCSDUP)
+ CHECK_FUNCTION_EXISTS(wcwidth HAVE_WCWIDTH)
+ CHECK_FUNCTION_EXISTS(wctype HAVE_WCTYPE)
+ CHECK_FUNCTION_EXISTS(iswlower HAVE_ISWLOWER)
+ CHECK_FUNCTION_EXISTS(iswupper HAVE_ISWUPPER)
+ CHECK_FUNCTION_EXISTS(towlower HAVE_TOWLOWER)
+ CHECK_FUNCTION_EXISTS(towupper HAVE_TOWUPPER)
+ CHECK_FUNCTION_EXISTS(iswctype HAVE_ISWCTYPE)
+
+ SET(CMAKE_EXTRA_INCLUDE_FILES wchar.h)
+ CHECK_TYPE_SIZE(wchar_t SIZEOF_WCHAR_T)
+ IF(SIZEOF_WCHAR_T)
+ SET(HAVE_WCHAR_T 1)
+ ENDIF()
+
+ SET(CMAKE_EXTRA_INCLUDE_FILES wctype.h)
+ CHECK_TYPE_SIZE(wctype_t SIZEOF_WCTYPE_T)
+ IF(SIZEOF_WCTYPE_T)
+ SET(HAVE_WCTYPE_T 1)
+ ENDIF()
+ CHECK_TYPE_SIZE(wint_t SIZEOF_WINT_T)
+ IF(SIZEOF_WINT_T)
+ SET(HAVE_WINT_T 1)
+ ENDIF()
+ SET(CMAKE_EXTRA_INCLUDE_FILES)
+
+ENDMACRO()
+
+MACRO (FIND_CURSES)
+ FIND_PACKAGE(Curses)
+ MARK_AS_ADVANCED(CURSES_CURSES_H_PATH CURSES_FORM_LIBRARY CURSES_HAVE_CURSES_H)
+ IF(NOT CURSES_FOUND)
+ SET(ERRORMSG "Curses library not found. Please install appropriate package,
+ remove CMakeCache.txt and rerun cmake.")
+ IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ SET(ERRORMSG ${ERRORMSG}
+ "On Debian/Ubuntu, package name is libncurses5-dev, on Redhat and derivates "
+ "it is ncurses-devel.")
+ ENDIF()
+ MESSAGE(FATAL_ERROR ${ERRORMSG})
+ ENDIF()
+
+ IF(CURSES_HAVE_CURSES_H)
+ SET(HAVE_CURSES_H 1 CACHE INTERNAL "")
+ ELSEIF(CURSES_HAVE_NCURSES_H)
+ SET(HAVE_NCURSES_H 1 CACHE INTERNAL "")
+ ENDIF()
+ IF(CMAKE_SYSTEM_NAME MATCHES "HP")
+ # CMake uses full path to library /lib/libcurses.sl
+ # On Itanium, it results into architecture mismatch+
+ # the library is for PA-RISC
+ SET(CURSES_LIBRARY "curses" CACHE INTERNAL "" FORCE)
+ SET(CURSES_CURSES_LIBRARY "curses" CACHE INTERNAL "" FORCE)
+ ENDIF()
+
+ IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ # -Wl,--as-needed breaks linking with -lcurses, e.g on Fedora
+ # Lower-level libcurses calls are exposed by libtinfo
+ CHECK_LIBRARY_EXISTS(${CURSES_LIBRARY} tputs "" HAVE_TPUTS_IN_CURSES)
+ IF(NOT HAVE_TPUTS_IN_CURSES)
+ CHECK_LIBRARY_EXISTS(tinfo tputs "" HAVE_TPUTS_IN_TINFO)
+ IF(HAVE_TPUTS_IN_TINFO)
+ SET(CURSES_LIBRARY tinfo)
+ ENDIF()
+ ENDIF()
+ ENDIF()
+ENDMACRO()
+
+MACRO (MYSQL_USE_BUNDLED_READLINE)
+ SET(USE_NEW_READLINE_INTERFACE 1)
+ SET(HAVE_HIST_ENTRY)
+ SET(USE_LIBEDIT_INTERFACE)
+ SET(READLINE_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/cmd-line-utils)
+ SET(READLINE_LIBRARY readline)
+ FIND_CURSES()
+ ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/cmd-line-utils/readline)
+ENDMACRO()
+
+MACRO (MYSQL_USE_BUNDLED_LIBEDIT)
+ SET(USE_LIBEDIT_INTERFACE 1)
+ SET(HAVE_HIST_ENTRY 1)
+ SET(READLINE_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/cmd-line-utils/libedit)
+ SET(READLINE_LIBRARY edit)
+ FIND_CURSES()
+ ADD_SUBDIRECTORY(${CMAKE_SOURCE_DIR}/cmd-line-utils/libedit)
+ENDMACRO()
+
+
+MACRO (MYSQL_FIND_SYSTEM_READLINE name)
+
+ FIND_PATH(${name}_INCLUDE_DIR readline/readline.h )
+ FIND_LIBRARY(${name}_LIBRARY NAMES ${name})
+ MARK_AS_ADVANCED(${name}_INCLUDE_DIR ${name}_LIBRARY)
+
+ INCLUDE(CheckCXXSourceCompiles)
+ SET(CMAKE_REQUIRES_LIBRARIES ${${name}_LIBRARY})
+
+ IF(${name}_LIBRARY AND ${name}_INCLUDE_DIR)
+ SET(SYSTEM_READLINE_FOUND 1)
+ SET(CMAKE_REQUIRED_LIBRARIES ${${name}_LIBRARY})
+ CHECK_CXX_SOURCE_COMPILES("
+ #include <stdio.h>
+ #include <readline/readline.h>
+ int main(int argc, char **argv)
+ {
+ HIST_ENTRY entry;
+ return 0;
+ }"
+ ${name}_HAVE_HIST_ENTRY)
+
+ CHECK_CXX_SOURCE_COMPILES("
+ #include <stdio.h>
+ #include <readline/readline.h>
+ int main(int argc, char **argv)
+ {
+ char res= *(*rl_completion_entry_function)(0,0);
+ completion_matches(0,0);
+ }"
+ ${name}_USE_LIBEDIT_INTERFACE)
+
+
+ CHECK_CXX_SOURCE_COMPILES("
+ #include <stdio.h>
+ #include <readline/readline.h>
+ int main(int argc, char **argv)
+ {
+ rl_completion_func_t *func1= (rl_completion_func_t*)0;
+ rl_compentry_func_t *func2= (rl_compentry_func_t*)0;
+ }"
+ ${name}_USE_NEW_READLINE_INTERFACE)
+
+ IF(${name}_USE_LIBEDIT_INTERFACE OR ${name}_USE_NEW_READLINE_INTERFACE)
+ SET(READLINE_LIBRARY ${${name}_LIBRARY})
+ SET(READLINE_INCLUDE_DIR ${${name}_INCLUDE_DIR})
+ SET(HAVE_HIST_ENTRY ${${name}_HAVE_HIST_ENTRY})
+ SET(USE_LIBEDIT_INTERFACE ${${name}_USE_LIBEDIT_INTERFACE})
+ SET(USE_NEW_READLINE_INTERFACE ${${name}_USE_NEW_READLINE_INTERFACE})
+ SET(READLINE_FOUND 1)
+ ENDIF()
+ ENDIF()
+ENDMACRO()
+
+
+MACRO (MYSQL_CHECK_READLINE)
+ IF (NOT WIN32)
+ MYSQL_CHECK_MULTIBYTE()
+ IF(NOT CYGWIN)
+ SET(WITH_LIBEDIT ON CACHE BOOL "Use bundled libedit")
+ SET(WITH_READLINE OFF CACHE BOOL "Use bundled readline")
+ ELSE()
+ # Bundled libedit does not compile on cygwin, only readline
+ SET(WITH_READLINE OFF CACHE BOOL "Use bundled readline")
+ ENDIF()
+
+ # Handle mutual exclusion of WITH_READLINE/WITH_LIBEDIT variables
+ # We save current setting to recognize when user switched between
+ # WITH_READLINE and WITH_LIBEDIT
+ IF(WITH_READLINE)
+ IF(NOT SAVE_READLINE_SETTING OR SAVE_READLINE_SETTING MATCHES
+ "WITH_LIBEDIT")
+ SET(WITH_LIBEDIT OFF CACHE BOOL "Use bundled libedit" FORCE)
+ ENDIF()
+ ELSEIF(WITH_LIBEDIT)
+ IF(NOT SAVE_READLINE_SETTING OR SAVE_READLINE_SETTING MATCHES
+ "WITH_READLINE")
+ SET(WITH_READLINE OFF CACHE BOOL "Use bundled readline" FORCE)
+ ENDIF()
+ ENDIF()
+
+ IF(WITH_READLINE)
+ MYSQL_USE_BUNDLED_READLINE()
+ SET(SAVE_READLINE_SETTING WITH_READLINE CACHE INTERNAL "" FORCE)
+ ELSEIF(WITH_LIBEDIT)
+ MYSQL_USE_BUNDLED_LIBEDIT()
+ SET(SAVE_READLINE_SETTING WITH_LIBEDIT CACHE INTERNAL "" FORCE)
+ ELSE()
+ MYSQL_FIND_SYSTEM_READLINE(readline)
+ IF(NOT READLINE_FOUND)
+ MYSQL_FIND_SYSTEM_READLINE(edit)
+ IF(NOT READLINE_FOUND)
+ MESSAGE(FATAL_ERROR "Cannot find system readline or libedit libraries.Use WITH_READLINE or WITH_LIBEDIT")
+ ENDIF()
+ ENDIF()
+ ENDIF()
+ ENDIF(NOT WIN32)
+ENDMACRO()
+
diff --git a/cmake/ssl.cmake b/cmake/ssl.cmake
new file mode 100644
index 00000000000..9b16bf09394
--- /dev/null
+++ b/cmake/ssl.cmake
@@ -0,0 +1,90 @@
+# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+MACRO (CHANGE_SSL_SETTINGS string)
+ SET(WITH_SSL ${string} CACHE STRING "Options are : no, bundled, yes (prefer os library if present otherwise use bundled), system (use os library)" FORCE)
+ENDMACRO()
+
+MACRO (MYSQL_USE_BUNDLED_SSL)
+ SET(INC_DIRS
+ ${CMAKE_SOURCE_DIR}/extra/yassl/include
+ ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/include
+ )
+ SET(SSL_LIBRARIES yassl taocrypt)
+ SET(SSL_INCLUDE_DIRS ${INC_DIRS})
+ SET(SSL_INTERNAL_INCLUDE_DIRS ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL)
+ SET(SSL_DEFINES "-DHAVE_YASSL -DYASSL_PURE_C -DYASSL_PREFIX -DHAVE_OPENSSL -DYASSL_THREAD_SAFE")
+ CHANGE_SSL_SETTINGS("bundled")
+ #Remove -fno-implicit-templates
+ #(yassl sources cannot be compiled with it)
+ SET(SAVE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+ IF(CMAKE_CXX_FLAGS)
+ STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS
+ ${CMAKE_CXX_FLAGS})
+ ENDIF()
+ ADD_SUBDIRECTORY(extra/yassl)
+ ADD_SUBDIRECTORY(extra/yassl/taocrypt)
+ SET(CMAKE_CXX_FLAGS ${SAVE_CXX_FLAGS})
+ GET_TARGET_PROPERTY(src yassl SOURCES)
+ FOREACH(file ${src})
+ SET(SSL_SOURCES ${SSL_SOURCES} ${CMAKE_SOURCE_DIR}/extra/yassl/${file})
+ ENDFOREACH()
+ GET_TARGET_PROPERTY(src taocrypt SOURCES)
+ FOREACH(file ${src})
+ SET(SSL_SOURCES ${SSL_SOURCES} ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/${file})
+ ENDFOREACH()
+ENDMACRO()
+
+# MYSQL_CHECK_SSL
+#
+# Provides the following configure options:
+# WITH_SSL=[yes|no|bundled]
+MACRO (MYSQL_CHECK_SSL)
+ IF(NOT WITH_SSL)
+ IF(WIN32)
+ CHANGE_SSL_SETTINGS("bundled")
+ ELSE()
+ CHANGE_SSL_SETTINGS("no")
+ ENDIF()
+ ENDIF()
+
+ IF(WITH_SSL STREQUAL "bundled")
+ MYSQL_USE_BUNDLED_SSL()
+ ELSEIF(WITH_SSL STREQUAL "system" OR WITH_SSL STREQUAL "yes")
+ # Check for system library
+ SET(OPENSSL_FIND_QUIETLY TRUE)
+ INCLUDE(FindOpenSSL)
+ FIND_LIBRARY(CRYPTO_LIBRARY crypto)
+ MARK_AS_ADVANCED(CRYPTO_LIBRARY)
+ INCLUDE(CheckSymbolExists)
+ CHECK_SYMBOL_EXISTS(SHA512_DIGEST_LENGTH "openssl/sha.h"
+ HAVE_SHA512_DIGEST_LENGTH)
+ IF(OPENSSL_FOUND AND CRYPTO_LIBRARY AND HAVE_SHA512_DIGEST_LENGTH)
+ SET(SSL_SOURCES "")
+ SET(SSL_LIBRARIES ${OPENSSL_LIBRARIES} ${CRYPTO_LIBRARY})
+ SET(SSL_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
+ SET(SSL_INTERNAL_INCLUDE_DIRS "")
+ SET(SSL_DEFINES "-DHAVE_OPENSSL")
+ CHANGE_SSL_SETTINGS("system")
+ ELSE()
+ IF(WITH_SSL STREQUAL "system")
+ MESSAGE(SEND_ERROR "Cannot find appropriate system libraries for SSL. Use WITH_SSL=bundled to enable SSL support")
+ ENDIF()
+ MYSQL_USE_BUNDLED_SSL()
+ ENDIF()
+ ELSEIF(NOT WITH_SSL STREQUAL "no")
+ MESSAGE(SEND_ERROR "Wrong option for WITH_SSL. Valid values are : yes, no, bundled")
+ ENDIF()
+ENDMACRO()
diff --git a/cmake/stack_direction.c b/cmake/stack_direction.c
new file mode 100644
index 00000000000..d75bbbfa035
--- /dev/null
+++ b/cmake/stack_direction.c
@@ -0,0 +1,33 @@
+/*
+ Copyright (c) 2009 Sun Microsystems, Inc.
+ Use is subject to license terms.
+
+ 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 */
+
+/* Check stack direction (0-down, 1-up) */
+int f(int *a)
+{
+ int b;
+ return(&b > a)?1:0;
+}
+/*
+ Prevent compiler optimizations by calling function
+ through pointer.
+*/
+volatile int (*ptr_f)(int *) = f;
+int main()
+{
+ int a;
+ return ptr_f(&a);
+}
diff --git a/cmake/tags.cmake b/cmake/tags.cmake
new file mode 100644
index 00000000000..07c1411a1d6
--- /dev/null
+++ b/cmake/tags.cmake
@@ -0,0 +1,26 @@
+# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+#
+# 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
+
+# Generate tag files
+IF(UNIX)
+ ADD_CUSTOM_TARGET (tags
+ COMMAND support-files/build-tags
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ )
+ ADD_CUSTOM_TARGET (ctags
+ COMMAND ctags -R -f CTAGS
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
+ )
+ENDIF()
diff --git a/cmake/versioninfo.rc.in b/cmake/versioninfo.rc.in
new file mode 100644
index 00000000000..f849a9fcb59
--- /dev/null
+++ b/cmake/versioninfo.rc.in
@@ -0,0 +1,38 @@
+// Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+//
+// 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
+
+#include <windows.h>
+VS_VERSION_INFO VERSIONINFO
+FILEVERSION @MAJOR_VERSION@,@MINOR_VERSION@,@PATCH_VERSION@,0
+PRODUCTVERSION @MAJOR_VERSION@,@MINOR_VERSION@,@PATCH_VERSION@,0
+FILEFLAGSMASK VS_FFI_FILEFLAGSMASK
+FILEFLAGS 0
+FILEOS VOS__WINDOWS32
+FILETYPE @FILETYPE@
+FILESUBTYPE VFT2_UNKNOWN
+BEGIN
+ BLOCK "StringFileInfo"
+ BEGIN
+ BLOCK "040904E4"
+ BEGIN
+ VALUE "FileVersion", "@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@.0\0"
+ VALUE "ProductVersion", "@MAJOR_VERSION@.@MINOR_VERSION@.@PATCH_VERSION@.0\0"
+ END
+ END
+ BLOCK "VarFileInfo"
+ BEGIN
+ VALUE "Translation", 0x409, 1252
+ END
+END
diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake
new file mode 100644
index 00000000000..3ede3aba228
--- /dev/null
+++ b/cmake/zlib.cmake
@@ -0,0 +1,74 @@
+# Copyright (c) 2009 Sun Microsystems, Inc.
+# Use is subject to license terms.
+#
+# 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
+
+MACRO (MYSQL_USE_BUNDLED_ZLIB)
+ SET(ZLIB_LIBRARY zlib)
+ SET(ZLIB_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/zlib)
+ SET(ZLIB_FOUND TRUE)
+ SET(WITH_ZLIB "bundled" CACHE STRING "Use bundled zlib")
+ ADD_SUBDIRECTORY(zlib)
+ GET_TARGET_PROPERTY(src zlib SOURCES)
+ FOREACH(file ${src})
+ SET(ZLIB_SOURCES ${ZLIB_SOURCES} ${CMAKE_SOURCE_DIR}/zlib/${file})
+ ENDFOREACH()
+ENDMACRO()
+
+# MYSQL_CHECK_ZLIB_WITH_COMPRESS
+#
+# Provides the following configure options:
+# WITH_ZLIB_BUNDLED
+# If this is set,we use bindled zlib
+# If this is not set,search for system zlib.
+# if system zlib is not found, use bundled copy
+# ZLIB_LIBRARIES, ZLIB_INCLUDE_DIR and ZLIB_SOURCES
+# are set after this macro has run
+
+MACRO (MYSQL_CHECK_ZLIB_WITH_COMPRESS)
+
+ IF(CMAKE_SYSTEM_NAME STREQUAL "OS400" OR
+ CMAKE_SYSTEM_NAME STREQUAL "AIX" OR
+ CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ # Use bundled zlib on some platforms by default (system one is too
+ # old or not existent)
+ IF (NOT WITH_ZLIB)
+ SET(WITH_ZLIB "bundled" CACHE STRING "By default use bundled zlib on this platform")
+ ENDIF()
+ ENDIF()
+
+ IF(WITH_ZLIB STREQUAL "bundled")
+ MYSQL_USE_BUNDLED_ZLIB()
+ ELSE()
+ SET(ZLIB_FIND_QUIETLY TRUE)
+ INCLUDE(FindZLIB)
+ IF(ZLIB_FOUND)
+ INCLUDE(CheckFunctionExists)
+ SET(CMAKE_REQUIRED_LIBRARIES z)
+ CHECK_FUNCTION_EXISTS(crc32 HAVE_CRC32)
+ SET(CMAKE_REQUIRED_LIBRARIES)
+ IF(HAVE_CRC32)
+ SET(ZLIB_LIBRARY z CACHE INTERNAL "System zlib library")
+ SET(WITH_ZLIB "system" CACHE STRING "Which zlib to use (possible values are 'bundled' or 'system')")
+ SET(ZLIB_SOURCES "")
+ ELSE()
+ SET(ZLIB_FOUND FALSE CACHE INTERNAL "Zlib found but not usable")
+ ENDIF()
+ ENDIF()
+ IF(NOT ZLIB_FOUND)
+ MYSQL_USE_BUNDLED_ZLIB()
+ ENDIF()
+ ENDIF()
+ SET(HAVE_COMPRESS 1)
+ENDMACRO()