summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--BUILD-CMAKE243
-rw-r--r--BUILD/Makefile.am1
-rwxr-xr-xBUILD/autorun.sh7
-rw-r--r--BUILD/choose_configure.sh14
-rwxr-xr-xCMakeLists.txt499
-rw-r--r--Makefile.am9
-rwxr-xr-xclient/CMakeLists.txt72
-rw-r--r--cmake/Makefile.am21
-rw-r--r--cmake/abi_check.cmake60
-rw-r--r--cmake/bison.cmake64
-rw-r--r--cmake/cat.cmake27
-rw-r--r--cmake/character_sets.cmake63
-rw-r--r--cmake/check_minimal_version.cmake19
-rw-r--r--cmake/configure.pl79
-rw-r--r--cmake/create_initial_db.cmake.in84
-rw-r--r--cmake/do_abi_check.cmake78
-rw-r--r--cmake/dtrace.cmake92
-rw-r--r--cmake/dtrace_prelink.cmake34
-rw-r--r--cmake/install_macros.cmake69
-rw-r--r--cmake/make_dist.cmake.in176
-rw-r--r--cmake/merge_archives_unix.cmake.in62
-rw-r--r--cmake/misc.cmake128
-rw-r--r--cmake/mysql_version.cmake142
-rw-r--r--cmake/plugin.cmake171
-rw-r--r--cmake/readline.cmake197
-rw-r--r--cmake/ssl.cmake88
-rw-r--r--cmake/stack_direction.c31
-rw-r--r--cmake/zlib.cmake73
-rw-r--r--cmd-line-utils/libedit/CMakeLists.txt167
-rw-r--r--cmd-line-utils/libedit/Makefile.am2
-rw-r--r--cmd-line-utils/readline/CMakeLists.txt60
-rw-r--r--cmd-line-utils/readline/Makefile.am2
-rw-r--r--config.h.cmake618
-rw-r--r--configure.cmake1335
-rw-r--r--configure.in4
-rwxr-xr-xdbug/CMakeLists.txt16
-rwxr-xr-xextra/CMakeLists.txt76
-rwxr-xr-xextra/yassl/CMakeLists.txt24
-rwxr-xr-xextra/yassl/taocrypt/CMakeLists.txt11
-rw-r--r--include/CMakeLists.txt61
-rw-r--r--include/Makefile.am3
-rw-r--r--include/keycache.h2
-rw-r--r--include/my_global.h111
-rw-r--r--include/my_pthread.h18
-rw-r--r--include/my_sys.h3
-rw-r--r--include/mysql/plugin.h29
-rw-r--r--include/thr_alarm.h2
-rwxr-xr-xlibmysql/CMakeLists.txt198
-rw-r--r--libmysqld/CMakeLists.txt169
-rw-r--r--libmysqld/examples/CMakeLists.txt48
-rw-r--r--libmysqld/lib_sql.cc5
-rw-r--r--man/CMakeLists.txt24
-rw-r--r--man/Makefile.am2
-rw-r--r--mysql-test/CMakeLists.txt110
-rw-r--r--mysql-test/Makefile.am5
-rw-r--r--mysql-test/lib/My/ConfigFactory.pm11
-rw-r--r--mysql-test/lib/My/Find.pm20
-rw-r--r--mysql-test/lib/My/SafeProcess.pm18
-rw-r--r--mysql-test/lib/My/SafeProcess/CMakeLists.txt14
-rwxr-xr-xmysql-test/lib/My/SafeProcess/safe_kill_win.cc1
-rwxr-xr-xmysql-test/lib/My/SafeProcess/safe_process_win.cc5
-rw-r--r--mysql-test/mtr.out-of-source5
-rwxr-xr-xmysql-test/mysql-test-run.pl161
-rw-r--r--mysql-test/t/fulltext_plugin.test3
-rwxr-xr-xmysys/CMakeLists.txt44
-rw-r--r--mysys/my_create.c9
-rw-r--r--mysys/my_getsystime.c5
-rw-r--r--mysys/my_winthread.c18
-rw-r--r--mysys/mysys_priv.h5
-rw-r--r--plugin/daemon_example/CMakeLists.txt18
-rw-r--r--plugin/daemon_example/Makefile.am1
-rw-r--r--plugin/fulltext/CMakeLists.txt18
-rw-r--r--plugin/fulltext/Makefile.am1
-rw-r--r--plugin/semisync/CMakeLists.txt33
-rwxr-xr-xregex/CMakeLists.txt5
-rw-r--r--regex/regex2.h4
-rwxr-xr-xscripts/CMakeLists.txt280
-rw-r--r--sql-bench/CMakeLists.txt51
-rw-r--r--sql-bench/Makefile.am2
-rwxr-xr-xsql/CMakeLists.txt280
-rw-r--r--sql/nt_servc.cc1
-rw-r--r--sql/share/CMakeLists.txt52
-rw-r--r--sql/share/Makefile.am5
-rw-r--r--sql/sql_builtin.cc.in7
-rw-r--r--sql/sql_class.h4
-rw-r--r--storage/Makefile.am1
-rw-r--r--storage/archive/CMakeLists.txt10
-rw-r--r--storage/blackhole/CMakeLists.txt5
-rw-r--r--storage/csv/CMakeLists.txt3
-rw-r--r--storage/example/CMakeLists.txt2
-rw-r--r--storage/federated/CMakeLists.txt8
-rwxr-xr-xstorage/heap/CMakeLists.txt3
-rw-r--r--storage/ibmdb2i/CMakeLists.txt27
-rw-r--r--storage/innobase/CMakeLists.txt167
-rw-r--r--storage/innobase/include/page0page.ic2
-rwxr-xr-xstorage/myisam/CMakeLists.txt50
-rwxr-xr-xstorage/myisammrg/CMakeLists.txt3
-rw-r--r--storage/mysql_storage_engine.cmake44
-rwxr-xr-xstrings/CMakeLists.txt8
-rw-r--r--support-files/CMakeLists.txt61
-rw-r--r--support-files/Makefile.am3
-rwxr-xr-xtests/CMakeLists.txt12
-rw-r--r--unittest/mysys/CMakeLists.txt36
-rw-r--r--unittest/mysys/Makefile.am2
-rw-r--r--unittest/mytap/CMakeLists.txt18
-rw-r--r--unittest/mytap/Makefile.am2
-rw-r--r--unittest/mytap/tap.c8
-rwxr-xr-xvio/CMakeLists.txt13
-rw-r--r--win/create_def_file.js1
-rwxr-xr-xzlib/CMakeLists.txt17
110 files changed, 6265 insertions, 1030 deletions
diff --git a/BUILD-CMAKE b/BUILD-CMAKE
new file mode 100644
index 00000000000..b5a01d52a5a
--- /dev/null
+++ b/BUILD-CMAKE
@@ -0,0 +1,243 @@
+How to Build MySQL server with CMake
+
+WHAT YOU NEED
+---------------------------------------------------------------
+CMake version 2.6 or later installed on your system.
+
+HOW TO INSTALL:
+
+Linux distributions:
+shell> sudo apt-get install cmake
+
+The above works on do Debian/Ubuntu based distributions.On others, command
+line needs to be modified to e.g "yum install" on Fedora or "zypper install"
+on OpenSUSE.
+
+OpenSolaris:
+shell> pfexec pkgadd install SUNWCMake
+
+Windows and Mac OSX:
+Download and install the latest distribution from
+http://www.cmake.org/cmake/resources/software.html.On Windows, download
+installer exe file and run it. On Mac, download the .dmg image and open it.
+
+Other Unixes:
+Precompiled packages for other Unix flavors (HPUX, AIX) are available from
+http://www.cmake.org/cmake/resources/software.html
+
+Alternatively, you can build from source, source package is also available on
+CMake download page.
+
+
+Compiler Tools
+--------------
+You will need a working compiler and make utility on your OS.
+On Windows, install Visual Studio (Express editions will work too).
+On Mac OSX, install Xcode tools.
+
+
+
+BUILD
+---------------------------------------------------------------
+Ensure that compiler and cmake are in PATH.
+The following description assumes that current working directory
+is the source directory.
+
+
+- Generic build on Unix, using "Unix Makefiles" generator
+
+shell>cmake .
+shell>make
+
+Note: by default, cmake build is less verbose than automake build. Use
+"make VERBOSE=1" if you want to see add command lines for each compiled source.
+
+- Windows, using "Visual Studio 9 2008" generator
+shell>cmake . -G "Visual Studio 9 2008"
+shell>devenv MySQL.sln /build /relwithdebinfo
+(alternatively, open MySQL.sln and build using the IDE)
+
+- Windows, using "NMake Makefiles" generator
+shell>cmake . -G "NMake Makefiles"
+shell>nmake
+
+- Mac OSX build with Xcode
+shell>cmake . -G Xcode
+shell>xcodebuild -configuration Relwithdebinfo
+(alternatively, open MySQL.xcodeproj and build using the IDE)
+
+Command line build with CMake 2.8
+After creating project with cmake -G as above, issue
+cmake . --build
+this works with any CMake generator.
+
+For Visual Studio and Xcode you might want to add an extra
+configuration parameter, to avoid building all configurations.
+
+cmake . --build --config Relwithdebinfo
+
+
+Building "out-of-source"
+---------------------------------------------------------------
+Building out-of-source provides additional benefits. For example it allows to
+build both Release and Debug configurations using the single source tree.Or
+build the same source with different version of the same compiler or with
+different compilers. Also you will prevent polluting the source tree with the
+objects and binaries produced during the make.
+
+Here is an example on how to do it (generic Unix), assuming the source tree is
+in directory named src and the current working directory is source root.
+
+shell>mkdir ../build # build directory is called build
+shell>cd ../build
+shell>cmake ../src
+
+Note: if a directory was used for in-source build, out-of-source will
+not work. To reenable out-of-source build, remove <source-root>/CMakeCache.txt
+file.
+
+
+CONFIGURATION PARAMETERS
+---------------------------------------------------------------
+The procedure above will build with default configuration.
+
+Let's you want to change the configuration parameters and have archive
+storage engine compiled into the server instead of building it as pluggable
+module.
+
+1)You can provide parameters on the command line, like
+
+shell> cmake . -DWITH_ARCHIVE_STORAGE_ENGINE=1
+
+This can be done during the initial configuration or any time later.
+
+Note, that parameters are "sticky", that is they are remebered in the CMake
+cache (CMakeCache.txt file in the build directory)
+
+2) Configuration using cmake-gui (Windows, OSX, or Linux with cmake-gui
+installed)
+
+From the build directory, issue
+shell> cmake-gui .
+
+- Check the WITH_INNOBASE_STORAGE_ENGINE checkbox
+- Click on "Configure" button
+- Click on "Generate" button
+- Close cmake-gui
+shell> make
+
+3)Using ccmake (Unix)
+ccmake is curses-based GUI application that provides the same functionality
+as cmake-gui. It is less user-friendly compared to cmake-gui but works also
+on exotic Unixes like HPUX, AIX or Solaris.
+
+Besides storage engines, probably the most important parameter from a
+developer's point of view is WITH_DEBUG (this allows to build server with
+dbug tracing library and with debug compile flags).
+
+After changing the configuration, recompile using
+shell> make
+
+
+Listing configuration parameters
+---------------------------------------------------------------
+shell> cmake -L
+
+Gives a brief overview of important configuration parameters (dump to stdout)
+
+shell> cmake -LH
+
+Does the same but also provides a short help text for each parameter.
+
+shell> cmake -LAH
+
+Dumps all config parameters (including advanced) to the stdout.
+
+PACKAGING
+---------------------------------------------------------------
+-- Binary distribution --
+Packaging in form of tar.gz archives (or .zip on Windows) is also supported
+To create a tar.gz package,
+
+1)If you're using "generic" Unix build with makefiles
+
+shell> make package
+this will create a tar.gz file in the top level build directory.
+
+2)On Windows, using "NMake Makefiles" generator
+
+shell> nmake package
+
+3)On Windows, using "Visual Studio" generator
+
+shell> devenv mysql.sln /build relwithdebinfo /project package
+
+Note On Windows, 7Zip or Winzip must be installed and 7z.exe rsp winzip.exe
+need to be in the PATH.
+
+
+Another way to build packages is calling cpack executable directly like
+shell> cpack -G TGZ --config CPackConfig.cmake
+(-G TGZ is for tar.gz generator, there is also -GZIP)
+
+-- Source distribution --
+"make dist" target is provided.
+
+ADDITIONAL MAKE TARGETS: "make install" AND "make test"
+----------------------------------------------------------------
+install target also provided for Makefile based generators. Installation
+directory can be controlled using configure-time parameter
+CMAKE_INSTALL_PREFIX (default is /usr/local. It is also possible to install to
+non-configured directory, using
+
+shell> make install DESTDIR="/some/absolute/path"
+
+"make test" runs unit tests (uses CTest for it)
+"make test-force" runs mysql-test-run.pl tests with --test-force parameter
+
+FOR PROGRAMMERS: WRITING PLATFORM CHECKS
+--------------------------------------------------------------
+If you modify MySQL source and want to add a new platform check,please read
+http://www.vtk.org/Wiki/CMake_HowToDoPlatformChecks first. In MySQL, most of
+the platform tests are implemented in config.cmake and the template header file
+is config.h.cmake
+
+Bigger chunks of functionality, for example non-trivial macros are implemented
+in files <src-root>/cmake subdirectory.
+
+For people with autotools background, it is important to remember CMake does
+not provide autoheader functionality. That is, when you add a check
+
+CHECK_FUNCTION_EXISTS(foo HAVE_FOO)
+to config.cmake, then you will also need to add
+#cmakedefine HAVE_FOO 1
+to config.h.cmake
+
+Troubleshooting platform checks
+--------------------------------
+If you suspect that a platform check returned wrong result, examine
+<build-root>/CMakeFiles/CMakeError.log and
+<build-root>/CMakeFiles/CMakeOutput.log
+These files they contain compiler command line, and exact error messages.
+
+Troubleshooting CMake code
+----------------------------------
+While there are advanced flags for cmake like -debug-trycompile and --trace,
+a simple and efficient way to debug to add
+MESSAGE("interesting variable=${some_invariable}")
+to the interesting places in CMakeLists.txt
+
+
+Tips:
+- When using Makefile generator it is easy to examine which compiler flags are
+used to build. For example, compiler flags for mysqld are in
+<build-root>/sql/CMakeFiles/mysqld.dir/flags.make and the linker command line
+is in <build-root>/sql/CMakeFiles/mysqld.dir/link.txt
+
+- CMake caches results of platform checks in CMakeCache.txt. It is a nice
+feature because tests do not rerun when reconfiguring (e.g when a new test was
+added).The downside of caching is that when a platform test was wrong and was
+later corrected, the cached result is still used. If you encounter this
+situation, which should be a rare occation, you need either to remove the
+offending entry from CMakeCache.txt (if test was for HAVE_FOO, remove lines
+containing HAVE_FOO from CMakeCache.txt) or just remove the cache file.
diff --git a/BUILD/Makefile.am b/BUILD/Makefile.am
index cd4b00ea731..312340e7132 100644
--- a/BUILD/Makefile.am
+++ b/BUILD/Makefile.am
@@ -20,6 +20,7 @@
EXTRA_DIST = FINISH.sh \
SETUP.sh \
autorun.sh \
+ choose_configure.sh \
build_mccge.sh \
check-cpu \
cleanup \
diff --git a/BUILD/autorun.sh b/BUILD/autorun.sh
index 35a2e56cbdf..f45b1f7d08c 100755
--- a/BUILD/autorun.sh
+++ b/BUILD/autorun.sh
@@ -20,6 +20,7 @@ do
done
IFS="$save_ifs"
+rm -rf configure
aclocal || die "Can't execute aclocal"
autoheader || die "Can't execute autoheader"
# --force means overwrite ltmain.sh script if it already exists
@@ -29,3 +30,9 @@ $LIBTOOLIZE --automake --force --copy || die "Can't execute libtoolize"
# and --force to overwrite them if they already exist
automake --add-missing --force --copy || die "Can't execute automake"
autoconf || die "Can't execute autoconf"
+# Do not use autotools generated configure directly. Instead, use a script
+# that will either call CMake or original configure shell script at build
+# time (CMake is preferred if installed).
+mv configure configure.am
+cp BUILD/choose_configure.sh configure
+chmod a+x configure
diff --git a/BUILD/choose_configure.sh b/BUILD/choose_configure.sh
new file mode 100644
index 00000000000..71243ea09b6
--- /dev/null
+++ b/BUILD/choose_configure.sh
@@ -0,0 +1,14 @@
+#!/bin/sh
+# Choose whether to use autoconf created configure
+# of perl script that calls cmake.
+
+# Ensure cmake and perl are there
+cmake -P cmake/check_minimal_version.cmake >/dev/null 2>&1 || HAVE_CMAKE=no
+perl --version >/dev/null 2>&1 || HAVE_CMAKE=no
+if test "$HAVE_CMAKE" = "no"
+then
+ sh ./configure.am $@
+else
+ perl ./cmake/configure.pl $@
+fi
+
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6e53ff30159..3d55d115cff 100755
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 MySQL AB
+# Copyright (C) 2006-2008 MySQL AB, 2009 Sun Microsystems, Inc
#
# 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
@@ -13,308 +13,217 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-CMAKE_MINIMUM_REQUIRED(VERSION 2.6 FATAL_ERROR)
-IF(COMMAND cmake_policy)
- cmake_policy(SET CMP0005 NEW)
-ENDIF(COMMAND cmake_policy)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6.0 FATAL_ERROR)
-PROJECT(MySql)
+# First, decide about build type (debug or release)
+# If custom compiler flags are set or cmake is invoked with -DCMAKE_BUILD_TYPE,
+# respect user wishes and do not (re)define CMAKE_BUILD_TYPE. If WITH_DEBUG{_FULL}
+# is given, set CMAKE_BUILD_TYPE = Debug. Otherwise, use Relwithdebinfo.
-# This reads user configuration, generated by configure.js.
-INCLUDE(win/configure.data)
-# Hardcode support for CSV storage engine
-SET(WITH_CSV_STORAGE_ENGINE TRUE)
+IF(CMAKE_BUILD_TYPE)
+ SET(HAVE_CMAKE_BUILD_TYPE TRUE)
+ENDIF()
+SET(CUSTOM_C_FLAGS $ENV{CFLAGS})
+IF(NOT CUSTOM_C_FLAGS)
+ SET(CUSTOM_C_FLAGS ${CMAKE_C_FLAGS})
+ENDIF()
-CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in
- ${CMAKE_SOURCE_DIR}/include/mysql_version.h @ONLY)
-
-# Set standard options
-ADD_DEFINITIONS(-DHAVE_YASSL)
-ADD_DEFINITIONS(-DCMAKE_CONFIGD)
-ADD_DEFINITIONS(-DDEFAULT_MYSQL_HOME="c:/Program Files/MySQL/MySQL Server ${MYSQL_BASE_VERSION}/")
-ADD_DEFINITIONS(-DDEFAULT_BASEDIR="c:/Program Files/MySQL/")
-ADD_DEFINITIONS(-DMYSQL_DATADIR="c:/Program Files/MySQL/MySQL Server ${MYSQL_BASE_VERSION}/data")
-ADD_DEFINITIONS(-DDEFAULT_CHARSET_HOME="c:/Program Files/MySQL/MySQL Server ${MYSQL_BASE_VERSION}/")
-ADD_DEFINITIONS(-DPACKAGE=mysql)
-ADD_DEFINITIONS(-DSHAREDIR="share")
-
-# Set debug options
-SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DFORCE_INIT_OF_VARS")
-
-# Do not use SAFEMALLOC for Windows builds, as Debug CRT has the same functionality
-# Neither SAFE_MUTEX works on Windows and it has been explicitely undefined in
-# my_pthread.h
-IF(NOT WIN32)
- SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
- SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
-ENDIF(NOT WIN32)
-
-SET(localstatedir "C:\\mysql\\data")
-CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-huge.cnf.sh
- ${CMAKE_SOURCE_DIR}/support-files/my-huge.ini @ONLY)
-CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-innodb-heavy-4G.cnf.sh
- ${CMAKE_SOURCE_DIR}/support-files/my-innodb-heavy-4G.ini @ONLY)
-CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-large.cnf.sh
- ${CMAKE_SOURCE_DIR}/support-files/my-large.ini @ONLY)
-CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-medium.cnf.sh
- ${CMAKE_SOURCE_DIR}/support-files/my-medium.ini @ONLY)
-CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/support-files/my-small.cnf.sh
- ${CMAKE_SOURCE_DIR}/support-files/my-small.ini @ONLY)
-
-IF(CYBOZU)
- ADD_DEFINITIONS(-DCYBOZU)
-ENDIF(CYBOZU)
-
-IF(EXTRA_DEBUG)
- ADD_DEFINITIONS(-D EXTRA_DEBUG)
-ENDIF(EXTRA_DEBUG)
-
-IF(ENABLED_DEBUG_SYNC)
- ADD_DEFINITIONS(-D ENABLED_DEBUG_SYNC)
-ENDIF(ENABLED_DEBUG_SYNC)
-SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DENABLED_DEBUG_SYNC")
-SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DENABLED_DEBUG_SYNC")
-
-# in some places we use DBUG_OFF
-SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DDBUG_OFF")
-SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -DDBUG_OFF")
-SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -DDBUG_OFF")
-SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -DDBUG_OFF")
-
-#TODO: update the code and remove the disabled warnings
-SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4800 /wd4805")
-SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /wd4800 /wd4805")
-
-# Disable warnings in Visual Studio 8 and above
-IF(MSVC AND NOT CMAKE_GENERATOR MATCHES "Visual Studio 7")
- SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /wd4996")
- SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /wd4996")
- SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /wd4996")
- SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /wd4996")
- SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /wd4996")
- SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /wd4996")
-ENDIF(MSVC AND NOT CMAKE_GENERATOR MATCHES "Visual Studio 7")
-
-IF(CMAKE_GENERATOR MATCHES "Visual Studio 7")
- # VS2003 has a bug that prevents linking mysqld with module definition file
- # (/DEF option for linker). Linker would incorrectly complain about multiply
- # defined symbols. Workaround is to disable dynamic plugins, so /DEF is not
- # used.
- MESSAGE("Warning: Building MySQL with Visual Studio 2003.NET is no more supported.")
- MESSAGE("Please use a newer version of Visual Studio.")
- SET(WITHOUT_DYNAMIC_PLUGINS TRUE)
-ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 7")
-
-# Settings for Visual Studio 7 and above.
-IF(MSVC)
- # replace /MDd with /MTd
- STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
- STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO})
- STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
- STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG_INIT ${CMAKE_C_FLAGS_DEBUG_INIT})
-
- STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
- STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
- STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
- STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG_INIT ${CMAKE_CXX_FLAGS_DEBUG_INIT})
-
- # generate map files, set stack size (see bug#20815)
- SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MAP /MAPINFO:EXPORTS")
- SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:1048576")
-
- # remove support for Exception handling
- STRING(REPLACE "/GX" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
- STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
- STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_INIT ${CMAKE_CXX_FLAGS_INIT})
- STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_DEBUG_INIT ${CMAKE_CXX_FLAGS_DEBUG_INIT})
-
- # 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(CMAKE_SIZEOF_VOID_P MATCHES 4)
-
- # Disable automatic manifest generation.
- STRING(REPLACE "/MANIFEST" "/MANIFEST:NO" CMAKE_EXE_LINKER_FLAGS
- ${CMAKE_EXE_LINKER_FLAGS})
- # Explicitly disable it since it is the default for newer versions of VS
- STRING(REGEX MATCH "MANIFEST:NO" tmp_manifest ${CMAKE_EXE_LINKER_FLAGS})
- IF(NOT tmp_manifest)
- SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MANIFEST:NO")
- ENDIF(NOT tmp_manifest)
-ENDIF(MSVC)
+OPTION(WITH_DEBUG "Use dbug" OFF)
+OPTION(WITH_DEBUG_FULL "Use dbug and safemalloc/safemutex. Slow" OFF)
+
+IF(NOT HAVE_CMAKE_BUILD_TYPE AND NOT CUSTOM_C_FLAGS)
+ IF(WITH_DEBUG)
+ SET(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Debug build" FORCE)
+ ELSE()
+ SET(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "RelWithDebInfo build" FORCE)
+ ENDIF()
+ENDIF()
+IF(WITH_DEBUG_FULL)
+ SET(WITH_DEBUG ON CACHE BOOL "Use DBUG")
+ENDIF()
+
+PROJECT(MySQL)
+
+IF(CYGWIN)
+ SET(WIN32 0)
+ENDIF()
IF(WIN32)
- ADD_DEFINITIONS("-D_WINDOWS -D__WIN__ -D_CRT_SECURE_NO_DEPRECATE")
- ADD_DEFINITIONS("-D_WIN32_WINNT=0x0501")
-ENDIF(WIN32)
-
-# default to x86 platform. We'll check for X64 in a bit
-SET (PLATFORM X86)
-
-# This definition is necessary to work around a bug with Intellisense described
-# here: http://tinyurl.com/2cb428. Syntax highlighting is important for proper
-# debugger functionality.
-IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
- MESSAGE(STATUS "Detected 64-bit platform.")
- ADD_DEFINITIONS("-D_WIN64")
- SET (PLATFORM X64)
-ENDIF(CMAKE_SIZEOF_VOID_P MATCHES 8)
-
-IF(EMBED_MANIFESTS)
- # Search for the tools (mt, makecat, signtool) necessary for embedding
- # manifests and signing executables with the MySQL AB authenticode cert.
- #
- # CMake will first search it's defaults (CMAKE_FRAMEWORK_PATH,
- # CMAKE_APPBUNDLE_PATH, CMAKE_PROGRAM_PATH and the system PATH) followed
- # by the listed paths which are the current possible defaults and should be
- # updated when necessary.
- #
- # The custom manifests are designed to be compatible with all mt versions.
- # The MySQL AB Authenticode certificate is available only internally.
- # Others should store a single signing certificate in a local cryptographic
- # service provider and alter the signtool command as necessary.
- FIND_PROGRAM(HAVE_MANIFEST_TOOL NAMES mt
- PATHS
- "$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/VC/bin"
- "$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/Common7/Tools/Bin"
- "$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/SDK/v2.0/Bin")
- FIND_PROGRAM(HAVE_CATALOG_TOOL NAMES makecat
- PATHS
- "$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/Common7/Tools/Bin")
- FIND_PROGRAM(HAVE_SIGN_TOOL NAMES signtool
- PATHS
- "$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/Common7/Tools/Bin"
- "$ENV{PROGRAMFILES}/Microsoft Visual Studio 8/SDK/v2.0/Bin")
-
- IF(HAVE_MANIFEST_TOOL)
- MESSAGE(STATUS "Found Mainfest Tool.")
- ELSE(HAVE_MANIFEST_TOOL)
- MESSAGE(FATAL_ERROR "Manifest tool, mt.exe, can't be found.")
- ENDIF(HAVE_MANIFEST_TOOL)
- IF(HAVE_CATALOG_TOOL)
- MESSAGE(STATUS "Found Catalog Tool.")
- ELSE(HAVE_CATALOG_TOOL)
- MESSAGE(FATAL_ERROR "Catalog tool, makecat.exe, can't be found.")
- ENDIF(HAVE_CATALOG_TOOL)
- IF(HAVE_SIGN_TOOL)
- MESSAGE(STATUS "Found Sign Tool. Embedding custom manifests and signing executables.")
- ELSE(HAVE_SIGN_TOOL)
- MESSAGE(FATAL_ERROR "Sign tool, signtool.exe, can't be found.")
- ENDIF(HAVE_SIGN_TOOL)
-
- # Set the processor architecture.
- IF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64")
- SET(PROCESSOR_ARCH "amd64")
- ELSE(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64")
- SET(PROCESSOR_ARCH "X86")
- ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 8 2005 Win64")
-ENDIF(EMBED_MANIFESTS)
-
-# Figure out what engines to build and how (statically or dynamically),
-# add preprocessor defines for storage engines.
-IF(WITHOUT_DYNAMIC_PLUGINS)
- MESSAGE("Dynamic plugins are disabled.")
-ENDIF(WITHOUT_DYNAMIC_PLUGINS)
-
-FILE(GLOB STORAGE_SUBDIRS storage/*)
-FOREACH(SUBDIR ${STORAGE_SUBDIRS})
- FILE(RELATIVE_PATH DIRNAME ${PROJECT_SOURCE_DIR}/storage ${SUBDIR})
- IF (EXISTS ${SUBDIR}/CMakeLists.txt)
- # Check MYSQL_STORAGE_ENGINE macro is present
- FILE(STRINGS ${SUBDIR}/CMakeLists.txt HAVE_STORAGE_ENGINE REGEX MYSQL_STORAGE_ENGINE)
- IF(HAVE_STORAGE_ENGINE)
- # Extract name of engine from HAVE_STORAGE_ENGINE
- STRING(REGEX REPLACE ".*MYSQL_STORAGE_ENGINE\\((.*\)\\).*"
- "\\1" ENGINE_NAME ${HAVE_STORAGE_ENGINE})
- STRING(TOUPPER ${ENGINE_NAME} ENGINE)
- STRING(TOLOWER ${ENGINE_NAME} ENGINE_LOWER)
-
- SET(ENGINE_BUILD_TYPE "DYNAMIC")
- # Read plug.in to find out if a plugin is mandatory and whether it supports
- # build as shared library (dynamic).
- IF(EXISTS ${SUBDIR}/plug.in)
- FILE(READ ${SUBDIR}/plug.in PLUGIN_FILE_CONTENT)
- STRING (REGEX MATCH "MYSQL_PLUGIN_DYNAMIC" MYSQL_PLUGIN_DYNAMIC ${PLUGIN_FILE_CONTENT})
- STRING (REGEX MATCH "MYSQL_PLUGIN_MANDATORY" MYSQL_PLUGIN_MANDATORY ${PLUGIN_FILE_CONTENT})
- STRING (REGEX MATCH "MYSQL_PLUGIN_STATIC" MYSQL_PLUGIN_STATIC ${PLUGIN_FILE_CONTENT})
-
- IF(MYSQL_PLUGIN_MANDATORY)
- SET(WITH_${ENGINE}_STORAGE_ENGINE TRUE)
- ENDIF(MYSQL_PLUGIN_MANDATORY)
-
- IF (WITH_${ENGINE}_STORAGE_ENGINE AND MYSQL_PLUGIN_STATIC)
- SET(ENGINE_BUILD_TYPE "STATIC")
- ELSEIF(NOT WITHOUT_${ENGINE}_STORAGE_ENGINE AND MYSQL_PLUGIN_DYNAMIC AND NOT WITHOUT_DYNAMIC_PLUGINS)
- SET(ENGINE_BUILD_TYPE "DYNAMIC")
- ELSE(WITH_${ENGINE}_STORAGE_ENGINE AND MYSQL_PLUGIN_STATIC)
- SET(ENGINE_BUILD_TYPE "NONE")
- ENDIF(WITH_${ENGINE}_STORAGE_ENGINE AND MYSQL_PLUGIN_STATIC)
- IF (ENGINE_BUILD_TYPE STREQUAL "STATIC")
- SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_${ENGINE_LOWER}_plugin")
- SET (MYSQLD_STATIC_ENGINE_LIBS ${MYSQLD_STATIC_ENGINE_LIBS} ${ENGINE_LOWER})
- SET (STORAGE_ENGINE_DEFS "${STORAGE_ENGINE_DEFS} -DWITH_${ENGINE}_STORAGE_ENGINE")
- SET (WITH_${ENGINE}_STORAGE_ENGINE TRUE)
- SET (${ENGINE}_DIR ${DIRNAME})
- ENDIF (ENGINE_BUILD_TYPE STREQUAL "STATIC")
- ENDIF(EXISTS ${SUBDIR}/plug.in)
-
- IF(NOT ENGINE_BUILD_TYPE STREQUAL "NONE")
- LIST(APPEND ${ENGINE_BUILD_TYPE}_ENGINE_DIRECTORIES ${SUBDIR})
- ENDIF(NOT ENGINE_BUILD_TYPE STREQUAL "NONE")
-
- ENDIF(HAVE_STORAGE_ENGINE)
- ENDIF(EXISTS ${SUBDIR}/CMakeLists.txt)
-ENDFOREACH(SUBDIR ${STORAGE_SUBDIRS})
-
-# Special handling for partition(not really pluggable)
-IF(NOT WITHOUT_PARTITION_STORAGE_ENGINE)
- SET (STORAGE_ENGINE_DEFS "${STORAGE_ENGINE_DEFS} -DWITH_PARTITION_STORAGE_ENGINE")
- SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_partition_plugin")
-ENDIF(NOT WITHOUT_PARTITION_STORAGE_ENGINE)
-
-ADD_DEFINITIONS(${STORAGE_ENGINE_DEFS})
-
-# Now write out our mysql_plugin_defs struct
-CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc.in
- ${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc @ONLY)
-
-# Add subdirectories for storage engines
-SET (ENGINE_BUILD_TYPE "STATIC")
-FOREACH(DIR ${STATIC_ENGINE_DIRECTORIES})
- ADD_SUBDIRECTORY(${DIR})
-ENDFOREACH(DIR ${STATIC_ENGINE_DIRECTORIES})
-
-SET (ENGINE_BUILD_TYPE "DYNAMIC")
-FOREACH(DIR ${DYNAMIC_ENGINE_DIRECTORIES})
- ADD_SUBDIRECTORY(${DIR})
-ENDFOREACH(DIR ${DYNAMIC_ENGINE_DIRECTORIES})
-
-# Add subdirectories for semisync plugin
-IF(NOT WITHOUT_DYNAMIC_PLUGINS)
- ADD_SUBDIRECTORY(plugin/semisync)
-ENDIF(NOT WITHOUT_DYNAMIC_PLUGINS)
-
-# FIXME "debug" only needed if build type is "Debug", but
-# CMAKE_BUILD_TYPE is not set during configure time.
-ADD_SUBDIRECTORY(vio)
+ SET(IF_WIN 0)
+ELSE()
+ SET(IF_WIN 1)
+ENDIF()
+
+# Add macros
+INCLUDE(cmake/character_sets.cmake)
+INCLUDE(cmake/zlib.cmake)
+INCLUDE(cmake/ssl.cmake)
+INCLUDE(cmake/readline.cmake)
+INCLUDE(cmake/mysql_version.cmake)
+INCLUDE(cmake/misc.cmake)
+INCLUDE(cmake/dtrace.cmake)
+INCLUDE(cmake/plugin.cmake)
+INCLUDE(cmake/install_macros.cmake)
+
+# Handle options
+OPTION(ENABLED_PROFILING "Enable profiling" ON)
+OPTION(CYBOZU "" OFF)
+OPTION(BACKUP_TEST "" OFF)
+OPTION(WITHOUT_SERVER OFF)
+MARK_AS_ADVANCED(CYBOZU BACKUP_TEST WITHOUT_SERVER)
+
+
+OPTION(ENABLE_DEBUG_SYNC "Enable debug sync (debug builds only)" ON)
+IF(ENABLE_DEBUG_SYNC)
+ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DENABLED_DEBUG_SYNC")
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DENABLED_DEBUG_SYNC")
+ENDIF()
+
+OPTION(WITH_ERROR_INJECT
+ "Enable error injection in MySQL Server (debug builds only)" OFF)
+IF(WITH_ERROR_INJECT)
+ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DERROR_INJECT_SUPPORT")
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DERROR_INJECT_SUPPORT")
+ENDIF()
+
+
+
+OPTION(ENABLE_LOCAL_INFILE
+ "If we should should enable LOAD DATA LOCAL by default" ${IF_WIN})
+MARK_AS_ADVANCED(ENABLE_LOCAL_INFILE)
+
+# Set DBUG_OFF for non-debug project types.
+FOREACH(BUILD_TYPE RELEASE RELWITHDEBINFO MINSIZEREL)
+ FOREACH(LANG C CXX)
+ SET(CMAKE_${LANG}_FLAGS_${BUILD_TYPE}
+ "${CMAKE_${LANG}_FLAGS_${BUILD_TYPE}} -DDBUG_OFF")
+ ENDFOREACH()
+ENDFOREACH()
+
+IF(NOT CMAKE_BUILD_TYPE
+ AND NOT CMAKE_GENERATOR MATCHES "Visual Studio"
+ AND NOT CMAKE_GENERATOR MATCHES "Xcode")
+ # This is the case of no CMAKE_BUILD_TYPE choosen, typical for VS and Xcode
+ # or if custom C flags are set. In VS and Xcode for non-Debug configurations
+ # DBUG_OFF is already correctly set. Use DBUG_OFF for Makefile based projects
+ # without build type too, unless user specifically requests DBUG.
+ IF(NOT CMAKE_C_FLAGS MATCHES "-DDBUG_ON")
+ ADD_DEFINITIONS(-DDBUG_OFF)
+ ENDIF()
+ENDIF()
+
+# Add safemalloc and safemutex for debug condifurations, except on Windows
+# (C runtime library provides safemalloc functionality and safemutex has never
+# worked there)
+IF(WITH_DEBUG OR WITH_DEBUG_FULL AND NOT WIN32)
+ FOREACH(LANG C CXX)
+ IF(WITH_DEBUG_FULL)
+ SET(CMAKE_${LANG}_FLAGS_DEBUG "-DSAFEMALLOC -DSAFE_MUTEX")
+ ELSE()
+ SET(CMAKE_${LANG}_FLAGS_DEBUG "-DSAFE_MUTEX")
+ ENDIF()
+ ENDFOREACH()
+ENDIF()
+
+
+
+
+# Set commonly used variables
+IF(WIN32)
+ SET(DEFAULT_MYSQL_HOME "C:/Program Files/MySQL/MySQL Server ${MYSQL_BASE_VERSION}/" )
+ SET(SHAREDIR share)
+ELSE()
+ SET(DEFAULT_MYSQL_HOME ${CMAKE_INSTALL_PREFIX}/mysql/)
+ SET(SHAREDIR ${DEFAULT_MYSQL_HOME}share)
+ENDIF()
+
+SET(DEFAULT_BASEDIR "${DEFAULT_MYSQL_HOME}")
+SET(MYSQL_DATADIR "${DEFAULT_MYSQL_HOME}data")
+SET(DEFAULT_CHARSET_HOME "${DEFAULT_MYSQL_HOME}")
+
+
+# Optionally read user configuration, generated by configure.js.
+# This is left for backward compatibility reasons only.
+IF(WIN32)
+ INCLUDE(win/configure.data OPTIONAL)
+ENDIF()
+
+# Run platform tests
+INCLUDE(configure.cmake)
+
+# Common defines and includes
+ADD_DEFINITIONS(-DHAVE_CONFIG_H)
+INCLUDE_DIRECTORIES(${CMAKE_CURRENT_BINARY_DIR}/include)
+
+# Add bundled or system zlib.
+MYSQL_CHECK_ZLIB_WITH_COMPRESS()
+# Optionally add bundled yassl/taocrypt or system openssl.
+MYSQL_CHECK_SSL()
+# Add readline or libedit.
+MYSQL_CHECK_READLINE()
+
+IF(NOT WITHOUT_SERVER)
+ # Add storage engines and plugins.
+ CONFIGURE_PLUGINS()
+ENDIF()
+
+ADD_SUBDIRECTORY(include)
ADD_SUBDIRECTORY(dbug)
ADD_SUBDIRECTORY(strings)
+ADD_SUBDIRECTORY(vio)
ADD_SUBDIRECTORY(regex)
ADD_SUBDIRECTORY(mysys)
-ADD_SUBDIRECTORY(scripts)
-ADD_SUBDIRECTORY(zlib)
-ADD_SUBDIRECTORY(extra/yassl)
-ADD_SUBDIRECTORY(extra/yassl/taocrypt)
-ADD_SUBDIRECTORY(extra)
-ADD_SUBDIRECTORY(client)
-ADD_SUBDIRECTORY(sql)
ADD_SUBDIRECTORY(libmysql)
-ADD_SUBDIRECTORY(libservices)
-ADD_SUBDIRECTORY(tests)
-IF(WITH_EMBEDDED_SERVER)
- ADD_SUBDIRECTORY(libmysqld)
- ADD_SUBDIRECTORY(libmysqld/examples)
-ENDIF(WITH_EMBEDDED_SERVER)
-ADD_SUBDIRECTORY(mysql-test/lib/My/SafeProcess)
+
+OPTION (WITH_UNIT_TESTS "Compile MySQL with unit tests" ON)
+IF(WITH_UNIT_TESTS)
+ ENABLE_TESTING()
+ENDIF()
+IF(WITH_UNIT_TESTS)
+ ADD_SUBDIRECTORY(unittest/mytap)
+ ADD_SUBDIRECTORY(unittest/mysys)
+ENDIF()
+
+IF(NOT WITHOUT_SERVER)
+ ADD_SUBDIRECTORY(tests)
+ ADD_SUBDIRECTORY(extra)
+ ADD_SUBDIRECTORY(client)
+ ADD_SUBDIRECTORY(sql)
+ ADD_SUBDIRECTORY(sql/share)
+ ADD_SUBDIRECTORY(libservices)
+ OPTION (WITH_EMBEDDED_SERVER "Compile MySQL with embedded server" OFF)
+ IF(WITH_EMBEDDED_SERVER)
+ ADD_SUBDIRECTORY(libmysqld)
+ ADD_SUBDIRECTORY(libmysqld/examples)
+ ENDIF(WITH_EMBEDDED_SERVER)
+
+ ADD_SUBDIRECTORY(mysql-test)
+ ADD_SUBDIRECTORY(mysql-test/lib/My/SafeProcess)
+ ADD_SUBDIRECTORY(support-files)
+ ADD_SUBDIRECTORY(scripts)
+ ADD_SUBDIRECTORY(sql-bench)
+ IF(UNIX)
+ ADD_SUBDIRECTORY(man)
+ ENDIF()
+ENDIF()
+
+INCLUDE(cmake/abi_check.cmake)
+
+CONFIGURE_FILE(config.h.cmake ${CMAKE_BINARY_DIR}/include/my_config.h)
+CONFIGURE_FILE(config.h.cmake ${CMAKE_BINARY_DIR}/include/config.h)
+CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/include/mysql_version.h.in
+ ${CMAKE_BINARY_DIR}/include/mysql_version.h )
+
+
+# Packaging
+IF(WIN32)
+ SET(CPACK_GENERATOR "ZIP")
+ELSE()
+ SET(CPACK_GENERATOR "TGZ")
+ENDIF()
+INCLUDE(CPack)
+INSTALL(FILES COPYING EXCEPTIONS-CLIENT README DESTINATION .)
+IF(UNIX)
+ INSTALL(FILES Docs/INSTALL-BINARY DESTINATION .)
+ENDIF()
diff --git a/Makefile.am b/Makefile.am
index a4b02d23393..498184330ba 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,7 +19,8 @@ AUTOMAKE_OPTIONS = foreign
# These are built from source in the Docs directory
EXTRA_DIST = INSTALL-SOURCE INSTALL-WIN-SOURCE \
- README COPYING EXCEPTIONS-CLIENT CMakeLists.txt
+ README COPYING EXCEPTIONS-CLIENT \
+ CMakeLists.txt configure.cmake config.h.cmake BUILD-CMAKE
SUBDIRS = . include @docs_dirs@ @zlib_dir@ \
@readline_topdir@ sql-common scripts \
@@ -28,8 +29,8 @@ SUBDIRS = . include @docs_dirs@ @zlib_dir@ \
@sql_server@ @man_dirs@ tests \
netware @libmysqld_dirs@ \
mysql-test support-files sql-bench \
- win
-
+ win \
+ cmake
DIST_SUBDIRS = . include Docs zlib \
cmd-line-utils sql-common scripts \
pstack libservices \
@@ -38,6 +39,7 @@ DIST_SUBDIRS = . include Docs zlib \
netware libmysqld \
mysql-test support-files sql-bench \
win \
+ cmake \
BUILD
DISTCLEANFILES = ac_available_languages_fragment
@@ -58,6 +60,7 @@ dist-hook:
--datadir=$(distdir)/win/data \
--srcdir=$(top_srcdir)
storage/myisam/myisamchk --silent --fast $(distdir)/win/data/mysql/*.MYI
+ test ! -f configure.am || $(INSTALL_DATA) configure.am $(distdir)
all-local: @ABI_CHECK@
diff --git a/client/CMakeLists.txt b/client/CMakeLists.txt
index 28e4c354a69..1cda6592a6e 100755
--- a/client/CMakeLists.txt
+++ b/client/CMakeLists.txt
@@ -12,46 +12,49 @@
# 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("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
- ${CMAKE_SOURCE_DIR}/zlib
- ${CMAKE_SOURCE_DIR}/extra/yassl/include
- ${CMAKE_SOURCE_DIR}/libmysql
- ${CMAKE_SOURCE_DIR}/regex
- ${CMAKE_SOURCE_DIR}/sql
- ${CMAKE_SOURCE_DIR}/strings)
+INCLUDE_DIRECTORIES(
+ ${CMAKE_SOURCE_DIR}/include
+ ${ZLIB_INCLUDE_DIR}
+ ${SSL_INCLUDE_DIRS}
+ ${CMAKE_SOURCE_DIR}/libmysql
+ ${CMAKE_SOURCE_DIR}/regex
+ ${CMAKE_SOURCE_DIR}/sql
+ ${CMAKE_SOURCE_DIR}/strings
+ ${READLINE_INCLUDE_DIR}
+ ${CMAKE_CURRENT_BINARY_DIR}
+)
-ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc ../mysys/my_conio.c)
+ADD_DEFINITIONS(${READLINE_DEFINES})
+ADD_DEFINITIONS(${SSL_DEFINES})
+ADD_EXECUTABLE(mysql completion_hash.cc mysql.cc readline.cc sql_string.cc)
TARGET_LINK_LIBRARIES(mysql mysqlclient)
+IF(UNIX)
+ TARGET_LINK_LIBRARIES(mysql ${READLINE_LIBRARY})
+ENDIF(UNIX)
ADD_EXECUTABLE(mysqltest mysqltest.cc)
SET_SOURCE_FILES_PROPERTIES(mysqltest.cc PROPERTIES COMPILE_FLAGS "-DTHREADS")
-TARGET_LINK_LIBRARIES(mysqltest mysqlclient mysys regex dbug)
+TARGET_LINK_LIBRARIES(mysqltest mysqlclient regex)
+
ADD_EXECUTABLE(mysqlcheck mysqlcheck.c)
TARGET_LINK_LIBRARIES(mysqlcheck mysqlclient)
-ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c ../mysys/mf_getdate.c)
+ADD_EXECUTABLE(mysqldump mysqldump.c ../sql-common/my_user.c)
TARGET_LINK_LIBRARIES(mysqldump mysqlclient)
ADD_EXECUTABLE(mysqlimport mysqlimport.c)
TARGET_LINK_LIBRARIES(mysqlimport mysqlclient)
-ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c ../mysys/my_getpagesize.c)
+ADD_EXECUTABLE(mysql_upgrade mysql_upgrade.c)
TARGET_LINK_LIBRARIES(mysql_upgrade mysqlclient)
ADD_DEPENDENCIES(mysql_upgrade GenFixPrivs)
ADD_EXECUTABLE(mysqlshow mysqlshow.c)
TARGET_LINK_LIBRARIES(mysqlshow mysqlclient)
-ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc
- ../mysys/mf_tempdir.c
- ../mysys/my_new.cc
- ../mysys/my_bit.c
- ../mysys/my_bitmap.c
- ../mysys/my_vle.c
- ../mysys/base64.c)
+ADD_EXECUTABLE(mysqlbinlog mysqlbinlog.cc)
TARGET_LINK_LIBRARIES(mysqlbinlog mysqlclient)
ADD_EXECUTABLE(mysqladmin mysqladmin.cc)
@@ -59,20 +62,25 @@ TARGET_LINK_LIBRARIES(mysqladmin mysqlclient)
ADD_EXECUTABLE(mysqlslap mysqlslap.c)
SET_SOURCE_FILES_PROPERTIES(mysqlslap.c PROPERTIES COMPILE_FLAGS "-DTHREADS")
-TARGET_LINK_LIBRARIES(mysqlslap mysqlclient mysys zlib dbug)
+TARGET_LINK_LIBRARIES(mysqlslap mysqlclient)
ADD_EXECUTABLE(echo echo.c)
-IF(EMBED_MANIFESTS)
- MYSQL_EMBED_MANIFEST("mysql" "asInvoker")
- MYSQL_EMBED_MANIFEST("mysqltest" "asInvoker")
- MYSQL_EMBED_MANIFEST("mysqlcheck" "asInvoker")
- MYSQL_EMBED_MANIFEST("mysqldump" "asInvoker")
- MYSQL_EMBED_MANIFEST("mysqlimport" "asInvoker")
- MYSQL_EMBED_MANIFEST("mysql_upgrade" "asInvoker")
- MYSQL_EMBED_MANIFEST("mysqlshow" "asInvoker")
- MYSQL_EMBED_MANIFEST("mysqlbinlog" "asInvoker")
- MYSQL_EMBED_MANIFEST("mysqladmin" "asInvoker")
- MYSQL_EMBED_MANIFEST("echo" "asInvoker")
-ENDIF(EMBED_MANIFESTS)
+SET_TARGET_PROPERTIES (mysqlcheck mysqldump mysqlimport mysql_upgrade mysqlshow mysqlslap
+PROPERTIES HAS_CXX TRUE)
+
+SET(INSTALL_EXES
+ mysqlcheck
+ mysqldump
+ mysqlimport
+ mysql_upgrade
+ mysqlshow
+ mysqlslap
+ mysql
+ mysqladmin
+ mysqlbinlog
+ mysqltest)
+
+INSTALL(TARGETS ${INSTALL_EXES} DESTINATION bin)
+INSTALL_DEBUG_SYMBOLS("${INSTALL_EXES}")
diff --git a/cmake/Makefile.am b/cmake/Makefile.am
new file mode 100644
index 00000000000..2326f787ab8
--- /dev/null
+++ b/cmake/Makefile.am
@@ -0,0 +1,21 @@
+EXTRA_DIST = \
+ cat.cmake \
+ check_minimal_version.cmake \
+ create_initial_db.cmake.in \
+ make_dist.cmake.in \
+ dtrace.cmake \
+ abi_check.cmake \
+ bison.cmake \
+ configure.pl \
+ character_sets.cmake \
+ misc.cmake \
+ readline.cmake \
+ mysql_version.cmake \
+ install_macros.cmake \
+ ssl.cmake \
+ plugin.cmake \
+ zlib.cmake \
+ stack_direction.c \
+ do_abi_check.cmake \
+ merge_archives_unix.cmake.in \
+ dtrace_prelink.cmake
diff --git a/cmake/abi_check.cmake b/cmake/abi_check.cmake
new file mode 100644
index 00000000000..61b0d9e7970
--- /dev/null
+++ b/cmake/abi_check.cmake
@@ -0,0 +1,60 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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.
+# API_PREPROCESSOR_HEADER will be used until mysql_priv.h stablizes
+# after which TEST_PREPROCESSOR_HEADER will be used.
+#
+# We use gcc specific preprocessing command and sed/diff, so it will
+# only be run on Unix and only if gcc is used.
+IF(CMAKE_COMPILER_IS_GNUCC AND UNIX)
+ 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.h
+ ${CMAKE_SOURCE_DIR}/include/mysql.h)
+
+ SET(TEST_PREPROCESSOR_HEADER
+ ${CMAKE_SOURCE_DIR}/include/mysql/plugin.h
+ ${CMAKE_SOURCE_DIR}/sql/mysql_priv.h
+ ${CMAKE_SOURCE_DIR}/include/mysql.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}
+ -DCMAKE_C_COMPILER=${COMPILER}
+ -DCMAKE_SOURCE_DIR=${CMAKE_SOURCE_DIR}
+ -DCMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}
+ "-DABI_HEADERS=${TEST_PREPROCESSOR_HEADER}"
+ -P ${CMAKE_SOURCE_DIR}/cmake/scripts/do_abi_check.cmake
+ VERBATIM
+ )
+ENDIF()
+
diff --git a/cmake/bison.cmake b/cmake/bison.cmake
new file mode 100644
index 00000000000..b1c2d7393fa
--- /dev/null
+++ b/cmake/bison.cmake
@@ -0,0 +1,64 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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
+
+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 -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.
+ MESSAGE(FATAL_ERROR "Please install bison.")
+ ENDIF()
+ ENDIF()
+ENDMACRO()
diff --git a/cmake/cat.cmake b/cmake/cat.cmake
new file mode 100644
index 00000000000..532f4115104
--- /dev/null
+++ b/cmake/cat.cmake
@@ -0,0 +1,27 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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..c21b6c60113
--- /dev/null
+++ b/cmake/character_sets.cmake
@@ -0,0 +1,63 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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_COLLATIONS)
+SET(DEFAULT_COLLATION "latin1_swedish_ci")
+ENDIF()
+
+SET(CHARSETS ${DEFAULT_CHARSET} latin1 utf8 utf8mb3)
+SET(CHARSETS_COMPLEX big5 cp1250 cp932 eucjpms euckr gb2312 gbk latin1 latin2 sjis tis620 ucs2 ujis utf8 utf8mb3 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 utf8mb3 utf16 utf32)
+
+
+IF(WIN32)
+ SET (EXTRA_CHARSETS "all")
+ELSE()
+ SET (EXTRA_CHARSETS "none")
+ENDIF()
+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..4f134712fae
--- /dev/null
+++ b/cmake/check_minimal_version.cmake
@@ -0,0 +1,19 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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/configure.pl b/cmake/configure.pl
new file mode 100644
index 00000000000..ee7846b9c36
--- /dev/null
+++ b/cmake/configure.pl
@@ -0,0 +1,79 @@
+#!/usr/bin/perl
+use Switch;
+
+my $cmakeargs="";
+foreach $option (@ARGV)
+{
+ if (substr ($option, 0, 2) == "--")
+ {
+ $option = substr($option, 2);
+ }
+ if($option =~ /help/)
+ {
+ system("cmake -LH");
+ exit(0);
+ }
+ if($option =~ /with-plugins=/)
+ {
+ my @plugins= split(/,/, substr($option,13));
+ foreach $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=bundled";
+ next;
+ }
+ if($option =~ /with-ssl/)
+ {
+ $cmakeargs = $cmakeargs." -DWITH_SSL=yes";
+ next;
+ }
+ if($option =~ /prefix=/)
+ {
+ my $cmake_install_prefix= substr($option, 7);
+ $cmakeargs = $cmakeargs." -DCMAKE_INSTALL_PREFIX=".$cmake_install_prefix;
+ next;
+ }
+ if ($options =~ /extra-charsets=all/)
+ {
+ $cmakeargs = $cmakeargs." -DWITH_CHARSETS=all";
+ next;
+ }
+ if ($options =~ /extra-charsets=complex/)
+ {
+ $cmakeargs = $cmakeargs." -DWITH_CHARSETS=complex";
+ next;
+ }
+ $option = uc($option);
+ $option =~ s/-/_/g;
+ $cmakeargs = $cmakeargs." -D".$option."=1";
+}
+print("configure.pl : calling cmake . $cmakeargs\n");
+my $rc = system("cmake . $cmakeargs");
+exit($rc);
diff --git a/cmake/create_initial_db.cmake.in b/cmake/create_initial_db.cmake.in
new file mode 100644
index 00000000000..92ebc72d425
--- /dev/null
+++ b/cmake/create_initial_db.cmake.in
@@ -0,0 +1,84 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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@")
+SET ($ENV{VS_UNICODE_OUTPUT})
+IF(CMAKE_CFG_INTDIR)
+ IF(CONFIG)
+ MESSAGE(${CONFIG})
+ #Resolve build configuration variables
+ STRING(REPLACE "${CMAKE_CFG_INTDIR}" ${CONFIG} MYSQLD_EXECUTABLE
+ "${MYSQLD_EXECUTABLE}")
+ ELSE()
+ MESSAGE(FATAL_ERROR "Please provide CONFIG parameter to the script")
+ ENDIF()
+ENDIF()
+
+# Create bootstrapper SQL script
+FILE(WRITE bootstrap.sql "use mysql;\n" )
+FOREACH(FILENAME mysql_system_tables.sql mysql_system_tables_data.sql
+ fill_help_tables.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()
+
+
+MAKE_DIRECTORY(data)
+FILE(REMOVE_RECURSE data/mysql)
+MAKE_DIRECTORY(data/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=.
+ --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()
+ \ No newline at end of file
diff --git a/cmake/do_abi_check.cmake b/cmake/do_abi_check.cmake
new file mode 100644
index 00000000000..aa7784e7372
--- /dev/null
+++ b/cmake/do_abi_check.cmake
@@ -0,0 +1,78 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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})
+ SET(tmpfile ${file}.pp.tmp)
+ EXECUTE_PROCESS(
+ COMMAND ${COMPILER}
+ -E -nostdinc -dI -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..5c031e04841
--- /dev/null
+++ b/cmake/dtrace.cmake
@@ -0,0 +1,92 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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 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")
+ 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
+ )
+ 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()
+
+
+MACRO (DTRACE_INSTRUMENT target)
+ IF(ENABLE_DTRACE)
+ ADD_DEPENDENCIES(${target} gen_dtrace_header)
+
+ # 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 ${CMAKE_CURRENT_BINARY_DIR}/${target}_dtrace.o)
+
+ 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}
+ -P ${CMAKE_SOURCE_DIR}/cmake/dtrace_prelink.cmake
+ WORKING_DIRECTORY ${OBJDIR}
+ )
+ SET_TARGET_PROPERTIES(${target} PROPERTIES LINK_FLAGS "${outfile}")
+ ENDIF()
+ ENDIF()
+ENDMACRO()
diff --git a/cmake/dtrace_prelink.cmake b/cmake/dtrace_prelink.cmake
new file mode 100644
index 00000000000..53e12407cb9
--- /dev/null
+++ b/cmake/dtrace_prelink.cmake
@@ -0,0 +1,34 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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(GLOB_RECURSE OBJECTS *.o)
+
+# Use relative paths to generate shorter command line
+GET_FILENAME_COMPONENT(CURRENT_ABS_DIR . ABSOLUTE)
+FOREACH(OBJ ${OBJECTS})
+ FILE(RELATIVE_PATH REL ${CURRENT_ABS_DIR} ${OBJ})
+ LIST(APPEND REL_OBJECTS ${REL})
+ENDFOREACH()
+
+EXECUTE_PROCESS(
+ COMMAND ${DTRACE} ${DTRACE_FLAGS} -o ${OUTFILE} -G -s ${DFILE} ${REL_OBJECTS}
+)
+
diff --git a/cmake/install_macros.cmake b/cmake/install_macros.cmake
new file mode 100644
index 00000000000..4fc6db6b9b7
--- /dev/null
+++ b/cmake/install_macros.cmake
@@ -0,0 +1,69 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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 (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})
+ STRING(REPLACE "$(OutDir)" "\${CMAKE_INSTALL_CONFIG_NAME}" pdb_location ${pdb_location})
+ STRING(REPLACE "$(ConfigurationName)" "\${CMAKE_INSTALL_CONFIG_NAME}" pdb_location ${pdb_location})
+ INSTALL(FILES ${pdb_location} DESTINATION ${INSTALL_LOCATION})
+ ENDFOREACH()
+ ENDIF()
+ENDMACRO()
+
+# 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 linkbasename target destination)
+IF(UNIX)
+ GET_TARGET_PROPERTY(location ${target} LOCATION)
+ GET_FILENAME_COMPONENT(path ${location} PATH)
+ GET_FILENAME_COMPONENT(name_we ${location} NAME_WE)
+ GET_FILENAME_COMPONENT(ext ${location} EXT)
+ SET(output ${path}/${linkbasename}${ext})
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${output}
+ COMMAND ${CMAKE_COMMAND} ARGS -E remove -f ${output}
+ COMMAND ${CMAKE_COMMAND} ARGS -E create_symlink
+ ${name_we}${ext}
+ ${linkbasename}${ext}
+ WORKING_DIRECTORY ${path}
+ DEPENDS ${target}
+ )
+
+ ADD_CUSTOM_TARGET(symlink_${linkbasename}${ext}
+ ALL
+ DEPENDS ${output})
+ SET_TARGET_PROPERTIES(symlink_${linkbasename}${ext} PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+ # For Xcode, replace project config with install config
+ STRING(REPLACE "$(CONFIGURATION)" "\${CMAKE_INSTALL_CONFIG_NAME}" output ${output})
+ INSTALL(FILES ${output} DESTINATION ${destination})
+ENDIF()
+ENDMACRO()
+
diff --git a/cmake/make_dist.cmake.in b/cmake/make_dist.cmake.in
new file mode 100644
index 00000000000..aae5bdbc666
--- /dev/null
+++ b/cmake/make_dist.cmake.in
@@ -0,0 +1,176 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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, add output of BUILD/autorun.sh
+# if autotools are present, also pack bison output into it.
+# 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(GLIBTOOLIZE_EXECUTABLE "@GLIBTOOLIZE_EXECUTABLE@")
+SET(LIBTOOLIZE_EXECUTABLE "@LIBTOOLIZE_EXECUTABLE@")
+SET(ACLOCAL_EXECUTABLE "@ACLOCAL_EXECUTABLE@")
+SET(AUTOCONF_EXECUTABLE "@AUTOCONF_EXECUTABLE@")
+SET(AUTOHEADER_EXECUTABLE "@AUTOHEADER_EXECUTABLE@")
+SET(AUTOMAKE_EXECUTABLE "@AUTOMAKE_EXECUTABLE@")
+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(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(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()
+
+# Try to pack output of BUILD/autorun, if autotools are present
+IF(GLIBTOOLIZE_EXECUTABLE OR LIBTOOLIZE_EXECUTABLE)
+ IF(ACLOCAL_EXECUTABLE AND AUTOMAKE_EXECUTABLE AND AUTOCONF_EXECUTABLE
+ AND AUTOHEADER_EXECUTABLE)
+ SET(HAVE_AUTOTOOLS 1)
+ ENDIF()
+ENDIF()
+
+IF(HAVE_AUTOTOOLS)
+ EXECUTE_PROCESS(COMMAND BUILD/autorun.sh
+ WORKING_DIRECTORY ${PACKAGE_DIR})
+ELSE()
+ MESSAGE( "Autotools not found, resulting source package can only be built"
+ " with cmake")
+ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/configure.pl
+ ${PACKAGE_DIR}/configure
+ COPYONLY)
+ IF(UNIX)
+ EXECUTE_PROCESS(COMMAND chmod +x ${PACKAGE_DIR}/configure)
+ ENDIF()
+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)
+
+
+# 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..a9a060ab49e
--- /dev/null
+++ b/cmake/merge_archives_unix.cmake.in
@@ -0,0 +1,62 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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/misc.cmake b/cmake/misc.cmake
new file mode 100644
index 00000000000..c73e66ef3d7
--- /dev/null
+++ b/cmake/misc.cmake
@@ -0,0 +1,128 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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
+
+# Merge static libraries.
+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})
+
+ 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.
+ TARGET_LINK_LIBRARIES(${TARGET} ${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})
+ ELSE()
+ # This is a shared library our static lib depends on.
+ TARGET_LINK_LIBRARIES(${TARGET} ${LIB})
+ ENDIF()
+ ENDIF()
+ ENDFOREACH()
+
+ # 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(
+ ${CMAKE_SOURCE_DIR}/cmake/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()
+
+# Convert static library to shared
+MACRO(STATIC_TO_SHARED STATIC_LIB SHARED_LIB EXPORTS_FILE)
+ IF(NOT MSVC)
+ MESSAGE(FATAL_ERROR
+ "Cannot convert static ${STATIC_LIB} to shared ${TARGET} library."
+ )
+ ENDIF()
+
+ # Need one source file.
+ SET(SOURCE_FILE ${CMAKE_CURRENT_BINARY_DIR}/${SHARED_LIB}_dummy.c)
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${SOURCE_FILE}
+ COMMAND ${CMAKE_COMMAND} -E touch ${SOURCE_FILE}
+ )
+
+ ADD_LIBRARY(${SHARED_LIB} SHARED ${SOURCE_FILE} ${EXPORTS_FILE})
+ TARGET_LINK_LIBRARIES(${SHARED_LIB} ${STATIC_LIB})
+ENDMACRO()
+
+MACRO(SET_TARGET_SOURCEDIR TARGET)
+ SET(${TARGET}_SOURCEDIR ${CMAKE_CURRENT_SOURCE_DIR} CACHE INTERNAL "source directory for a target")
+ENDMACRO()
+
+# Handy macro to use when source projects maybe used somewhere else
+# For example, embedded or client library may recompile mysys sources
+# In such cases, using absolute names in ADD_LIBRARY has the advantage that
+# GET_TARGET_PROPERTY(xxx SOURCES) also returns absolute names, so there is
+# no need to know the base directory of a target.
+MACRO(USE_ABSOLUTE_FILENAMES FILELIST)
+ # Use absolute file paths for sources
+ # It helps when building embedded where we need to
+ # sources files for the plugin to recompile.
+ SET(RESOLVED_PATHS)
+ FOREACH(FILE ${${FILELIST}})
+ GET_FILENAME_COMPONENT(ABSOLUTE_PATH ${FILE} ABSOLUTE)
+ LIST(APPEND RESOLVED_PATHS ${ABSOLUTE_PATH})
+ ENDFOREACH()
+ SET(${FILELIST} ${RESOLVED_PATHS})
+ENDMACRO()
diff --git a/cmake/mysql_version.cmake b/cmake/mysql_version.cmake
new file mode 100644
index 00000000000..8b0e8f4efab
--- /dev/null
+++ b/cmake/mysql_version.cmake
@@ -0,0 +1,142 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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
+
+# Read value for a variable from configure.in
+
+MACRO(MYSQL_GET_CONFIG_VALUE keyword var)
+ IF(NOT ${var})
+ IF (EXISTS ${CMAKE_SOURCE_DIR}/configure.in)
+ FILE (STRINGS ${CMAKE_SOURCE_DIR}/configure.in str REGEX "^[ ]*${keyword}=")
+ IF(str)
+ STRING(REPLACE "${keyword}=" "" str ${str})
+ STRING(REGEX REPLACE "[ ].*" "" str ${str})
+ SET(${var} ${str} CACHE INTERNAL "Config variable")
+ ENDIF()
+ ENDIF()
+ ENDIF()
+ENDMACRO()
+
+
+# Read mysql version for configure script
+
+MACRO(GET_MYSQL_VERSION)
+
+ IF(NOT VERSION_STRING)
+ IF(EXISTS ${CMAKE_SOURCE_DIR}/configure.in)
+ FILE(STRINGS ${CMAKE_SOURCE_DIR}/configure.in str REGEX "AM_INIT_AUTOMAKE")
+ STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+[-][^ \\)]+" VERSION_STRING "${str}")
+ IF(NOT VERSION_STRING)
+ FILE(STRINGS configure.in str REGEX "AC_INIT\\(")
+ STRING(REGEX MATCH "[0-9]+\\.[0-9]+\\.[0-9]+[-][^ \\]]+" VERSION_STRING "${str}")
+ ENDIF()
+ ENDIF()
+ ENDIF()
+
+ IF(NOT VERSION_STRING)
+ MESSAGE(FATAL_ERROR
+ "VERSION_STRING cannot be parsed, please specify -DVERSION_STRING=major.minor.patch-extra"
+ "when calling cmake")
+ ENDIF()
+
+ SET(VERSION ${VERSION_STRING})
+
+ STRING(REGEX REPLACE "([0-9]+)\\.[0-9]+\\.[0-9]+[^ ]+" "\\1" MAJOR_VERSION "${VERSION_STRING}")
+ STRING(REGEX REPLACE "[0-9]+\\.([0-9]+)\\.[0-9]+[^ ]+" "\\1" MINOR_VERSION "${VERSION_STRING}")
+ STRING(REGEX REPLACE "[0-9]+\\.[0-9]+\\.([0-9]+)[^ ]+" "\\1" PATCH "${VERSION_STRING}")
+ SET(MYSQL_BASE_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}" CACHE INTERNAL "MySQL Base version")
+ SET(MYSQL_NO_DASH_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH}")
+ MATH(EXPR MYSQL_VERSION_ID "10000*${MAJOR_VERSION} + 100*${MINOR_VERSION} + ${PATCH}")
+ 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})
+ENDMACRO()
+
+# Get mysql version and other interesting variables
+GET_MYSQL_VERSION()
+
+MYSQL_GET_CONFIG_VALUE("PROTOCOL_VERSION" PROTOCOL_VERSION)
+MYSQL_GET_CONFIG_VALUE("DOT_FRM_VERSION" DOT_FRM_VERSION)
+MYSQL_GET_CONFIG_VALUE("MYSQL_TCP_PORT_DEFAULT" MYSQL_TCP_PORT_DEFAULT)
+MYSQL_GET_CONFIG_VALUE("MYSQL_UNIX_ADDR_DEFAULT" MYSQL_UNIX_ADDR_DEFAULT)
+MYSQL_GET_CONFIG_VALUE("SHARED_LIB_MAJOR_VERSION" SHARED_LIB_MAJOR_VERSION)
+IF(NOT MYSQL_TCP_PORT_DEFAULT)
+ SET(MYSQL_TCP_PORT_DEFAULT "3306")
+ENDIF()
+IF(NOT MYSQL_TCP_PORT)
+ SET(MYSQL_TCP_PORT ${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()
+
+
+
+# Use meaningful package name for the binary package
+IF(NOT CPACK_PACKAGE_FILE_NAME)
+ IF( NOT SYSTEM_NAME_AND_PROCESSOR)
+ IF(WIN32)
+ # CMake does not set CMAKE_SYSTEM_PROCESSOR correctly on Win64
+ # (uses x86). Besides, we try to be compatible with existing naming
+ IF(CMAKE_SIZEOF_VOID_P EQUAL 8)
+ SET(SYSTEM_NAME_AND_PROCESSOR "winx64")
+ ELSE()
+ SET(SYSTEM_NAME_AND_PROCESSOR "win32")
+ ENDIF()
+ ELSE()
+ IF(NOT PLATFORM)
+ SET(PLATFORM ${CMAKE_SYSTEM_NAME})
+ ENDIF()
+ IF(NOT MACHINE)
+ SET(MACHINE ${CMAKE_SYSTEM_PROCESSOR})
+ IF(CMAKE_SIZEOF_VOID_P EQUAL 8 AND NOT ${MACHINE} MATCHES "ia64")
+ # On almost every 64 bit machine (except IA64) it is possible
+ # to build 32 bit packages. Add -64bit suffix to differentiate
+ # between 32 and 64 bit packages.
+ SET(MACHINE ${MACHINE}-64bit)
+ ENDIF()
+ ENDIF()
+ SET(SYSTEM_NAME_AND_PROCESSOR "${PLATFORM}-${MACHINE}")
+ ENDIF()
+ ENDIF()
+
+ SET(package_name "mysql-${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(CPACK_PACKAGE_FILE_NAME ${package_name})
+ENDIF()
+
+IF(NOT CPACK_SOURCE_PACKAGE_FILE_NAME)
+ SET(CPACK_SOURCE_PACKAGE_FILE_NAME "mysql-${VERSION}")
+ENDIF()
+SET(CPACK_PACKAGE_VENDOR "Sun Microsystems")
+SET(CPACK_SOURCE_GENERATOR "TGZ")
+SET(CPACK_SOURCE_IGNORE_FILES
+ \\\\.bzr/
+ \\\\.bzr-mysql
+ .bzrignore
+ CMakeCache.txt
+ /CMakeFiles/
+ /_CPack_Packages/
+ $.gz
+ $.zip
+)
diff --git a/cmake/plugin.cmake b/cmake/plugin.cmake
new file mode 100644
index 00000000000..58a3dafa2f4
--- /dev/null
+++ b/cmake/plugin.cmake
@@ -0,0 +1,171 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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
+
+# Creates a project to build plugin either as static or shared library
+# Parameters:
+# plugin - storage engine name.
+# variable BUILD_TYPE should be set to "STATIC" or "DYNAMIC"
+# Remarks:
+# ${PLUGIN}_SOURCES variable containing source files to produce the
+# library must set before calling this macro
+
+MACRO(MYSQL_PLUGIN plugin)
+ # Add common include directories
+ INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_SOURCE_DIR}/sql
+ ${CMAKE_SOURCE_DIR}/regex
+ ${SSL_INCLUDE_DIRS}
+ ${ZLIB_INCLUDE_DIR})
+
+ STRING(TOUPPER ${plugin} plugin)
+ STRING(TOLOWER ${plugin} target)
+
+ IF(NOT ${plugin}_PLUGIN_STATIC AND NOT ${plugin}_PLUGIN_DYNAMIC)
+ MESSAGE(FATAL_ERROR
+ "Neither ${plugin}_PLUGIN_STATIC nor ${plugin}_PLUGIN_DYNAMIC is defined.
+ Please set at least one of these variables to the name of the output
+ library in CMakeLists.txt prior to calling MYSQL_PLUGIN"
+ )
+ ENDIF()
+
+ IF(WITH_PLUGIN_${plugin})
+ SET(WITH_${plugin} 1)
+ 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})
+ 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(${plugin}_PLUGIN_MANDATORY)
+ SET(WITH_${plugin} 1)
+ ENDIF()
+
+ IF(${plugin} MATCHES NDBCLUSTER AND WITH_MAX_NO_NDB)
+ SET(WITH_${plugin} 0)
+ SET(WITH_${plugin}_STORAGE_ENGINE 0)
+ SET(WITHOUT_${plugin} 1)
+ SET(WITHOUT_${plugin}_STORAGE_ENGINE 0)
+ ENDIF()
+
+ IF(STORAGE_ENGINE)
+ SET(with_var "WITH_${plugin}_STORAGE_ENGINE" )
+ ELSE()
+ SET(with_var "WITH_${plugin}")
+ ENDIF()
+
+
+ USE_ABSOLUTE_FILENAMES(${plugin}_SOURCES)
+
+ IF (WITH_${plugin} AND ${plugin}_PLUGIN_STATIC)
+ ADD_DEFINITIONS(-DMYSQL_SERVER)
+ #Create static library.
+ ADD_LIBRARY(${target} ${${plugin}_SOURCES})
+ DTRACE_INSTRUMENT(${target})
+ ADD_DEPENDENCIES(${target} GenError)
+ IF(${plugin}_LIBS)
+ TARGET_LINK_LIBRARIES(${target} ${${plugin}_LIBS})
+ ENDIF()
+ SET_TARGET_PROPERTIES(${target} PROPERTIES
+ OUTPUT_NAME "${${plugin}_PLUGIN_STATIC}")
+ # Update mysqld dependencies
+ SET (MYSQLD_STATIC_PLUGIN_LIBS ${MYSQLD_STATIC_PLUGIN_LIBS}
+ ${target} PARENT_SCOPE)
+ SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_${target}_plugin"
+ PARENT_SCOPE)
+ SET(${with_var} ON CACHE BOOL "Link ${plugin} statically to the server"
+ FORCE)
+ ELSEIF(NOT WITHOUT_${plugin} AND ${plugin}_PLUGIN_DYNAMIC
+ AND NOT WITHOUT_DYNAMIC_PLUGINS)
+
+ # Create a shared module.
+ ADD_DEFINITIONS(-DMYSQL_DYNAMIC_PLUGIN)
+ ADD_LIBRARY(${target} MODULE ${${plugin}_SOURCES})
+ IF(${plugin}_LIBS)
+ TARGET_LINK_LIBRARIES(${target} ${${plugin}_LIBS})
+ ENDIF()
+ DTRACE_INSTRUMENT(${target})
+ SET_TARGET_PROPERTIES (${target} PROPERTIES PREFIX "")
+ 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)
+ ENDIF()
+
+ ADD_DEPENDENCIES(${target} GenError)
+
+ IF(${plugin}_PLUGIN_DYNAMIC)
+ SET_TARGET_PROPERTIES(${target} PROPERTIES
+ OUTPUT_NAME "${${plugin}_PLUGIN_DYNAMIC}")
+ ENDIF()
+
+ # Update cache "WITH" variable for plugins that support static linking
+ IF(${plugin}_PLUGIN_STATIC)
+ SET(${with_var} OFF CACHE BOOL "Link ${plugin} statically to the server"
+ FORCE)
+ ENDIF()
+
+ # Install dynamic library
+ SET(INSTALL_LOCATION lib/plugin)
+ INSTALL(TARGETS ${target} DESTINATION ${INSTALL_LOCATION})
+ INSTALL_DEBUG_SYMBOLS(${target})
+ ELSE()
+ IF(STORAGE_ENGINE)
+ SET(without_var "WITHOUT_${plugin}_STORAGE_ENGINE")
+ ELSE()
+ SET(without_var "WITHOUT_${plugin}")
+ ENDIF()
+ SET(${without_var} ON CACHE BOOL "Link ${plugin} statically to the server"
+ FORCE)
+ MARK_AS_ADVANCED(${without_var})
+ ENDIF()
+ENDMACRO()
+
+MACRO (MYSQL_STORAGE_ENGINE engine)
+ SET(STORAGE_ENGINE 1)
+ MYSQL_PLUGIN(${engine})
+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()
+ # Special handling for partition(not really pluggable)
+ IF(NOT WITHOUT_PARTITION_STORAGE_ENGINE)
+ SET (WITH_PARTITION_STORAGE_ENGINE 1)
+ SET (mysql_plugin_defs "${mysql_plugin_defs},builtin_partition_plugin")
+ ENDIF(NOT WITHOUT_PARTITION_STORAGE_ENGINE)
+ ADD_DEFINITIONS(${STORAGE_ENGINE_DEFS})
+ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc.in
+ ${CMAKE_BINARY_DIR}/sql/sql_builtin.cc)
+ENDMACRO()
diff --git a/cmake/readline.cmake b/cmake/readline.cmake
new file mode 100644
index 00000000000..7661f12cce2
--- /dev/null
+++ b/cmake/readline.cmake
@@ -0,0 +1,197 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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(SET_WITH_BUNDLED_READLINE option)
+ IF(option)
+ SET(not_option OFF)
+ ELSE()
+ SET(not_option ON)
+ ENDIF()
+ SET(WITH_READLINE ${option} CACHE BOOL "Use bundled readline")
+ SET(WITH_LIBEDIT ${not_option} CACHE BOOL "Use bundled libedit")
+ENDMACRO()
+
+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)
+ INCLUDE (FindCurses)
+ MARK_AS_ADVANCED(CURSES_CURSES_H_PATH CURSES_FORM_LIBRARY CURSES_HAVE_CURSES_H)
+ IF(NOT CURSES_FOUND)
+ MESSAGE(FATAL_ERROR "curses library not found")
+ 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()
+ENDMACRO()
+
+MACRO (MYSQL_USE_BUNDLED_READLINE)
+ SET_WITH_BUNDLED_READLINE(ON)
+ SET(USE_NEW_READLINE_INTERFACE 1)
+ 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_WITH_BUNDLED_READLINE(OFF)
+ SET(USE_LIBEDIT_INTERFACE 1 CACHE INTERNAL "")
+ SET(HAVE_HIST_ENTRY 1 CACHE INTERNAL "")
+ 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(SYSTEM_READLINE_INCLUDE_DIR readline/readline.h )
+ FIND_LIBRARY(SYSTEM_READLINE_LIBRARY NAMES ${name})
+ MARK_AS_ADVANCED(SYSTEM_READLINE_INCLUDE_DIR SYSTEM_READLINE_LIBRARY)
+
+ INCLUDE(CheckCXXSourceCompiles)
+ SET(CMAKE_REQUIRES_LIBRARIES ${SYSTEM_READLINE_LIBRARY})
+
+ IF(SYSTEM_READLINE_LIBRARY AND SYSTEM_READLINE_INCLUDE_DIR)
+ SET(SYSTEM_READLINE_FOUND 1)
+ SET(CMAKE_REQUIRED_LIBRARIES ${SYSTEM_READLINE_LIBRARY})
+ CHECK_CXX_SOURCE_COMPILES("
+ #include <stdio.h>
+ #include <readline/readline.h>
+ int main(int argc, char **argv)
+ {
+ HIST_ENTRY entry;
+ return 0;
+ }"
+ 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);
+ }"
+ 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;
+ }"
+ USE_NEW_READLINE_INTERFACE)
+
+ IF(USE_LIBEDIT_INTERFACE OR USE_NEW_READLINE_INTERFACE)
+ SET(READLINE_LIBRARY ${SYSTEM_READLINE_LIBRARY})
+ SET(READLINE_INCLUDE_DIR ${SYSTEM_READLINE_INCLUDE_DIR})
+ SET(READLINE_FOUND 1)
+ ENDIF()
+ ENDIF()
+ENDMACRO()
+
+MACRO (MYSQL_CHECK_READLINE)
+ IF (NOT WIN32)
+ MYSQL_CHECK_MULTIBYTE()
+ OPTION(WITH_READLINE "Use bundled readline" OFF)
+ IF(NOT CYGWIN)
+ # Bundled libedit does not compile on cygwin
+ OPTION(WITH_LIBEDIT "Use bundled libedit" ON)
+ ELSE()
+ OPTION(WITH_LIBEDIT "Use bundled libedit" OFF)
+ ENDIF()
+
+ IF(WITH_READLINE)
+ MYSQL_USE_BUNDLED_READLINE()
+ ELSEIF(WITH_LIBEDIT)
+ MYSQL_USE_BUNDLED_LIBEDIT()
+ 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..44f57899784
--- /dev/null
+++ b/cmake/ssl.cmake
@@ -0,0 +1,88 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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")
+ CHANGE_SSL_SETTINGS("bundled")
+ #Remove -fno-implicit-templates
+ #(yassl sources cannot be compiled with it)
+ SET(SAVE_CXX_FLAGS ${CXX_FLAGS})
+ STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS
+ ${CMAKE_CXX_FLAGS})
+ ADD_SUBDIRECTORY(extra/yassl)
+ ADD_SUBDIRECTORY(extra/yassl/taocrypt)
+ SET(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..11bcf803bfa
--- /dev/null
+++ b/cmake/stack_direction.c
@@ -0,0 +1,31 @@
+/* Copyright (C) 2009 Sun Microsystems, Inc
+
+ 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);
+} \ No newline at end of file
diff --git a/cmake/zlib.cmake b/cmake/zlib.cmake
new file mode 100644
index 00000000000..59f1f7ba68e
--- /dev/null
+++ b/cmake/zlib.cmake
@@ -0,0 +1,73 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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()
diff --git a/cmd-line-utils/libedit/CMakeLists.txt b/cmd-line-utils/libedit/CMakeLists.txt
new file mode 100644
index 00000000000..0c58fe9546f
--- /dev/null
+++ b/cmd-line-utils/libedit/CMakeLists.txt
@@ -0,0 +1,167 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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_DIRECTORIES(BEFORE ${CMAKE_CURRENT_SOURCE_DIR} )
+INCLUDE(CheckIncludeFile)
+CHECK_INCLUDE_FILES(term.h HAVE_TERM_H)
+
+SET(CMAKE_REQUIRED_LIBRARIES ${CURSES_CURSES_LIBRARY})
+CHECK_CXX_SOURCE_COMPILES("
+#include <term.h>
+int main()
+{
+ tgoto(0,0,0);
+ return 0;
+}" HAVE_DECL_TGOTO)
+SET(CMAKE_REQUIRED_LIBRARIES)
+
+
+
+IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+ #On Solaris, default awk is next to unusable while the xpg4 one is ok.
+ IF(EXISTS /usr/xpg4/bin/awk)
+ SET(AWK_EXECUTABLE /usr/xpg4/bin/awk)
+ ENDIF()
+ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "OS400")
+ #Workaround for cases, where /usr/bin/gawk is not executable
+ IF(EXISTS /QOpenSys/usr/bin/awk)
+ SET(AWK_EXECUTABLE /QOpenSys/usr/bin/awk)
+ ENDIF()
+ENDIF()
+
+IF(NOT AWK_EXECUTABLE)
+ FIND_PROGRAM(AWK_EXECUTABLE NAMES gawk awk DOC "path to the awk executable")
+ENDIF()
+
+MARK_AS_ADVANCED(AWK_EXECUTABLE)
+SET(AWK ${AWK_EXECUTABLE})
+CONFIGURE_FILE(makelist.sh ${CMAKE_CURRENT_SOURCE_DIR}/makelist @ONLY)
+
+
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
+ ${CURSES_INCLUDE_PATH}
+ }
+)
+
+SET(ASRC vi.c emacs.c common.c)
+SET(AHDR vi.h emacs.h common.h)
+
+
+SET(LIBEDIT_SOURCES
+ chared.c el.c history.c map.c prompt.c readline.c
+ search.c tokenizer.c vi.c common.c emacs.c
+ hist.c key.c parse.c read.c refresh.c sig.c term.c
+ tty.c help.c fcns.c filecomplete.c
+ ${AHDR}
+ )
+
+include(CheckFunctionExists)
+include(CheckIncludeFile)
+CHECK_INCLUDE_FILE(vis.h HAVE_VIS_H)
+
+IF(HAVE_VIS_H)
+ CHECK_FUNCTION_EXISTS(strvis HAVE_STRVIS)
+ IF(NOT HAVE_STRVIS)
+ SET(HAVE_VIS_H FALSE CACHE INTERNAL "" FORCE)
+ ENDIF()
+ENDIF()
+
+CHECK_FUNCTION_EXISTS(strvis HAVE_STRVIS)
+IF(NOT HAVE_STRVIS)
+ SET(LIBEDIT_SOURCES ${LIBEDIT_SOURCES} np/vis.c)
+ENDIF()
+
+
+CHECK_FUNCTION_EXISTS(strunvis HAVE_STRUNVIS)
+IF(NOT HAVE_STRUNVIS)
+ SET(LIBEDIT_SOURCES ${LIBEDIT_SOURCES} np/unvis.c)
+ENDIF()
+
+CHECK_FUNCTION_EXISTS(strlcpy HAVE_STRLCPY)
+IF(NOT HAVE_STRLCPY)
+ SET(LIBEDIT_SOURCES ${LIBEDIT_SOURCES} np/strlcpy.c)
+ENDIF()
+
+
+CHECK_FUNCTION_EXISTS(strlcat HAVE_STRLCAT)
+IF(NOT HAVE_STRLCAT)
+ SET(LIBEDIT_SOURCES ${LIBEDIT_SOURCES} np/strlcat.c)
+ENDIF()
+
+
+CHECK_FUNCTION_EXISTS(fgetln HAVE_FGETLN)
+IF(NOT HAVE_FGETLN)
+ SET(LIBEDIT_SOURCES ${LIBEDIT_SOURCES} np/fgetln.c)
+ENDIF()
+
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/vi.h
+ COMMAND sh ./makelist -h vi.c > vi.h
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS vi.c)
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/emacs.h
+ COMMAND sh ./makelist -h emacs.c > emacs.h
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS emacs.c)
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/common.h
+ COMMAND sh ./makelist -h common.c > common.h
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS common.c)
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/help.c
+ COMMAND sh ./makelist -bc ${ASRC} > help.c
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS ${ASRC}
+ )
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/help.h
+ COMMAND sh ./makelist -bh ${ASRC} > help.h
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS ${ASRC}
+ )
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/fcns.h
+ COMMAND sh ./makelist -fh ${AHDR} > fcns.h
+ VERBATIM
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS ${AHDR}
+ )
+
+ADD_CUSTOM_COMMAND(OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/fcns.c
+ COMMAND sh ./makelist -fc ${AHDR} > fcns.c
+ VERBATIM
+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
+ DEPENDS ${AHDR}
+ )
+
+
+ADD_CUSTOM_TARGET(
+ GenLibeditSource
+ DEPENDS
+ ${CMAKE_CURRENT_SOURCE_DIR}/vi.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/emacs.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/common.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/help.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/help.h
+ ${CMAKE_CURRENT_SOURCE_DIR}/fcns.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/fcns.h
+)
+
+ADD_LIBRARY(edit ${LIBEDIT_SOURCES})
+ADD_DEPENDENCIES(edit GenLibeditSource)
+TARGET_LINK_LIBRARIES(edit ${CURSES_LIBRARY})
+
diff --git a/cmd-line-utils/libedit/Makefile.am b/cmd-line-utils/libedit/Makefile.am
index ddafa4aab44..88ea97afffd 100644
--- a/cmd-line-utils/libedit/Makefile.am
+++ b/cmd-line-utils/libedit/Makefile.am
@@ -23,7 +23,7 @@ noinst_HEADERS = chared.h el.h el_term.h histedit.h key.h parse.h refresh.h sig.
sys.h config.h hist.h map.h prompt.h read.h \
search.h tty.h filecomplete.h np/vis.h
-EXTRA_DIST = makelist.sh
+EXTRA_DIST = makelist.sh CMakeLists.txt
CLEANFILES = makelist common.h emacs.h vi.h fcns.h help.h fcns.c help.c
diff --git a/cmd-line-utils/readline/CMakeLists.txt b/cmd-line-utils/readline/CMakeLists.txt
new file mode 100644
index 00000000000..506dc1a0ef6
--- /dev/null
+++ b/cmd-line-utils/readline/CMakeLists.txt
@@ -0,0 +1,60 @@
+# Copyright (C) 2007 MySQL AB
+#
+# 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_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_SOURCE_DIR}/cmd-line-utils)
+
+ADD_DEFINITIONS(-DHAVE_CONFIG_H -DNO_KILL_INTR -DMYSQL_CLIENT_NO_THREADS)
+
+INCLUDE_DIRECTORIES(${CURSES_INCLUDE_PATH})
+
+ADD_LIBRARY(readline
+ readline.c
+ funmap.c
+ keymaps.c
+ vi_mode.c
+ parens.c
+ rltty.c
+ complete.c
+ bind.c
+ isearch.c
+ display.c
+ signals.c
+ util.c
+ kill.c
+ undo.c
+ macro.c
+ input.c
+ callback.c
+ terminal.c
+ xmalloc.c
+ history.c
+ histsearch.c
+ histexpand.c
+ histfile.c
+ nls.c
+ search.c
+ shell.c
+ tilde.c
+ misc.c
+ text.c
+ mbutil.c
+ compat.c
+ savestring.c
+)
+
+# Declare dependency
+# so every executable that links with readline links with curses as well
+TARGET_LINK_LIBRARIES(readline ${CURSES_LIBRARY})
diff --git a/cmd-line-utils/readline/Makefile.am b/cmd-line-utils/readline/Makefile.am
index e5f5717858d..d58ce0f1de1 100644
--- a/cmd-line-utils/readline/Makefile.am
+++ b/cmd-line-utils/readline/Makefile.am
@@ -29,7 +29,7 @@ noinst_HEADERS = readline.h chardefs.h keymaps.h \
tilde.h rlconf.h rltty.h ansi_stdlib.h \
tcap.h rlstdc.h
-EXTRA_DIST= emacs_keymap.c vi_keymap.c
+EXTRA_DIST= emacs_keymap.c vi_keymap.c CMakeLists.txt
DEFS = -DMYSQL_CLIENT_NO_THREADS -DHAVE_CONFIG_H -DNO_KILL_INTR
diff --git a/config.h.cmake b/config.h.cmake
new file mode 100644
index 00000000000..054777e9f43
--- /dev/null
+++ b/config.h.cmake
@@ -0,0 +1,618 @@
+/* Copyright (C) 2009 Sun Microsystems, Inc
+
+ 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 */
+
+#ifndef MY_CONFIG_H
+#define MY_CONFIG_H
+#cmakedefine DOT_FRM_VERSION @DOT_FRM_VERSION@
+/* Headers we may want to use. */
+#cmakedefine STDC_HEADERS 1
+#cmakedefine HAVE_ALLOCA_H 1
+#cmakedefine HAVE_AIO_H 1
+#cmakedefine HAVE_ARPA_INET_H 1
+#cmakedefine HAVE_BSEARCH 1
+#cmakedefine HAVE_CRYPT_H 1
+#cmakedefine HAVE_CURSES_H 1
+#cmakedefine HAVE_CXXABI_H 1
+#cmakedefine HAVE_NCURSES_H 1
+#cmakedefine HAVE_DIRENT_H 1
+#cmakedefine HAVE_DLFCN_H 1
+#cmakedefine HAVE_EXECINFO_H 1
+#cmakedefine HAVE_FCNTL_H 1
+#cmakedefine HAVE_FENV_H 1
+#cmakedefine HAVE_FLOAT_H 1
+#cmakedefine HAVE_FLOATINGPOINT_H 1
+#cmakedefine HAVE_FNMATCH_H 1
+#cmakedefine HAVE_FPU_CONTROL_H 1
+#cmakedefine HAVE_GRP_H 1
+#cmakedefine HAVE_EXPLICIT_TEMPLATE_INSTANTIATION 1
+#cmakedefine HAVE_IEEEFP_H 1
+#cmakedefine HAVE_INTTYPES_H 1
+#cmakedefine HAVE_LIMITS_H 1
+#cmakedefine HAVE_LOCALE_H 1
+#cmakedefine HAVE_MALLOC_H 1
+#cmakedefine HAVE_MEMORY_H 1
+#cmakedefine HAVE_NETINET_IN_H 1
+#cmakedefine HAVE_PATHS_H 1
+#cmakedefine HAVE_PORT_H 1
+#cmakedefine HAVE_PWD_H 1
+#cmakedefine HAVE_SCHED_H 1
+#cmakedefine HAVE_SELECT_H 1
+#cmakedefine HAVE_SOLARIS_LARGE_PAGES 1
+#cmakedefine HAVE_STDDEF_H 1
+#cmakedefine HAVE_STDLIB_H 1
+#cmakedefine HAVE_STDARG_H 1
+#cmakedefine HAVE_STRINGS_H 1
+#cmakedefine HAVE_STRING_H 1
+#cmakedefine HAVE_STDINT_H 1
+#cmakedefine HAVE_SEMAPHORE_H 1
+#cmakedefine HAVE_SYNCH_H 1
+#cmakedefine HAVE_SYSENT_H 1
+#cmakedefine HAVE_SYS_DIR_H 1
+#cmakedefine HAVE_SYS_CDEFS_H 1
+#cmakedefine HAVE_SYS_FILE_H 1
+#cmakedefine HAVE_SYS_FPU_H 1
+#cmakedefine HAVE_SYS_IOCTL_H 1
+#cmakedefine HAVE_SYS_IPC_H 1
+#cmakedefine HAVE_SYS_MALLOC_H 1
+#cmakedefine HAVE_SYS_MMAN_H 1
+#cmakedefine HAVE_SYS_PTE_H 1
+#cmakedefine HAVE_SYS_PTEM_H 1
+#cmakedefine HAVE_SYS_PRCTL_H 1
+#cmakedefine HAVE_SYS_RESOURCE_H 1
+#cmakedefine HAVE_SYS_SELECT_H 1
+#cmakedefine HAVE_SYS_SHM_H 1
+#cmakedefine HAVE_SYS_SOCKET_H 1
+#cmakedefine HAVE_SYS_STAT_H 1
+#cmakedefine HAVE_SYS_STREAM_H 1
+#cmakedefine HAVE_SYS_TERMCAP_H 1
+#cmakedefine HAVE_SYS_TIMEB_H 1
+#cmakedefine HAVE_SYS_TYPES_H 1
+#cmakedefine HAVE_SYS_UN_H 1
+#cmakedefine HAVE_SYS_VADVISE_H 1
+#cmakedefine HAVE_TERM_H 1
+#cmakedefine HAVE_TERMIOS_H 1
+#cmakedefine HAVE_TERMIO_H 1
+#cmakedefine HAVE_TERMCAP_H 1
+#cmakedefine HAVE_UNISTD_H 1
+#cmakedefine HAVE_UTIME_H 1
+#cmakedefine HAVE_VARARGS_H 1
+#cmakedefine HAVE_VIS_H 1
+#cmakedefine HAVE_SYS_UTIME_H 1
+#cmakedefine HAVE_SYS_WAIT_H 1
+#cmakedefine HAVE_SYS_PARAM_H 1
+
+/* Libraries */
+#cmakedefine HAVE_LIBPTHREAD 1
+#cmakedefine HAVE_LIBM 1
+#cmakedefine HAVE_LIBDL 1
+#cmakedefine HAVE_LIBRT 1
+#cmakedefine HAVE_LIBSOCKET 1
+#cmakedefine HAVE_LIBNSL 1
+#cmakedefine HAVE_LIBCRYPT 1
+#cmakedefine HAVE_LIBMTMALLOC 1
+#cmakedefine HAVE_LIBWRAP 1
+/* Does "struct timespec" have a "sec" and "nsec" field? */
+#cmakedefine HAVE_TIMESPEC_TS_SEC 1
+
+/* Readline */
+#cmakedefine HAVE_HIST_ENTRY 1
+#cmakedefine USE_LIBEDIT_INTERFACE 1
+#cmakedefine USE_NEW_READLINE_INTERFACE 1
+
+#cmakedefine FIONREAD_IN_SYS_IOCTL 1
+#cmakedefine GWINSZ_IN_SYS_IOCTL 1
+#cmakedefine TIOCSTAT_IN_SYS_IOCTL 1
+
+/* Functions we may want to use. */
+#cmakedefine HAVE_AIOWAIT 1
+#cmakedefine HAVE_ALARM 1
+#cmakedefine HAVE_ALLOCA 1
+#cmakedefine HAVE_BCMP 1
+#cmakedefine HAVE_BFILL 1
+#cmakedefine HAVE_BMOVE 1
+#cmakedefine HAVE_BZERO 1
+#cmakedefine HAVE_INDEX 1
+#cmakedefine HAVE_CLOCK_GETTIME 1
+#cmakedefine HAVE_CRYPT 1
+#cmakedefine HAVE_CUSERID 1
+#cmakedefine HAVE_DIRECTIO 1
+#cmakedefine HAVE_DLERROR 1
+#cmakedefine HAVE_DLOPEN 1
+#cmakedefine HAVE_DOPRNT 1
+#cmakedefine HAVE_FCHMOD 1
+#cmakedefine HAVE_FCNTL 1
+#cmakedefine HAVE_FCONVERT 1
+#cmakedefine HAVE_FDATASYNC 1
+#cmakedefine HAVE_FESETROUND 1
+#cmakedefine HAVE_FINITE 1
+#cmakedefine HAVE_FP_EXCEPT 1
+#cmakedefine HAVE_FPSETMASK 1
+#cmakedefine HAVE_FSEEKO 1
+#cmakedefine HAVE_FSYNC 1
+#cmakedefine HAVE_GETADDRINFO 1
+#cmakedefine HAVE_GETCWD 1
+#cmakedefine HAVE_GETHOSTBYADDR_R 1
+#cmakedefine HAVE_GETHOSTBYNAME_R 1
+#cmakedefine HAVE_GETHRTIME 1
+#cmakedefine HAVE_GETLINE 1
+#cmakedefine HAVE_GETNAMEINFO 1
+#cmakedefine HAVE_GETPAGESIZE 1
+#cmakedefine HAVE_GETPASS 1
+#cmakedefine HAVE_GETPASSPHRASE 1
+#cmakedefine HAVE_GETPWNAM 1
+#cmakedefine HAVE_GETPWUID 1
+#cmakedefine HAVE_GETRLIMIT 1
+#cmakedefine HAVE_GETRUSAGE 1
+#cmakedefine HAVE_GETTIMEOFDAY 1
+#cmakedefine HAVE_GETWD 1
+#cmakedefine HAVE_GMTIME_R 1
+#cmakedefine gmtime_r @gmtime_r@
+#cmakedefine HAVE_INITGROUPS 1
+#cmakedefine HAVE_ISSETUGID 1
+#cmakedefine HAVE_ISNAN 1
+#cmakedefine HAVE_ISINF 1
+#cmakedefine HAVE_LARGE_PAGE_OPTION 1
+#cmakedefine HAVE_LDIV 1
+#cmakedefine HAVE_LRAND48 1
+#cmakedefine HAVE_LOCALTIME_R 1
+#cmakedefine HAVE_LOG2 1
+#cmakedefine HAVE_LONGJMP 1
+#cmakedefine HAVE_LSTAT 1
+#cmakedefine HAVE_NPTL 1
+#cmakedefine HAVE_NL_LANGINFO 1
+#cmakedefine HAVE_MADVISE 1
+#cmakedefine HAVE_DECL_MADVISE 1
+#cmakedefine HAVE_DECL_TGOTO 1
+#cmakedefine HAVE_DECL_MHA_MAPSIZE_VA
+#cmakedefine HAVE_MALLINFO 1
+#cmakedefine HAVE_MEMCPY 1
+#cmakedefine HAVE_MEMMOVE 1
+#cmakedefine HAVE_MKSTEMP 1
+#cmakedefine HAVE_MLOCKALL 1
+#cmakedefine HAVE_MMAP 1
+#cmakedefine HAVE_MMAP64 1
+#cmakedefine HAVE_PERROR 1
+#cmakedefine HAVE_POLL 1
+#cmakedefine HAVE_PORT_CREATE 1
+#cmakedefine HAVE_POSIX_FALLOCATE 1
+#cmakedefine HAVE_PREAD 1
+#cmakedefine HAVE_PAUSE_INSTRUCTION 1
+#cmakedefine HAVE_FAKE_PAUSE_INSTRUCTION 1
+#cmakedefine HAVE_PTHREAD_ATTR_CREATE 1
+#cmakedefine HAVE_PTHREAD_ATTR_GETSTACKSIZE 1
+#cmakedefine HAVE_PTHREAD_ATTR_SETPRIO 1
+#cmakedefine HAVE_PTHREAD_ATTR_SETSCHEDPARAM 1
+#cmakedefine HAVE_PTHREAD_ATTR_SETSCOPE 1
+#cmakedefine HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
+#cmakedefine HAVE_PTHREAD_CONDATTR_CREATE 1
+#cmakedefine HAVE_PTHREAD_CONDATTR_SETCLOCK 1
+#cmakedefine HAVE_PTHREAD_INIT 1
+#cmakedefine HAVE_PTHREAD_KEY_DELETE 1
+#cmakedefine HAVE_PTHREAD_KEY_DELETE 1
+#cmakedefine HAVE_PTHREAD_KILL 1
+#cmakedefine HAVE_PTHREAD_RWLOCK_RDLOCK 1
+#cmakedefine HAVE_PTHREAD_SETPRIO_NP 1
+#cmakedefine HAVE_PTHREAD_SETSCHEDPARAM 1
+#cmakedefine HAVE_PTHREAD_SIGMASK 1
+#cmakedefine HAVE_PTHREAD_THREADMASK 1
+#cmakedefine HAVE_PTHREAD_YIELD_NP 1
+#cmakedefine HAVE_PTHREAD_YIELD_ZERO_ARG 1
+#cmakedefine HAVE_PUTENV 1
+#cmakedefine HAVE_RE_COMP 1
+#cmakedefine HAVE_REGCOMP 1
+#cmakedefine HAVE_READDIR_R 1
+#cmakedefine HAVE_READLINK 1
+#cmakedefine HAVE_REALPATH 1
+#cmakedefine HAVE_RENAME 1
+#cmakedefine HAVE_RINT 1
+#cmakedefine HAVE_RWLOCK_INIT 1
+#cmakedefine HAVE_SCHED_YIELD 1
+#cmakedefine HAVE_SELECT 1
+#cmakedefine HAVE_SETFD 1
+#cmakedefine HAVE_SETENV 1
+#cmakedefine HAVE_SETLOCALE 1
+#cmakedefine HAVE_SIGADDSET 1
+#cmakedefine HAVE_SIGEMPTYSET 1
+#cmakedefine HAVE_SIGHOLD 1
+#cmakedefine HAVE_SIGSET 1
+#cmakedefine HAVE_SIGSET_T 1
+#cmakedefine HAVE_SIGACTION 1
+#cmakedefine HAVE_SIGTHREADMASK 1
+#cmakedefine HAVE_SIGWAIT 1
+#cmakedefine HAVE_SLEEP 1
+#cmakedefine HAVE_SNPRINTF 1
+#cmakedefine HAVE_STPCPY 1
+#cmakedefine HAVE_STRERROR 1
+#cmakedefine HAVE_STRCOLL 1
+#cmakedefine HAVE_STRSIGNAL 1
+#cmakedefine HAVE_STRLCPY 1
+#cmakedefine HAVE_STRLCAT 1
+#cmakedefine HAVE_FGETLN 1
+#cmakedefine HAVE_STRNLEN 1
+#cmakedefine HAVE_STRPBRK 1
+#cmakedefine HAVE_STRSEP 1
+#cmakedefine HAVE_STRSTR 1
+#cmakedefine HAVE_STRTOK_R 1
+#cmakedefine HAVE_STRTOL 1
+#cmakedefine HAVE_STRTOLL 1
+#cmakedefine HAVE_STRTOUL 1
+#cmakedefine HAVE_STRTOULL 1
+#cmakedefine HAVE_SHMAT 1
+#cmakedefine HAVE_SHMCTL 1
+#cmakedefine HAVE_SHMDT 1
+#cmakedefine HAVE_SHMGET 1
+#cmakedefine HAVE_TELL 1
+#cmakedefine HAVE_TEMPNAM 1
+#cmakedefine HAVE_THR_SETCONCURRENCY 1
+#cmakedefine HAVE_THR_YIELD 1
+#cmakedefine HAVE_VALLOC 1
+#define HAVE_VIO_READ_BUFF 1
+#cmakedefine HAVE_VASPRINTF 1
+#cmakedefine HAVE_VPRINTF 1
+#cmakedefine HAVE_VSNPRINTF 1
+#cmakedefine HAVE_FTRUNCATE 1
+#cmakedefine HAVE_TZNAME 1
+#cmakedefine HAVE_AIO_READ 1
+/* Symbols we may use */
+#cmakedefine HAVE_SYS_ERRLIST 1
+/* used by stacktrace functions */
+#cmakedefine HAVE_BSS_START 1
+#cmakedefine HAVE_BACKTRACE 1
+#cmakedefine HAVE_BACKTRACE_SYMBOLS 1
+#cmakedefine HAVE_BACKTRACE_SYMBOLS_FD 1
+#cmakedefine HAVE_STRUCT_SOCKADDR_IN6 1
+#cmakedefine HAVE_STRUCT_IN6_ADDR 1
+#cmakedefine HAVE_NETINET_IN6_H 1
+#cmakedefine HAVE_IPV6 1
+#cmakedefine ss_family @ss_family@
+#cmakedefine HAVE_TIMESPEC_TS_SEC 1
+#cmakedefine STRUCT_DIRENT_HAS_D_INO 1
+#cmakedefine STRUCT_DIRENT_HAS_D_NAMLEN 1
+#cmakedefine SPRINTF_RETURNS_INT 1
+
+#define USE_MB 1
+#define USE_MB_IDENT 1
+
+
+
+/* Types we may use */
+#cmakedefine SIZEOF_CHAR @SIZEOF_CHAR@
+#if SIZEOF_CHAR
+# define HAVE_CHAR 1
+#endif
+
+#cmakedefine SIZEOF_CHARP @SIZEOF_CHARP@
+#if SIZEOF_CHARP
+#define HAVE_CHARP 1
+#define SIZEOF_VOIDP SIZEOF_CHARP
+#endif
+
+#cmakedefine SIZEOF_SHORT @SIZEOF_SHORT@
+#if SIZEOF_SHORT
+# define HAVE_SHORT 1
+#endif
+
+#cmakedefine SIZEOF_INT @SIZEOF_INT@
+#if SIZEOF_INT
+# define HAVE_INT 1
+#endif
+
+#cmakedefine SIZEOF_LONG @SIZEOF_LONG@
+#if SIZEOF_LONG
+# define HAVE_LONG 1
+#endif
+
+#cmakedefine SIZEOF_LONG_LONG @SIZEOF_LONG_LONG@
+#if SIZEOF_LONG_LONG
+# define HAVE_LONG_LONG 1
+#endif
+
+#cmakedefine SIZEOF_OFF_T @SIZEOF_OFF_T@
+#if SIZEOF_OFF_T
+#define HAVE_OFF_T 1
+#endif
+
+#cmakedefine SIZEOF_SIGSET_T @SIZEOF_SIGSET_T@
+#if SIZEOF_SIGSET_T
+#define HAVE_SIGSET_T 1
+#endif
+
+#cmakedefine SIZEOF_SIZE_T @SIZEOF_SIZE_T@
+#if SIZEOF_SIZE_T
+#define HAVE_SIZE_T 1
+#endif
+
+#cmakedefine SIZEOF_UCHAR @SIZEOF_UCHAR@
+#if SIZEOF_UCHAR
+#define HAVE_UCHAR 1
+#endif
+
+#cmakedefine SIZEOF_UINT @SIZEOF_UINT@
+#if SIZEOF_UINT
+#define HAVE_UINT 1
+#endif
+
+#cmakedefine SIZEOF_ULONG @SIZEOF_ULONG@
+#if SIZEOF_ULONG
+#define HAVE_ULONG 1
+#endif
+
+#cmakedefine SIZEOF_INT8 @SIZEOF_INT8@
+#if SIZEOF_INT8
+#define HAVE_INT8 1
+#endif
+#cmakedefine SIZEOF_UINT8 @SIZEOF_UINT8@
+#if SIZEOF_UINT8
+#define HAVE_UINT8 1
+#endif
+
+#cmakedefine SIZEOF_INT16 @SIZEOF_INT16@
+#if SIZEOF_INT16
+# define HAVE_INT16 1
+#endif
+#cmakedefine SIZEOF_UINT16 @SIZEOF_UINT16@
+#if SIZEOF_UINT16
+#define HAVE_UINT16 1
+#endif
+
+#cmakedefine SIZEOF_INT32 @SIZEOF_INT32@
+#if SIZEOF_INT32
+#define HAVE_INT32 1
+#endif
+#cmakedefine SIZEOF_UINT32 @SIZEOF_UINT32@
+#if SIZEOF_UINT32
+#define HAVE_UINT32 1
+#endif
+#cmakedefine SIZEOF_U_INT32_T @SIZEOF_U_INT32_T@
+#if SIZEOF_U_INT32_T
+#define HAVE_U_INT32_T 1
+#endif
+
+#cmakedefine SIZEOF_INT64 @SIZEOF_INT64@
+#if SIZEOF_INT64
+#define HAVE_INT64 1
+#endif
+#cmakedefine SIZEOF_UINT64 @SIZEOF_UINT64@
+#if SIZEOF_UINT64
+#define HAVE_UINT64 1
+#endif
+
+#cmakedefine SOCKET_SIZE_TYPE @SOCKET_SIZE_TYPE@
+
+#cmakedefine SIZEOF_BOOL @SIZEOF_BOOL@
+#if SIZEOF_BOOL
+#define HAVE_BOOL 1
+#endif
+#cmakedefine HAVE_MBSTATE_T
+
+#define MAX_INDEXES 64
+
+#cmakedefine QSORT_TYPE_IS_VOID 1
+#define RETQSORTTYPE void
+
+#cmakedefine SIGNAL_RETURN_TYPE_IS_VOID 1
+#define RETSIGTYPE void
+#if SIGNAL_RETURN_TYPE_IS_VOID
+#define VOID_SIGHANDLER 1
+#endif
+#define STRUCT_RLIMIT struct rlimit
+
+#cmakedefine WORDS_BIGENDIAN 1
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler calls
+ it, or to nothing if 'inline' is not supported under any name. */
+#cmakedefine C_HAS_inline 1
+#if !(C_HAS_inline)
+#ifndef __cplusplus
+# define inline @C_INLINE@
+#endif
+#endif
+
+
+#cmakedefine TARGET_OS_LINUX 1
+#cmakedefine TARGET_OS_SOLARIS 1
+
+#cmakedefine HAVE_WCTYPE_H 1
+#cmakedefine HAVE_WCHAR_H 1
+#cmakedefine HAVE_LANGINFO_H 1
+#cmakedefine HAVE_MBRLEN
+#cmakedefine HAVE_MBSCMP
+#cmakedefine HAVE_MBSRTOWCS
+#cmakedefine HAVE_WCRTOMB
+#cmakedefine HAVE_MBRTOWC
+#cmakedefine HAVE_WCSCOLL
+#cmakedefine HAVE_WCSDUP
+#cmakedefine HAVE_WCWIDTH
+#cmakedefine HAVE_WCTYPE
+#cmakedefine HAVE_ISWLOWER 1
+#cmakedefine HAVE_ISWUPPER 1
+#cmakedefine HAVE_TOWLOWER 1
+#cmakedefine HAVE_TOWUPPER 1
+#cmakedefine HAVE_ISWCTYPE 1
+#cmakedefine HAVE_WCHAR_T 1
+#cmakedefine HAVE_WCTYPE_T 1
+#cmakedefine HAVE_WINT_T 1
+
+
+#cmakedefine HAVE_STRCASECMP 1
+#cmakedefine HAVE_STRNCASECMP 1
+#cmakedefine HAVE_STRDUP 1
+#cmakedefine HAVE_LANGINFO_CODESET
+#cmakedefine HAVE_TCGETATTR 1
+#cmakedefine HAVE_FLOCKFILE 1
+
+#cmakedefine HAVE_WEAK_SYMBOL 1
+#cmakedefine HAVE_ABI_CXA_DEMANGLE 1
+
+
+#cmakedefine HAVE_POSIX_SIGNALS 1
+#cmakedefine HAVE_BSD_SIGNALS 1
+#cmakedefine HAVE_SVR3_SIGNALS 1
+#cmakedefine HAVE_V7_SIGNALS 1
+
+
+#cmakedefine HAVE_SOLARIS_STYLE_GETHOST 1
+#cmakedefine HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE 1
+#cmakedefine HAVE_GETHOSTBYNAME_R_RETURN_INT 1
+
+#cmakedefine MY_ATOMIC_MODE_DUMMY 1
+#cmakedefine MY_ATOMIC_MODE_RWLOCKS 1
+#cmakedefine HAVE_GCC_ATOMIC_BUILTINS 1
+#cmakedefine HAVE_SOLARIS_ATOMIC 1
+#cmakedefine HAVE_DECL_SHM_HUGETLB 1
+#cmakedefine HAVE_LARGE_PAGES 1
+#cmakedefine HUGETLB_USE_PROC_MEMINFO 1
+#cmakedefine NO_FCNTL_NONBLOCK 1
+
+#cmakedefine _LARGE_FILES 1
+#cmakedefine _LARGEFILE_SOURCE 1
+#cmakedefine _LARGEFILE64_SOURCE 1
+#cmakedefine _FILE_OFFSET_BITS @_FILE_OFFSET_BITS@
+
+#cmakedefine TIME_WITH_SYS_TIME 1
+
+#cmakedefine STACK_DIRECTION @STACK_DIRECTION@
+
+#define THREAD 1
+#define THREAD_SAFE_CLIENT 1
+
+#define SYSTEM_TYPE "@SYSTEM_TYPE@"
+#define MACHINE_TYPE "@CMAKE_SYSTEM_PROCESSOR@"
+#cmakedefine HAVE_DTRACE 1
+
+#cmakedefine SIGNAL_WITH_VIO_CLOSE 1
+
+/* Windows stuff, mostly functions, that have Posix analogs but named differently */
+#cmakedefine S_IROTH @S_IROTH@
+#cmakedefine S_IFIFO @S_IFIFO@
+#cmakedefine IPPROTO_IPV6 @IPPROTO_IPV6@
+#cmakedefine IPV6_V6ONLY @IPV6_V6ONLY@
+#cmakedefine sigset_t @sigset_t@
+#cmakedefine mode_t @mode_t@
+#cmakedefine SIGQUIT @SIGQUIT@
+#cmakedefine SIGPIPE @SIGPIPE@
+#cmakedefine isnan @isnan@
+#cmakedefine finite @finite@
+#cmakedefine popen @popen@
+#cmakedefine pclose @pclose@
+#cmakedefine ssize_t @ssize_t@
+#cmakedefine strcasecmp @strcasecmp@
+#cmakedefine strncasecmp @strncasecmp@
+#cmakedefine snprintf @snprintf@
+#cmakedefine strtok_r @strtok_r@
+#cmakedefine strtoll @strtoll@
+#cmakedefine strtoull @strtoull@
+
+
+
+/*
+ MySQL features
+*/
+#cmakedefine ENABLED_LOCAL_INFILE 1
+#cmakedefine ENABLED_PROFILING 1
+#cmakedefine EXTRA_DEBUG 1
+#cmakedefine BACKUP_TEST 1
+#cmakedefine CYBOZU 1
+
+/* Character sets and collations */
+#cmakedefine MYSQL_DEFAULT_CHARSET_NAME "latin1"
+#cmakedefine MYSQL_DEFAULT_COLLATION_NAME "latin1_swedish_ci"
+
+#cmakedefine USE_MB 1
+#cmakedefine USE_MB_IDENT 1
+#cmakedefine USE_STRCOLL 1
+
+#cmakedefine HAVE_CHARSET_armscii8 1
+#cmakedefine HAVE_CHARSET_ascii
+#cmakedefine HAVE_CHARSET_big5 1
+#cmakedefine HAVE_CHARSET_cp1250 1
+#cmakedefine HAVE_CHARSET_cp1251 1
+#cmakedefine HAVE_CHARSET_cp1256 1
+#cmakedefine HAVE_CHARSET_cp1257 1
+#cmakedefine HAVE_CHARSET_cp850 1
+#cmakedefine HAVE_CHARSET_cp852 1
+#cmakedefine HAVE_CHARSET_cp866 1
+#cmakedefine HAVE_CHARSET_cp932 1
+#cmakedefine HAVE_CHARSET_dec8 1
+#cmakedefine HAVE_CHARSET_eucjpms 1
+#cmakedefine HAVE_CHARSET_euckr 1
+#cmakedefine HAVE_CHARSET_gb2312 1
+#cmakedefine HAVE_CHARSET_gbk 1
+#cmakedefine HAVE_CHARSET_geostd8 1
+#cmakedefine HAVE_CHARSET_greek 1
+#cmakedefine HAVE_CHARSET_hebrew 1
+#cmakedefine HAVE_CHARSET_hp8 1
+#cmakedefine HAVE_CHARSET_keybcs2 1
+#cmakedefine HAVE_CHARSET_koi8r 1
+#cmakedefine HAVE_CHARSET_koi8u 1
+#cmakedefine HAVE_CHARSET_latin1 1
+#cmakedefine HAVE_CHARSET_latin2 1
+#cmakedefine HAVE_CHARSET_latin5 1
+#cmakedefine HAVE_CHARSET_latin7 1
+#cmakedefine HAVE_CHARSET_macce 1
+#cmakedefine HAVE_CHARSET_macroman 1
+#cmakedefine HAVE_CHARSET_sjis 1
+#cmakedefine HAVE_CHARSET_swe7 1
+#cmakedefine HAVE_CHARSET_tis620 1
+#cmakedefine HAVE_CHARSET_ucs2 1
+#cmakedefine HAVE_CHARSET_ujis 1
+#cmakedefine HAVE_CHARSET_utf8mb4 1
+#cmakedefine HAVE_CHARSET_utf8mb3 1
+#cmakedefine HAVE_CHARSET_utf8 1
+#cmakedefine HAVE_CHARSET_utf16 1
+#cmakedefine HAVE_CHARSET_utf32 1
+#cmakedefine HAVE_UCA_COLLATIONS 1
+#cmakedefine HAVE_COMPRESS 1
+
+
+/*
+ Stuff that always need to be defined (compile breaks without it)
+*/
+#define HAVE_SPATIAL 1
+#define HAVE_RTREE_KEYS 1
+#define HAVE_QUERY_CACHE 1
+
+/*
+ Important storage engines (those that really need define
+ WITH_<ENGINE>_STORAGE_ENGINE for the whole server)
+*/
+#cmakedefine WITH_MYISAM_STORAGE_ENGINE 1
+#cmakedefine WITH_MYISAMMRG_STORAGE_ENGINE 1
+#cmakedefine WITH_HEAP_STORAGE_ENGINE 1
+#cmakedefine WITH_CSV_STORAGE_ENGINE 1
+#cmakedefine WITH_PARTITION_STORAGE_ENGINE 1
+#cmakedefine WITH_PERFSCHEMA_STORAGE_ENGINE 1
+#cmakedefine WITH_NDBCLUSTER_STORAGE_ENGINE 1
+#if (WITH_NDBCLUSTER_STORAGE_ENGINE) && !defined(EMBEDDED_LIBRARY)
+#define HAVE_NDB_BINLOG 1
+#endif
+
+#cmakedefine DEFAULT_MYSQL_HOME "@DEFAULT_MYSQL_HOME@"
+#cmakedefine SHAREDIR "@SHAREDIR@"
+#cmakedefine DEFAULT_BASEDIR "@DEFAULT_BASEDIR@"
+#cmakedefine MYSQL_DATADIR "@MYSQL_DATADIR@"
+#cmakedefine DEFAULT_CHARSET_HOME "@DEFAULT_CHARSET_HOME@"
+
+#define PACKAGE "mysql"
+#define PACKAGE_BUGREPORT ""
+#define PACKAGE_NAME "MySQL Server"
+#define PACKAGE_STRING "MySQL Server @VERSION@"
+#define PACKAGE_TARNAME "mysql"
+#define PACKAGE_VERSION "@VERSION@"
+#define VERSION "@VERSION@"
+#define PROTOCOL_VERSION 10
+
+
+#endif
diff --git a/configure.cmake b/configure.cmake
new file mode 100644
index 00000000000..aff4c1403f9
--- /dev/null
+++ b/configure.cmake
@@ -0,0 +1,1335 @@
+# Copyright (C) 2009 Sun Microsystems,Inc
+#
+# 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 (CheckCSourceCompiles)
+INCLUDE (CheckCXXSourceCompiles)
+INCLUDE (CheckStructHasMember)
+INCLUDE (CheckLibraryExists)
+INCLUDE (CheckFunctionExists)
+INCLUDE (CheckCCompilerFlag)
+INCLUDE (CheckCSourceRuns)
+
+
+# Sometimes it is handy to know if PIC option
+# is set, to avoid recompilation of the same source
+# for shared libs. We also allow it as an option for
+# fast compile.
+IF(UNIX)
+ IF(APPLE)
+ # OSX executable are always PIC
+ SET(WITH_PIC ON)
+ ELSE()
+ OPTION(WITH_PIC "Generate PIC objects" OFF)
+ IF(WITH_PIC)
+ SET(CMAKE_C_FLAGS
+ "${CMAKE_C_FLAGS} ${CMAKE_SHARED_LIBRARY_C_FLAGS}")
+ SET(CMAKE_CXX_FLAGS
+ "${CMAKE_CXX_FLAGS} ${CMAKE_SHARED_LIBRARY_CXX_FLAGS}")
+ ENDIF()
+ ENDIF()
+ENDIF()
+
+
+#
+# Tests for OS
+IF (CMAKE_SYSTEM_NAME MATCHES "Linux")
+ SET(TARGET_OS_LINUX 1)
+ SET(HAVE_NPTL 1)
+ELSEIF(CMAKE_SYSTEM_NAME MATCHES "SunOS")
+ SET(TARGET_OS_SOLARIS 1)
+ENDIF()
+
+
+# OS display name (version_compile_os etc).
+# Used by the test suite to ignore bugs on some platforms,
+# typically on Windows.
+IF(WIN32)
+ IF(CMAKE_SIZEOF_VOID_P MATCHES 8)
+ SET(SYSTEM_TYPE "Win64")
+ ELSE()
+ SET(SYSTEM_TYPE "Win32")
+ ENDIF()
+ELSE()
+ IF(PLATFORM)
+ SET(SYSTEM_TYPE ${PLATFORM})
+ ELSE()
+ SET(SYSTEM_TYPE ${CMAKE_SYSTEM_NAME})
+ ENDIF()
+ENDIF()
+
+
+# Intel compiler is almost Visual C++
+# (same compile flags etc). Set MSVC flag
+IF(WIN32 AND CMAKE_C_COMPILER MATCHES "icl")
+ SET(MSVC TRUE)
+ENDIF()
+
+IF(CMAKE_COMPILER_IS_GNUCXX)
+ SET(CMAKE_CXX_FLAGS
+ "${CMAKE_CXX_FLAGS} -fno-implicit-templates -fno-exceptions -fno-rtti")
+ IF(CMAKE_CXX_FLAGS)
+ STRING(REGEX MATCH "fno-implicit-templates" NO_IMPLICIT_TEMPLATES
+ ${CMAKE_CXX_FLAGS})
+ IF (NO_IMPLICIT_TEMPLATES)
+ SET(HAVE_EXPLICIT_TEMPLATE_INSTANTIATION TRUE)
+ ENDIF()
+ ENDIF()
+ IF(MINGW AND CMAKE_SIZEOF_VOIDP EQUAL 4)
+ # mininal architecture flags, i486 enables GCC atomics
+ ADD_DEFINITIONS(-march=i486)
+ ENDIF()
+ENDIF(CMAKE_COMPILER_IS_GNUCXX)
+
+IF(WIN32)
+ SET(CAN_CONVERT_STATIC_TO_SHARED_LIB 1)
+ENDIF()
+
+# Large files
+SET(_LARGEFILE_SOURCE 1)
+IF(CMAKE_SYSTEM_NAME STREQUAL "HP-UX")
+ SET(_LARGEFILE64_SOURCE 1)
+ SET(_FILE_OFFSET_BITS 64)
+ENDIF()
+IF(CMAKE_SYSTEM_NAME STREQUAL "Linux" OR CMAKE_SYSTEM_NAME STREQUAL "SunOS" )
+ SET(_FILE_OFFSET_BITS 64)
+ENDIF()
+IF(CMAKE_SYSTEM_NAME MATCHES "AIX" OR CMAKE_SYSTEM_NAME MATCHES "OS400")
+ SET(_LARGE_FILES 1)
+ENDIF()
+
+
+
+
+IF(MSVC)
+# Enable debug info also in Release build, and create PDB to be able to analyze
+# crashes
+ SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
+ SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Zi")
+ SET(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /debug")
+ENDIF()
+
+IF(CMAKE_GENERATOR MATCHES "Visual Studio 7")
+ # VS2003 has a bug that prevents linking mysqld with module definition file
+ # (/DEF option for linker). Linker would incorrectly complain about multiply
+ # defined symbols. Workaround is to disable dynamic plugins, so /DEF is not
+ # used.
+ MESSAGE(
+ "Warning: Building MySQL with Visual Studio 2003.NET is no more supported.")
+ MESSAGE("Please use a newer version of Visual Studio.")
+ SET(WITHOUT_DYNAMIC_PLUGINS TRUE)
+
+ # VS2003 needs the /Op compiler option to disable floating point
+ # optimizations
+ SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Op")
+ SET(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Op")
+ SET(CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} /Op")
+ SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} /Op")
+ SET(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} /Op")
+ SET(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} /Op")
+ENDIF(CMAKE_GENERATOR MATCHES "Visual Studio 7")
+
+
+IF(CMAKE_SYSTEM_NAME STREQUAL "HP-UX" )
+ IF(CMAKE_SIZEOF_VOID_P EQUAL 4)
+ # HPUX linker crashes building plugins
+ SET(WITHOUT_DYNAMIC_PLUGINS TRUE)
+ ENDIF()
+ # If not PA-RISC 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()
+ENDIF()
+
+#Some OS specific hacks
+IF(CMAKE_SYSTEM_NAME MATCHES "FreeBSD")
+ ADD_DEFINITIONS(-DNET_RETRY_COUNT=1000000)
+ELSEIF(CMAKE_SYSTEM MATCHES "HP-UX" AND CMAKE_SYSTEM MATCHES "11")
+ ADD_DEFINITIONS(-DHPUX11)
+ENDIF()
+
+# Disable warnings in Visual Studio 8 and above
+IF(MSVC AND NOT CMAKE_GENERATOR MATCHES "Visual Studio 7")
+ #TODO: update the code and remove the disabled warnings
+ ADD_DEFINITIONS(/wd4800 /wd4805)
+ ADD_DEFINITIONS(/wd4996)
+ENDIF()
+
+
+# Settings for Visual Studio 7 and above.
+IF(MSVC)
+ # replace /MDd with /MTd
+ STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})
+ STRING(REPLACE "/MD" "/MT" CMAKE_C_FLAGS_RELWITHDEBINFO ${CMAKE_C_FLAGS_RELWITHDEBINFO})
+ STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
+ STRING(REPLACE "/MDd" "/MTd" CMAKE_C_FLAGS_DEBUG_INIT ${CMAKE_C_FLAGS_DEBUG_INIT})
+
+ STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELEASE ${CMAKE_CXX_FLAGS_RELEASE})
+ STRING(REPLACE "/MD" "/MT" CMAKE_CXX_FLAGS_RELWITHDEBINFO ${CMAKE_CXX_FLAGS_RELWITHDEBINFO})
+ STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG ${CMAKE_CXX_FLAGS_DEBUG})
+ STRING(REPLACE "/MDd" "/MTd" CMAKE_CXX_FLAGS_DEBUG_INIT ${CMAKE_CXX_FLAGS_DEBUG_INIT})
+
+ # generate map files, set stack size (see bug#20815)
+ SET(thread_stack_size 1048576)
+ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /STACK:${thread_stack_size}")
+ ADD_DEFINITIONS(-DPTHREAD_STACK_MIN=${thread_stack_size})
+
+ # remove support for Exception handling
+ STRING(REPLACE "/GX" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+ STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS})
+ STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_INIT ${CMAKE_CXX_FLAGS_INIT})
+ STRING(REPLACE "/EHsc" "" CMAKE_CXX_FLAGS_DEBUG_INIT ${CMAKE_CXX_FLAGS_DEBUG_INIT})
+
+ # 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(CMAKE_SIZEOF_VOID_P MATCHES 4)
+ENDIF(MSVC)
+
+IF(WIN32)
+ 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")
+ IF (MSVC_VERSION GREATER 1400)
+ # Speed up multiprocessor build
+ ADD_DEFINITIONS("/MP")
+ ENDIF()
+
+ # default to x86 platform. We'll check for X64 in a bit
+ SET (PLATFORM X86)
+ IF(MSVC AND 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")
+ SET (PLATFORM X64)
+ ENDIF()
+ENDIF()
+
+
+
+# Figure out what engines to build and how (statically or dynamically),
+# add preprocessor defines for storage engines.
+IF(WITHOUT_DYNAMIC_PLUGINS)
+ MESSAGE("Dynamic plugins are disabled.")
+ENDIF(WITHOUT_DYNAMIC_PLUGINS)
+
+
+# Perform machine tests on posix platforms only
+IF(WIN32)
+ SET(SYSTEM_LIBS ws2_32)
+ SET(CMAKE_REQUIRED_INCLUDES "winsock2.h;ws2tcpip.h")
+ SET(CMAKE_REQUIRED_DEFINITONS "-D_WIN32_WINNT=0x0501")
+ SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ws2_32)
+ LINK_LIBRARIES(ws2_32)
+ENDIF()
+
+
+
+MACRO(MY_CHECK_LIB func lib found)
+ SET(${found} 0)
+ CHECK_FUNCTION_EXISTS(${func} HAVE_${func}_IN_LIBC)
+ CHECK_LIBRARY_EXISTS(${lib} ${func} "" HAVE_${func}_IN_${lib})
+ IF (HAVE_${func}_IN_${lib})
+ SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${lib})
+ LINK_LIBRARIES(${lib})
+ STRING(TOUPPER ${lib} upper_lib)
+ SET(HAVE_LIB${upper_lib} 1 CACHE INTERNAL "Library check")
+ SET(${found} 1)
+ ENDIF()
+ENDMACRO()
+
+MACRO(MY_SEARCH_LIBS func lib found)
+ SET(${found} 0)
+ CHECK_FUNCTION_EXISTS(${func} HAVE_${func}_IN_LIBC)
+ IF(NOT HAVE_${func}_IN_LIBC)
+ MY_CHECK_LIB(${func} ${lib} ${found})
+ ELSE()
+ SET(${found} 1)
+ ENDIF()
+ENDMACRO()
+
+IF(UNIX)
+ MY_CHECK_LIB(floor m found)
+ IF(NOT found)
+ MY_CHECK_LIB( __infinity m found)
+ ENDIF()
+ MY_CHECK_LIB(gethostbyname_r nsl_r found)
+ IF (NOT found)
+ MY_CHECK_LIB(gethostbyname_r nsl found)
+ ENDIF()
+ MY_SEARCH_LIBS(bind bind found)
+ MY_SEARCH_LIBS(crypt crypt found)
+ MY_SEARCH_LIBS(setsockopt socket found)
+ MY_SEARCH_LIBS(aio_read rt found)
+ MY_SEARCH_LIBS(sched_yield posix4 found)
+ MY_CHECK_LIB(pthread_create pthread found)
+ MY_SEARCH_LIBS(dlopen dl found)
+
+ OPTION(WITH_LIBWRAP "Compile with tcp wrappers support" OFF)
+ IF(WITH_LIBWRAP)
+ SET(SAVE_CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES})
+ SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} wrap)
+ CHECK_C_SOURCE_COMPILES(
+ "
+ #include <tcpd.h>
+ int allow_severity = 0;
+ int deny_severity = 0;
+ int main()
+ {
+ hosts_access(0);
+ }"
+ HAVE_LIBWRAP)
+ SET(CMAKE_REQUIRED_LIBRARIES ${SAVE_CMAKE_REQUIRED_LIBRARIES})
+ IF(HAVE_LIBWRAP)
+ SET(MYSYS_LIBWRAP_SOURCE ${CMAKE_SOURCE_DIR}/mysys/my_libwrap.c)
+ SET(LIBWRAP_LIBRARY "wrap")
+ ENDIF()
+ ENDIF()
+ENDIF()
+
+IF (CMAKE_SYSTEM_NAME MATCHES "SunOS")
+ INCLUDE(CheckLibraryExists)
+ CHECK_LIBRARY_EXISTS(mtmalloc malloc "" HAVE_LIBMTMALLOC)
+ IF(HAVE_LIBMTMALLOC)
+ LINK_LIBRARIES(mtmalloc)
+ ENDIF()
+ENDIF()
+
+
+# Workaround for CMake bug#9051
+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()
+
+# This macro is used only on Windows at the moment
+# 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()
+
+
+MACRO(CHECK_INCLUDE_FILES_UNIX INCLUDES VAR)
+IF(UNIX)
+ CHECK_INCLUDE_FILES ("${INCLUDES}" ${VAR})
+ENDIF()
+ENDMACRO()
+
+MACRO(CHECK_C_SOURCE_COMPILES_UNIX SRC VAR)
+IF(UNIX)
+ CHECK_C_SOURCE_COMPILES("${SRC}" ${VAR})
+ENDIF()
+ENDMACRO()
+
+MACRO(CHECK_CXX_SOURCE_COMPILES_UNIX SRC VAR)
+IF(UNIX)
+ CHECK_CXX_SOURCE_COMPILES("${SRC}" ${VAR})
+ENDIF()
+ENDMACRO()
+
+MACRO(CHECK_FUNCTION_EXISTS_UNIX FUNC VAR)
+IF(UNIX)
+ CHECK_FUNCTION_EXISTS("${FUNC}" ${VAR})
+ENDIF()
+ENDMACRO()
+
+MACRO (CHECK_SYMBOL_EXISTS_UNIX SYM HEADER VAR)
+IF(UNIX)
+ CHECK_SYMBOL_EXISTS("${SYM}" "${HEADER}" ${VAR})
+ENDIF()
+ENDMACRO()
+
+#
+# Tests for header files
+#
+INCLUDE (CheckIncludeFiles)
+
+CHECK_INCLUDE_FILES ("stdlib.h;stdarg.h;string.h;float.h" STDC_HEADERS)
+CHECK_INCLUDE_FILES (sys/types.h HAVE_SYS_TYPES_H)
+CHECK_INCLUDE_FILES_UNIX (alloca.h HAVE_ALLOCA_H)
+CHECK_INCLUDE_FILES_UNIX (aio.h HAVE_AIO_H)
+CHECK_INCLUDE_FILES_UNIX (arpa/inet.h HAVE_ARPA_INET_H)
+CHECK_INCLUDE_FILES_UNIX (crypt.h HAVE_CRYPT_H)
+CHECK_INCLUDE_FILES (dirent.h HAVE_DIRENT_H)
+CHECK_INCLUDE_FILES_UNIX (dlfcn.h HAVE_DLFCN_H)
+CHECK_INCLUDE_FILES_UNIX (execinfo.h HAVE_EXECINFO_H)
+CHECK_INCLUDE_FILES (fcntl.h HAVE_FCNTL_H)
+CHECK_INCLUDE_FILES (fenv.h HAVE_FENV_H)
+CHECK_INCLUDE_FILES (float.h HAVE_FLOAT_H)
+CHECK_INCLUDE_FILES_UNIX (floatingpoint.h HAVE_FLOATINGPOINT_H)
+CHECK_INCLUDE_FILES_UNIX (fpu_control.h HAVE_FPU_CONTROL_H)
+CHECK_INCLUDE_FILES_UNIX (grp.h HAVE_GRP_H)
+CHECK_INCLUDE_FILES_UNIX (ieeefp.h HAVE_IEEEFP_H)
+CHECK_INCLUDE_FILES (inttypes.h HAVE_INTTYPES_H)
+CHECK_INCLUDE_FILES_UNIX (langinfo.h HAVE_LANGINFO_H)
+CHECK_INCLUDE_FILES (limits.h HAVE_LIMITS_H)
+CHECK_INCLUDE_FILES (locale.h HAVE_LOCALE_H)
+CHECK_INCLUDE_FILES (malloc.h HAVE_MALLOC_H)
+CHECK_INCLUDE_FILES (memory.h HAVE_MEMORY_H)
+CHECK_INCLUDE_FILES_UNIX (netinet/in.h HAVE_NETINET_IN_H)
+CHECK_INCLUDE_FILES_UNIX (paths.h HAVE_PATHS_H)
+CHECK_INCLUDE_FILES_UNIX (port.h HAVE_PORT_H)
+CHECK_INCLUDE_FILES_UNIX (pwd.h HAVE_PWD_H)
+CHECK_INCLUDE_FILES_UNIX (sched.h HAVE_SCHED_H)
+CHECK_INCLUDE_FILES_UNIX (select.h HAVE_SELECT_H)
+CHECK_INCLUDE_FILES_UNIX (semaphore.h HAVE_SEMAPHORE_H)
+CHECK_INCLUDE_FILES_UNIX (sys/dir.h HAVE_SYS_DIR_H)
+CHECK_INCLUDE_FILES_UNIX (sys/pte.h HAVE_SYS_PTE_H)
+CHECK_INCLUDE_FILES_UNIX (sys/ptem.h HAVE_SYS_PTEM_H)
+CHECK_INCLUDE_FILES (stddef.h HAVE_STDDEF_H)
+CHECK_INCLUDE_FILES (stdint.h HAVE_STDINT_H)
+CHECK_INCLUDE_FILES (stdlib.h HAVE_STDLIB_H)
+CHECK_INCLUDE_FILES (strings.h HAVE_STRINGS_H)
+CHECK_INCLUDE_FILES (string.h HAVE_STRING_H)
+CHECK_INCLUDE_FILES_UNIX (synch.h HAVE_SYNCH_H)
+CHECK_INCLUDE_FILES_UNIX (sysent.h HAVE_SYSENT_H)
+CHECK_INCLUDE_FILES_UNIX (sys/cdefs.h HAVE_SYS_CDEFS_H)
+CHECK_INCLUDE_FILES_UNIX (sys/file.h HAVE_SYS_FILE_H)
+CHECK_INCLUDE_FILES_UNIX (sys/fpu.h HAVE_SYS_FPU_H)
+CHECK_INCLUDE_FILES_UNIX (sys/ioctl.h HAVE_SYS_IOCTL_H)
+CHECK_INCLUDE_FILES_UNIX (sys/ipc.h HAVE_SYS_IPC_H)
+CHECK_INCLUDE_FILES_UNIX (sys/malloc.h HAVE_SYS_MALLOC_H)
+CHECK_INCLUDE_FILES_UNIX (sys/mman.h HAVE_SYS_MMAN_H)
+CHECK_INCLUDE_FILES_UNIX (sys/prctl.h HAVE_SYS_PRCTL_H)
+CHECK_INCLUDE_FILES_UNIX (sys/resource.h HAVE_SYS_RESOURCE_H)
+CHECK_INCLUDE_FILES_UNIX (sys/select.h HAVE_SYS_SELECT_H)
+CHECK_INCLUDE_FILES_UNIX (sys/shm.h HAVE_SYS_SHM_H)
+CHECK_INCLUDE_FILES_UNIX (sys/socket.h HAVE_SYS_SOCKET_H)
+CHECK_INCLUDE_FILES (sys/stat.h HAVE_SYS_STAT_H)
+CHECK_INCLUDE_FILES_UNIX (sys/stream.h HAVE_SYS_STREAM_H)
+CHECK_INCLUDE_FILES_UNIX (sys/termcap.h HAVE_SYS_TERMCAP_H)
+CHECK_INCLUDE_FILES ("time.h;sys/timeb.h" HAVE_SYS_TIMEB_H)
+CHECK_INCLUDE_FILES_UNIX ("curses.h;term.h" HAVE_TERM_H)
+CHECK_INCLUDE_FILES_UNIX (termios.h HAVE_TERMIOS_H)
+CHECK_INCLUDE_FILES_UNIX (termio.h HAVE_TERMIO_H)
+CHECK_INCLUDE_FILES_UNIX (termcap.h HAVE_TERMCAP_H)
+CHECK_INCLUDE_FILES_UNIX (unistd.h HAVE_UNISTD_H)
+CHECK_INCLUDE_FILES (utime.h HAVE_UTIME_H)
+CHECK_INCLUDE_FILES (varargs.h HAVE_VARARGS_H)
+CHECK_INCLUDE_FILES (sys/time.h HAVE_SYS_TIME_H)
+CHECK_INCLUDE_FILES (sys/utime.h HAVE_SYS_UTIME_H)
+CHECK_INCLUDE_FILES_UNIX (sys/wait.h HAVE_SYS_WAIT_H)
+CHECK_INCLUDE_FILES_UNIX (sys/param.h HAVE_SYS_PARAM_H)
+CHECK_INCLUDE_FILES_UNIX (sys/vadvise.h HAVE_SYS_VADVISE_H)
+CHECK_INCLUDE_FILES_UNIX (fnmatch.h HAVE_FNMATCH_H)
+CHECK_INCLUDE_FILES (stdarg.h HAVE_STDARG_H)
+
+# sys/un.h is broken on Linux and Solaris
+# It cannot be included alone ( it references types
+# defined in stdlib.h, i.e size_t)
+CHECK_C_SOURCE_COMPILES_UNIX("
+#include <stdlib.h>
+#include <sys/un.h>
+int main()
+{
+ return 0;
+}
+"
+HAVE_SYS_UN_H)
+
+#
+# Figure out threading library
+#
+FIND_PACKAGE (Threads)
+
+#
+# Tests for functions
+#
+#CHECK_FUNCTION_EXISTS (aiowait HAVE_AIOWAIT)
+CHECK_FUNCTION_EXISTS_UNIX (aio_read HAVE_AIO_READ)
+CHECK_FUNCTION_EXISTS_UNIX (alarm HAVE_ALARM)
+SET(HAVE_ALLOCA 1)
+CHECK_FUNCTION_EXISTS_UNIX (backtrace HAVE_BACKTRACE)
+CHECK_FUNCTION_EXISTS_UNIX (backtrace_symbols HAVE_BACKTRACE_SYMBOLS)
+CHECK_FUNCTION_EXISTS_UNIX (backtrace_symbols_fd HAVE_BACKTRACE_SYMBOLS_FD)
+CHECK_FUNCTION_EXISTS_UNIX (bcmp HAVE_BCMP)
+CHECK_FUNCTION_EXISTS_UNIX (bfill HAVE_BFILL)
+CHECK_FUNCTION_EXISTS_UNIX (bmove HAVE_BMOVE)
+CHECK_FUNCTION_EXISTS (bsearch HAVE_BSEARCH)
+CHECK_FUNCTION_EXISTS (index HAVE_INDEX)
+CHECK_FUNCTION_EXISTS_UNIX (bzero HAVE_BZERO)
+CHECK_FUNCTION_EXISTS_UNIX (clock_gettime HAVE_CLOCK_GETTIME)
+CHECK_FUNCTION_EXISTS_UNIX (cuserid HAVE_CUSERID)
+CHECK_FUNCTION_EXISTS_UNIX (directio HAVE_DIRECTIO)
+CHECK_FUNCTION_EXISTS_UNIX (_doprnt HAVE_DOPRNT)
+CHECK_FUNCTION_EXISTS_UNIX (flockfile HAVE_FLOCKFILE)
+CHECK_FUNCTION_EXISTS_UNIX (ftruncate HAVE_FTRUNCATE)
+CHECK_FUNCTION_EXISTS_UNIX (getline HAVE_GETLINE)
+CHECK_FUNCTION_EXISTS_UNIX (compress HAVE_COMPRESS)
+CHECK_FUNCTION_EXISTS_UNIX (crypt HAVE_CRYPT)
+CHECK_FUNCTION_EXISTS_UNIX (dlerror HAVE_DLERROR)
+CHECK_FUNCTION_EXISTS_UNIX (dlopen HAVE_DLOPEN)
+IF (CMAKE_COMPILER_IS_GNUCC)
+ IF (CMAKE_EXE_LINKER_FLAGS MATCHES " -static "
+ OR CMAKE_EXE_LINKER_FLAGS MATCHES " -static$")
+ SET(HAVE_DLOPEN FALSE CACHE "Disable dlopen due to -static flag" FORCE)
+ SET(WITHOUT_DYNAMIC_PLUGINS TRUE)
+ ENDIF()
+ENDIF()
+CHECK_FUNCTION_EXISTS_UNIX (fchmod HAVE_FCHMOD)
+CHECK_FUNCTION_EXISTS_UNIX (fcntl HAVE_FCNTL)
+CHECK_FUNCTION_EXISTS_UNIX (fconvert HAVE_FCONVERT)
+CHECK_FUNCTION_EXISTS_UNIX (fdatasync HAVE_FDATASYNC)
+CHECK_FUNCTION_EXISTS_UNIX (fesetround HAVE_FESETROUND)
+CHECK_FUNCTION_EXISTS_UNIX (fpsetmask HAVE_FPSETMASK)
+CHECK_FUNCTION_EXISTS_UNIX (fseeko HAVE_FSEEKO)
+CHECK_FUNCTION_EXISTS_UNIX (fsync HAVE_FSYNC)
+CHECK_FUNCTION_EXISTS (getcwd HAVE_GETCWD)
+CHECK_FUNCTION_EXISTS_UNIX (gethostbyaddr_r HAVE_GETHOSTBYADDR_R)
+CHECK_FUNCTION_EXISTS_UNIX (gethostbyname_r HAVE_GETHOSTBYNAME_R)
+CHECK_FUNCTION_EXISTS_UNIX (gethrtime HAVE_GETHRTIME)
+CHECK_FUNCTION_EXISTS (getnameinfo HAVE_GETNAMEINFO)
+CHECK_FUNCTION_EXISTS_UNIX (getpass HAVE_GETPASS)
+CHECK_FUNCTION_EXISTS_UNIX (getpassphrase HAVE_GETPASSPHRASE)
+CHECK_FUNCTION_EXISTS_UNIX (getpwnam HAVE_GETPWNAM)
+CHECK_FUNCTION_EXISTS_UNIX (getpwuid HAVE_GETPWUID)
+CHECK_FUNCTION_EXISTS_UNIX (getrlimit HAVE_GETRLIMIT)
+CHECK_FUNCTION_EXISTS_UNIX (getrusage HAVE_GETRUSAGE)
+CHECK_FUNCTION_EXISTS_UNIX (getwd HAVE_GETWD)
+CHECK_FUNCTION_EXISTS_UNIX (gmtime_r HAVE_GMTIME_R)
+CHECK_FUNCTION_EXISTS_UNIX (initgroups HAVE_INITGROUPS)
+CHECK_FUNCTION_EXISTS_UNIX (issetugid HAVE_ISSETUGID)
+CHECK_FUNCTION_EXISTS (ldiv HAVE_LDIV)
+CHECK_FUNCTION_EXISTS_UNIX (localtime_r HAVE_LOCALTIME_R)
+CHECK_FUNCTION_EXISTS (longjmp HAVE_LONGJMP)
+CHECK_FUNCTION_EXISTS (lstat HAVE_LSTAT)
+CHECK_FUNCTION_EXISTS_UNIX (madvise HAVE_MADVISE)
+CHECK_FUNCTION_EXISTS_UNIX (mallinfo HAVE_MALLINFO)
+CHECK_FUNCTION_EXISTS (memcpy HAVE_MEMCPY)
+CHECK_FUNCTION_EXISTS (memmove HAVE_MEMMOVE)
+CHECK_FUNCTION_EXISTS (mkstemp HAVE_MKSTEMP)
+CHECK_FUNCTION_EXISTS_UNIX (mlock HAVE_MLOCK)
+CHECK_FUNCTION_EXISTS_UNIX (mlockall HAVE_MLOCKALL)
+CHECK_FUNCTION_EXISTS_UNIX (mmap HAVE_MMAP)
+CHECK_FUNCTION_EXISTS_UNIX (mmap64 HAVE_MMAP64)
+CHECK_FUNCTION_EXISTS (perror HAVE_PERROR)
+CHECK_FUNCTION_EXISTS_UNIX (poll HAVE_POLL)
+CHECK_FUNCTION_EXISTS_UNIX (port_create HAVE_PORT_CREATE)
+CHECK_FUNCTION_EXISTS_UNIX (posix_fallocate HAVE_POSIX_FALLOCATE)
+CHECK_FUNCTION_EXISTS_UNIX (pread HAVE_PREAD)
+CHECK_FUNCTION_EXISTS_UNIX (pthread_attr_create HAVE_PTHREAD_ATTR_CREATE)
+CHECK_FUNCTION_EXISTS_UNIX (pthread_attr_getstacksize HAVE_PTHREAD_ATTR_GETSTACKSIZE)
+CHECK_FUNCTION_EXISTS_UNIX (pthread_attr_setprio HAVE_PTHREAD_ATTR_SETPRIO)
+CHECK_FUNCTION_EXISTS_UNIX (pthread_attr_setschedparam
+ HAVE_PTHREAD_ATTR_SETSCHEDPARAM)
+CHECK_FUNCTION_EXISTS_UNIX (pthread_attr_setscope HAVE_PTHREAD_ATTR_SETSCOPE)
+CHECK_FUNCTION_EXISTS_UNIX (pthread_attr_setstacksize HAVE_PTHREAD_ATTR_SETSTACKSIZE)
+CHECK_FUNCTION_EXISTS_UNIX (pthread_condattr_create HAVE_PTHREAD_CONDATTR_CREATE)
+CHECK_FUNCTION_EXISTS_UNIX (pthread_condattr_setclock HAVE_PTHREAD_CONDATTR_SETCLOCK)
+CHECK_FUNCTION_EXISTS_UNIX (pthread_init HAVE_PTHREAD_INIT)
+CHECK_FUNCTION_EXISTS_UNIX (pthread_key_delete HAVE_PTHREAD_KEY_DELETE)
+CHECK_FUNCTION_EXISTS_UNIX (pthread_rwlock_rdlock HAVE_PTHREAD_RWLOCK_RDLOCK)
+CHECK_FUNCTION_EXISTS_UNIX (pthread_setprio_np HAVE_PTHREAD_SETPRIO_NP)
+CHECK_FUNCTION_EXISTS_UNIX (pthread_setschedparam HAVE_PTHREAD_SETSCHEDPARAM)
+CHECK_FUNCTION_EXISTS_UNIX (pthread_sigmask HAVE_PTHREAD_SIGMASK)
+CHECK_FUNCTION_EXISTS_UNIX (pthread_threadmask HAVE_PTHREAD_THREADMASK)
+CHECK_FUNCTION_EXISTS_UNIX (pthread_yield_np HAVE_PTHREAD_YIELD_NP)
+CHECK_FUNCTION_EXISTS (putenv HAVE_PUTENV)
+CHECK_FUNCTION_EXISTS_UNIX (readdir_r HAVE_READDIR_R)
+CHECK_FUNCTION_EXISTS_UNIX (readlink HAVE_READLINK)
+CHECK_FUNCTION_EXISTS_UNIX (re_comp HAVE_RE_COMP)
+CHECK_FUNCTION_EXISTS_UNIX (regcomp HAVE_REGCOMP)
+CHECK_FUNCTION_EXISTS_UNIX (realpath HAVE_REALPATH)
+CHECK_FUNCTION_EXISTS (rename HAVE_RENAME)
+CHECK_FUNCTION_EXISTS_UNIX (rwlock_init HAVE_RWLOCK_INIT)
+CHECK_FUNCTION_EXISTS_UNIX (sched_yield HAVE_SCHED_YIELD)
+CHECK_FUNCTION_EXISTS_UNIX (setenv HAVE_SETENV)
+CHECK_FUNCTION_EXISTS (setlocale HAVE_SETLOCALE)
+CHECK_FUNCTION_EXISTS_UNIX (setfd HAVE_SETFD)
+CHECK_FUNCTION_EXISTS_UNIX (sigaction HAVE_SIGACTION)
+CHECK_FUNCTION_EXISTS_UNIX (sigthreadmask HAVE_SIGTHREADMASK)
+CHECK_FUNCTION_EXISTS_UNIX (sigwait HAVE_SIGWAIT)
+CHECK_FUNCTION_EXISTS_UNIX (sigaddset HAVE_SIGADDSET)
+CHECK_FUNCTION_EXISTS_UNIX (sigemptyset HAVE_SIGEMPTYSET)
+CHECK_FUNCTION_EXISTS_UNIX (sighold HAVE_SIGHOLD)
+CHECK_FUNCTION_EXISTS_UNIX (sigset HAVE_SIGSET)
+CHECK_FUNCTION_EXISTS_UNIX (sleep HAVE_SLEEP)
+CHECK_FUNCTION_EXISTS (snprintf HAVE_SNPRINTF)
+CHECK_FUNCTION_EXISTS_UNIX (stpcpy HAVE_STPCPY)
+CHECK_FUNCTION_EXISTS (strcoll HAVE_STRCOLL)
+CHECK_FUNCTION_EXISTS (strerror HAVE_STRERROR)
+CHECK_FUNCTION_EXISTS_UNIX (strlcpy HAVE_STRLCPY)
+CHECK_FUNCTION_EXISTS (strnlen HAVE_STRNLEN)
+CHECK_FUNCTION_EXISTS_UNIX (strlcat HAVE_STRLCAT)
+CHECK_FUNCTION_EXISTS_UNIX (strsignal HAVE_STRSIGNAL)
+CHECK_FUNCTION_EXISTS_UNIX (fgetln HAVE_FGETLN)
+CHECK_FUNCTION_EXISTS (strpbrk HAVE_STRPBRK)
+CHECK_FUNCTION_EXISTS (strsep HAVE_STRSEP)
+CHECK_FUNCTION_EXISTS (strstr HAVE_STRSTR)
+CHECK_FUNCTION_EXISTS_UNIX (strtok_r HAVE_STRTOK_R)
+CHECK_FUNCTION_EXISTS (strtol HAVE_STRTOL)
+CHECK_FUNCTION_EXISTS (strtoll HAVE_STRTOLL)
+CHECK_FUNCTION_EXISTS (strtoul HAVE_STRTOUL)
+CHECK_FUNCTION_EXISTS (strtoull HAVE_STRTOULL)
+CHECK_FUNCTION_EXISTS (strcasecmp HAVE_STRCASECMP)
+CHECK_FUNCTION_EXISTS (strncasecmp HAVE_STRNCASECMP)
+CHECK_FUNCTION_EXISTS (strdup HAVE_STRDUP)
+CHECK_FUNCTION_EXISTS_UNIX (shmat HAVE_SHMAT)
+CHECK_FUNCTION_EXISTS_UNIX (shmctl HAVE_SHMCTL)
+CHECK_FUNCTION_EXISTS_UNIX (shmdt HAVE_SHMDT)
+CHECK_FUNCTION_EXISTS_UNIX (shmget HAVE_SHMGET)
+CHECK_FUNCTION_EXISTS (tell HAVE_TELL)
+CHECK_FUNCTION_EXISTS (tempnam HAVE_TEMPNAM)
+CHECK_FUNCTION_EXISTS_UNIX (thr_setconcurrency HAVE_THR_SETCONCURRENCY)
+CHECK_FUNCTION_EXISTS_UNIX (thr_yield HAVE_THR_YIELD)
+CHECK_FUNCTION_EXISTS_UNIX (vasprintf HAVE_VASPRINTF)
+CHECK_FUNCTION_EXISTS (vsnprintf HAVE_VSNPRINTF)
+CHECK_FUNCTION_EXISTS_UNIX (vprintf HAVE_VPRINTF)
+CHECK_FUNCTION_EXISTS_UNIX (valloc HAVE_VALLOC)
+CHECK_FUNCTION_EXISTS_UNIX (memalign HAVE_MEMALIGN)
+CHECK_FUNCTION_EXISTS_UNIX (chown HAVE_CHOWN)
+CHECK_FUNCTION_EXISTS_UNIX (nl_langinfo HAVE_NL_LANGINFO)
+
+
+#
+# Tests for symbols
+#
+INCLUDE (CheckSymbolExists)
+CHECK_SYMBOL_EXISTS_UNIX(sys_errlist "stdio.h" HAVE_SYS_ERRLIST)
+CHECK_SYMBOL_EXISTS_UNIX(madvise "sys/mman.h" HAVE_DECL_MADVISE)
+CHECK_SYMBOL_EXISTS_UNIX(tzname "time.h" HAVE_TZNAME)
+CHECK_SYMBOL_EXISTS(lrand48 "stdlib.h" HAVE_LRAND48)
+CHECK_SYMBOL_EXISTS_UNIX(getpagesize "unistd.h" HAVE_GETPAGESIZE)
+CHECK_SYMBOL_EXISTS_UNIX(TIOCGWINSZ "sys/ioctl.h" GWINSZ_IN_SYS_IOCTL)
+CHECK_SYMBOL_EXISTS_UNIX(FIONREAD "sys/ioctl.h" FIONREAD_IN_SYS_IOCTL)
+CHECK_SYMBOL_EXISTS_UNIX(TIOCSTAT "sys/ioctl.h" TIOCSTAT_IN_SYS_IOCTL)
+CHECK_SYMBOL_EXISTS(gettimeofday "sys/time.h" HAVE_GETTIMEOFDAY)
+
+CHECK_SYMBOL_EXISTS(finite "math.h" HAVE_FINITE_IN_MATH_H)
+IF(HAVE_FINITE_IN_MATH_H)
+ SET(HAVE_FINITE TRUE CACHE INTERNAL "")
+ELSE()
+ CHECK_SYMBOL_EXISTS(finite "ieeefp.h" HAVE_FINITE)
+ENDIF()
+CHECK_SYMBOL_EXISTS(log2 "math.h" HAVE_LOG2)
+
+
+
+#
+# Test for endianess
+#
+INCLUDE(TestBigEndian)
+IF(APPLE)
+ # Care for universal binary format
+ SET(WORDS_BIGENDIAN __BIG_ENDIAN CACHE INTERNAL "big endian test")
+ELSE()
+ TEST_BIG_ENDIAN(WORDS_BIGENDIAN)
+ENDIF()
+
+#
+# Tests for type sizes (and presence)
+#
+INCLUDE (CheckTypeSize)
+set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ -D_LARGEFILE_SOURCE -D_LARGE_FILES -D_FILE_OFFSET_BITS=64
+ -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS)
+SET(CMAKE_EXTRA_INCLUDE_FILES signal.h)
+CHECK_TYPE_SIZE(sigset_t SIZEOF_SIGSET_T)
+IF(SIZEOF_SIGSET_T)
+ SET(HAVE_SIGSET_T 1)
+ENDIF()
+IF(NOT SIZEOF_SIGSET_T)
+ SET(sigset_t int)
+ENDIF()
+CHECK_TYPE_SIZE(mode_t SIZEOF_MODE_T)
+IF(NOT SIZEOF_MODE_T)
+ SET(mode_t int)
+ENDIF()
+
+
+IF(HAVE_STDINT_H)
+ SET(CMAKE_EXTRA_INCLUDE_FILES stdint.h)
+ENDIF(HAVE_STDINT_H)
+CHECK_TYPE_SIZE(char SIZEOF_CHAR)
+CHECK_TYPE_SIZE("char *" SIZEOF_CHARP)
+CHECK_TYPE_SIZE(short SIZEOF_SHORT)
+CHECK_TYPE_SIZE(int SIZEOF_INT)
+CHECK_TYPE_SIZE(long SIZEOF_LONG)
+CHECK_TYPE_SIZE("long long" SIZEOF_LONG_LONG)
+SET(CMAKE_EXTRA_INCLUDE_FILES stdio.h)
+CHECK_TYPE_SIZE(size_t SIZEOF_SIZE_T)
+SET(CMAKE_EXTRA_INCLUDE_FILES sys/types.h)
+CHECK_TYPE_SIZE(off_t SIZEOF_OFF_T)
+CHECK_TYPE_SIZE(uchar SIZEOF_UCHAR)
+CHECK_TYPE_SIZE(uint SIZEOF_UINT)
+CHECK_TYPE_SIZE(ulong SIZEOF_ULONG)
+CHECK_TYPE_SIZE(int8 SIZEOF_INT8)
+CHECK_TYPE_SIZE(uint8 SIZEOF_UINT8)
+CHECK_TYPE_SIZE(int16 SIZEOF_INT16)
+CHECK_TYPE_SIZE(uint16 SIZEOF_UINT16)
+CHECK_TYPE_SIZE(int32 SIZEOF_INT32)
+CHECK_TYPE_SIZE(uint32 SIZEOF_UINT32)
+CHECK_TYPE_SIZE(u_int32_t SIZEOF_U_INT32_T)
+CHECK_TYPE_SIZE(int64 SIZEOF_INT64)
+CHECK_TYPE_SIZE(uint64 SIZEOF_UINT64)
+SET (CMAKE_EXTRA_INCLUDE_FILES sys/types.h)
+CHECK_TYPE_SIZE(bool SIZEOF_BOOL)
+SET(CMAKE_EXTRA_INCLUDE_FILES)
+IF(HAVE_SYS_SOCKET_H)
+ SET(CMAKE_EXTRA_INCLUDE_FILES sys/socket.h)
+ENDIF(HAVE_SYS_SOCKET_H)
+CHECK_TYPE_SIZE(socklen_t SIZEOF_SOCKLEN_T)
+SET(CMAKE_EXTRA_INCLUDE_FILES)
+
+IF(HAVE_IEEEFP_H)
+ SET(CMAKE_EXTRA_INCLUDE_FILES ieeefp.h)
+ CHECK_TYPE_SIZE(fp_except SIZEOF_FP_EXCEPT)
+ IF(SIZEOF_FP_EXCEPT)
+ SET(HAVE_FP_EXCEPT TRUE)
+ ENDIF()
+ENDIF()
+
+
+#
+# Code tests
+#
+
+CHECK_C_SOURCE_COMPILES("
+#ifdef _WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#else
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#endif
+int main()
+{
+ getaddrinfo( 0, 0, 0, 0);
+ return 0;
+}"
+HAVE_GETADDRINFO)
+
+CHECK_C_SOURCE_COMPILES("
+#ifdef _WIN32
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#else
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netdb.h>
+#endif
+int main()
+{
+ select(0,0,0,0,0);
+ return 0;
+}"
+HAVE_SELECT)
+
+#
+# Check if timespec has ts_sec and ts_nsec fields
+#
+
+CHECK_C_SOURCE_COMPILES_UNIX("
+#include <pthread.h>
+
+int main(int ac, char **av)
+{
+ struct timespec abstime;
+ abstime.ts_sec = time(NULL)+1;
+ abstime.ts_nsec = 0;
+}
+" HAVE_TIMESPEC_TS_SEC)
+
+
+#
+# Check return type of qsort()
+#
+CHECK_C_SOURCE_COMPILES("
+#include <stdlib.h>
+#ifdef __cplusplus
+extern \"C\"
+#endif
+void qsort(void *base, size_t nel, size_t width,
+ int (*compar) (const void *, const void *));
+int main(int ac, char **av) {}
+" QSORT_TYPE_IS_VOID)
+IF(QSORT_TYPE_IS_VOID)
+ SET(RETQSORTTYPE "void")
+ELSE(QSORT_TYPE_IS_VOID)
+ SET(RETQSORTTYPE "int")
+ENDIF(QSORT_TYPE_IS_VOID)
+
+IF(WIN32)
+SET(SOCKET_SIZE_TYPE int)
+ELSE()
+CHECK_CXX_SOURCE_COMPILES("
+#include <sys/socket.h>
+int main(int argc, char **argv)
+{
+ getsockname(0,0,(socklen_t *) 0);
+ return 0;
+}"
+HAVE_SOCKET_SIZE_T_AS_socklen_t)
+
+IF(HAVE_SOCKET_SIZE_T_AS_socklen_t)
+ SET(SOCKET_SIZE_TYPE socklen_t)
+ELSE()
+ CHECK_CXX_SOURCE_COMPILES("
+ #include <sys/socket.h>
+ int main(int argc, char **argv)
+ {
+ getsockname(0,0,(int *) 0);
+ return 0;
+ }"
+ HAVE_SOCKET_SIZE_T_AS_int)
+ IF(HAVE_SOCKET_SIZE_T_AS_int)
+ SET(SOCKET_SIZE_TYPE int)
+ ELSE()
+ CHECK_CXX_SOURCE_COMPILES("
+ #include <sys/socket.h>
+ int main(int argc, char **argv)
+ {
+ getsockname(0,0,(size_t *) 0);
+ return 0;
+ }"
+ HAVE_SOCKET_SIZE_T_AS_size_t)
+ IF(HAVE_SOCKET_SIZE_T_AS_size_t)
+ SET(SOCKET_SIZE_TYPE size_t)
+ ELSE()
+ SET(SOCKET_SIZE_TYPE int)
+ ENDIF()
+ ENDIF()
+ENDIF()
+ENDIF()
+
+CHECK_CXX_SOURCE_COMPILES_UNIX("
+#include <pthread.h>
+int main()
+{
+ pthread_yield();
+ return 0;
+}
+" HAVE_PTHREAD_YIELD_ZERO_ARG)
+
+IF(NOT STACK_DIRECTION)
+ IF(CMAKE_CROSSCOMPILING)
+ MESSAGE(FATAL_ERROR
+ "STACK_DIRECTION is not defined. Please specify -DSTACK_DIRECTION=1 "
+ "or -DSTACK_DIRECTION=-1 when calling cmake.")
+ ELSE()
+ TRY_RUN(STACKDIR_RUN_RESULT STACKDIR_COMPILE_RESULT
+ ${CMAKE_BINARY_DIR}
+ ${CMAKE_SOURCE_DIR}/cmake/stack_direction.c
+ )
+ # Test program returns 0 (down) or 1 (up).
+ # Convert to -1 or 1
+ IF(STACKDIR_RUN_RESULT EQUAL 0)
+ SET(STACK_DIRECTION -1 CACHE INTERNAL "Stack grows direction")
+ ELSE()
+ SET(STACK_DIRECTION 1 CACHE INTERNAL "Stack grows direction")
+ ENDIF()
+ MESSAGE(STATUS "Checking stack grows direction : ${STACK_DIRECTION}")
+ ENDIF()
+ENDIF()
+
+#
+# Check return type of signal handlers
+#
+CHECK_C_SOURCE_COMPILES("
+#include <signal.h>
+#ifdef signal
+# undef signal
+#endif
+#ifdef __cplusplus
+extern \"C\" void (*signal (int, void (*)(int)))(int);
+#else
+void (*signal ()) ();
+#endif
+int main(int ac, char **av) {}
+" SIGNAL_RETURN_TYPE_IS_VOID)
+IF(SIGNAL_RETURN_TYPE_IS_VOID)
+ SET(RETSIGTYPE void)
+ELSE(SIGNAL_RETURN_TYPE_IS_VOID)
+ SET(RETSIGTYPE int)
+ENDIF(SIGNAL_RETURN_TYPE_IS_VOID)
+
+#
+# isnan() is trickier than the usual function test -- it may be a macro
+#
+CHECK_CXX_SOURCE_COMPILES("#include <math.h>
+ int main(int ac, char **av)
+ {
+ isnan(0.0);
+ return 0;
+ }"
+ HAVE_ISNAN)
+
+#
+# isinf() is trickier than the usual function test -- it may be a macro
+#
+CHECK_CXX_SOURCE_COMPILES("#include <math.h>
+ int main(int ac, char **av)
+ {
+ isinf(0.0);
+ return 0;
+ }"
+ HAVE_ISINF)
+#
+# rint() is trickier than the usual function test -- it may be a macro
+#
+CHECK_CXX_SOURCE_COMPILES("#include <math.h>
+ int main(int ac, char **av)
+ {
+ rint(0.0);
+ return 0;
+ }"
+ HAVE_RINT)
+
+CHECK_CXX_SOURCE_COMPILES("
+ #include <time.h>
+ #include <sys/time.h>
+ int main()
+ {
+ return 0;
+ }"
+ TIME_WITH_SYS_TIME)
+
+IF(UNIX)
+CHECK_C_SOURCE_COMPILES("
+#include <unistd.h>
+#include <fcntl.h>
+int main()
+{
+ fcntl(0, F_SETFL, O_NONBLOCK);
+ return 0;
+}
+"
+HAVE_FCNTL_NONBLOCK)
+ENDIF()
+
+IF(NOT HAVE_FCNTL_NONBLOCK)
+ SET(NO_FCNTL_NONBLOCK 1)
+ENDIF()
+
+#
+# Test for how the C compiler does inline, if at all
+#
+CHECK_C_SOURCE_COMPILES("
+static inline int foo(){return 0;}
+int main(int argc, char *argv[]){return 0;}"
+ C_HAS_inline)
+IF(NOT C_HAS_inline)
+ CHECK_C_SOURCE_COMPILES("
+ static __inline int foo(){return 0;}
+ int main(int argc, char *argv[]){return 0;}"
+ C_HAS___inline)
+ SET(C_INLINE __inline)
+ENDIF()
+
+IF(NOT CMAKE_CROSSCOMPILING AND NOT MSVC)
+ STRING(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} processor)
+ IF(processor MATCHES "86" OR processor MATCHES "amd64" OR processor MATCHES "x64")
+ #Check for x86 PAUSE instruction
+ # We have to actually try running the test program, because of a bug
+ # in Solaris on x86_64, where it wrongly reports that PAUSE is not
+ # supported when trying to run an application. See
+ # http://bugs.opensolaris.org/bugdatabase/printableBug.do?bug_id=6478684
+ CHECK_C_SOURCE_RUNS("
+ int main()
+ {
+ __asm__ __volatile__ (\"pause\");
+ return 0;
+ }" HAVE_PAUSE_INSTRUCTION)
+ ENDIF()
+ IF (NOT HAVE_PAUSE_INSTRUCTION)
+ CHECK_C_SOURCE_COMPILES("
+ int main()
+ {
+ __asm__ __volatile__ (\"rep; nop\");
+ return 0;
+ }
+ " HAVE_FAKE_PAUSE_INSTRUCTION)
+ ENDIF()
+ENDIF()
+
+
+
+
+CHECK_SYMBOL_EXISTS_UNIX(tcgetattr "termios.h" HAVE_TCGETATTR 1)
+CHECK_INCLUDE_FILES_UNIX(sys/ioctl.h HAVE_SYS_IOCTL 1)
+
+
+#
+# Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7)
+#
+CHECK_C_SOURCE_COMPILES_UNIX("
+ #include <signal.h>
+ int main(int ac, char **av)
+ {
+ sigset_t ss;
+ struct sigaction sa;
+ sigemptyset(&ss); sigsuspend(&ss);
+ sigaction(SIGINT, &sa, (struct sigaction *) 0);
+ sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0);
+ }"
+ HAVE_POSIX_SIGNALS)
+
+IF(NOT HAVE_POSIX_SIGNALS)
+ CHECK_C_SOURCE_COMPILES_UNIX("
+ #include <signal.h>
+ int main(int ac, char **av)
+ {
+ int mask = sigmask(SIGINT);
+ sigsetmask(mask); sigblock(mask); sigpause(mask);
+ }"
+ HAVE_BSD_SIGNALS)
+ IF (NOT HAVE_BSD_SIGNALS)
+ CHECK_C_SOURCE_COMPILES_UNIX("
+ #include <signal.h>
+ void foo() { }
+ int main(int ac, char **av)
+ {
+ int mask = sigmask(SIGINT);
+ sigset(SIGINT, foo); sigrelse(SIGINT);
+ sighold(SIGINT); sigpause(SIGINT);
+ }"
+ HAVE_SVR3_SIGNALS)
+ IF (NOT HAVE_SVR3_SIGNALS)
+ SET(HAVE_V7_SIGNALS 1)
+ ENDIF(NOT HAVE_SVR3_SIGNALS)
+ ENDIF(NOT HAVE_BSD_SIGNALS)
+ENDIF(NOT HAVE_POSIX_SIGNALS)
+
+# Assume regular sprintf
+SET(SPRINTFS_RETURNS_INT 1)
+
+IF(CMAKE_COMPILER_IS_GNUXX)
+CHECK_CXX_SOURCE_COMPILES("
+ #include <cxxabi.h>
+ int main(int argc, char **argv)
+ {
+ char *foo= 0; int bar= 0;
+ foo= abi::__cxa_demangle(foo, foo, 0, &bar);
+ return 0;
+ }"
+ HAVE_ABI_CXA_DEMANGLE)
+IF(HAVE_ABI_CXA_DEMANGLE)
+ SET(HAVE_CXXABI_H 1)
+ENDIF()
+ENDIF()
+
+CHECK_C_SOURCE_COMPILES_UNIX("
+ int main(int argc, char **argv)
+ {
+ extern char *__bss_start;
+ return __bss_start ? 1 : 0;
+ }"
+HAVE_BSS_START)
+
+CHECK_C_SOURCE_COMPILES_UNIX("
+ int main()
+ {
+ extern void __attribute__((weak)) foo(void);
+ return 0;
+ }"
+ HAVE_WEAK_SYMBOL
+)
+
+
+CHECK_CXX_SOURCE_COMPILES("
+ #include <new>
+ int main()
+ {
+ char *c = new char;
+ return 0;
+ }"
+ HAVE_CXX_NEW
+)
+
+CHECK_CXX_SOURCE_COMPILES_UNIX("
+ #undef inline
+ #if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT)
+ #define _REENTRANT
+ #endif
+ #include <pthread.h>
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
+ #include <netdb.h>
+ int main()
+ {
+
+ struct hostent *foo =
+ gethostbyaddr_r((const char *) 0,
+ 0, 0, (struct hostent *) 0, (char *) NULL, 0, (int *)0);
+ return 0;
+ }
+ "
+ HAVE_SOLARIS_STYLE_GETHOST)
+
+CHECK_CXX_SOURCE_COMPILES_UNIX("
+ #undef inline
+ #if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT)
+ #define _REENTRANT
+ #endif
+ #include <pthread.h>
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
+ #include <netdb.h>
+ int main()
+ {
+ int ret = gethostbyname_r((const char *) 0,
+ (struct hostent*) 0, (char*) 0, 0, (struct hostent **) 0, (int *) 0);
+ return 0;
+ }"
+ HAVE_GETHOSTBYNAME_R_GLIBC2_STYLE)
+
+CHECK_CXX_SOURCE_COMPILES_UNIX("
+ #undef inline
+ #if !defined(SCO) && !defined(__osf__) && !defined(_REENTRANT)
+ #define _REENTRANT
+ #endif
+ #include <pthread.h>
+ #include <sys/types.h>
+ #include <sys/socket.h>
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
+ #include <netdb.h>
+ int main()
+ {
+ int ret = gethostbyname_r((const char *) 0, (struct hostent*) 0, (struct hostent_data*) 0);
+ return 0;
+ }"
+ HAVE_GETHOSTBYNAME_R_RETURN_INT)
+
+IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ 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()
+ENDIF()
+
+IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+ 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()
+ENDIF()
+
+IF(CMAKE_SYSTEM_NAME STREQUAL "AIX" OR CMAKE_SYSTEM_NAME STREQUAL "OS400")
+ # 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
+ # from libraries and mysqld
+ 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})
+ENDIF()
+
+IF(CMAKE_COMPILER_IS_GNUCXX)
+IF(WITH_ATOMIC_OPS STREQUAL "up")
+ SET(MY_ATOMIC_MODE_DUMMY 1 CACHE BOOL "Assume single-CPU mode, no concurrency")
+ELSEIF(WITH_ATOMIC_OPS STREQUAL "rwlocks")
+ SET(MY_ATOMIC_MODE_RWLOCK 1 CACHE BOOL "Use pthread rwlocks for atomic ops")
+ELSEIF(WITH_ATOMIC_OPS STREQUAL "smp")
+ELSEIF(NOT WITH_ATOMIC_OPS)
+ CHECK_CXX_SOURCE_COMPILES("
+ int main()
+ {
+ int foo= -10;
+ int bar= 10;
+ if (!__sync_fetch_and_add(&foo, bar) || foo)
+ return -1;
+ bar= __sync_lock_test_and_set(&foo, bar);
+ if (bar || foo != 10)
+ return -1;
+ bar= __sync_val_compare_and_swap(&bar, foo, 15);
+ if (bar)
+ return -1;
+ return 0;
+ }"
+ HAVE_GCC_ATOMIC_BUILTINS)
+ELSE()
+ MESSAGE(FATAL_ERROR "${WITH_ATOMIC_OPS} is not a valid value for WITH_ATOMIC_OPS!")
+ENDIF()
+ENDIF()
+
+SET(WITH_ATOMIC_LOCKS "${WITH_ATOMIC_LOCKS}" CACHE STRING
+"Implement atomic operations using pthread rwlocks or atomic CPU
+instructions for multi-processor or uniprocessor
+configuration. By default gcc built-in sync functions are used,
+if available and 'smp' configuration otherwise.")
+MARK_AS_ADVANCED(WITH_ATOMIC_LOCKS MY_ATOMIC_MODE_RWLOCK MY_ATOMIC_MODE_DUMMY)
+
+IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+ CHECK_C_SOURCE_RUNS(
+ "
+ #include <atomic.h>
+ int main()
+ {
+ int foo = -10; int bar = 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;
+ return 0;
+ }
+" HAVE_SOLARIS_ATOMIC)
+ENDIF()
+
+#--------------------------------------------------------------------
+# Check for IPv6 support
+#--------------------------------------------------------------------
+CHECK_INCLUDE_FILE(netinet/in6.h HAVE_NETINET_IN6_H)
+
+IF(UNIX)
+ SET(CMAKE_EXTRA_INCLUDE_FILES sys/types.h netinet/in.h sys/socket.h)
+ IF(HAVE_NETINET_IN6_H)
+ SET(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} netinet/in6.h)
+ ENDIF()
+ELSEIF(WIN32)
+ SET(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} winsock2.h ws2ipdef.h)
+ENDIF()
+
+CHECK_TYPE_SIZE("struct sockaddr_in6" SIZEOF_SOCKADDR_IN6)
+CHECK_TYPE_SIZE("struct in6_addr" SIZEOF_IN6_ADDR)
+IF(SIZEOF_SOCKADDR_IN6)
+ SET(HAVE_STRUCT_SOCKADDR_IN6 1)
+ENDIF()
+IF(SIZEOF_IN6_ADDR)
+ SET(HAVE_STRUCT_IN6_ADDR 1)
+ENDIF()
+
+IF(HAVE_STRUCT_SOCKADDR_IN6 OR HAVE_STRUCT_IN6_ADDR)
+ SET(HAVE_IPV6 TRUE CACHE INTERNAL "")
+ENDIF()
+
+
+# Check for sockaddr_storage.ss_family
+# It is called differently under OS400 and older AIX
+
+CHECK_STRUCT_HAS_MEMBER("struct sockaddr_storage"
+ ss_family "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_SOCKADDR_STORAGE_SS_FAMILY)
+IF(NOT HAVE_SOCKADDR_STORAGE_SS_FAMILY)
+ CHECK_STRUCT_HAS_MEMBER("struct sockaddr_storage"
+ __ss_family "${CMAKE_EXTRA_INCLUDE_FILES}" HAVE_SOCKADDR_STORAGE___SS_FAMILY)
+ IF(HAVE_SOCKADDR_STORAGE___SS_FAMILY)
+ SET(ss_family __ss_family)
+ ENDIF()
+ENDIF()
+SET(CMAKE_EXTRA_INCLUDE_FILES)
+
+CHECK_STRUCT_HAS_MEMBER("struct dirent" d_ino "dirent.h" STRUCT_DIRENT_HAS_D_INO)
+CHECK_STRUCT_HAS_MEMBER("struct dirent" d_namlen "dirent.h" STRUCT_DIRENT_HAS_D_NAMLEN)
+SET(SPRINTF_RETURNS_INT 1)
+
+IF(WIN32)
+ SET(SIGNAL_WITH_VIO_CLOSE 1)
+ 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_TYPE_SIZE(ssize_t SIZE_OF_SSIZE_T)
+ IF(NOT SIZE_OF_SSIZE_T)
+ SET(ssize_t SSIZE_T)
+ ENDIF()
+
+
+ # IPv6 definition (appeared in Vista SDK first)
+ CHECK_C_SOURCE_COMPILES("
+ #include <winsock2.h>
+ int main()
+ {
+ return IPPROTO_IPV6;
+ }"
+ HAVE_IPPROTO_IPV6)
+
+ CHECK_C_SOURCE_COMPILES("
+ #include <winsock2.h>
+ #include <ws2ipdef.h>
+ int main()
+ {
+ return IPV6_V6ONLY;
+ }"
+ HAVE_IPV6_V6ONLY)
+
+ IF(NOT HAVE_IPPROTO_IPV6)
+ SET(HAVE_IPPROTO_IPV6 41)
+ ENDIF()
+ IF(NOT HAVE_IPV6_V6ONLY)
+ SET(IPV6_V6ONLY 27)
+ ENDIF()
+
+ENDIF(WIN32)
+
+
diff --git a/configure.in b/configure.in
index 9fe5c741a03..24c44358c3c 100644
--- a/configure.in
+++ b/configure.in
@@ -2929,7 +2929,9 @@ AC_CONFIG_FILES(Makefile extra/Makefile mysys/Makefile dnl
libmysqld/Makefile libmysqld/examples/Makefile dnl
mysql-test/Makefile mysql-test/lib/My/SafeProcess/Makefile dnl
netware/Makefile sql-bench/Makefile dnl
- include/mysql_version.h plugin/Makefile win/Makefile)
+ include/mysql_version.h plugin/Makefile win/Makefile
+ cmake/Makefile
+ )
AC_CONFIG_COMMANDS([default], , test -z "$CONFIG_HEADERS" || echo timestamp > stamp-h)
diff --git a/dbug/CMakeLists.txt b/dbug/CMakeLists.txt
index fabb592dccc..00de8ba11ff 100755
--- a/dbug/CMakeLists.txt
+++ b/dbug/CMakeLists.txt
@@ -13,11 +13,11 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/dbug)
-
-SET(DBUG_SOURCES dbug.c factorial.c sanity.c)
-
-IF(NOT SOURCE_SUBLIBS)
- INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
- ADD_LIBRARY(dbug ${DBUG_SOURCES})
-ENDIF(NOT SOURCE_SUBLIBS)
+INCLUDE_DIRECTORIES(
+ ${CMAKE_SOURCE_DIR}/dbug
+ ${CMAKE_SOURCE_DIR}/include
+)
+SET(DBUG_SOURCES dbug.c sanity.c)
+USE_ABSOLUTE_FILENAMES(DBUG_SOURCES)
+ADD_LIBRARY(dbug ${DBUG_SOURCES})
+TARGET_LINK_LIBRARIES(dbug mysys)
diff --git a/extra/CMakeLists.txt b/extra/CMakeLists.txt
index b67fdfa601f..c1487149acd 100755
--- a/extra/CMakeLists.txt
+++ b/extra/CMakeLists.txt
@@ -12,42 +12,78 @@
# 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("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+INCLUDE_DIRECTORIES(
+${CMAKE_SOURCE_DIR}/include
+${ZLIB_INCLUDE_DIR}
+# Following is for perror, in case NDB is compiled in.
+${CMAKE_SOURCE_DIR}/storage/ndb/include
+${CMAKE_SOURCE_DIR}/storage/ndb/include/util
+${CMAKE_SOURCE_DIR}/storage/ndb/include/ndbapi
+${CMAKE_SOURCE_DIR}/storage/ndb/include/portlib
+${CMAKE_SOURCE_DIR}/storage/ndb/include/mgmapi)
-ADD_EXECUTABLE(comp_err comp_err.c)
-TARGET_LINK_LIBRARIES(comp_err dbug mysys strings zlib)
-GET_TARGET_PROPERTY(COMP_ERR_EXE comp_err LOCATION)
+IF(NOT CMAKE_CROSSCOMPILING)
+ ADD_EXECUTABLE(comp_err comp_err.c)
+ TARGET_LINK_LIBRARIES(comp_err ${ZLIB_LIBRARY} mysys)
+ENDIF()
-ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/include/mysqld_error.h
- COMMAND ${COMP_ERR_EXE}
+ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_BINARY_DIR}/include/mysqld_error.h
+ ${PROJECT_BINARY_DIR}/sql/share/english/errmsg.sys
+ COMMAND comp_err
--charset=${PROJECT_SOURCE_DIR}/sql/share/charsets
- --out-dir=${PROJECT_SOURCE_DIR}/sql/share/
- --header_file=${PROJECT_SOURCE_DIR}/include/mysqld_error.h
- --name_file=${PROJECT_SOURCE_DIR}/include/mysqld_ername.h
- --state_file=${PROJECT_SOURCE_DIR}/include/sql_state.h
+ --out-dir=${PROJECT_BINARY_DIR}/sql/share/
+ --header_file=${PROJECT_BINARY_DIR}/include/mysqld_error.h
+ --name_file=${PROJECT_BINARY_DIR}/include/mysqld_ername.h
+ --state_file=${PROJECT_BINARY_DIR}/include/sql_state.h
--in_file=${PROJECT_SOURCE_DIR}/sql/share/errmsg-utf8.txt
- DEPENDS comp_err ${PROJECT_SOURCE_DIR}/sql/share/errmsg-utf8.txt)
+ DEPENDS ${PROJECT_SOURCE_DIR}/sql/share/errmsg-utf8.txt
+ ${CMAKE_CURRENT_SOURCE_DIR}/comp_err.c)
ADD_CUSTOM_TARGET(GenError
ALL
- DEPENDS ${PROJECT_SOURCE_DIR}/include/mysqld_error.h)
+ DEPENDS
+ ${PROJECT_BINARY_DIR}/include/mysqld_error.h
+ ${PROJECT_BINARY_DIR}/sql/share/english/errmsg.sys
+ ${PROJECT_SOURCE_DIR}/sql/share/errmsg-utf8.txt)
ADD_EXECUTABLE(my_print_defaults my_print_defaults.c)
-TARGET_LINK_LIBRARIES(my_print_defaults strings mysys dbug taocrypt)
+TARGET_LINK_LIBRARIES(my_print_defaults mysys)
ADD_EXECUTABLE(perror perror.c)
-TARGET_LINK_LIBRARIES(perror strings mysys dbug)
+ADD_DEPENDENCIES(perror GenError)
+TARGET_LINK_LIBRARIES(perror mysys)
ADD_EXECUTABLE(resolveip resolveip.c)
-TARGET_LINK_LIBRARIES(resolveip strings mysys dbug)
+TARGET_LINK_LIBRARIES(resolveip mysys)
+# On Solaris, inet_aton() function used by resolveip could be in resolv library
+IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+ INCLUDE(CheckFunctionExists)
+ INCLUDE(CheckLibraryExists)
+ CHECK_FUNCTION_EXISTS(inet_aton HAVE_INET_ATON)
+ IF(NOT HAVE_INET_ATON)
+ CHECK_LIBRARY_EXISTS(resolv inet_aton "" HAVE_INET_ATON_IN_RESOLV)
+ IF(HAVE_INET_ATON_IN_RESOLV)
+ TARGET_LINK_LIBRARIES(resolveip resolv)
+ ENDIF()
+ ENDIF()
+ENDIF()
+
ADD_EXECUTABLE(replace replace.c)
-TARGET_LINK_LIBRARIES(replace strings mysys dbug)
+TARGET_LINK_LIBRARIES(replace mysys)
+IF(UNIX)
+ ADD_EXECUTABLE(innochecksum innochecksum.c)
+
+ ADD_EXECUTABLE(resolve_stack_dump resolve_stack_dump.c)
+ TARGET_LINK_LIBRARIES(resolve_stack_dump mysys)
+
+ ADD_EXECUTABLE(mysql_waitpid mysql_waitpid.c)
+ TARGET_LINK_LIBRARIES(mysql_waitpid mysys)
+
+ INSTALL(TARGETS innochecksum mysql_waitpid resolve_stack_dump DESTINATION bin)
+ENDIF()
-IF(EMBED_MANIFESTS)
- MYSQL_EMBED_MANIFEST("myTest" "asInvoker")
-ENDIF(EMBED_MANIFESTS)
+INSTALL(TARGETS perror resolveip my_print_defaults replace DESTINATION bin)
diff --git a/extra/yassl/CMakeLists.txt b/extra/yassl/CMakeLists.txt
index ffb72b831af..a815a46a323 100755
--- a/extra/yassl/CMakeLists.txt
+++ b/extra/yassl/CMakeLists.txt
@@ -13,16 +13,22 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/extra/yassl/include
- ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/include
- ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL)
-
-ADD_DEFINITIONS("-D_LIB -DYASSL_PREFIX")
+INCLUDE_DIRECTORIES(
+ ${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_SOURCE_DIR}/extra/yassl/include
+ ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/include
+ ${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL)
+ADD_DEFINITIONS(${SSL_DEFINES})
+IF(CMAKE_COMPILER_IS_GNUXX)
+ #Remove -fno-implicit-templates
+ #(yassl sources cannot be compiled with it)
+ STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS
+${CMAKE_CXX_FLAGS})
+ENDIF()
SET(YASSL_SOURCES src/buffer.cpp src/cert_wrapper.cpp src/crypto_wrapper.cpp src/handshake.cpp src/lock.cpp
src/log.cpp src/socket_wrapper.cpp src/ssl.cpp src/timer.cpp src/yassl_error.cpp
src/yassl_imp.cpp src/yassl_int.cpp)
-IF(NOT SOURCE_SUBLIBS)
- ADD_LIBRARY(yassl ${YASSL_SOURCES})
- ADD_DEPENDENCIES(yassl GenError)
-ENDIF(NOT SOURCE_SUBLIBS)
+USE_ABSOLUTE_FILENAMES(YASSL_SOURCES)
+ADD_LIBRARY(yassl ${YASSL_SOURCES})
+
diff --git a/extra/yassl/taocrypt/CMakeLists.txt b/extra/yassl/taocrypt/CMakeLists.txt
index e91fa021de5..58de3989b73 100755
--- a/extra/yassl/taocrypt/CMakeLists.txt
+++ b/extra/yassl/taocrypt/CMakeLists.txt
@@ -16,6 +16,11 @@
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/mySTL
${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+ADD_DEFINITIONS(${SSL_DEFINES})
+IF(PREVENT_CPP_RUNTIME)
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${PREVENT_CPP_RUNTIME}")
+ENDIF()
SET(TAOCRYPT_SOURCES src/aes.cpp src/aestables.cpp src/algebra.cpp src/arc4.cpp src/asn.cpp src/coding.cpp
src/des.cpp src/dh.cpp src/dsa.cpp src/file.cpp src/hash.cpp src/integer.cpp src/md2.cpp
src/md4.cpp src/md5.cpp src/misc.cpp src/random.cpp src/ripemd.cpp src/rsa.cpp src/sha.cpp
@@ -24,6 +29,6 @@ SET(TAOCRYPT_SOURCES src/aes.cpp src/aestables.cpp src/algebra.cpp src/arc4.cpp
include/error.hpp include/file.hpp include/hash.hpp include/hmac.hpp include/integer.hpp
include/md2.hpp include/md5.hpp include/misc.hpp include/modarith.hpp include/modes.hpp
include/random.hpp include/ripemd.hpp include/rsa.hpp include/sha.hpp)
-IF(NOT SOURCE_SUBLIBS)
- ADD_LIBRARY(taocrypt ${TAOCRYPT_SOURCES})
-ENDIF(NOT SOURCE_SUBLIBS)
+USE_ABSOLUTE_FILENAMES(TAOCRYPT_SOURCES)
+ADD_LIBRARY(taocrypt ${TAOCRYPT_SOURCES})
+
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt
new file mode 100644
index 00000000000..c16f8ea1ff8
--- /dev/null
+++ b/include/CMakeLists.txt
@@ -0,0 +1,61 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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(HEADERS_GEN_CONFIGURE
+${CMAKE_CURRENT_BINARY_DIR}/mysql_version.h
+${CMAKE_CURRENT_BINARY_DIR}/my_config.h
+${CMAKE_CURRENT_BINARY_DIR}/mysqld_ername.h
+${CMAKE_CURRENT_BINARY_DIR}/mysqld_error.h
+${CMAKE_CURRENT_BINARY_DIR}/sql_state.h
+)
+SET(HEADERS_ABI
+ mysql.h
+ mysql_com.h
+ mysql_time.h
+ my_list.h
+ my_alloc.h
+ typelib.h
+)
+
+SET(HEADERS
+ ${HEADERS_ABI}
+ my_dbug.h
+ m_string.h
+ my_sys.h
+ my_xml.h
+ mysql_embed.h
+ my_pthread.h
+ my_no_pthread.h
+ decimal.h
+ errmsg.h
+ my_global.h
+ my_net.h
+ my_getopt.h
+ sslopt-longopts.h
+ my_dir.h
+ sslopt-vars.h
+ sslopt-case.h
+ sql_common.h
+ keycache.h
+ m_ctype.h
+ my_attribute.h
+ ${HEADERS_GEN_CONFIGURE}
+)
+
+INSTALL(FILES ${HEADERS} DESTINATION include)
+INSTALL(DIRECTORY mysql/ DESTINATION include
+ FILES_MATCHING PATTERN "*.h")
+
+
diff --git a/include/Makefile.am b/include/Makefile.am
index 0a7a35bd6fa..f9a069bc4b5 100644
--- a/include/Makefile.am
+++ b/include/Makefile.am
@@ -43,7 +43,8 @@ noinst_HEADERS = config-win.h config-netware.h my_bit.h \
atomic/solaris.h \
atomic/gcc_builtins.h my_libwrap.h my_stacktrace.h
-EXTRA_DIST = mysql.h.pp mysql/plugin.h.pp probes_mysql.d.base
+EXTRA_DIST = mysql.h.pp mysql/plugin.h.pp probes_mysql.d.base \
+ CMakeLists.txt
# Remove built files and the symlinked directories
CLEANFILES = $(BUILT_SOURCES) readline openssl probes_mysql.d probes_mysql_nodtrace.h
diff --git a/include/keycache.h b/include/keycache.h
index a6005bae878..1ffb1dbb71f 100644
--- a/include/keycache.h
+++ b/include/keycache.h
@@ -67,7 +67,7 @@ typedef struct st_key_cache
HASH_LINK *free_hash_list; /* list of free hash links */
BLOCK_LINK *free_block_list; /* list of free blocks */
BLOCK_LINK *block_root; /* memory for block links */
- uchar HUGE_PTR *block_mem; /* memory for block buffers */
+ uchar *block_mem; /* memory for block buffers */
BLOCK_LINK *used_last; /* ptr to the last block of the LRU chain */
BLOCK_LINK *used_ins; /* ptr to the insertion block in LRU chain */
pthread_mutex_t cache_lock; /* to lock access to the cache structure */
diff --git a/include/my_global.h b/include/my_global.h
index f6d1592fc6f..c95861204d7 100644
--- a/include/my_global.h
+++ b/include/my_global.h
@@ -68,8 +68,8 @@
#define C_MODE_END
#endif
-#if defined(_WIN32) || defined(_WIN64) || defined(__WIN32__) || defined(WIN32)
-#include <config-win.h>
+#if defined(_WIN32)
+#include <my_config.h>
#elif defined(__NETWARE__)
#include <my_config.h>
#include <config-netware.h>
@@ -107,6 +107,49 @@
#define NETWARE_SET_SCREEN_MODE(A)
#endif
+#if defined (_WIN32)
+/*
+ off_t is 32 bit long. We do not use C runtime functions
+ with off_t but native Win32 file IO APIs, that work with
+ 64 bit offsets.
+*/
+#undef SIZEOF_OFF_T
+#define SIZEOF_OFF_T 8
+
+/*
+ Prevent inclusion of Windows GDI headers - they define symbol
+ ERROR that conflicts with mysql headers.
+*/
+#ifndef NOGDI
+#define NOGDI
+#endif
+
+/* Include common headers.*/
+#include <winsock2.h>
+#include <ws2tcpip.h> /* SOCKET */
+#include <io.h> /* access(), chmod() */
+#include <process.h> /* getpid() */
+
+#define sleep(a) Sleep((a)*1000)
+
+/* Define missing access() modes. */
+#define F_OK 0
+#define W_OK 2
+
+/* Define missing file locking constants. */
+#define F_RDLCK 1
+#define F_WRLCK 2
+#define F_UNLCK 3
+#define F_TO_EOF 0x3FFFFFFF
+
+/* Shared memory and named pipe connections are supported. */
+#define HAVE_SMEM 1
+#define HAVE_NAMED_PIPE 1
+#define shared_memory_buffer_length 16000
+#define default_shared_memory_base_name "MYSQL"
+#endif /* _WIN32*/
+
+
/* Workaround for _LARGE_FILES and _LARGE_FILE_API incompatibility on AIX */
#if defined(_AIX) && defined(_LARGE_FILE_API)
#undef _LARGE_FILE_API
@@ -486,8 +529,11 @@ C_MODE_END
/* Go around some bugs in different OS and compilers */
#if defined (HPUX11) && defined(_LARGEFILE_SOURCE)
+#ifndef _LARGEFILE64_SOURCE
#define _LARGEFILE64_SOURCE
#endif
+#endif
+
#if defined(_HPUX_SOURCE) && defined(HAVE_SYS_STREAM_H)
#include <sys/stream.h> /* HPUX 10.20 defines ulong here. UGLY !!! */
#define HAVE_ULONG
@@ -656,7 +702,9 @@ C_MODE_END
/* Some types that is different between systems */
typedef int File; /* File descriptor */
-#ifndef Socket_defined
+#ifdef _WIN32
+typedef SOCKET my_socket;
+#else
typedef int my_socket; /* File descriptor for sockets */
#define INVALID_SOCKET -1
#endif
@@ -744,7 +792,13 @@ typedef SOCKET_SIZE_TYPE size_socket;
#define FN_CURLIB '.' /* ./ is used as abbrev for current dir */
#define FN_PARENTDIR ".." /* Parent directory; Must be a string */
-#ifndef FN_LIBCHAR
+#ifdef _WIN32
+#define FN_LIBCHAR '\\'
+#define FN_ROOTDIR "\\"
+#define FN_DEVCHAR ':'
+#define FN_NETWORK_DRIVES /* Uses \\ to indicate network drives */
+#define FN_NO_CASE_SENCE /* Files are not case-sensitive */
+#else
#define FN_LIBCHAR '/'
#define FN_ROOTDIR "/"
#endif
@@ -828,6 +882,31 @@ typedef SOCKET_SIZE_TYPE size_socket;
#undef remove /* Crashes MySQL on SCO 5.0.0 */
#ifndef __WIN__
#define closesocket(A) close(A)
+#endif
+
+#if (_MSC_VER)
+#if !defined(_WIN64)
+inline double my_ulonglong2double(unsigned long long value)
+{
+ long long nr=(long long) value;
+ if (nr >= 0)
+ return (double) nr;
+ return (18446744073709551616.0 + (double) nr);
+}
+#define ulonglong2double my_ulonglong2double
+#define my_off_t2double my_ulonglong2double
+#endif /* _WIN64 */
+inline unsigned long long my_double2ulonglong(double d)
+{
+ double t= d - (double) 0x8000000000000000ULL;
+
+ if (t >= 0)
+ return ((unsigned long long) t) + 0x8000000000000000ULL;
+ return (unsigned long long) d;
+}
+#define double2ulonglong my_double2ulonglong
+#endif
+
#ifndef ulonglong2double
#define ulonglong2double(A) ((double) (ulonglong) (A))
#define my_off_t2double(A) ((double) (my_off_t) (A))
@@ -835,7 +914,6 @@ typedef SOCKET_SIZE_TYPE size_socket;
#ifndef double2ulonglong
#define double2ulonglong(A) ((ulonglong) (double) (A))
#endif
-#endif
#ifndef offsetof
#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
@@ -1092,15 +1170,18 @@ typedef long long intptr;
#define SYSTEM_SIZEOF_OFF_T SIZEOF_OFF_T
#endif /* USE_RAID */
+#if defined(_WIN32)
+typedef unsigned long long my_off_t;
+typedef unsigned long long os_off_t;
+#else
+typedef off_t os_off_t;
#if SIZEOF_OFF_T > 4
typedef ulonglong my_off_t;
#else
typedef unsigned long my_off_t;
#endif
+#endif /*_WIN32*/
#define MY_FILEPOS_ERROR (~(my_off_t) 0)
-#if !defined(__WIN__)
-typedef off_t os_off_t;
-#endif
#if defined(__WIN__)
#define socket_errno WSAGetLastError()
@@ -1127,9 +1208,6 @@ typedef uint8 int7; /* Most effective integer 0 <= x <= 127 */
typedef short int15; /* Most effective integer 0 <= x <= 32767 */
typedef int myf; /* Type of MyFlags in my_funcs */
typedef char my_bool; /* Small bool */
-#if !defined(bool) && (!defined(HAVE_BOOL) || !defined(__cplusplus))
-typedef char bool; /* Ordinary boolean values 0 1 */
-#endif
/* Macros for converting *constants* to the right type */
#define INT8(v) (int8) (v)
#define INT16(v) (int16) (v)
@@ -1522,12 +1600,15 @@ do { doubleget_union _tmp; \
#define NO_EMBEDDED_ACCESS_CHECKS
#endif
-#ifdef HAVE_DLOPEN
-#if defined(__WIN__)
-#define dlsym(lib, name) GetProcAddress((HMODULE)lib, name)
+#if defined(_WIN32)
+#define dlsym(lib, name) (void*)GetProcAddress((HMODULE)lib, name)
#define dlopen(libname, unused) LoadLibraryEx(libname, NULL, 0)
#define dlclose(lib) FreeLibrary((HMODULE)lib)
-#elif defined(HAVE_DLFCN_H)
+#define HAVE_DLOPEN
+#endif
+
+#ifdef HAVE_DLOPEN
+#if defined(HAVE_DLFCN_H)
#include <dlfcn.h>
#endif
#endif
diff --git a/include/my_pthread.h b/include/my_pthread.h
index b6d9feae067..9f46d1f76c1 100644
--- a/include/my_pthread.h
+++ b/include/my_pthread.h
@@ -117,9 +117,11 @@ struct tm *gmtime_r(const time_t *timep,struct tm *tmp);
void pthread_exit(void *a);
int pthread_join(pthread_t thread, void **value_ptr);
+int pthread_cancel(pthread_t thread);
-
+#ifndef ETIMEDOUT
#define ETIMEDOUT 145 /* Win32 doesn't have this */
+#endif
#define HAVE_LOCALTIME_R 1
#define _REENTRANT 1
#define HAVE_PTHREAD_ATTR_SETSTACKSIZE 1
@@ -154,6 +156,7 @@ int pthread_join(pthread_t thread, void **value_ptr);
#define pthread_condattr_destroy(A)
#define my_pthread_getprio(thread_id) pthread_dummy(0)
+#define my_sigset(A,B) signal(A,B)
#else /* Normal threads */
@@ -699,25 +702,32 @@ extern uint thd_lib_detected;
Warning:
When compiling without threads, this file is not included.
See the *other* declarations of thread_safe_xxx in include/my_global.h
-
- Second warning:
- See include/config-win.h, for yet another implementation.
*/
#ifdef THREAD
#ifndef thread_safe_increment
+#ifdef _WIN32
+#define thread_safe_increment(V,L) InterlockedIncrement((long*) &(V))
+#define thread_safe_decrement(V,L) InterlockedDecrement((long*) &(V))
+#else
#define thread_safe_increment(V,L) \
(pthread_mutex_lock((L)), (V)++, pthread_mutex_unlock((L)))
#define thread_safe_decrement(V,L) \
(pthread_mutex_lock((L)), (V)--, pthread_mutex_unlock((L)))
#endif
+#endif
#ifndef thread_safe_add
+#ifdef _WIN32
+#define thread_safe_add(V,C,L) InterlockedExchangeAdd((long*) &(V),(C))
+#define thread_safe_sub(V,C,L) InterlockedExchangeAdd((long*) &(V),-(long) (C))
+#else
#define thread_safe_add(V,C,L) \
(pthread_mutex_lock((L)), (V)+=(C), pthread_mutex_unlock((L)))
#define thread_safe_sub(V,C,L) \
(pthread_mutex_lock((L)), (V)-=(C), pthread_mutex_unlock((L)))
#endif
#endif
+#endif
/*
statistics_xxx functions are for non critical statistic,
diff --git a/include/my_sys.h b/include/my_sys.h
index 9121f0f249e..ea466653372 100644
--- a/include/my_sys.h
+++ b/include/my_sys.h
@@ -34,6 +34,9 @@ extern int NEAR my_errno; /* Last error in mysys */
#include <m_ctype.h> /* for CHARSET_INFO */
#include <stdarg.h>
#include <typelib.h>
+#ifdef _WIN32
+#include <malloc.h> /*for alloca*/
+#endif
#define MYSYS_PROGRAM_USES_CURSES() { error_handler_hook = my_message_curses; mysys_uses_curses=1; }
#define MYSYS_PROGRAM_DONT_USE_CURSES() { error_handler_hook = my_message_no_curses; mysys_uses_curses=0;}
diff --git a/include/mysql/plugin.h b/include/mysql/plugin.h
index f158dc20999..289d1f06fbc 100644
--- a/include/mysql/plugin.h
+++ b/include/mysql/plugin.h
@@ -18,10 +18,25 @@
/*
On Windows, exports from DLL need to be declared
-*/
-#if (defined(_WIN32) && defined(MYSQL_DYNAMIC_PLUGIN))
-#define MYSQL_PLUGIN_EXPORT extern "C" __declspec(dllexport)
-#else
+ Also, plugin needs to be declared as extern "C" because MSVC
+ unlike other compilers, uses C++ mangling for variables not only
+ for functions.
+*/
+#if defined(_MSC_VER)
+#if defined(MYSQL_DYNAMIC_PLUGIN)
+ #ifdef __cplusplus
+ #define MYSQL_PLUGIN_EXPORT extern "C" __declspec(dllexport)
+ #else
+ #define MYSQL_PLUGIN_EXPORT __declspec(dllexport)
+ #endif
+#else /* MYSQL_DYNAMIC_PLUGIN */
+ #ifdef __cplusplus
+ #define MYSQL_PLUGIN_EXPORT extern "C"
+ #else
+ #define MYSQL_PLUGIN_EXPORT
+ #endif
+#endif /*MYSQL_DYNAMIC_PLUGIN */
+#else /*_MSC_VER */
#define MYSQL_PLUGIN_EXPORT
#endif
@@ -87,9 +102,9 @@ typedef struct st_mysql_xid MYSQL_XID;
#ifndef MYSQL_DYNAMIC_PLUGIN
#define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS) \
-int VERSION= MYSQL_PLUGIN_INTERFACE_VERSION; \
-int PSIZE= sizeof(struct st_mysql_plugin); \
-struct st_mysql_plugin DECLS[]= {
+MYSQL_PLUGIN_EXPORT int VERSION= MYSQL_PLUGIN_INTERFACE_VERSION; \
+MYSQL_PLUGIN_EXPORT int PSIZE= sizeof(struct st_mysql_plugin); \
+MYSQL_PLUGIN_EXPORT struct st_mysql_plugin DECLS[]= {
#else
#define __MYSQL_DECLARE_PLUGIN(NAME, VERSION, PSIZE, DECLS) \
MYSQL_PLUGIN_EXPORT int _mysql_plugin_interface_version_= MYSQL_PLUGIN_INTERFACE_VERSION; \
diff --git a/include/thr_alarm.h b/include/thr_alarm.h
index fb906039269..8d7f5bcdee0 100644
--- a/include/thr_alarm.h
+++ b/include/thr_alarm.h
@@ -64,7 +64,7 @@ typedef my_bool ALARM;
#if defined(__WIN__)
typedef struct st_thr_alarm_entry
{
- rf_SetTimer crono;
+ UINT_PTR crono;
} thr_alarm_entry;
#else /* System with posix threads */
diff --git a/libmysql/CMakeLists.txt b/libmysql/CMakeLists.txt
index 84ad50e03e3..916aeae491a 100755
--- a/libmysql/CMakeLists.txt
+++ b/libmysql/CMakeLists.txt
@@ -12,102 +12,106 @@
# 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("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
-
-
-# Note that we don't link with the libraries "strings" or "mysys"
-# here, instead we recompile the files needed and include them
-# directly. This means we don't have to worry here about if these
-# libraries are compiled defining USE_TLS or not. Not that it *should*
-# have been a problem anyway, they don't use thread local storage.
-
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
- ${CMAKE_SOURCE_DIR}/libmysql
- ${CMAKE_SOURCE_DIR}/regex
- ${CMAKE_SOURCE_DIR}/sql
- ${CMAKE_SOURCE_DIR}/strings)
-
-# We include the source file listing instead of referencing the
-# libraries. At least with CMake 2.4 and Visual Studio 2005 a static
-# library created from other static libraries would not be complete,
-# i.e. the libraries listed in TARGET_LINK_LIBRARIES() were just
-# ignored.
-
-
-# Include and add the directory path
-SET(SOURCE_SUBLIBS TRUE)
-SET(LIB_SOURCES "")
-
-INCLUDE(${CMAKE_SOURCE_DIR}/zlib/CMakeLists.txt)
-FOREACH(rpath ${ZLIB_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../zlib/${rpath})
-ENDFOREACH(rpath)
-
-# FIXME only needed if build type is "Debug", but CMAKE_BUILD_TYPE is
-# not set during configure time.
-INCLUDE(${CMAKE_SOURCE_DIR}/dbug/CMakeLists.txt)
-FOREACH(rpath ${DBUG_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../dbug/${rpath})
-ENDFOREACH(rpath)
-
-INCLUDE(${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/CMakeLists.txt)
-FOREACH(rpath ${TAOCRYPT_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../extra/yassl/taocrypt/${rpath})
-ENDFOREACH(rpath)
-
-INCLUDE(${CMAKE_SOURCE_DIR}/extra/yassl/CMakeLists.txt)
-FOREACH(rpath ${YASSL_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../extra/yassl/${rpath})
-ENDFOREACH(rpath)
-
-SET(CLIENT_SOURCES ../mysys/array.c ../strings/bchange.c ../strings/bmove.c
- ../strings/bmove_upp.c ../mysys/charset-def.c ../mysys/charset.c
- ../sql-common/client.c ../strings/ctype-big5.c ../strings/ctype-bin.c
- ../strings/ctype-cp932.c ../strings/ctype-czech.c ../strings/ctype-euc_kr.c
- ../strings/ctype-eucjpms.c ../strings/ctype-extra.c ../strings/ctype-gb2312.c
- ../strings/ctype-gbk.c ../strings/ctype-latin1.c ../strings/ctype-mb.c
- ../strings/ctype-simple.c ../strings/ctype-sjis.c ../strings/ctype-tis620.c
- ../strings/ctype-uca.c ../strings/ctype-ucs2.c ../strings/ctype-ujis.c
- ../strings/ctype-utf8.c ../strings/ctype-win1250ch.c ../strings/ctype.c
- ../mysys/default.c errmsg.c ../mysys/errors.c
- ../mysys/hash.c ../mysys/my_sleep.c ../mysys/default_modify.c
- get_password.c ../strings/int2str.c ../strings/is_prefix.c
- libmysql.c ../mysys/list.c ../strings/llstr.c
- ../strings/longlong2str.c ../mysys/mf_arr_appstr.c ../mysys/mf_cache.c
- ../mysys/mf_dirname.c ../mysys/mf_fn_ext.c ../mysys/mf_format.c
- ../mysys/mf_iocache.c ../mysys/mf_iocache2.c ../mysys/mf_loadpath.c
- ../mysys/mf_pack.c ../mysys/mf_path.c ../mysys/mf_tempfile.c ../mysys/mf_unixpath.c
- ../mysys/mf_wcomp.c ../mysys/mulalloc.c ../mysys/my_access.c ../mysys/my_alloc.c
- ../mysys/my_chsize.c ../mysys/my_compress.c ../mysys/my_create.c
- ../mysys/my_delete.c ../mysys/my_div.c ../mysys/my_error.c ../mysys/my_file.c
- ../mysys/my_fopen.c ../mysys/my_fstream.c ../mysys/my_gethostbyname.c
- ../mysys/my_getopt.c ../mysys/my_getwd.c ../mysys/my_init.c ../mysys/my_lib.c
- ../mysys/my_malloc.c ../mysys/my_messnc.c ../mysys/my_net.c ../mysys/my_once.c
- ../mysys/my_open.c ../mysys/my_pread.c ../mysys/my_pthread.c ../mysys/my_read.c
- ../mysys/my_realloc.c ../mysys/my_rename.c ../mysys/my_seek.c
- ../mysys/my_static.c ../strings/my_strtoll10.c ../mysys/my_symlink.c
- ../mysys/my_symlink2.c ../mysys/my_thr_init.c ../sql-common/my_time.c
- ../strings/my_vsnprintf.c ../mysys/my_wincond.c ../mysys/my_winthread.c
- ../mysys/my_write.c ../sql/net_serv.cc ../sql-common/pack.c ../sql/password.c
- ../mysys/safemalloc.c ../mysys/sha1.c ../strings/str2int.c
- ../strings/str_alloc.c ../strings/strcend.c ../strings/strcont.c ../strings/strend.c
- ../strings/strfill.c ../mysys/string.c ../strings/strinstr.c ../strings/strmake.c
- ../strings/strmov.c ../strings/strnlen.c ../strings/strnmov.c ../strings/strtod.c
- ../strings/strtoll.c ../strings/strtoull.c ../strings/strxmov.c ../strings/strxnmov.c
- ../mysys/thr_mutex.c ../mysys/typelib.c ../vio/vio.c ../vio/viosocket.c
- ../vio/viossl.c ../vio/viosslfactories.c ../strings/xml.c ../mysys/mf_qsort.c
- ../mysys/my_getsystime.c ../mysys/my_sync.c ../mysys/my_winerr.c ../mysys/my_winfile.c ${LIB_SOURCES})
-
-
-
-ADD_LIBRARY(mysqlclient STATIC ${CLIENT_SOURCES})
-ADD_DEPENDENCIES(mysqlclient GenError)
-TARGET_LINK_LIBRARIES(mysqlclient)
-ADD_LIBRARY(libmysql SHARED ${CLIENT_SOURCES} dll.c libmysql.def)
-ADD_DEPENDENCIES(libmysql GenError)
-TARGET_LINK_LIBRARIES(libmysql)
+INCLUDE_DIRECTORIES(
+ ${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_SOURCE_DIR}/libmysql
+ ${CMAKE_SOURCE_DIR}/regex
+ ${CMAKE_SOURCE_DIR}/sql
+ ${CMAKE_SOURCE_DIR}/strings
+ ${SSL_INCLUDE_DIRS}
+ ${SSL_INTERNAL_INCLUDE_DIRS}
+ ${ZLIB_INCLUDE_DIR})
+ADD_DEFINITIONS(${SSL_DEFINES})
+
+
+#Remove -fno-implicit-templates
+#(yassl sources cannot be compiled with it)
+STRING(REPLACE "-fno-implicit-templates" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
+ADD_DEFINITIONS(-DDISABLE_DTRACE)
+
+
-IF(EMBED_MANIFESTS)
- MYSQL_EMBED_MANIFEST("myTest" "asInvoker")
-ENDIF(EMBED_MANIFESTS)
+SET(CLIENT_SOURCES
+ get_password.c
+ libmysql.c
+ errmsg.c
+ ../sql-common/client.c
+ ../sql-common/my_time.c
+ ../sql/net_serv.cc
+ ../sql-common/pack.c
+ ../sql/password.c
+)
+
+ADD_LIBRARY(clientlib STATIC ${CLIENT_SOURCES})
+ADD_DEPENDENCIES(clientlib GenError)
+
+# Merge several static libraries into one big mysqlclient.
+SET(LIBS dbug strings vio mysys ${ZLIB_LIBRARY} ${SSL_LIBRARIES})
+MERGE_STATIC_LIBS(mysqlclient mysqlclient "${LIBS};clientlib")
+
+ADD_DEPENDENCIES(mysqlclient GenError)
+SET_TARGET_PROPERTIES(mysqlclient PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+
+
+# Make shared client library
+IF(WIN32)
+ SET(SHARED_OUTPUT_NAME libmysql)
+ELSE()
+ SET(SHARED_OUTPUT_NAME mysqlclient)
+ENDIF()
+
+# On Windows, we can make a shared library out of static.
+# On Unix, we need to recompile all sources, unless we compiled with -fPIC, in
+# which case we can link static libraries to shared.
+IF(MSVC)
+ STATIC_TO_SHARED(mysqlclient libmysql libmysql.def)
+ELSE()
+ SET(LIBMYSQL_SOURCES ${CLIENT_SOURCES})
+
+ IF(NOT WITH_PIC)
+ # Add all sources that come into common static libs.
+ FOREACH(LIB ${LIBS})
+ GET_TARGET_PROPERTY(SRC ${LIB} SOURCES)
+ IF (NOT SRC)
+ # This must be system shared lib (zlib or openssl)
+ # Users of libmysql must link with it too.
+ LIST(APPEND OS_LIBS ${LIB})
+ ELSE()
+ LIST(APPEND LIBMYSQL_SOURCES ${SRC})
+ ENDIF()
+ ENDFOREACH()
+
+ # Some extra flags as in mysys
+ IF(CMAKE_COMPILER_IS_GNUCC AND NOT HAVE_CXX_NEW)
+ SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/mysys/my_new.cc
+ PROPERTIES COMPILE_FLAGS "-DUSE_MYSYS_NEW")
+ ENDIF()
+ ENDIF()
+
+
+ ADD_LIBRARY(libmysql SHARED ${LIBMYSQL_SOURCES})
+ ADD_DEPENDENCIES(libmysql GenError)
+ SET_TARGET_PROPERTIES(libmysql PROPERTIES OUTPUT_NAME ${SHARED_OUTPUT_NAME}
+ SOVERSION "${SHARED_LIB_MAJOR_VERSION}.0")
+ SET_TARGET_PROPERTIES(libmysql PROPERTIES CLEAN_DIRECT_OUTPUT 1)
+
+ IF(WITH_PIC)
+ TARGET_LINK_LIBRARIES(libmysql ${LIBS})
+ ENDIF()
+
+ IF(OS_LIBS)
+ TARGET_LINK_LIBRARIES(libmysql ${OS_LIBS})
+ ENDIF()
+ENDIF()
+
+
+IF(UNIX)
+ # Install links to shared and static libraries
+ # (append _r to base name)
+ INSTALL_SYMLINK(${CMAKE_SHARED_LIBRARY_PREFIX}mysqlclient_r libmysql lib)
+ INSTALL_SYMLINK(${CMAKE_STATIC_LIBRARY_PREFIX}mysqlclient_r mysqlclient lib)
+ENDIF()
+
+INSTALL(TARGETS mysqlclient libmysql DESTINATION lib)
+INSTALL_DEBUG_SYMBOLS( "mysqlclient;libmysql")
diff --git a/libmysqld/CMakeLists.txt b/libmysqld/CMakeLists.txt
index 65b8e12bc26..80f45a4491d 100644
--- a/libmysqld/CMakeLists.txt
+++ b/libmysqld/CMakeLists.txt
@@ -13,84 +13,45 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-ADD_DEFINITIONS(-DMYSQL_SERVER -DEMBEDDED_LIBRARY -DHAVE_DLOPEN)
+ADD_DEFINITIONS(-DMYSQL_SERVER -DEMBEDDED_LIBRARY -DDISABLE_DTRACE
+ ${SSL_DEFINES})
+
+INCLUDE_DIRECTORIES(
+${CMAKE_SOURCE_DIR}/include
+${CMAKE_SOURCE_DIR}/libmysql
+${CMAKE_SOURCE_DIR}/libmysqld
+${CMAKE_SOURCE_DIR}/sql
+${CMAKE_BINARY_DIR}/sql
+${CMAKE_SOURCE_DIR}/regex
+${ZLIB_INCLUDE_DIR}
+${SSL_INCLUDE_DIRS}
+${SSL_INTERNAL_INCLUDE_DIRS}
+${NDB_CLUSTER_INCLUDES}
+${CMAKE_SOURCE_DIR}/sql/backup
+)
+
+SET(GEN_SOURCES
+${CMAKE_BINARY_DIR}/sql/sql_yacc.h
+${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
+${CMAKE_BINARY_DIR}/sql/lex_hash.h
+)
+
+SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES} PROPERTIES GENERATED TRUE)
+SET(LIBS dbug strings regex mysys vio ${ZLIB_LIBRARY} ${SSL_LIBRARIES}
+${MYSQLD_STATIC_PLUGIN_LIBS} ${NDB_CLIENT_LIBS})
+
+# Quirk: recompile selected storage engines with -DEMBEDDED_LIBRARY
+# They depend on internal structures like THD that is different in embedded.
+SET(RECOMPILE_ENGINES myisam myisammrg heap ndbcluster)
+FOREACH(ENGINE ${RECOMPILE_ENGINES})
+ LIST(REMOVE_ITEM LIBS ${ENGINE})
+ GET_TARGET_PROPERTY(SRC ${ENGINE} SOURCES)
+ IF(SRC)
+ LIST(APPEND ENGINE_SOURCES ${SRC})
+ ENDIF()
+ENDFOREACH()
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
- ${CMAKE_SOURCE_DIR}/libmysqld
- ${CMAKE_SOURCE_DIR}/libmysql
- ${CMAKE_SOURCE_DIR}/sql
- ${CMAKE_SOURCE_DIR}/regex
- ${CMAKE_SOURCE_DIR}/extra/yassl/include
- ${CMAKE_SOURCE_DIR}/zlib)
-SET(GEN_SOURCES ${CMAKE_SOURCE_DIR}/sql/sql_yacc.cc
- ${CMAKE_SOURCE_DIR}/sql/sql_yacc.h
- ${CMAKE_SOURCE_DIR}/sql/message.h
- ${CMAKE_SOURCE_DIR}/sql/message.rc
- ${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc
- ${CMAKE_SOURCE_DIR}/sql/lex_hash.h)
-
-SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES} PROPERTIES GENERATED 1)
-
-# Include and add the directory path
-SET(SOURCE_SUBLIBS TRUE)
-SET(LIB_SOURCES "")
-
-INCLUDE(${CMAKE_SOURCE_DIR}/zlib/CMakeLists.txt)
-FOREACH(rpath ${ZLIB_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../zlib/${rpath})
-ENDFOREACH(rpath)
-
-# FIXME only needed if build type is "Debug", but CMAKE_BUILD_TYPE is
-# not set during configure time.
-INCLUDE(${CMAKE_SOURCE_DIR}/dbug/CMakeLists.txt)
-FOREACH(rpath ${DBUG_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../dbug/${rpath})
-ENDFOREACH(rpath)
-
-INCLUDE(${CMAKE_SOURCE_DIR}/extra/yassl/taocrypt/CMakeLists.txt)
-FOREACH(rpath ${TAOCRYPT_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../extra/yassl/taocrypt/${rpath})
-ENDFOREACH(rpath)
-
-INCLUDE(${CMAKE_SOURCE_DIR}/extra/yassl/CMakeLists.txt)
-FOREACH(rpath ${YASSL_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../extra/yassl/${rpath})
-ENDFOREACH(rpath)
-
-INCLUDE(${CMAKE_SOURCE_DIR}/strings/CMakeLists.txt)
-FOREACH(rpath ${STRINGS_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../strings/${rpath})
-ENDFOREACH(rpath)
-
-INCLUDE(${CMAKE_SOURCE_DIR}/regex/CMakeLists.txt)
-FOREACH(rpath ${REGEX_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../regex/${rpath})
-ENDFOREACH(rpath)
-
-INCLUDE(${CMAKE_SOURCE_DIR}/mysys/CMakeLists.txt)
-FOREACH(rpath ${MYSYS_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../mysys/${rpath})
-ENDFOREACH(rpath)
-
-INCLUDE(${CMAKE_SOURCE_DIR}/vio/CMakeLists.txt)
-FOREACH(rpath ${VIO_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ../vio/${rpath})
-ENDFOREACH(rpath)
-
-
-
-FOREACH (ENGINE_LIB ${MYSQLD_STATIC_ENGINE_LIBS})
- STRING(TOUPPER ${ENGINE_LIB} ENGINE_LIB_UPPER)
- SET(ENGINE_DIR ${${ENGINE_LIB_UPPER}_DIR})
- INCLUDE(${CMAKE_SOURCE_DIR}/storage/${ENGINE_DIR}/CMakeLists.txt)
- FOREACH(rpath ${${ENGINE_LIB_UPPER}_SOURCES})
- SET(LIB_SOURCES ${LIB_SOURCES} ${CMAKE_SOURCE_DIR}/storage/${ENGINE_DIR}/${rpath})
- ENDFOREACH(rpath)
-ENDFOREACH(ENGINE_LIB)
-
-
-SET(SOURCE_SUBLIBS FALSE)
SET(LIBMYSQLD_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
../libmysql/libmysql.c ../libmysql/errmsg.c ../client/get_password.c
@@ -133,29 +94,35 @@ SET(LIBMYSQLD_SOURCES emb_qcache.cc libmysqld.c lib_sql.cc
../sql/partition_info.cc ../sql/sql_connect.cc
../sql/scheduler.cc ../sql/event_parse_data.cc
../sql/sql_signal.cc ../sql/rpl_handler.cc
+ ${CMAKE_BINARY_DIR}/sql/sql_builtin.cc
${GEN_SOURCES}
- ${LIB_SOURCES})
-
-# Seems we cannot make a library without at least one source file. So use a
-# dummy empty file
-FILE(WRITE cmake_dummy.c " ")
-
-# Tried use the correct ${GEN_SOURCES} as dependency, worked on Unix
-# but not on Windows and Visual Studio generators. Likely because they
-# are no real targets from the Visual Studio project files view. Added
-# custom targets to "sql/CMakeLists.txt" and reference them here.
-ADD_LIBRARY(mysqlserver STATIC ${LIBMYSQLD_SOURCES})
-ADD_DEPENDENCIES(mysqlserver GenServerSource GenError)
-TARGET_LINK_LIBRARIES(mysqlserver)
-
-# Add any additional libraries requested by engine(s)
-FOREACH (ENGINE_LIB ${MYSQLD_STATIC_ENGINE_LIBS})
- STRING(TOUPPER ${ENGINE_LIB} ENGINE_LIB_UPPER)
- IF(${ENGINE_LIB_UPPER}_LIBS)
- TARGET_LINK_LIBRARIES(mysqlserver ${${ENGINE_LIB_UPPER}_LIBS})
- ENDIF(${ENGINE_LIB_UPPER}_LIBS)
-ENDFOREACH(ENGINE_LIB)
-
-ADD_LIBRARY(libmysqld SHARED cmake_dummy.c libmysqld.def)
-ADD_DEPENDENCIES(libmysqld mysqlserver)
-TARGET_LINK_LIBRARIES(libmysqld mysqlserver wsock32)
+ ${ENGINE_SOURCES}
+ ${MYSYS_LIBWRAP_SOURCE}
+)
+
+
+ADD_LIBRARY(mysqlserver_int STATIC ${LIBMYSQLD_SOURCES})
+ADD_DEPENDENCIES(mysqlserver_int GenError GenServerSource)
+
+# On Windows, static embedded server library is called mysqlserver.lib
+# On Unix, it is libmysqld.a
+IF(WIN32)
+ SET(MYSQLSERVER_OUTPUT_NAME mysqlserver)
+ELSE()
+ SET(MYSQLSERVER_OUTPUT_NAME mysqld)
+ENDIF()
+
+# Merge slim mysqlserver_int with other libraries like mysys to create a big
+# static library that contains everything.
+MERGE_STATIC_LIBS(mysqlserver ${MYSQLSERVER_OUTPUT_NAME}
+ "mysqlserver_int;${LIBS}")
+
+IF(LIBWRAP_LIBRARY)
+ TARGET_LINK_LIBRARIES(mysqlserver ${LIBWRAP_LIBRARY})
+ENDIF()
+INSTALL(TARGETS mysqlserver DESTINATION lib)
+
+IF(MSVC)
+ STATIC_TO_SHARED(mysqlserver libmysqld libmysqld.def)
+ INSTALL(TARGETS libmysqld DESTINATION lib)
+ENDIF()
diff --git a/libmysqld/examples/CMakeLists.txt b/libmysqld/examples/CMakeLists.txt
index e4b6533f8a2..400ddd8b729 100644
--- a/libmysqld/examples/CMakeLists.txt
+++ b/libmysqld/examples/CMakeLists.txt
@@ -15,24 +15,44 @@
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
${CMAKE_SOURCE_DIR}/libmysqld/include
- ${CMAKE_SOURCE_DIR}/regex
- ${CMAKE_SOURCE_DIR}/zlib
- ${CMAKE_SOURCE_DIR}/extra/yassl/include)
+ ${CMAKE_SOURCE_DIR}/regex
+ ${READLINE_INCLUDE_DIR}
+ )
-# Currently does not work with DBUG, there are missing symbols reported.
-ADD_DEFINITIONS(-DEMBEDDED_LIBRARY)
+ADD_DEFINITIONS(-DEMBEDDED_LIBRARY -UMYSQL_CLIENT)
+
ADD_EXECUTABLE(mysql_embedded ../../client/completion_hash.cc
- ../../client/mysql.cc ../../client/readline.cc
- ../../client/sql_string.cc)
-TARGET_LINK_LIBRARIES(mysql_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32)
-TARGET_LINK_LIBRARIES(mysql_embedded libmysqld)
+ ../../client/mysql.cc ../../client/readline.cc)
+TARGET_LINK_LIBRARIES(mysql_embedded mysqlserver)
+IF(UNIX)
+ ADD_DEFINITIONS(${READLINE_DEFINES})
+ TARGET_LINK_LIBRARIES(mysql_embedded ${READLINE_LIBRARY})
+ENDIF(UNIX)
ADD_EXECUTABLE(mysqltest_embedded ../../client/mysqltest.cc)
-TARGET_LINK_LIBRARIES(mysqltest_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32)
-TARGET_LINK_LIBRARIES(mysqltest_embedded libmysqld)
+TARGET_LINK_LIBRARIES(mysqltest_embedded mysqlserver)
+
+
+IF(CMAKE_GENERATOR MATCHES "Xcode")
+# It does not seem possible to tell Xcode the resulting target might need
+# to be linked with C++ runtime. The project needs to have at least one C++
+# file. Add a dummy one.
+ MYSQL_CREATE_EMPTY_FILE(mysql_client_test_embedded_dummy.cc)
+ ADD_EXECUTABLE(mysql_client_test_embedded
+ mysql_client_test_embedded_dummy.cc
+ ../../tests/mysql_client_test.c)
+ELSE()
+ ADD_EXECUTABLE(mysql_client_test_embedded ../../tests/mysql_client_test.c)
+ SET_TARGET_PROPERTIES(mysql_client_test_embedded PROPERTIES HAS_CXX TRUE)
+ENDIF()
+TARGET_LINK_LIBRARIES(mysql_client_test_embedded mysqlserver)
+
+IF(UNIX)
+SET_TARGET_PROPERTIES(mysql_embedded PROPERTIES ENABLE_EXPORTS TRUE)
+SET_TARGET_PROPERTIES(mysqltest_embedded PROPERTIES ENABLE_EXPORTS TRUE)
+SET_TARGET_PROPERTIES(mysql_client_test_embedded PROPERTIES ENABLE_EXPORTS TRUE)
+ENDIF()
-ADD_EXECUTABLE(mysql_client_test_embedded ../../tests/mysql_client_test.c)
-TARGET_LINK_LIBRARIES(mysql_client_test_embedded debug dbug strings mysys vio yassl taocrypt regex ws2_32)
-TARGET_LINK_LIBRARIES(mysql_client_test_embedded libmysqld)
+INSTALL(TARGETS mysql_embedded mysqltest_embedded mysql_client_test_embedded DESTINATION bin)
diff --git a/libmysqld/lib_sql.cc b/libmysqld/lib_sql.cc
index 1a078d0d0c6..92b64d98fa0 100644
--- a/libmysqld/lib_sql.cc
+++ b/libmysqld/lib_sql.cc
@@ -731,11 +731,6 @@ void THD::clear_data_list()
cur_data= 0;
}
-void THD::clear_error()
-{
- if (stmt_da->is_error())
- stmt_da->reset_diagnostics_area();
-}
static char *dup_str_aux(MEM_ROOT *root, const char *from, uint length,
CHARSET_INFO *fromcs, CHARSET_INFO *tocs)
diff --git a/man/CMakeLists.txt b/man/CMakeLists.txt
new file mode 100644
index 00000000000..35da3411805
--- /dev/null
+++ b/man/CMakeLists.txt
@@ -0,0 +1,24 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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
+
+# Copy man pages
+FILE(GLOB MAN1_FILES *.1)
+FILE(GLOB MAN8_FILES *.8)
+IF(MAN1_FILES)
+ INSTALL(FILES ${MAN1_FILES} DESTINATION man/man1)
+ENDIF()
+IF(MAN8_FILES)
+ INSTALL(FILES ${MAN8_FILES} DESTINATION man/man8)
+ENDIF()
diff --git a/man/Makefile.am b/man/Makefile.am
index 72e67f7445f..8ccada67828 100644
--- a/man/Makefile.am
+++ b/man/Makefile.am
@@ -19,7 +19,7 @@
man1_MANS = @man1_files@
man8_MANS = @man8_files@
-EXTRA_DIST = $(man1_MANS) $(man8_MANS)
+EXTRA_DIST = $(man1_MANS) $(man8_MANS) CMakeLists.txt
# "make_win_*" are not needed in Unix binary packages,
install-data-hook:
diff --git a/mysql-test/CMakeLists.txt b/mysql-test/CMakeLists.txt
new file mode 100644
index 00000000000..b3afa4f8f98
--- /dev/null
+++ b/mysql-test/CMakeLists.txt
@@ -0,0 +1,110 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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
+
+INSTALL(
+ DIRECTORY .
+ DESTINATION mysql-test
+ PATTERN "var/" EXCLUDE
+ PATTERN "lib/My/SafeProcess" EXCLUDE
+ PATTERN "CPack" EXCLUDE
+ PATTERN "CMake" EXCLUDE
+ PATTERN "mtr.out" EXCLUDE
+ PATTERN ".cvsignore" EXCLUDE
+)
+
+
+
+IF(NOT ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR})
+ # Enable running mtr from build directory
+ CONFIGURE_FILE(
+ ${CMAKE_CURRENT_SOURCE_DIR}/mtr.out-of-source
+ ${CMAKE_CURRENT_BINARY_DIR}/mysql-test-run.pl
+ @ONLY
+ )
+ENDIF()
+IF(UNIX)
+ EXECUTE_PROCESS(
+ COMMAND chmod +x mysql-test-run.pl
+ COMMAND ${CMAKE_COMMAND} -E create_symlink
+ ./mysql-test-run.pl mtr
+ COMMAND ${CMAKE_COMMAND} -E create_symlink
+ ./mysql-test-run.pl mysql-test-run
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ )
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mtr
+ ${CMAKE_CURRENT_BINARY_DIR}/mysql-test-run DESTINATION mysql-test)
+ENDIF()
+
+IF(CMAKE_GENERATOR MATCHES "Visual Studio")
+ SET(SETCONFIG_COMMAND set MTR_VS_CONFIG=$(OutDir))
+ELSEIF(CMAKE_GENERATOR MATCHES "Xcode")
+ SET(SETCONFIG_COMMAND export MTR_VS_CONFIG=$(CONFIGURATION))
+ELSE()
+ SET(SETCONFIG_COMMAND echo Running tests)
+ENDIF()
+IF(CYGWIN)
+ # On cygwin, pretend to be "Unix" system
+ SET(SETOS_COMMAND export MTR_CYGWIN_IS_UNIX=1)
+ELSE()
+ SET(SETOS_COMMAND echo OS=${CMAKE_SYSTEM_NAME})
+ENDIF()
+
+
+ADD_CUSTOM_TARGET(test-force
+ COMMAND ${SETCONFIG_COMMAND}
+ COMMAND ${SETOS_COMMAND}
+ COMMAND perl mysql-test-run.pl --force
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+)
+
+SET(EXP --experimental=collections/default.experimental)
+IF(WIN32)
+ SET(SET_ENV set)
+ELSE()
+ SET(SET_ENV export)
+ENDIF()
+
+
+SET(MTR_FORCE perl ./mysql-test-run.pl --force)
+IF(EXISTS ${CMAKE_SOURCE_DIR}/mysql-test/suite/nist)
+ SET(TEST_NIST ${MTR_FORCE} --comment=nist suite=nist ${EXP} &&
+ ${MTR_FORCE} --comment=nist --force --suite=nist+ps ${EXP})
+ELSE()
+ SET(TEST_NIST echo "NIST tests not found")
+ENDIF()
+
+IF(WITH_EMBEDDED_SERVER)
+ SET(TEST_EMBEDDED ${MTR_FORCE} --comment=embedded --timer --embedded-server
+ --skip-rpl --skip-ndbcluster $(EXP))
+ELSE()
+ SET(TEST_EMBEDDED echo "Can not test embedded, not compiled in")
+ENDIF()
+
+ADD_CUSTOM_TARGET(test-bt
+ COMMAND ${SETCONFIG_COMMAND}
+ COMMAND ${SETOS_COMMAND}
+ COMMAND ${SET_ENV} MTR_BUILD_THREAD=auto
+ COMMAND ${MTR_FORCE} --comment=normal --timer --skip-ndbcluster --report-features ${EXP}
+ COMMAND ${MTR_FORCE} --comment=ps --timer --skip-ndbcluster --ps-protocol ${EXP}
+ COMMAND ${MTR_FORCE} --comment=funcs1+ps --ps-protocol --reorder --suite=funcs_1 ${EXP}
+ COMMAND ${MTR_FORCE} --comment=funcs2 --suite=funcs_2 ${EXP}
+ COMMAND ${MTR_FORCE} --comment=partitions --suite=parts ${EXP}
+ COMMAND ${MTR_FORCE} --comment=stress --suite=stress ${EXP}
+ COMMAND ${MTR_FORCE} --force --comment=jp --suite=jp ${EXP}
+ COMMAND ${TEST_NIST}
+ COMMAND ${TEST_EMBEDDED}
+)
+
+
diff --git a/mysql-test/Makefile.am b/mysql-test/Makefile.am
index b1d0e85c70e..a040688596f 100644
--- a/mysql-test/Makefile.am
+++ b/mysql-test/Makefile.am
@@ -71,7 +71,10 @@ SUBDIRS = lib/My/SafeProcess
EXTRA_DIST = README \
$(test_SCRIPTS) \
- $(nobase_test_DATA)
+ $(nobase_test_DATA) \
+ CMakeLists.txt \
+ mtr.out-of-source
+
# List of directories containing test + result files and the
# related test data files that should be copied
diff --git a/mysql-test/lib/My/ConfigFactory.pm b/mysql-test/lib/My/ConfigFactory.pm
index 505f93f1fec..1d2c606a6f7 100644
--- a/mysql-test/lib/My/ConfigFactory.pm
+++ b/mysql-test/lib/My/ConfigFactory.pm
@@ -29,6 +29,15 @@ sub get_basedir {
return $basedir;
}
+# Retrive build directory (which is different from basedir in out-of-source build)
+sub get_bindir {
+ if (defined $ENV{MTR_BINDIR})
+ {
+ return $ENV{MTR_BINDIR};
+ }
+ my ($self, $group)= @_;
+ return $self->get_basedir($group);
+}
sub fix_charset_dir {
my ($self, $config, $group_name, $group)= @_;
@@ -38,7 +47,7 @@ sub fix_charset_dir {
sub fix_language {
my ($self, $config, $group_name, $group)= @_;
- return my_find_dir($self->get_basedir($group),
+ return my_find_dir($self->get_bindir($group),
\@share_locations);
}
diff --git a/mysql-test/lib/My/Find.pm b/mysql-test/lib/My/Find.pm
index 8557584bbc8..b2fec0d77b8 100644
--- a/mysql-test/lib/My/Find.pm
+++ b/mysql-test/lib/My/Find.pm
@@ -167,16 +167,16 @@ sub my_find_paths {
}
# -------------------------------------------------------
- # Windows specific
- # -------------------------------------------------------
- if (IS_WINDOWS) {
- # Add the default extra build dirs unless a specific one has
- # already been selected
- push(@extra_dirs,
- ("release",
- "relwithdebinfo",
- "debug")) if @extra_dirs == 0;
- }
+ # CMake generator specific (Visual Studio and Xcode have multimode builds)
+ # -------------------------------------------------------
+
+ # Add the default extra build dirs unless a specific one has
+ # already been selected
+ push(@extra_dirs,
+ ("Release",
+ "Relwithdebinfo",
+ "Debug")) if @extra_dirs == 0;
+
#print "extra_build_dir: @extra_dirs\n";
diff --git a/mysql-test/lib/My/SafeProcess.pm b/mysql-test/lib/My/SafeProcess.pm
index 7e102b628ca..0fac25b814b 100644
--- a/mysql-test/lib/My/SafeProcess.pm
+++ b/mysql-test/lib/My/SafeProcess.pm
@@ -84,19 +84,31 @@ sub is_child {
# Find the safe process binary or script
my @safe_process_cmd;
my $safe_kill;
+my $bindir;
+if(defined $ENV{MTR_BINDIR})
+{
+ # This is an out-of-source build. Build directory
+ # is given in MTR_BINDIR env.variable
+ $bindir = $ENV{MTR_BINDIR}."/mysql-test";
+}
+else
+{
+ $bindir = ".";
+}
+
if (IS_WIN32PERL or IS_CYGWIN){
# Use my_safe_process.exe
- my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
+ my $exe= my_find_bin($bindir, ["lib/My/SafeProcess", "My/SafeProcess"],
"my_safe_process");
push(@safe_process_cmd, $exe);
# Use my_safe_kill.exe
- $safe_kill= my_find_bin(".", "lib/My/SafeProcess", "my_safe_kill");
+ $safe_kill= my_find_bin($bindir, "lib/My/SafeProcess", "my_safe_kill");
}
else
{
# Use my_safe_process
- my $exe= my_find_bin(".", ["lib/My/SafeProcess", "My/SafeProcess"],
+ my $exe= my_find_bin($bindir, ["lib/My/SafeProcess", "My/SafeProcess"],
"my_safe_process");
push(@safe_process_cmd, $exe);
}
diff --git a/mysql-test/lib/My/SafeProcess/CMakeLists.txt b/mysql-test/lib/My/SafeProcess/CMakeLists.txt
index 97fab820f95..d22d4fddddf 100644
--- a/mysql-test/lib/My/SafeProcess/CMakeLists.txt
+++ b/mysql-test/lib/My/SafeProcess/CMakeLists.txt
@@ -13,5 +13,15 @@
# 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(my_safe_process safe_process_win.cc)
-ADD_EXECUTABLE(my_safe_kill safe_kill_win.cc)
+IF (WIN32)
+ ADD_EXECUTABLE(my_safe_process safe_process_win.cc)
+ ADD_EXECUTABLE(my_safe_kill safe_kill_win.cc)
+ELSE()
+ ADD_EXECUTABLE(my_safe_process safe_process.cc)
+ENDIF()
+
+INSTALL(TARGETS my_safe_process DESTINATION "mysql-test/lib/My/SafeProcess")
+IF(WIN32)
+ INSTALL(TARGETS my_safe_kill DESTINATION "mysql-test/lib/My/SafeProcess")
+ENDIF()
+INSTALL(FILES safe_process.pl Base.pm DESTINATION "mysql-test/lib/My/SafeProcess")
diff --git a/mysql-test/lib/My/SafeProcess/safe_kill_win.cc b/mysql-test/lib/My/SafeProcess/safe_kill_win.cc
index 963a02c8099..f72b851d0b6 100755
--- a/mysql-test/lib/My/SafeProcess/safe_kill_win.cc
+++ b/mysql-test/lib/My/SafeProcess/safe_kill_win.cc
@@ -24,6 +24,7 @@
#include <windows.h>
#include <stdio.h>
#include <signal.h>
+#include <stdlib.h>
int main(int argc, const char** argv )
{
diff --git a/mysql-test/lib/My/SafeProcess/safe_process_win.cc b/mysql-test/lib/My/SafeProcess/safe_process_win.cc
index 455262b29f5..ce5deb4d82a 100755
--- a/mysql-test/lib/My/SafeProcess/safe_process_win.cc
+++ b/mysql-test/lib/My/SafeProcess/safe_process_win.cc
@@ -57,6 +57,7 @@
#include <stdio.h>
#include <tlhelp32.h>
#include <signal.h>
+#include <stdlib.h>
static int verbose= 0;
static char safe_process_name[32]= {0};
@@ -248,6 +249,10 @@ int main(int argc, const char** argv )
Make all processes associated with the job terminate when the
last handle to the job is closed.
*/
+#ifndef JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE
+#define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x00002000
+#endif
+
jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE;
if (SetInformationJobObject(job_handle, JobObjectExtendedLimitInformation,
&jeli, sizeof(jeli)) == 0)
diff --git a/mysql-test/mtr.out-of-source b/mysql-test/mtr.out-of-source
new file mode 100644
index 00000000000..c2809ede136
--- /dev/null
+++ b/mysql-test/mtr.out-of-source
@@ -0,0 +1,5 @@
+#!/usr/bin/perl
+# Call mtr in out-of-source build
+$ENV{MTR_BINDIR} = "@CMAKE_BINARY_DIR@";
+chdir("@CMAKE_SOURCE_DIR@/mysql-test");
+exit(system($^X, "@CMAKE_SOURCE_DIR@/mysql-test/mysql-test-run.pl", @ARGV) >> 8); \ No newline at end of file
diff --git a/mysql-test/mysql-test-run.pl b/mysql-test/mysql-test-run.pl
index f76cb008c3c..9a9fa85aa79 100755
--- a/mysql-test/mysql-test-run.pl
+++ b/mysql-test/mysql-test-run.pl
@@ -94,6 +94,7 @@ $SIG{INT}= sub { mtr_error("Got ^C signal"); };
our $mysql_version_id;
our $glob_mysql_test_dir;
our $basedir;
+our $bindir;
our $path_charsetsdir;
our $path_client_bindir;
@@ -943,7 +944,11 @@ sub command_line_setup {
{
$basedir= dirname($basedir);
}
-
+
+ # Respect MTR_BINDIR variable, which is typically set in to the
+ # build directory in out-of-source builds.
+ $bindir=$ENV{MTR_BINDIR}||$basedir;
+
# Look for the client binaries directory
if ($path_client_bindir)
{
@@ -952,21 +957,21 @@ sub command_line_setup {
}
else
{
- $path_client_bindir= mtr_path_exists("$basedir/client_release",
- "$basedir/client_debug",
+ $path_client_bindir= mtr_path_exists("$bindir/client_release",
+ "$bindir/client_debug",
vs_config_dirs('client', ''),
- "$basedir/client",
- "$basedir/bin");
+ "$bindir/client",
+ "$bindir/bin");
}
# Look for language files and charsetsdir, use same share
- $path_language= mtr_path_exists("$basedir/share/mysql",
- "$basedir/sql/share",
- "$basedir/share");
-
-
+ $path_language= mtr_path_exists("$bindir/share/mysql",
+ "$bindir/sql/share",
+ "$bindir/share");
my $path_share= $path_language;
- $path_charsetsdir= mtr_path_exists("$path_share/charsets");
+ $path_charsetsdir = mtr_path_exists("$basedir/share/mysql/charsets",
+ "$basedir/sql/share/charsets",
+ "$basedir/share/charsets");
if (using_extern())
{
@@ -1104,7 +1109,14 @@ sub command_line_setup {
# --------------------------------------------------------------------------
# Set the "var/" directory, the base for everything else
# --------------------------------------------------------------------------
- $default_vardir= "$glob_mysql_test_dir/var";
+ if(defined $ENV{MTR_BINDIR})
+ {
+ $default_vardir= "$ENV{MTR_BINDIR}/mysql-test/var";
+ }
+ else
+ {
+ $default_vardir= "$glob_mysql_test_dir/var";
+ }
if ( ! $opt_vardir )
{
$opt_vardir= $default_vardir;
@@ -1558,7 +1570,8 @@ sub collect_mysqld_features_from_running_server ()
}
sub find_mysqld {
- my ($mysqld_basedir)= @_;
+
+ my ($mysqld_basedir)= $ENV{MTR_BINDIR}|| @_;
my @mysqld_names= ("mysqld", "mysqld-max-nt", "mysqld-max",
"mysqld-nt");
@@ -1644,7 +1657,7 @@ sub client_debug_arg($$) {
sub mysql_fix_arguments () {
- return "" if ( IS_WINDOWS );
+ return "" ;
my $exe=
mtr_script_exists("$basedir/scripts/mysql_fix_privilege_tables",
@@ -1744,6 +1757,30 @@ sub mysql_client_test_arguments(){
# Set environment to be used by childs of this process for
# things that are constant during the whole lifetime of mysql-test-run
#
+
+sub find_plugin($$)
+{
+ my ($plugin, $location) = @_;
+ my $plugin_filename;
+
+ if (IS_WINDOWS)
+ {
+ $plugin_filename = $plugin.".dll";
+ }
+ else
+ {
+ $plugin_filename = $plugin.".so";
+ }
+
+ my $lib_example_plugin=
+ mtr_file_exists(vs_config_dirs($location,$plugin_filename),
+ "$basedir/lib/plugin/".$plugin_filename,
+ "$basedir/$location/.libs/".$plugin_filename,
+ "$basedir/lib/mysql/plugin/".$plugin_filename,
+ );
+ return $lib_example_plugin;
+}
+
sub environment_setup {
umask(022);
@@ -1782,9 +1819,18 @@ sub environment_setup {
# --------------------------------------------------------------------------
# Add the path where mysqld will find udf_example.so
# --------------------------------------------------------------------------
+ my $udf_example_filename;
+ if (IS_WINDOWS)
+ {
+ $udf_example_filename = "udf_example.dll";
+ }
+ else
+ {
+ $udf_example_filename = "udf_example.so";
+ }
my $lib_udf_example=
- mtr_file_exists(vs_config_dirs('sql', 'udf_example.dll'),
- "$basedir/sql/.libs/udf_example.so",);
+ mtr_file_exists(vs_config_dirs('sql', $udf_example_filename),
+ "$basedir/sql/.libs/$udf_example_filename",);
if ( $lib_udf_example )
{
@@ -1800,60 +1846,46 @@ sub environment_setup {
# Add the path where mysqld will find ha_example.so
# --------------------------------------------------------------------------
if ($mysql_version_id >= 50100) {
- my $plugin_filename;
- if (IS_WINDOWS)
- {
- $plugin_filename = "ha_example.dll";
+ my ($lib_example_plugin) = find_plugin("ha_example", "storage/example");
+
+ if($lib_example_plugin)
+ {
+ $ENV{'EXAMPLE_PLUGIN'}=
+ ($lib_example_plugin ? basename($lib_example_plugin) : "");
+ $ENV{'EXAMPLE_PLUGIN_OPT'}= "--plugin-dir=".
+ ($lib_example_plugin ? dirname($lib_example_plugin) : "");
+
+ $ENV{'HA_EXAMPLE_SO'}="'".basename($lib_example_plugin)."'";
+ $ENV{'EXAMPLE_PLUGIN_LOAD'}="--plugin_load=EXAMPLE=".basename($lib_example_plugin);
}
- else
+ else
{
- $plugin_filename = "ha_example.so";
+ # Some ".opt" files use some of these variables, so they must be defined
+ $ENV{'EXAMPLE_PLUGIN'}= "";
+ $ENV{'EXAMPLE_PLUGIN_OPT'}= "";
+ $ENV{'HA_EXAMPLE_SO'}= "";
+ $ENV{'EXAMPLE_PLUGIN_LOAD'}= "";
}
- my $lib_example_plugin=
- mtr_file_exists(vs_config_dirs('storage/example',$plugin_filename),
- "$basedir/storage/example/.libs/".$plugin_filename,
- "$basedir/lib/mysql/plugin/".$plugin_filename);
- $ENV{'EXAMPLE_PLUGIN'}=
- ($lib_example_plugin ? basename($lib_example_plugin) : "");
- $ENV{'EXAMPLE_PLUGIN_OPT'}= "--plugin-dir=".
- ($lib_example_plugin ? dirname($lib_example_plugin) : "");
-
- $ENV{'HA_EXAMPLE_SO'}="'".$plugin_filename."'";
- $ENV{'EXAMPLE_PLUGIN_LOAD'}="--plugin_load=EXAMPLE=".$plugin_filename;
- }
- else
- {
- # Some ".opt" files use some of these variables, so they must be defined
- $ENV{'EXAMPLE_PLUGIN'}= "";
- $ENV{'EXAMPLE_PLUGIN_OPT'}= "";
- $ENV{'HA_EXAMPLE_SO'}= "";
- $ENV{'EXAMPLE_PLUGIN_LOAD'}= "";
}
+
# --------------------------------------------------------------------------
# Add the path where mysqld will find semisync plugins
# --------------------------------------------------------------------------
if (!$opt_embedded_server) {
- my $semisync_master_filename;
- my $semisync_slave_filename;
+ my $semisync_lib_prefix;
if (IS_WINDOWS)
{
- $semisync_master_filename = "semisync_master.dll";
- $semisync_slave_filename = "semisync_slave.dll";
+ $semisync_lib_prefix = "";
}
else
{
- $semisync_master_filename = "libsemisync_master.so";
- $semisync_slave_filename = "libsemisync_slave.so";
+ $semisync_lib_prefix= "lib";
}
- my $lib_semisync_master_plugin=
- mtr_file_exists(vs_config_dirs('plugin/semisync',$semisync_master_filename),
- "$basedir/plugin/semisync/.libs/" . $semisync_master_filename,
- "$basedir/lib/mysql/plugin/" . $semisync_master_filename);
- my $lib_semisync_slave_plugin=
- mtr_file_exists(vs_config_dirs('plugin/semisync',$semisync_slave_filename),
- "$basedir/plugin/semisync/.libs/" . $semisync_slave_filename,
- "$basedir/lib/mysql/plugin/" . $semisync_slave_filename);
+
+ my ($lib_semisync_master_plugin) = find_plugin($semisync_lib_prefix."semisync_master", "plugin/semisync");
+ my ($lib_semisync_slave_plugin) = find_plugin($semisync_lib_prefix."semisync_slave", "plugin/semisync");
+
if ($lib_semisync_master_plugin && $lib_semisync_slave_plugin)
{
$ENV{'SEMISYNC_MASTER_PLUGIN'}= basename($lib_semisync_master_plugin);
@@ -1871,10 +1903,10 @@ sub environment_setup {
# ----------------------------------------------------
# Add the path where mysqld will find mypluglib.so
# ----------------------------------------------------
- my $lib_simple_parser=
- mtr_file_exists(vs_config_dirs('plugin/fulltext', 'mypluglib.dll'),
- "$basedir/plugin/fulltext/.libs/mypluglib.so",);
+ my ($lib_simple_parser) = find_plugin("mypluglib", "plugin/fulltext");
+
+ $ENV{'MYPLUGLIB_SO'}="'".basename($lib_simple_parser)."'";
$ENV{'SIMPLE_PARSER'}=
($lib_simple_parser ? basename($lib_simple_parser) : "");
$ENV{'SIMPLE_PARSER_OPT'}= "--plugin-dir=".
@@ -2303,18 +2335,15 @@ sub vs_config_dirs ($$) {
my ($path_part, $exe) = @_;
$exe = "" if not defined $exe;
-
- # Don't look in these dirs when not on windows
- return () unless IS_WINDOWS;
-
if ($opt_vs_config)
{
- return ("$basedir/$path_part/$opt_vs_config/$exe");
+ return ("$bindir/$path_part/$opt_vs_config/$exe");
}
- return ("$basedir/$path_part/release/$exe",
- "$basedir/$path_part/relwithdebinfo/$exe",
- "$basedir/$path_part/debug/$exe");
+ return ("$bindir/$path_part/Release/$exe",
+ "$bindir/$path_part/RelWithDebinfo/$exe",
+ "$bindir/$path_part/Debug/$exe",
+ "$bindir/$path_part/$exe");
}
diff --git a/mysql-test/t/fulltext_plugin.test b/mysql-test/t/fulltext_plugin.test
index 31978dadc51..25e4302ef0d 100644
--- a/mysql-test/t/fulltext_plugin.test
+++ b/mysql-test/t/fulltext_plugin.test
@@ -3,7 +3,8 @@
#
# BUG#39746 - Debug flag breaks struct definition (server crash)
#
-INSTALL PLUGIN simple_parser SONAME 'mypluglib.so';
+--replace_regex /\.dll/.so/
+eval INSTALL PLUGIN simple_parser SONAME $MYPLUGLIB_SO;
CREATE TABLE t1(a TEXT, b TEXT, FULLTEXT(a) WITH PARSER simple_parser);
ALTER TABLE t1 ADD FULLTEXT(b) WITH PARSER simple_parser;
DROP TABLE t1;
diff --git a/mysys/CMakeLists.txt b/mysys/CMakeLists.txt
index 21b04e7c968..5c0cebf5938 100755
--- a/mysys/CMakeLists.txt
+++ b/mysys/CMakeLists.txt
@@ -13,15 +13,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-# Only the server link with this library, the client libraries and the client
-# executables all link with recompiles of source found in the "mysys" directory.
-# So we only need to create one version of this library, with the "static"
-# Thread Local Storage model.
-#
-# Exception is the embedded server that needs this library compiled with
-# dynamic TLS, i.e. define USE_TLS
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/zlib ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys)
+
+INCLUDE_DIRECTORIES(${ZLIB_INCLUDE_DIR} ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/mysys)
SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_modify.c
errors.c hash.c list.c md5.c mf_brkhant.c mf_cache.c mf_dirname.c mf_fn_ext.c
@@ -30,17 +24,39 @@ SET(MYSYS_SOURCES array.c charset-def.c charset.c checksum.c default.c default_
mf_radix.c mf_same.c mf_sort.c mf_soundex.c mf_arr_appstr.c mf_tempdir.c
mf_tempfile.c mf_unixpath.c mf_wcomp.c mf_wfile.c mulalloc.c my_access.c
my_aes.c my_alarm.c my_alloc.c my_append.c my_bit.c my_bitmap.c my_chsize.c
- my_clock.c my_compress.c my_conio.c my_copy.c my_crc32.c my_create.c my_delete.c
+ my_clock.c my_compress.c my_copy.c my_crc32.c my_create.c my_delete.c
my_div.c my_error.c my_file.c my_fopen.c my_fstream.c my_gethostbyname.c
my_gethwaddr.c my_getopt.c my_getsystime.c my_getwd.c my_handler.c my_init.c
my_lib.c my_lock.c my_lockmem.c my_malloc.c my_messnc.c
my_mkdir.c my_mmap.c my_net.c my_once.c my_open.c my_pread.c my_pthread.c
my_quick.c my_read.c my_realloc.c my_redel.c my_rename.c my_seek.c my_sleep.c
- my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c my_wincond.c
- my_winerr.c my_winfile.c my_windac.c my_winthread.c my_write.c ptr_cmp.c queues.c stacktrace.c
+ my_static.c my_symlink.c my_symlink2.c my_sync.c my_thr_init.c
+ my_write.c ptr_cmp.c queues.c stacktrace.c
rijndael.c safemalloc.c sha1.c string.c thr_alarm.c thr_lock.c thr_mutex.c
thr_rwlock.c tree.c typelib.c my_vle.c base64.c my_memmem.c my_getpagesize.c)
-IF(NOT SOURCE_SUBLIBS)
- ADD_LIBRARY(mysys ${MYSYS_SOURCES})
-ENDIF(NOT SOURCE_SUBLIBS)
+IF (WIN32)
+ SET (MYSYS_SOURCES ${MYSYS_SOURCES} my_winthread.c my_wincond.c my_winerr.c my_winfile.c my_windac.c my_conio.c)
+ENDIF()
+
+IF(CMAKE_COMPILER_IS_GNUCC AND NOT HAVE_CXX_NEW)
+ # gcc as C++ compiler does not have new/delete
+ SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_new.cc)
+ ADD_DEFINITIONS( -DUSE_MYSYS_NEW)
+ENDIF()
+
+IF(HAVE_LARGE_PAGES)
+ SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_largepage.c)
+ENDIF()
+
+IF(UNIX)
+ # some workarounds
+ SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_port.c)
+ # Some stuff not ported to windows
+ SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_atomic.c)
+ SET(MYSYS_SOURCES ${MYSYS_SOURCES} my_getncpus.c)
+ENDIF()
+USE_ABSOLUTE_FILENAMES(MYSYS_SOURCES)
+ADD_LIBRARY(mysys ${MYSYS_SOURCES})
+TARGET_LINK_LIBRARIES(mysys dbug strings ${ZLIB_LIBRARY})
+DTRACE_INSTRUMENT(mysys)
diff --git a/mysys/my_create.c b/mysys/my_create.c
index d0436276d03..49529f9b7b5 100644
--- a/mysys/my_create.c
+++ b/mysys/my_create.c
@@ -39,14 +39,11 @@ File my_create(const char *FileName, int CreateFlags, int access_flags,
DBUG_ENTER("my_create");
DBUG_PRINT("my",("Name: '%s' CreateFlags: %d AccessFlags: %d MyFlags: %d",
FileName, CreateFlags, access_flags, MyFlags));
-
-#if !defined(NO_OPEN_3)
- fd= open((char *) FileName, access_flags | O_CREAT,
- CreateFlags ? CreateFlags : my_umask);
-#elif defined(_WIN32)
+#if defined(_WIN32)
fd= my_win_open(FileName, access_flags | O_CREAT);
#else
- fd= open(FileName, access_flags);
+ fd= open((char *) FileName, access_flags | O_CREAT,
+ CreateFlags ? CreateFlags : my_umask);
#endif
if ((MyFlags & MY_SYNC_DIR) && (fd >=0) &&
diff --git a/mysys/my_getsystime.c b/mysys/my_getsystime.c
index b692b18bfc7..b9f385d83a9 100644
--- a/mysys/my_getsystime.c
+++ b/mysys/my_getsystime.c
@@ -150,7 +150,10 @@ ulonglong my_micro_time()
Value in microseconds from some undefined point in time
*/
-#define DELTA_FOR_SECONDS LL(500000000) /* Half a second */
+#define DELTA_FOR_SECONDS 500000000LL /* Half a second */
+
+/* Difference between GetSystemTimeAsFileTime() and now() */
+#define OFFSET_TO_EPOCH 116444736000000000ULL
ulonglong my_micro_time_and_time(time_t *time_arg)
{
diff --git a/mysys/my_winthread.c b/mysys/my_winthread.c
index 9e8458b0799..35715832fc6 100644
--- a/mysys/my_winthread.c
+++ b/mysys/my_winthread.c
@@ -129,4 +129,22 @@ error_return:
return -1;
}
+int pthread_cancel(pthread_t thread)
+{
+
+ HANDLE handle= 0;
+ BOOL ok= FALSE;
+
+ handle= OpenThread(THREAD_TERMINATE, FALSE, thread);
+ if (handle)
+ {
+ ok= TerminateThread(handle,0);
+ CloseHandle(handle);
+ }
+ if (ok)
+ return 0;
+
+ errno= EINVAL;
+ return -1;
+}
#endif
diff --git a/mysys/mysys_priv.h b/mysys/mysys_priv.h
index 4c4d6ea3598..8f125a2320e 100644
--- a/mysys/mysys_priv.h
+++ b/mysys/mysys_priv.h
@@ -44,6 +44,7 @@ extern pthread_mutex_t THR_LOCK_charset, THR_LOCK_time;
void my_error_unregister_all(void);
#ifdef _WIN32
+#include <sys/stat.h>
/* my_winfile.c exports, should not be used outside mysys */
extern File my_win_open(const char *path, int oflag);
extern int my_win_close(File fd);
@@ -59,8 +60,8 @@ extern FILE* my_win_fopen(const char *filename, const char *type);
extern File my_win_fclose(FILE *file);
extern File my_win_fileno(FILE *file);
extern FILE* my_win_fdopen(File Filedes, const char *type);
-extern int my_win_stat(const char *path, struct _stat64 *buf);
-extern int my_win_fstat(File fd, struct _stat64 *buf);
+extern int my_win_stat(const char *path, struct _stati64 *buf);
+extern int my_win_fstat(File fd, struct _stati64 *buf);
extern int my_win_fsync(File fd);
extern File my_win_dup(File fd);
extern File my_win_sopen(const char *path, int oflag, int shflag, int perm);
diff --git a/plugin/daemon_example/CMakeLists.txt b/plugin/daemon_example/CMakeLists.txt
new file mode 100644
index 00000000000..97ada05f935
--- /dev/null
+++ b/plugin/daemon_example/CMakeLists.txt
@@ -0,0 +1,18 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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(DAEMON_EXAMPLE_PLUGIN_DYNAMIC daemon_example)
+SET(DAEMON_EXAMPLE_SOURCES daemon_example.cc)
+MYSQL_PLUGIN(DAEMON_EXAMPLE)
diff --git a/plugin/daemon_example/Makefile.am b/plugin/daemon_example/Makefile.am
index fce67285a5f..d1f2555594c 100644
--- a/plugin/daemon_example/Makefile.am
+++ b/plugin/daemon_example/Makefile.am
@@ -38,6 +38,7 @@ noinst_LIBRARIES = @plugin_daemon_example_static_target@
libdaemon_example_a_CXXFLAGS = $(AM_CFLAGS)
libdaemon_example_a_CFLAGS = $(AM_CFLAGS)
libdaemon_example_a_SOURCES= daemon_example.cc
+EXTRA_DIST = CMakeLists.txt
# Don't update the files from bitkeeper
%::SCCS/s.%
diff --git a/plugin/fulltext/CMakeLists.txt b/plugin/fulltext/CMakeLists.txt
new file mode 100644
index 00000000000..e0dd2ac510c
--- /dev/null
+++ b/plugin/fulltext/CMakeLists.txt
@@ -0,0 +1,18 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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(FTEXAMPLE_PLUGIN_DYNAMIC mypluglib)
+SET(FTEXAMPLE_SOURCES plugin_example.c)
+MYSQL_PLUGIN(FTEXAMPLE)
diff --git a/plugin/fulltext/Makefile.am b/plugin/fulltext/Makefile.am
index 343416072dd..0747e6d0193 100644
--- a/plugin/fulltext/Makefile.am
+++ b/plugin/fulltext/Makefile.am
@@ -22,6 +22,7 @@ pkgplugin_LTLIBRARIES= mypluglib.la
mypluglib_la_SOURCES= plugin_example.c
mypluglib_la_LDFLAGS= -module -rpath $(pkgplugindir)
mypluglib_la_CFLAGS= -DMYSQL_DYNAMIC_PLUGIN
+EXTRA_DIST= CMakeLists.txt
# Don't update the files from bitkeeper
%::SCCS/s.%
diff --git a/plugin/semisync/CMakeLists.txt b/plugin/semisync/CMakeLists.txt
index d42510fab18..7681894207d 100644
--- a/plugin/semisync/CMakeLists.txt
+++ b/plugin/semisync/CMakeLists.txt
@@ -1,4 +1,4 @@
-# Copyright (C) 2006 MySQL AB
+# Copyright (C) 2009 Sun Microsystems,Inc
#
# 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
@@ -11,25 +11,22 @@
#
# 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
+# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02
-# This is CMakeLists.txt for semi-sync replication plugins
+IF(WIN32)
+ SET(LIBPREFIX "")
+ELSE()
+ SET(LIBPREFIX "lib")
+ENDIF()
-SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
-SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
+SET(SEMISYNC_MASTER_SOURCES semisync.cc semisync_master.cc semisync_master_plugin.cc
+ semisync.h semisync_master.h)
-# Add common include directories
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib
- ${CMAKE_SOURCE_DIR}/sql
- ${CMAKE_SOURCE_DIR}/regex
- ${CMAKE_SOURCE_DIR}/extra/yassl/include)
+SET(SEMISYNC_MASTER_PLUGIN_DYNAMIC ${LIBPREFIX}semisync_master)
+MYSQL_PLUGIN(SEMISYNC_MASTER)
-SET(SEMISYNC_MASTER_SOURCES semisync.cc semisync_master.cc semisync_master_plugin.cc)
-SET(SEMISYNC_SLAVE_SOURCES semisync.cc semisync_slave.cc semisync_slave_plugin.cc)
+SET(SEMISYNC_SLAVE_SOURCES semisync.cc semisync_slave.cc semisync_slave_plugin.cc
+semisync.h semisync_slave.h )
+SET(SEMISYNC_SLAVE_PLUGIN_DYNAMIC ${LIBPREFIX}semisync_slave)
+MYSQL_PLUGIN(SEMISYNC_SLAVE)
-ADD_DEFINITIONS(-DMYSQL_DYNAMIC_PLUGIN)
-ADD_LIBRARY(semisync_master SHARED ${SEMISYNC_MASTER_SOURCES})
-TARGET_LINK_LIBRARIES(semisync_master mysqld)
-ADD_LIBRARY(semisync_slave SHARED ${SEMISYNC_SLAVE_SOURCES})
-TARGET_LINK_LIBRARIES(semisync_slave mysqld)
-MESSAGE("build SEMISYNC as DLL")
diff --git a/regex/CMakeLists.txt b/regex/CMakeLists.txt
index 440be4d2f12..f02c5745ef3 100755
--- a/regex/CMakeLists.txt
+++ b/regex/CMakeLists.txt
@@ -17,7 +17,6 @@
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
SET(REGEX_SOURCES regcomp.c regerror.c regexec.c regfree.c reginit.c)
+USE_ABSOLUTE_FILENAMES(REGEX_SOURCES)
+ADD_LIBRARY(regex ${REGEX_SOURCES})
-IF(NOT SOURCE_SUBLIBS)
- ADD_LIBRARY(regex ${REGEX_SOURCES})
-ENDIF(NOT SOURCE_SUBLIBS)
diff --git a/regex/regex2.h b/regex/regex2.h
index bba54ea2054..2ab32c62da8 100644
--- a/regex/regex2.h
+++ b/regex/regex2.h
@@ -83,9 +83,7 @@ typedef long sopno;
* a string of multi-character elements, and decide the size of the
* vectors at run time.
*/
-#ifdef __WIN__
-typedef unsigned char uch ;
-#endif
+
typedef struct {
uch *ptr; /* -> uch [csetsize] */
diff --git a/scripts/CMakeLists.txt b/scripts/CMakeLists.txt
index 25cdae2b522..de3e4c661f6 100755
--- a/scripts/CMakeLists.txt
+++ b/scripts/CMakeLists.txt
@@ -13,65 +13,257 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-# Build mysql_fix_privilege_tables.sql
-ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables.sql
- COMMAND copy /b
- mysql_system_tables.sql + mysql_system_tables_fix.sql
- mysql_fix_privilege_tables.sql
- DEPENDS
- ${PROJECT_SOURCE_DIR}/scripts/mysql_system_tables.sql
- ${PROJECT_SOURCE_DIR}/scripts/mysql_system_tables_fix.sql)
+IF(UNIX)
+ # FIND_PROC and CHECK_PID are used by mysqld_safe
+IF(CMAKE_SYSTEM_NAME MATCHES "Linux")
+ SET (FIND_PROC
+ "ps wwwp $PID | grep -v \" grep\" | grep -v mysqld_safe | grep -- \"$MYSQLD\" > /dev/null")
+ENDIF()
+IF(NOT FIND_PROC AND CMAKE_SYSTEM_NAME MATCHES "SunOS")
+ SET (FIND_PROC
+ "ps -p $PID | grep -v \" grep\" | grep -v mysqld_safe | grep -- \"$MYSQLD\" > /dev/null")
+ENDIF()
+
+IF(NOT FIND_PROC)
+ # BSD style
+ EXECUTE_PROCESS(COMMAND ps -uaxww OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE result)
+ IF(result MATCHES 0)
+ SET( FIND_PROC
+ "ps -uaxww | grep -v \" grep\" | grep -v mysqld_safe | grep -- "\$MYSQLD\" | grep \" $PID \" > /dev/null")
+ ENDIF()
+ENDIF()
+
+IF(NOT FIND_PROC)
+ # SysV style
+ EXECUTE_PROCESS(COMMAND ps -ef OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE result)
+ IF(result MATCHES 0)
+ SET( FIND_PROC "ps -ef | grep -v \" grep\" | grep -v mysqld_safe | grep -- "\$MYSQLD\" | grep \" $PID \" > /dev/null")
+ ENDIF()
+ENDIF()
+
+EXECUTE_PROCESS(COMMAND sh -c "kill -0 $$" OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE result2)
+IF(result3 MATCHES 0)
+ SET(CHECK_PID "kill -0 $PID > /dev/null 2> /dev/null")
+ELSE()
+ EXECUTE_PROCESS(COMMAND sh -c "kill -s 0 $$" OUTPUT_QUIET ERROR_QUIET RESULT_VARIABLE result3)
+ IF(result4 MATCHES 0)
+ SET(CHECK_PID "kill -s 0 $PID > /dev/null 2> /dev/null")
+ ELSE()
+ SET(CHECK_PID "kill -s SIGCONT $PID > /dev/null 2> /dev/null")
+ ENDIF()
+ENDIF()
+
+ENDIF(UNIX)
+
# Build comp_sql - used for embedding SQL in C or C++ programs
-ADD_EXECUTABLE(comp_sql comp_sql.c)
-TARGET_LINK_LIBRARIES(comp_sql dbug mysys strings)
+IF(NOT CMAKE_CROSSCOMPILING)
+ ADD_EXECUTABLE(comp_sql comp_sql.c)
+ TARGET_LINK_LIBRARIES(comp_sql)
+ENDIF()
+
+SET(FIX_PRIVS_IN
+ ${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables.sql
+ ${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables_fix.sql
+)
+SET(FIX_PRIVILEGES_SQL
+ ${CMAKE_CURRENT_BINARY_DIR}/mysql_fix_privilege_tables.sql
+)
-# Use comp_sql to build mysql_fix_privilege_tables_sql.c
-GET_TARGET_PROPERTY(COMP_SQL_EXE comp_sql LOCATION)
+# Build mysql_fix_privilege_tables.sql (concatenate 2 sql scripts)
+ADD_CUSTOM_COMMAND(
+ OUTPUT ${FIX_PRIVILEGES_SQL}
+ COMMAND ${CMAKE_COMMAND} "-DIN=${FIX_PRIVS_IN}" "-DOUT=${FIX_PRIVILEGES_SQL}"
+ -P "${CMAKE_SOURCE_DIR}/cmake/cat.cmake"
+ VERBATIM
+ DEPENDS ${FIX_PRIVS_IN}
+)
-ADD_CUSTOM_COMMAND(OUTPUT ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables_sql.c
- COMMAND ${COMP_SQL_EXE}
- mysql_fix_privilege_tables
- mysql_fix_privilege_tables.sql
- mysql_fix_privilege_tables_sql.c
- DEPENDS comp_sql ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables.sql)
+# Build mysql_fix_privilege_tables.c
+ADD_CUSTOM_COMMAND(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mysql_fix_privilege_tables_sql.c
+ COMMAND comp_sql
+ mysql_fix_privilege_tables
+ mysql_fix_privilege_tables.sql
+ mysql_fix_privilege_tables_sql.c
+ DEPENDS comp_sql ${CMAKE_CURRENT_BINARY_DIR}/mysql_fix_privilege_tables.sql
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+)
-# Add dummy target for the above to be built
+# Add target for the above to be built
ADD_CUSTOM_TARGET(GenFixPrivs
- ALL
- DEPENDS ${PROJECT_SOURCE_DIR}/scripts/mysql_fix_privilege_tables_sql.c)
+ ALL
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mysql_fix_privilege_tables_sql.c
+)
# ----------------------------------------------------------------------
# Replace some variables @foo@ in the .in/.sh file, and write the new script
# ----------------------------------------------------------------------
-SET(CFLAGS "-D_WINDOWS ${CMAKE_C_FLAGS_RELWITHDEBINFO}")
-SET(prefix "${CMAKE_INSTALL_PREFIX}/MySQL Server ${MYSQL_BASE_VERSION}")
-SET(sysconfdir ${prefix})
-SET(bindir ${prefix}/bin)
-SET(libexecdir ${prefix}/bin)
-SET(scriptdir ${prefix}/bin)
-SET(datadir ${prefix}/share)
-SET(pkgdatadir ${prefix}/share)
-SET(localstatedir ${prefix}/data)
+SET(CFLAGS "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
+SET(CXXFLAGS "${CMAKE_C_FLAGS_RELWITHDEBINFO}")
+SET(LDFLAGS "${CMAKE_SHARED_LIBRARY_LINK_FLAGS}")
+
+IF(WIN32)
+ SET(prefix "${CMAKE_INSTALL_PREFIX}/MySQL Server ${MYSQL_BASE_VERSION}")
+ELSE()
+ set(prefix "${CMAKE_INSTALL_PREFIX}/mysql")
+ENDIF()
+
+SET(sysconfdir ${prefix})
+SET(bindir ${prefix}/bin)
+SET(libexecdir ${prefix}/bin)
+SET(scriptdir ${prefix}/bin)
+SET(datadir ${prefix}/share)
+SET(pkgdatadir ${prefix}/share)
+SET(pkgincludedir ${prefix}/include)
+SET(pkglibdir ${prefix}/lib)
+SET(pkgplugindir ${prefix}/lib/plugin)
+SET(localstatedir ${prefix}/data)
+
+# Use cmake variables to inspect dependencies for
+# mysqlclient library
+SET(CLIENT_LIBS "")
+SET(LIBS "")
+FOREACH(lib ${mysqlclient_LIB_DEPENDS})
+ # Filter out general, it is CMake hint
+ # not real
+ IF(NOT lib STREQUAL "general" AND NOT CLIENT_LIBS MATCHES "-l${lib} ")
+ SET(CLIENT_LIBS "${CLIENT_LIBS}-l${lib} " )
+ ENDIF()
+ENDFOREACH()
+FOREACH(lib ${mysqlserver_LIB_DEPENDS})
+ IF(NOT lib STREQUAL "general" AND NOT LIBS MATCHES "-l${lib} ")
+ SET(LIBS "${LIBS}-l${lib} " )
+ ENDIF()
+ENDFOREACH()
+IF(MSVC)
+ STRING(REPLACE "-l" "" CLIENT_LIBS "${CLIENT_LIBS}")
+ STRING(REPLACE "-l" "" LIBS "${LIBS}" )
+ENDIF()
+
+SET(NON_THREADED_LIBS ${CLIENT_LIBS})
+
+IF(WIN32)
+ # On Windows, some .sh and some .pl.in files are configured
+ # The resulting files will have .pl extension (those are perl scripts)
+
+ # Input files with pl.in extension
+ SET(PLIN_FILES mysql_config mysql_secure_installation)
+ # Input files with .sh extension
+ SET(SH_FILES mysql_convert_table_format mysqld_multi)
+
+ FOREACH(file ${PLIN_FILES})
+ CONFIGURE_FILE(${file}.pl.in
+ ${CMAKE_CURRENT_BINARY_DIR}/${file}.pl ESCAPE_QUOTES @ONLY)
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${file}.pl DESTINATION scripts)
+ ENDFOREACH()
+
+ FOREACH(file ${SH_FILES})
+ CONFIGURE_FILE(${file}.sh
+ ${CMAKE_CURRENT_BINARY_DIR}/${file}.pl ESCAPE_QUOTES @ONLY)
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${file}.pl DESTINATION scripts)
+ ENDFOREACH()
+ELSE()
+ # On Unix, most of the files end up in the bin directory
+ SET(BIN_SCRIPTS
+ msql2mysql
+ mysql_config
+ mysql_fix_extensions
+ mysql_setpermission
+ mysql_secure_installation
+ mysql_zap
+ mysqlaccess
+ mysqlbug
+ mysql_convert_table_format
+ mysql_find_rows
+ mysqlhotcopy
+ mysqldumpslow
+ mysqld_multi
+ mysqlaccess
+ mysqlaccess.conf
+ mysql_install_db
+ )
+ FOREACH(file ${BIN_SCRIPTS})
+ IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh)
+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}.sh
+ ${CMAKE_CURRENT_BINARY_DIR}/${file} ESCAPE_QUOTES @ONLY)
+ ELSEIF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${file})
+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${file}
+ ${CMAKE_CURRENT_BINARY_DIR}/${file} COPYONLY)
+ ELSE()
+ MESSAGE(FATAL_ERROR "Can not find ${file}.sh or ${file} in "
+ "${CMAKE_CURRENT_SOURCE_DIR}" )
+ ENDIF()
+
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${file} DESTINATION bin
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
+ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+ ENDFOREACH()
+
+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/mysqld_safe.sh
+ ${CMAKE_CURRENT_BINARY_DIR}/mysqld_safe @ONLY)
+
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mysqld_safe DESTINATION bin
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
+ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+
+ # For some reason, mysqld_safe needs to be also in scripts directory
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/mysql_install_db
+ DESTINATION scripts
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ
+ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
+ )
+ENDIF()
-CONFIGURE_FILE(mysql_config.pl.in
- scripts/mysql_config.pl ESCAPE_QUOTES @ONLY)
+INSTALL(FILES mysql_test_data_timezone.sql DESTINATION share)
-CONFIGURE_FILE(mysql_convert_table_format.sh
- scripts/mysql_convert_table_format.pl ESCAPE_QUOTES @ONLY)
+IF(UNIX)
+ FILE(WRITE ${CMAKE_CURRENT_BINARY_DIR}/make_binary_distribution
+ "cd ${CMAKE_BINARY_DIR} && ${CMAKE_CPACK_COMMAND} -G TGZ --config CPackConfig.cmake" )
+ EXECUTE_PROCESS(
+ COMMAND chmod +x ${CMAKE_CURRENT_BINARY_DIR}/make_binary_distribution
+)
+ENDIF()
-CONFIGURE_FILE(mysql_install_db.pl.in
- scripts/mysql_install_db.pl ESCAPE_QUOTES @ONLY)
+# Install libgcc as mylibgcc.a
+IF(CMAKE_COMPILER_IS_GNUCXX)
+ IF(NOT LIBGCC_LOCATION)
+ EXECUTE_PROCESS (
+ COMMAND ${CMAKE_CXX_COMPILER} ${CMAKE_CXX_COMPILER_ARG1}
+ ${CMAKE_CXX_FLAGS} --print-libgcc
+ OUTPUT_VARIABLE LIBGCC_LOCATION
+ RESULT_VARIABLE RESULT
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ ERROR_QUIET
+ )
+ IF(${RESULT} EQUAL 0 AND EXISTS ${LIBGCC_LOCATION})
+ SET(LIBGCC_LOCATION "${LIBGCC_LOCATION}" CACHE INTERNAL
+ "location of libgcc" )
+ ENDIF()
+ ENDIF()
+
+ IF(LIBGCC_LOCATION)
+ INSTALL (CODE "CONFIGURE_FILE (${LIBGCC_LOCATION}
+ ${CMAKE_CURRENT_BINARY_DIR}/libmygcc.a COPYONLY)")
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/libmygcc.a DESTINATION lib
+ OPTIONAL)
+ ENDIF()
+ENDIF()
-CONFIGURE_FILE(mysql_secure_installation.pl.in
- scripts/mysql_secure_installation.pl ESCAPE_QUOTES @ONLY)
-CONFIGURE_FILE(mysqld_multi.sh
- scripts/mysqld_multi.pl ESCAPE_QUOTES @ONLY)
+INSTALL (FILES
+ ${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables.sql
+ ${CMAKE_CURRENT_SOURCE_DIR}/mysql_system_tables_data.sql
+ ${CMAKE_CURRENT_SOURCE_DIR}/fill_help_tables.sql
+ DESTINATION share
+)
-CONFIGURE_FILE(mysqldumpslow.sh
- scripts/mysqldumpslow.pl ESCAPE_QUOTES @ONLY)
+# TCMalloc hacks
+IF($ENV{MALLOC_LIB})
+ SET(MALLOC_LIB $ENV{MALLOC_LIB} CACHE STRING "malloc library")
+ENDIF()
-CONFIGURE_FILE(mysqlhotcopy.sh
- scripts/mysqlhotcopy.pl ESCAPE_QUOTES @ONLY)
+IF(MALLOC_LIB)
+ INSTALL(FILES ${MALLOC_LIB} DESTINATION lib OPTIONAL)
+ENDIF()
diff --git a/sql-bench/CMakeLists.txt b/sql-bench/CMakeLists.txt
new file mode 100644
index 00000000000..e69fa9fa18f
--- /dev/null
+++ b/sql-bench/CMakeLists.txt
@@ -0,0 +1,51 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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
+
+# Install sql-bench files
+FILE(GLOB all_files
+${CMAKE_SOURCE_DIR}/sql-bench/*
+${CMAKE_SOURCE_DIR}/sql-bench/Data/ATIS/*
+${CMAKE_SOURCE_DIR}/sql-bench/Data/Wisconsin/*
+${CMAKE_SOURCE_DIR}/sql-bench/Comments/*
+${CMAKE_SOURCE_DIR}/sql-bench/limits/*
+)
+
+GET_FILENAME_COMPONENT(basedir ${CMAKE_SOURCE_DIR} ABSOLUTE)
+FOREACH(file ${all_files})
+ IF(NOT IS_DIRECTORY ${file} AND NOT ${file} MATCHES "Make" )
+ FILE(RELATIVE_PATH relpath ${basedir} ${file})
+ SET(target_relpath ${relpath})
+ GET_FILENAME_COMPONENT(ext ${file} EXT)
+ GET_FILENAME_COMPONENT(dir ${relpath} PATH)
+ IF(ext MATCHES ".sh$")
+ # Those are perl files actually
+ STRING(REPLACE ".sh" "" target_relpath ${target_relpath} )
+ IF(WIN32)
+ IF(NOT ext MATCHES ".pl")
+ SET(target_relpath "${target_relpath}.pl")
+ ENDIF()
+ ENDIF()
+ ENDIF()
+ SET(target "${CMAKE_BINARY_DIR}/${target_relpath}")
+ CONFIGURE_FILE(${file} ${target} COPYONLY)
+ IF (ext MATCHES ".bat")
+ IF(WIN32)
+ INSTALL(FILES ${target} DESTINATION ${dir})
+ ENDIF()
+ ELSE()
+ INSTALL(FILES ${target} DESTINATION ${dir})
+ ENDIF()
+ ENDIF()
+ENDFOREACH()
diff --git a/sql-bench/Makefile.am b/sql-bench/Makefile.am
index a7aff83e7aa..ff726ff561e 100644
--- a/sql-bench/Makefile.am
+++ b/sql-bench/Makefile.am
@@ -37,7 +37,7 @@ EXTRA_SCRIPTS = test-ATIS.sh test-connect.sh test-create.sh \
graph-compare-results.sh innotest1.sh innotest1a.sh \
innotest1b.sh innotest2.sh innotest2a.sh innotest2b.sh \
bench-count-distinct.sh
-EXTRA_DIST = $(EXTRA_SCRIPTS)
+EXTRA_DIST = $(EXTRA_SCRIPTS) CMakeLists.txt
dist-hook:
mkdir -p $(distdir)/Data/ATIS $(distdir)/Data/Wisconsin \
diff --git a/sql/CMakeLists.txt b/sql/CMakeLists.txt
index 15c2d950ff9..881772bfc5a 100755
--- a/sql/CMakeLists.txt
+++ b/sql/CMakeLists.txt
@@ -12,32 +12,36 @@
# 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("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
-
-SET(CMAKE_CXX_FLAGS_DEBUG
- "${CMAKE_CXX_FLAGS_DEBUG} -DUSE_SYMDIR /Zi")
-SET(CMAKE_C_FLAGS_DEBUG
- "${CMAKE_C_FLAGS_DEBUG} -DUSE_SYMDIR /Zi")
-SET(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /MAP /MAPINFO:EXPORTS")
-
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
- ${CMAKE_SOURCE_DIR}/extra/yassl/include
- ${CMAKE_SOURCE_DIR}/sql
- ${CMAKE_SOURCE_DIR}/regex
- ${CMAKE_SOURCE_DIR}/zlib
+
+IF(MSVC)
+ #Innodb plugin needs linker-generated map file to locate server exports
+ #see bug#42001
+ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} /MAP /MAPINFO:EXPORTS")
+ENDIF(MSVC)
+
+INCLUDE_DIRECTORIES(
+${CMAKE_SOURCE_DIR}/include
+${CMAKE_SOURCE_DIR}/sql
+${CMAKE_SOURCE_DIR}/regex
+${ZLIB_INCLUDE_DIR}
+${SSL_INCLUDE_DIRS}
+${CMAKE_BINARY_DIR}/sql
+)
+
+SET(GEN_SOURCES
+${CMAKE_BINARY_DIR}/sql/sql_yacc.h
+${CMAKE_BINARY_DIR}/sql/sql_yacc.cc
+${CMAKE_BINARY_DIR}/sql/sql_builtin.cc
+${CMAKE_BINARY_DIR}/sql/lex_hash.h
)
-SET_SOURCE_FILES_PROPERTIES(${CMAKE_SOURCE_DIR}/sql/sql_yacc.h
- ${CMAKE_SOURCE_DIR}/sql/sql_yacc.cc
- ${CMAKE_SOURCE_DIR}/include/mysql_version.h
- ${CMAKE_SOURCE_DIR}/sql/sql_builtin.cc
- ${CMAKE_SOURCE_DIR}/sql/lex_hash.h
- ${PROJECT_SOURCE_DIR}/include/mysqld_error.h
- ${PROJECT_SOURCE_DIR}/include/mysqld_ername.h
- ${PROJECT_SOURCE_DIR}/include/sql_state.h
- PROPERTIES GENERATED 1)
+SET_SOURCE_FILES_PROPERTIES(${GEN_SOURCES} PROPERTIES GENERATED 1)
+
+ADD_DEFINITIONS(-DMYSQL_SERVER -DHAVE_EVENT_SCHEDULER)
+IF(SSL_DEFINES)
+ ADD_DEFINITIONS(${SSL_DEFINES})
+ENDIF()
-ADD_DEFINITIONS(-DMYSQL_SERVER -D_CONSOLE -DHAVE_DLOPEN -DHAVE_EVENT_SCHEDULER)
SET (SQL_SOURCE
@@ -54,7 +58,7 @@ SET (SQL_SOURCE
log_event_old.cc rpl_record_old.cc
message.h mf_iocache.cc my_decimal.cc ../sql-common/my_time.c
mysqld.cc net_serv.cc
- nt_servc.cc nt_servc.h opt_range.cc opt_range.h opt_sum.cc
+ opt_range.cc opt_range.h opt_sum.cc
../sql-common/pack.c parse_file.cc password.c procedure.cc
protocol.cc records.cc repl_failsafe.cc rpl_filter.cc set_var.cc
slave.cc sp.cc sp_cache.cc sp_head.cc sp_pcontext.cc
@@ -77,79 +81,169 @@ SET (SQL_SOURCE
sql_connect.cc scheduler.cc
sql_profile.cc event_parse_data.cc
sql_signal.cc rpl_handler.cc
- ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc
- ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h
- ${PROJECT_SOURCE_DIR}/include/mysqld_error.h
- ${PROJECT_SOURCE_DIR}/include/mysqld_ername.h
- ${PROJECT_SOURCE_DIR}/include/sql_state.h
- ${PROJECT_SOURCE_DIR}/include/mysql_version.h
- ${PROJECT_SOURCE_DIR}/sql/sql_builtin.cc
- ${PROJECT_SOURCE_DIR}/sql/lex_hash.h)
-ADD_LIBRARY(sql ${SQL_SOURCE})
-
-IF (NOT EXISTS cmake_dummy.cc)
- FILE (WRITE cmake_dummy.cc "")
-ENDIF (NOT EXISTS cmake_dummy.cc)
-ADD_EXECUTABLE(mysqld cmake_dummy.cc)
-
-SET_TARGET_PROPERTIES(mysqld PROPERTIES OUTPUT_NAME mysqld${MYSQLD_EXE_SUFFIX})
-SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE)
-
-SET (MYSQLD_CORE_LIBS mysys zlib dbug strings yassl taocrypt vio regex sql)
-TARGET_LINK_LIBRARIES(mysqld ${MYSQLD_CORE_LIBS} ${MYSQLD_STATIC_ENGINE_LIBS})
-
-
-IF(MSVC AND NOT WITHOUT_DYNAMIC_PLUGINS)
- # Set module definition file. Also use non-incremental linker,
- # incremental appears to crash from time to time,if used with /DEF option
- SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS "/DEF:mysqld.def /INCREMENTAL:NO")
-
- FOREACH (CORELIB ${MYSQLD_CORE_LIBS})
- GET_TARGET_PROPERTY(LOC ${CORELIB} LOCATION)
- FILE(TO_NATIVE_PATH ${LOC} LOC)
- SET (LIB_LOCATIONS ${LIB_LOCATIONS} ${LOC})
- ENDFOREACH (CORELIB ${MYSQLD_CORE_LIBS})
+ ${GEN_SOURCES}
+ ${MYSYS_LIBWRAP_SOURCE})
+
+
+SET (MYSQLD_CORE_LIBS mysys ${ZLIB_LIBRARY} ${SSL_LIBRARIES} vio regex )
+IF(WIN32)
+ SET(SQL_SOURCE ${SQL_SOURCE} nt_servc.cc nt_servc.h)
+ENDIF()
+IF(MSVC)
+ ADD_LIBRARY(sql ${SQL_SOURCE})
+ ADD_EXECUTABLE(mysqld mysqld_dummy.cc)
+ ADD_CUSTOM_COMMAND(
+ OUTPUT mysqld_dummy.cc
+ COMMAND cmake ARGS -E touch mysqld_dummy.cc
+ VERBATIM)
+ SET(MYSQLD_CORE_LIBS ${MYSQLD_CORE_LIBS} sql)
+
+ELSE()
+ ADD_EXECUTABLE(mysqld ${SQL_SOURCE})
+ DTRACE_INSTRUMENT(mysqld)
+ENDIF()
+
+IF(NOT WITHOUT_DYNAMIC_PLUGINS)
+ SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE)
+ IF (MINGW OR CYGWIN)
+ SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS "-Wl,--export-all-symbols")
+ ENDIF()
+ IF(MSVC)
+ # Set module definition file. Also use non-incremental linker,
+ # incremental appears to crash from time to time,if used with /DEF option
+ SET_TARGET_PROPERTIES(mysqld PROPERTIES LINK_FLAGS "/DEF:mysqld.def /INCREMENTAL:NO")
+
+ FOREACH (CORELIB ${MYSQLD_CORE_LIBS} dbug strings)
+ GET_TARGET_PROPERTY(LOC ${CORELIB} LOCATION)
+ FILE(TO_NATIVE_PATH ${LOC} LOC)
+ SET (LIB_LOCATIONS ${LIB_LOCATIONS} ${LOC})
+ ENDFOREACH (CORELIB ${MYSQLD_CORE_LIBS})
- ADD_CUSTOM_COMMAND(TARGET mysqld PRE_LINK
- COMMAND cscript ARGS //nologo ${PROJECT_SOURCE_DIR}/win/create_def_file.js
+ ADD_CUSTOM_COMMAND(TARGET mysqld PRE_LINK
+ COMMAND echo ${PLATFORM} && cscript ARGS //nologo ${PROJECT_SOURCE_DIR}/win/create_def_file.js
${PLATFORM} ${LIB_LOCATIONS} > mysqld.def
- WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/sql)
-ENDIF(MSVC AND NOT WITHOUT_DYNAMIC_PLUGINS)
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
+ ADD_DEPENDENCIES(sql GenError)
+ ENDIF()
+ENDIF()
+
+SET_TARGET_PROPERTIES(mysqld PROPERTIES ENABLE_EXPORTS TRUE)
+SET_TARGET_PROPERTIES(mysqld PROPERTIES OUTPUT_NAME mysqld${MYSQLD_EXE_SUFFIX})
+TARGET_LINK_LIBRARIES(mysqld ${MYSQLD_STATIC_PLUGIN_LIBS} ${MYSQLD_CORE_LIBS} ${LIBWRAP_LIBRARY})
+INSTALL(TARGETS mysqld DESTINATION bin)
+INSTALL_DEBUG_SYMBOLS(mysqld)
+
+
+FIND_PROGRAM(BISON_EXECUTABLE bison DOC "path to the bison executable")
+MARK_AS_ADVANCED(BISON_EXECUTABLE "")
+
+
+# Handle out-of-source build from source package with possibly broken
+# bison. Copy bison output to from source to build directory, if not already
+# there
+IF (NOT ${CMAKE_CURRENT_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_BINARY_DIR})
+ IF(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.cc)
+ IF(NOT EXISTS ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc)
+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.cc
+ ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc COPYONLY)
+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.h
+ ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h COPYONLY)
+ ENDIF()
+ ENDIF()
+ENDIF()
+
+
+INCLUDE(${CMAKE_SOURCE_DIR}/cmake/bison.cmake)
+RUN_BISON(
+ ${CMAKE_CURRENT_SOURCE_DIR}/sql_yacc.yy
+ ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.cc
+ ${CMAKE_CURRENT_BINARY_DIR}/sql_yacc.h
+)
-ADD_DEPENDENCIES(sql GenError)
+# Gen_lex_hash
+ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc)
+TARGET_LINK_LIBRARIES(gen_lex_hash mysys)
-# Sql Parser custom command
ADD_CUSTOM_COMMAND(
- OUTPUT ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h
- ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc
- COMMAND bison ARGS -y -p MYSQL --defines=sql_yacc.h
- --output=sql_yacc.cc sql_yacc.yy
- DEPENDS ${PROJECT_SOURCE_DIR}/sql/sql_yacc.yy)
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/lex_hash.h
+ COMMAND gen_lex_hash ARGS > lex_hash.h
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
+ DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gen_lex_hash.cc)
+
+ADD_CUSTOM_TARGET(
+ GenServerSource
+ DEPENDS ${GEN_SOURCES}
+)
+#Need this only for embedded
+SET_TARGET_PROPERTIES(GenServerSource PROPERTIES EXCLUDE_FROM_ALL TRUE)
+
+IF(WIN32 OR HAVE_DLOPEN)
+ ADD_LIBRARY(udf_example MODULE udf_example.c)
+ SET_TARGET_PROPERTIES(udf_example PROPERTIES PREFIX "")
+ # udf_example depends on strings
+ IF(WIN32)
+ IF(MSVC)
+ SET_TARGET_PROPERTIES(udf_example PROPERTIES LINK_FLAGS "/DEF:${CMAKE_CURRENT_SOURCE_DIR}/udf_example.def")
+ ENDIF()
+ TARGET_LINK_LIBRARIES(udf_example strings)
+ ENDIF()
+ENDIF()
+
+FOREACH(tool glibtoolize libtoolize aclocal autoconf autoheader automake gtar
+ tar bzr)
+ STRING(TOUPPER ${tool} TOOL)
+ FIND_PROGRAM(${TOOL}_EXECUTABLE ${tool} DOC "path to the executable")
+ MARK_AS_ADVANCED(${TOOL}_EXECUTABLE)
+ENDFOREACH()
+
+CONFIGURE_FILE(
+ ${CMAKE_SOURCE_DIR}/cmake/make_dist.cmake.in ${CMAKE_BINARY_DIR}/make_dist.cmake @ONLY)
+
+ADD_CUSTOM_TARGET(dist
+ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/make_dist.cmake
+ DEPENDS ${CMAKE_BINARY_DIR}/sql/sql_yacc.cc ${CMAKE_BINARY_DIR}/sql/sql_yacc.h
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+)
-# Gen_lex_hash
-ADD_EXECUTABLE(gen_lex_hash gen_lex_hash.cc)
-TARGET_LINK_LIBRARIES(gen_lex_hash dbug mysqlclient)
-GET_TARGET_PROPERTY(GEN_LEX_HASH_EXE gen_lex_hash LOCATION)
-ADD_CUSTOM_COMMAND(
- OUTPUT ${PROJECT_SOURCE_DIR}/sql/lex_hash.h
- COMMAND ${GEN_LEX_HASH_EXE} ARGS > lex_hash.h
- DEPENDS ${GEN_LEX_HASH_EXE})
-
-ADD_CUSTOM_TARGET(
- GenServerSource ALL
- DEPENDS ${PROJECT_SOURCE_DIR}/sql/sql_yacc.h
- ${PROJECT_SOURCE_DIR}/sql/sql_yacc.cc
- ${PROJECT_SOURCE_DIR}/sql/message.h
- ${PROJECT_SOURCE_DIR}/sql/message.rc
- ${PROJECT_SOURCE_DIR}/sql/lex_hash.h)
-
-ADD_DEPENDENCIES(mysqld GenServerSource)
-
-# Remove the auto-generated files as part of 'Clean Solution'
-SET_DIRECTORY_PROPERTIES(PROPERTIES ADDITIONAL_MAKE_CLEAN_FILES
- "lex_hash.h;sql_yacc.h;sql_yacc.cc;mysqld.def")
-
-ADD_LIBRARY(udf_example MODULE udf_example.c udf_example.def)
-ADD_DEPENDENCIES(udf_example strings GenError)
-TARGET_LINK_LIBRARIES(udf_example strings)
+
+
+
+
+# We need to create empty directories (data/test) the installation.
+# This does not work with current CPack due to http://www.cmake.org/Bug/view.php?id=8767
+# Avoid completely empty directories and install dummy file instead.
+
+SET(DUMMY_FILE ${CMAKE_CURRENT_BINARY_DIR}/.empty )
+FILE(WRITE ${DUMMY_FILE} "")
+INSTALL(FILES ${DUMMY_FILE} DESTINATION data/test)
+
+# Install initial database on windows
+IF(NOT CMAKE_CROSSCOMPILING)
+ GET_TARGET_PROPERTY(MYSQLD_EXECUTABLE mysqld LOCATION)
+ENDIF()
+IF(WIN32 AND MYSQLD_EXECUTABLE)
+ CONFIGURE_FILE(
+ ${CMAKE_SOURCE_DIR}/cmake/create_initial_db.cmake.in
+ ${CMAKE_CURRENT_BINARY_DIR}/create_initial_db.cmake
+ @ONLY
+ )
+
+ MAKE_DIRECTORY(${CMAKE_CURRENT_BINARY_DIR}/data)
+ ADD_CUSTOM_COMMAND(
+ OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/data/mysql/user.frm
+ COMMAND ${CMAKE_COMMAND}
+ -DCONFIG=${CMAKE_CFG_INTDIR}
+ -P ${CMAKE_CURRENT_BINARY_DIR}/create_initial_db.cmake
+ WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data
+ DEPENDS mysqld
+ )
+ ADD_CUSTOM_TARGET(initial_database
+ ALL
+ DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/data/mysql/user.frm
+ )
+ INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/data/mysql DESTINATION data)
+ELSE()
+ # Not windows or cross compiling, just install an empty directory
+ INSTALL(FILES ${DUMMY_FILE} DESTINATION data/mysql)
+ENDIF() \ No newline at end of file
diff --git a/sql/nt_servc.cc b/sql/nt_servc.cc
index f41fa08f828..76dc2846ed0 100644
--- a/sql/nt_servc.cc
+++ b/sql/nt_servc.cc
@@ -10,6 +10,7 @@
#include <windows.h>
#include <process.h>
#include <stdio.h>
+#include <stdlib.h>
#include "nt_servc.h"
diff --git a/sql/share/CMakeLists.txt b/sql/share/CMakeLists.txt
new file mode 100644
index 00000000000..7a67833f9e3
--- /dev/null
+++ b/sql/share/CMakeLists.txt
@@ -0,0 +1,52 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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 (dirs
+danish
+german
+slovak
+dutch
+greek
+norwegian
+spanish
+english
+hungarian
+norwegian-ny
+swedish
+italian
+polish
+ukrainian
+japanese
+portuguese
+romanian
+estonian
+korean
+russian
+czech
+french
+serbian
+)
+
+SET(files
+ errmsg-utf8.txt
+)
+
+FOREACH (dir ${dirs})
+ INSTALL(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${dir}
+ DESTINATION share)
+ENDFOREACH()
+INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/charsets DESTINATION share)
+
+INSTALL(FILES ${files} DESTINATION share)
diff --git a/sql/share/Makefile.am b/sql/share/Makefile.am
index 06b349d5de2..c4078440abf 100644
--- a/sql/share/Makefile.am
+++ b/sql/share/Makefile.am
@@ -15,8 +15,9 @@
## Process this file with automake to create Makefile.in
-EXTRA_DIST= errmsg-utf8.txt
-
+EXTRA_DIST= errmsg-utf8.txt \
+ CMakeLists.txt
+
dist-hook:
for dir in charsets @AVAILABLE_LANGUAGES@; do \
test -d $(distdir)/$$dir || mkdir $(distdir)/$$dir; \
diff --git a/sql/sql_builtin.cc.in b/sql/sql_builtin.cc.in
index 3becdbaccfe..1b9b152247f 100644
--- a/sql/sql_builtin.cc.in
+++ b/sql/sql_builtin.cc.in
@@ -17,7 +17,12 @@
typedef struct st_mysql_plugin builtin_plugin[];
-extern builtin_plugin
+#if defined(_MSC_VER)
+extern "C"
+#else
+extern
+#endif
+builtin_plugin
builtin_binlog_plugin@mysql_plugin_defs@;
struct st_mysql_plugin *mysqld_builtins[]=
diff --git a/sql/sql_class.h b/sql/sql_class.h
index 1a5cceaca90..e876b2a6787 100644
--- a/sql/sql_class.h
+++ b/sql/sql_class.h
@@ -1960,7 +1960,7 @@ public:
void add_changed_table(const char *key, long key_length);
CHANGED_TABLE_LIST * changed_table_dup(const char *key, long key_length);
int send_explain_fields(select_result *result);
-#ifndef EMBEDDED_LIBRARY
+
/**
Clear the current error, if any.
We do not clear is_fatal_error or is_fatal_sub_stmt_error since we
@@ -1976,9 +1976,9 @@ public:
is_slave_error= 0;
DBUG_VOID_RETURN;
}
+#ifndef EMBEDDED_LIBRARY
inline bool vio_ok() const { return net.vio != 0; }
#else
- void clear_error();
inline bool vio_ok() const { return true; }
#endif
/**
diff --git a/storage/Makefile.am b/storage/Makefile.am
index 8aa1e4f7dc6..5b4e32374ae 100644
--- a/storage/Makefile.am
+++ b/storage/Makefile.am
@@ -18,7 +18,6 @@
AUTOMAKE_OPTIONS = foreign
# These are built from source in the Docs directory
-EXTRA_DIST = mysql_storage_engine.cmake
SUBDIRS = @mysql_se_dirs@
DIST_SUBDIRS = @mysql_se_distdirs@
diff --git a/storage/archive/CMakeLists.txt b/storage/archive/CMakeLists.txt
index ce4d92d3f99..458f21bfb6c 100644
--- a/storage/archive/CMakeLists.txt
+++ b/storage/archive/CMakeLists.txt
@@ -13,6 +13,14 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-INCLUDE("${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake")
+SET(ARCHIVE_PLUGIN_STATIC "archive")
+SET(ARCHIVE_PLUGIN_DYNAMIC "ha_archive")
+
SET(ARCHIVE_SOURCES azio.c ha_archive.cc ha_archive.h)
MYSQL_STORAGE_ENGINE(ARCHIVE)
+IF(NOT WITH_ARCHIVE_STORAGE_ENGINE AND NOT WITHOUT_ARCHIVE_STORAGE_ENGINE
+ AND NOT WITH_ZLIB STREQUAL "bundled")
+ TARGET_LINK_LIBRARIES(archive ${ZLIB_LIBRARY})
+ENDIF()
+
+
diff --git a/storage/blackhole/CMakeLists.txt b/storage/blackhole/CMakeLists.txt
index bed282ef21d..ec28208c311 100644
--- a/storage/blackhole/CMakeLists.txt
+++ b/storage/blackhole/CMakeLists.txt
@@ -13,7 +13,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-INCLUDE("${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake")
-SET(BLACKHOLE_SOURCES ha_blackhole.cc ha_blackhole.h)
+SET(BLACKHOLE_PLUGIN_STATIC "blackhole")
+SET(BLACKHOLE_PLUGIN_DYNAMIC "ha_blackhole")
+SET(BLACKHOLE_SOURCES ha_blackhole.cc ha_blackhole.h)
MYSQL_STORAGE_ENGINE(BLACKHOLE)
diff --git a/storage/csv/CMakeLists.txt b/storage/csv/CMakeLists.txt
index 37760588897..b9d31fc372f 100644
--- a/storage/csv/CMakeLists.txt
+++ b/storage/csv/CMakeLists.txt
@@ -13,7 +13,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+SET(CSV_PLUGIN_STATIC "csv")
+SET(CSV_PLUGIN_MANDATORY TRUE)
-INCLUDE("${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake")
SET(CSV_SOURCES ha_tina.cc ha_tina.h transparent_file.cc transparent_file.h)
MYSQL_STORAGE_ENGINE(CSV) \ No newline at end of file
diff --git a/storage/example/CMakeLists.txt b/storage/example/CMakeLists.txt
index f0b1343ab9c..47722dfd53b 100644
--- a/storage/example/CMakeLists.txt
+++ b/storage/example/CMakeLists.txt
@@ -13,6 +13,6 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-INCLUDE("${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake")
+SET(EXAMPLE_PLUGIN_DYNAMIC "ha_example")
SET(EXAMPLE_SOURCES ha_example.cc)
MYSQL_STORAGE_ENGINE(EXAMPLE)
diff --git a/storage/federated/CMakeLists.txt b/storage/federated/CMakeLists.txt
index fa54d36481a..f47c7240682 100644
--- a/storage/federated/CMakeLists.txt
+++ b/storage/federated/CMakeLists.txt
@@ -13,6 +13,12 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-INCLUDE("${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake")
+SET(FEDERATED_PLUGIN_STATIC "federated")
+SET(FEDERATED_PLUGIN_DYNAMIC "ha_federated")
SET(FEDERATED_SOURCES ha_federated.cc)
+IF(NOT WITH_FEDERATED AND NOT WITH_FEDERATED_STORAGE_ENGINE)
+ # Bug#45488- federated uses symbols that are not used anywhere in
+ # mysqld and are optimized away by the linker.
+ SET(FEDERATED_SOURCES ${FEDERATED_SOURCES} ${CMAKE_SOURCE_DIR}/mysys/string.c)
+ENDIF()
MYSQL_STORAGE_ENGINE(FEDERATED)
diff --git a/storage/heap/CMakeLists.txt b/storage/heap/CMakeLists.txt
index 4a0fa22c8f1..1e88ecd503f 100755
--- a/storage/heap/CMakeLists.txt
+++ b/storage/heap/CMakeLists.txt
@@ -13,8 +13,9 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+SET(HEAP_PLUGIN_STATIC "heap")
+SET(HEAP_PLUGIN_MANDATORY TRUE)
-INCLUDE("${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake")
SET(HEAP_SOURCES _check.c _rectest.c hp_block.c hp_clear.c hp_close.c hp_create.c
ha_heap.cc
hp_delete.c hp_extra.c hp_hash.c hp_info.c hp_open.c hp_panic.c
diff --git a/storage/ibmdb2i/CMakeLists.txt b/storage/ibmdb2i/CMakeLists.txt
index 11cc4300569..76ef3b2662d 100644
--- a/storage/ibmdb2i/CMakeLists.txt
+++ b/storage/ibmdb2i/CMakeLists.txt
@@ -13,13 +13,28 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
-SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
+SET(IBMDB2I_PLUGIN_DYNAMIC "ha_ibmdb2i")
+CHECK_INCLUDE_FILES(qlgusr.h HAVE_PASE_ENVIRONMENT)
+IF(HAVE_PASE_ENVIRONMENT)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/sql
- ${CMAKE_SOURCE_DIR}/regex
- ${CMAKE_SOURCE_DIR}/extra/yassl/include)
-ADD_LIBRARY(ibmdb2i ha_ibmdb2i.cc db2i_ileBridge.cc db2i_conversion.cc
+INCLUDE_DIRECTORIES(
+ ${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_BINARY_DIR}/include
+ ${CMAKE_SOURCE_DIR}/regex
+ ${CMAKE_SOURCE_DIR}/sql
+ ${CMAKE_CURRENT_SOURCE_DIR}
+ /afs/rchland.ibm.com/lande/shadow/dev2000/osxpf/v5r4m0f.xpf/cur/cmvc/base.pgm/my.xpf/apis
+ /afs/rchland.ibm.com/lande/shadow/dev2000/osxpf/v5r4m0.xpf/bld/cmvc/base.pgm/lg.xpf
+ /afs/rchland.ibm.com/lande/shadow/dev2000/osxpf/v5r4m0.xpf/bld/cmvc/base.pgm/tq.xpf
+)
+
+
+SET (IBMDB2I_SOURCES ha_ibmdb2i.cc db2i_ileBridge.cc db2i_conversion.cc
db2i_blobCollection.cc db2i_file.cc db2i_charsetSupport.cc
db2i_collationSupport.cc db2i_errors.cc db2i_constraints.cc
db2i_rir.cc db2i_sqlStatementStream.cc db2i_ioBuffers.cc db2i_myconv.cc)
+
+SET(IBMDB2I_LIBS iconv)
+MYSQL_STORAGE_ENGINE(IBMDB2I)
+
+ENDIF(HAVE_PASE_ENVIRONMENT)
diff --git a/storage/innobase/CMakeLists.txt b/storage/innobase/CMakeLists.txt
index d67b518642c..c8ec56ee5c9 100644
--- a/storage/innobase/CMakeLists.txt
+++ b/storage/innobase/CMakeLists.txt
@@ -15,40 +15,127 @@
# This is the CMakeLists for InnoDB Plugin
+INCLUDE(CheckFunctionExists)
+INCLUDE(CheckCSourceCompiles)
+INCLUDE(CheckCSourceRuns)
-# TODO: remove the two FLAGS_DEBUG settings when merging into
-# 6.0-based trees, like is already the case for other engines in
-# those trees.
-SET(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
-SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -DSAFEMALLOC -DSAFE_MUTEX")
+# OS tests
+IF(UNIX)
+ IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ ADD_DEFINITIONS("-DUNIV_LINUX")
+ ELSEIF(CMAKE_SYSTEM_NAME MATCHES "HP*")
+ ADD_DEFINITIONS("-DUNIV_HPUX -DUNIV_MUST_NOT_INLINE")
+ ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "AIX")
+ ADD_DEFINITIONS("-DUNIV_AIX -DUNIX_MUST_NOT_INLINE")
+ ELSEIF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+ ADD_DEFINITIONS("-DUNIV_SOLARIS")
+ ELSE()
+ ADD_DEFINITIONS("-DUNIV_MUST_NOT_INLINE")
+ ENDIF()
+ENDIF()
-# Starting at 5.1.38, MySQL CMake files are simplified. But the plugin
-# CMakeLists.txt still needs to work with previous versions of MySQL.
-IF (MYSQL_VERSION_ID GREATER "50137")
- INCLUDE("${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake")
-ENDIF (MYSQL_VERSION_ID GREATER "50137")
+# Solaris atomics
+IF(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
+ CHECK_FUNCTION_EXISTS(atomic_cas_ulong HAVE_ATOMIC_CAS_ULONG)
+ CHECK_FUNCTION_EXISTS(atomic_cas_32 HAVE_ATOMIC_CAS_32)
+ CHECK_FUNCTION_EXISTS(atomic_cas_64 HAVE_ATOMIC_CAS_64)
+ CHECK_FUNCTION_EXISTS(atomic_add_long HAVE_ATOMIC_ADD_LONG)
+ IF(HAVE_ATOMIC_CAS_ULONG AND HAVE_ATOMIC_CAS_32 AND
+ HAVE_ATOMIC_CAS_64 AND HAVE_ATOMIC_ADD_LONG)
+ SET(HAVE_SOLARIS_ATOMICS 1)
+ ENDIF()
+ENDIF()
+
+IF(HAVE_GCC_ATOMIC_BUILTINS)
+ CHECK_C_SOURCE_COMPILES("
+ #include <pthread.h>
+ #include <string.h>
+ int main()
+ {
+ pthread_t x1;
+ pthread_t x2;
+ pthread_t x3;
+ __sync_bool_compare_and_swap(&x1, x2, x3);
+ return 0;
+ }" HAVE_ATOMIC_PTHREAD_T_GCC
+ )
+ENDIF()
+
+IF(NOT HAVE_ATOMIC_PTHREAD_T_GCC AND HAVE_SOLARIS_ATOMICS)
+ CHECK_C_SOURCE_COMPILES("
+ #include <pthread.h>
+ int main()
+ {
+ pthread_t x = 0;
+ return(0);
+ }" HAVE_ATOMIC_PTHREAD_T_SOLARIS
+ )
+ IF(HAVE_ATOMIC_PTHREAD_T_SOLARIS)
+ SET(CMAKE_EXTRA_INCLUDE_FILES pthread.h)
+ CHECK_TYPE_SIZE(pthread_t SIZEOF_PTHREAD_T)
+ SET(CMAKE_EXTRA_INCLUDE_FILES)
+ ENDIF()
+ENDIF()
+
+IF(NOT CMAKE_CROSSCOMPILING)
+ STRING(TOLOWER ${CMAKE_SYSTEM_PROCESSOR} processor)
+ IF(NOT WIN32 AND processor MATCHES "86" OR processor MATCHES "amd64"
+ OR processor MATCHES "x64")
+ # Check for x86 PAUSE instruction
+ # We have to actually try running the test program, because of a bug
+ # in Solaris on x86_64, where it wrongly reports that PAUSE is not
+ # supported when trying to run an application. See
+ # http://bugs.opensolaris.org/bugdatabase/printableBug.do?bug_id=6478684
+ CHECK_C_SOURCE_RUNS("
+ int main()
+ {
+ __asm__ __volatile__ (\"pause\");
+ return 0;
+ }" IB_HAVE_PAUSE_INSTRUCTION)
+ ENDIF()
+ENDIF()
+
+IF(HAVE_ATOMIC_PTHREAD_T_SOLARIS OR HAVE_ATOMIC_PTHREAD_T_GCC)
+ ADD_DEFINITIONS(-DHAVE_ATOMIC_PTHREAD_T=1)
+ENDIF()
+
+IF(HAVE_SOLARIS_ATOMICS)
+ ADD_DEFINITIONS(-DHAVE_SOLARIS_ATOMICS=1)
+ENDIF()
+
+IF(IB_HAVE_PAUSE_INSTRUCTIONS)
+ ADD_DEFINITIONS(-DIB_HAVE_PAUSE_INSTRUCTIONS=1)
+ENDIF()
+
+IF(SIZEOF_PTHREAD_T)
+ ADD_DEFINITIONS(-DSIZEOF_PTHREAD_T=${SIZEOF_PTHREAD_T})
+ENDIF()
+
+IF(MSVC)
+ ADD_DEFINITIONS(-DHAVE_WINDOWS_ATOMICS -DIB_HAVE_PAUSE_INSTRUCTION)
+ENDIF()
-IF (CMAKE_SIZEOF_VOID_P MATCHES 8)
- SET(WIN64 TRUE)
-ENDIF (CMAKE_SIZEOF_VOID_P MATCHES 8)
# Include directories under innobase
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/storage/innobase/include
${CMAKE_SOURCE_DIR}/storage/innobase/handler)
-# Include directories under mysql
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
- ${CMAKE_SOURCE_DIR}/sql
- ${CMAKE_SOURCE_DIR}/regex
- ${CMAKE_SOURCE_DIR}/zlib
- ${CMAKE_SOURCE_DIR}/extra/yassl/include)
+# Sun Studio bug with -xO2
+IF(CMAKE_C_COMPILER_ID MATCHES "SunPro"
+ AND CMAKE_C_FLAGS_RELEASE MATCHES "O2"
+ AND NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
+ # Sun Studio 12 crashes with -xO2 flag, but not with higher optimization
+ # -xO3
+ SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/rem/rem0rec.c
+ PROPERTIES COMPILE_FLAGS -xO3)
+ENDIF()
# Removing compiler optimizations for innodb/mem/* files on 64-bit Windows
# due to 64-bit compiler error, See MySQL Bug #19424, #36366, #34297
-IF (MSVC AND $(WIN64))
+IF (MSVC AND CMAKE_SIZEOF_VOIDP EQUAL 8)
SET_SOURCE_FILES_PROPERTIES(mem/mem0mem.c mem/mem0pool.c
PROPERTIES COMPILE_FLAGS -Od)
-ENDIF (MSVC AND $(WIN64))
+ENDIF()
SET(INNOBASE_SOURCES btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c
buf/buf0buddy.c buf/buf0buf.c buf/buf0flu.c buf/buf0lru.c buf/buf0rea.c
@@ -83,20 +170,42 @@ SET(INNOBASE_SOURCES btr/btr0btr.c btr/btr0cur.c btr/btr0pcur.c btr/btr0sea.c
usr/usr0sess.c
ut/ut0byte.c ut/ut0dbg.c ut/ut0mem.c ut/ut0rnd.c ut/ut0ut.c ut/ut0vec.c
ut/ut0list.c ut/ut0wqueue.c)
-ADD_DEFINITIONS(-DHAVE_WINDOWS_ATOMICS -DIB_HAVE_PAUSE_INSTRUCTION)
-IF (MYSQL_VERSION_ID GREATER "50137")
+IF(WITH_INNODB)
+ # Legacy option
+ SET(WITH_INNOBASE_STORAGE_ENGINE TRUE)
+ENDIF()
+
+SET(INNOBASE_PLUGIN_STATIC "innobase")
+SET(INNOBASE_PLUGIN_DYNAMIC "ha_innodb")
+
+# Innobase depends on zlib. If server links with system
+# zlib shared library, and innobase builds as shared library,
+# innobase need to link with it too, to avoid unresolved symbols.
+IF(ZLIB_FOUND AND NOT WITH_ZLIB STREQUAL "bundled")
+ SET(INNOBASE_LIBS ${ZLIB_LIBRARY})
+ENDIF()
+
+#The plugin's CMakeLists.txt still needs to work with previous versions of MySQL.
+IF(EXISTS ${SOURCE_DIR}/storage/mysql_storage_engine.cmake)
+ # Old plugin support on Windows only,
+ # use tricks to force ha_innodb.dll name for DLL
+ INCLUDE(${SOURCE_DIR}/storage/mysql_storage_engine.cmake)
MYSQL_STORAGE_ENGINE(INNOBASE)
- # Use ha_innodb for plugin name, if plugin is built
GET_TARGET_PROPERTY(LIB_LOCATION ha_innobase LOCATION)
IF(LIB_LOCATION)
SET_TARGET_PROPERTIES(ha_innobase PROPERTIES OUTPUT_NAME ha_innodb)
- ENDIF(LIB_LOCATION)
-ELSE (MYSQL_VERSION_ID GREATER "50137")
+ ENDIF()
+ELSEIF (MYSQL_VERSION_ID LESS "50137")
+ # Windows only, no plugin support
IF (NOT SOURCE_SUBLIBS)
- ADD_DEFINITIONS(-D_WIN32 -DMYSQL_SERVER)
+ ADD_DEFINITIONS(-DMYSQL_SERVER)
ADD_LIBRARY(innobase STATIC ${INNOBASE_SOURCES})
# Require mysqld_error.h, which is built as part of the GenError
ADD_DEPENDENCIES(innobase GenError)
- ENDIF (NOT SOURCE_SUBLIBS)
-ENDIF (MYSQL_VERSION_ID GREATER "50137")
+ ENDIF()
+ELSE()
+ # New plugin support, cross-platform , name for shared library
+ # is given in INNOBASE_PLUGIN_STATIC and INNOBASE_PLUGIN_DYNAMIC
+ MYSQL_STORAGE_ENGINE(INNOBASE)
+ENDIF()
diff --git a/storage/innobase/include/page0page.ic b/storage/innobase/include/page0page.ic
index 318ec1cc1f2..8f794410f20 100644
--- a/storage/innobase/include/page0page.ic
+++ b/storage/innobase/include/page0page.ic
@@ -907,7 +907,7 @@ page_get_data_size(
/************************************************************//**
Allocates a block of memory from the free list of an index page. */
-UNIV_INTERN
+UNIV_INLINE
void
page_mem_alloc_free(
/*================*/
diff --git a/storage/myisam/CMakeLists.txt b/storage/myisam/CMakeLists.txt
index 829d89a798a..080448eb3f6 100755
--- a/storage/myisam/CMakeLists.txt
+++ b/storage/myisam/CMakeLists.txt
@@ -12,9 +12,9 @@
# 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("${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake")
-INCLUDE("${PROJECT_SOURCE_DIR}/win/mysql_manifest.cmake")
+SET(MYISAM_PLUGIN_STATIC "myisam")
+SET(MYISAM_PLUGIN_MANDATORY TRUE)
SET(MYISAM_SOURCES ft_boolean_search.c ft_nlq_search.c ft_parser.c ft_static.c ft_stem.c
ha_myisam.cc
@@ -30,26 +30,38 @@ SET(MYISAM_SOURCES ft_boolean_search.c ft_nlq_search.c ft_parser.c ft_static.c
MYSQL_STORAGE_ENGINE(MYISAM)
-IF(NOT SOURCE_SUBLIBS)
- ADD_EXECUTABLE(myisam_ftdump myisam_ftdump.c)
- TARGET_LINK_LIBRARIES(myisam_ftdump myisam mysys dbug strings zlib)
+ADD_EXECUTABLE(myisam_ftdump myisam_ftdump.c)
+TARGET_LINK_LIBRARIES(myisam_ftdump myisam mysys)
- ADD_EXECUTABLE(myisamchk myisamchk.c)
- TARGET_LINK_LIBRARIES(myisamchk myisam mysys dbug strings zlib)
+ADD_EXECUTABLE(myisamchk myisamchk.c)
+TARGET_LINK_LIBRARIES(myisamchk myisam mysys)
- ADD_EXECUTABLE(myisamlog myisamlog.c)
- TARGET_LINK_LIBRARIES(myisamlog myisam mysys dbug strings zlib)
+ADD_EXECUTABLE(myisamlog myisamlog.c)
+TARGET_LINK_LIBRARIES(myisamlog myisam mysys)
- ADD_EXECUTABLE(myisampack myisampack.c)
- TARGET_LINK_LIBRARIES(myisampack myisam mysys dbug strings zlib)
+ADD_EXECUTABLE(myisampack myisampack.c)
- SET_TARGET_PROPERTIES(myisamchk myisampack PROPERTIES LINK_FLAGS "setargv.obj")
+TARGET_LINK_LIBRARIES(myisampack myisam mysys)
+
+IF(WITH_UNIT_TESTS AND FALSE)
+ ADD_EXECUTABLE(mi_test1 mi_test1.c)
+ TARGET_LINK_LIBRARIES(mi_test1 myisam mysys)
+
+ ADD_EXECUTABLE(mi_test2 mi_test2.c)
+ TARGET_LINK_LIBRARIES(mi_test2 myisam mysys)
- IF(EMBED_MANIFESTS)
- MYSQL_EMBED_MANIFEST("myisam_ftdump" "asInvoker")
- MYSQL_EMBED_MANIFEST("myisamchk" "asInvoker")
- MYSQL_EMBED_MANIFEST("myisamlog" "asInvoker")
- MYSQL_EMBED_MANIFEST("myisampack" "asInvoker")
- ENDIF(EMBED_MANIFESTS)
+ ADD_EXECUTABLE(mi_test3 mi_test3.c)
+ TARGET_LINK_LIBRARIES(mi_test3 myisam mysys)
+
+ ADD_EXECUTABLE(sp_test sp_test.c)
+ TARGET_LINK_LIBRARIES(sp_test myisam mysys)
+
+ ADD_EXECUTABLE(rt_test rt_test.c)
+ TARGET_LINK_LIBRARIES(rt_test myisam mysys)
+ENDIF()
+
+IF (MSVC)
+ SET_TARGET_PROPERTIES(myisamchk myisampack PROPERTIES LINK_FLAGS "setargv.obj")
+ENDIF()
-ENDIF(NOT SOURCE_SUBLIBS)
+INSTALL(TARGETS myisamchk myisamlog myisampack myisam_ftdump DESTINATION bin)
diff --git a/storage/myisammrg/CMakeLists.txt b/storage/myisammrg/CMakeLists.txt
index c545d04a780..206848b1715 100755
--- a/storage/myisammrg/CMakeLists.txt
+++ b/storage/myisammrg/CMakeLists.txt
@@ -13,7 +13,8 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-INCLUDE("${PROJECT_SOURCE_DIR}/storage/mysql_storage_engine.cmake")
+SET(MYISAMMRG_PLUGIN_STATIC "myisammrg")
+SET(MYISAMMRG_PLUGIN_MANDATORY 1)
SET(MYISAMMRG_SOURCES myrg_close.c myrg_create.c myrg_delete.c myrg_extra.c myrg_info.c
ha_myisammrg.cc
diff --git a/storage/mysql_storage_engine.cmake b/storage/mysql_storage_engine.cmake
deleted file mode 100644
index b920f16452b..00000000000
--- a/storage/mysql_storage_engine.cmake
+++ /dev/null
@@ -1,44 +0,0 @@
-# MYSQL_STORAGE_ENGINE Macro creates a project to build storage engine
-# library.
-#
-# Parameters:
-# engine - storage engine name.
-# variable ENGINE_BUILD_TYPE should be set to "STATIC" or "DYNAMIC"
-# Remarks:
-# ${engine}_SOURCES variable containing source files to produce the library must set before
-# calling this macro
-# ${engine}_LIBS variable containing extra libraries to link with may be set
-
-
-MACRO(MYSQL_STORAGE_ENGINE engine)
-IF(NOT SOURCE_SUBLIBS)
- # Add common include directories
- INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/zlib
- ${CMAKE_SOURCE_DIR}/sql
- ${CMAKE_SOURCE_DIR}/regex
- ${CMAKE_SOURCE_DIR}/extra/yassl/include)
- STRING(TOUPPER ${engine} engine)
- STRING(TOLOWER ${engine} libname)
- IF(${ENGINE_BUILD_TYPE} STREQUAL "STATIC")
- ADD_DEFINITIONS(-DWITH_${engine}_STORAGE_ENGINE -DMYSQL_SERVER)
- #Create static library. The name of the library is <storage_engine>.lib
- ADD_LIBRARY(${libname} ${${engine}_SOURCES})
- ADD_DEPENDENCIES(${libname} GenError)
- IF(${engine}_LIBS)
- TARGET_LINK_LIBRARIES(${libname} ${${engine}_LIBS})
- ENDIF(${engine}_LIBS)
- MESSAGE("build ${engine} as static library")
- ELSEIF(${ENGINE_BUILD_TYPE} STREQUAL "DYNAMIC")
- ADD_DEFINITIONS(-DMYSQL_DYNAMIC_PLUGIN)
- #Create a DLL.The name of the dll is ha_<storage_engine>.dll
- #The dll is linked to the mysqld executable
- SET(dyn_libname ha_${libname})
- ADD_LIBRARY(${dyn_libname} SHARED ${${engine}_SOURCES})
- TARGET_LINK_LIBRARIES (${dyn_libname} mysqlservices mysqld)
- IF(${engine}_LIBS)
- TARGET_LINK_LIBRARIES(${dyn_libname} ${${engine}_LIBS})
- ENDIF(${engine}_LIBS)
- MESSAGE("build ${engine} as DLL")
- ENDIF(${ENGINE_BUILD_TYPE} STREQUAL "STATIC")
-ENDIF(NOT SOURCE_SUBLIBS)
-ENDMACRO(MYSQL_STORAGE_ENGINE)
diff --git a/strings/CMakeLists.txt b/strings/CMakeLists.txt
index 294a129fc1b..79fe03f019a 100755
--- a/strings/CMakeLists.txt
+++ b/strings/CMakeLists.txt
@@ -22,8 +22,8 @@ SET(STRINGS_SOURCES bchange.c bcmp.c bfill.c bmove512.c bmove_upp.c ctype-big5.c
is_prefix.c llstr.c longlong2str.c my_strtoll10.c my_vsnprintf.c r_strinstr.c
str2int.c str_alloc.c strcend.c strend.c strfill.c strmake.c strmov.c strnmov.c
strtod.c strtol.c strtoll.c strtoul.c strtoull.c strxmov.c strxnmov.c xml.c
- my_strchr.c strcont.c strinstr.c strnlen.c)
+ my_strchr.c strcont.c strinstr.c strnlen.c strappend.c)
+
+USE_ABSOLUTE_FILENAMES(STRINGS_SOURCES)
+ADD_LIBRARY(strings ${STRINGS_SOURCES})
-IF(NOT SOURCE_SUBLIBS)
- ADD_LIBRARY(strings ${STRINGS_SOURCES})
-ENDIF(NOT SOURCE_SUBLIBS)
diff --git a/support-files/CMakeLists.txt b/support-files/CMakeLists.txt
new file mode 100644
index 00000000000..f8aa1f329f5
--- /dev/null
+++ b/support-files/CMakeLists.txt
@@ -0,0 +1,61 @@
+# Copyright (C) 2009 Sun Microsystems, Inc
+#
+# 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(WIN32)
+ SET(localstatedir "C:\\mysql\\data")
+ SET(install_destination .)
+ SET(ini_file_extension "ini")
+ELSE()
+ SET(localstatedir "/usr/local/mysql/data")
+ SET(prefix "/usr/local")
+ SET(libexedir "/usr/local/mysql/bin")
+ SET(bindir "/usr/local/mysql/bin" )
+ SET(sbindir "/usr/local/mysql/bin")
+ SET(datadir "/usr/local/mysql/data")
+ SET(CC ${CMAKE_C_COMPILER})
+ SET(CXX ${CMAKE_CXX_COMPILER})
+ SET(CFLAGS ${CMAKE_C_COMPILE_FLAGS})
+ SET(CXXFLAGS ${CMAKE_COMPILE_CXX_FLAGS})
+ SET(MYSQLD_USER "mysql")
+ SET(install_destination "support-files")
+ SET(ini_file_extension "cnf")
+ENDIF()
+
+FOREACH(inifile my-huge my-innodb-heavy-4G my-large my-medium my-small)
+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${inifile}.cnf.sh
+ ${CMAKE_CURRENT_BINARY_DIR}/${inifile}.${ini_file_extension} @ONLY)
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${inifile}.${ini_file_extension} DESTINATION ${install_destination})
+
+ENDFOREACH()
+
+IF(UNIX)
+ FILE(GLOB ndb_ini_files ${CMAKE_CURRENT_SOURCE_DIR}/*.ini)
+ INSTALL(FILES ${ndb_ini_files} DESTINATION ${install_destination})
+
+ FOREACH(script mysql.server mysqld_multi.server mysql-log-rotate)
+ CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/${script}.sh
+ ${CMAKE_CURRENT_BINARY_DIR}/${script} @ONLY )
+
+ INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/${script} DESTINATION support-files
+ PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE)
+ ENDFOREACH()
+ INSTALL(FILES magic DESTINATION support-files)
+ INSTALL(FILES mysql.m4 DESTINATION share/aclocal)
+ CONFIGURE_FILE(MySQL-shared-compat.spec.sh ${CMAKE_CURRENT_BINARY_DIR}/MySQL-shared-compat.spec @ONLY)
+ CONFIGURE_FILE(mysql.spec.sh ${CMAKE_CURRENT_BINARY_DIR}/mysql.spec @ONLY)
+ CONFIGURE_FILE(mysql.spec.sh ${CMAKE_CURRENT_BINARY_DIR}/mysql.${VERSION}.spec @ONLY)
+ CONFIGURE_FILE(MySQL-shared-compat.spec.sh ${CMAKE_CURRENT_BINARY_DIR}/MySQL-shared-compat.spec @ONLY)
+ENDIF()
+
diff --git a/support-files/Makefile.am b/support-files/Makefile.am
index 47e8c395b31..9718c6e7ebf 100644
--- a/support-files/Makefile.am
+++ b/support-files/Makefile.am
@@ -34,7 +34,8 @@ EXTRA_DIST = mysql.spec.sh \
MySQL-shared-compat.spec.sh \
ndb-config-2-node.ini.sh \
compiler_warnings.supp \
- dtrace
+ dtrace \
+ CMakeLists.txt
SUBDIRS = MacOSX RHEL4-SElinux
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 0ee8769cd23..ea2f41abb73 100755
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -17,8 +17,14 @@ ADD_DEFINITIONS("-DMYSQL_CLIENT")
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
-ADD_EXECUTABLE(mysql_client_test mysql_client_test.c ../mysys/my_memmem.c)
+ADD_EXECUTABLE(mysql_client_test mysql_client_test.c)
TARGET_LINK_LIBRARIES(mysql_client_test mysqlclient)
+SET_TARGET_PROPERTIES(mysql_client_test PROPERTIES LINKER_LANGUAGE CXX)
-ADD_EXECUTABLE(bug25714 bug25714.c)
-TARGET_LINK_LIBRARIES(bug25714 mysqlclient)
+IF(WITH_UNIT_TESTS)
+ ADD_EXECUTABLE(bug25714 bug25714.c)
+ TARGET_LINK_LIBRARIES(bug25714 mysqlclient)
+ SET_TARGET_PROPERTIES(bug25714 PROPERTIES LINKER_LANGUAGE CXX)
+ENDIF()
+
+INSTALL(TARGETS mysql_client_test DESTINATION bin)
diff --git a/unittest/mysys/CMakeLists.txt b/unittest/mysys/CMakeLists.txt
new file mode 100644
index 00000000000..94eb3159693
--- /dev/null
+++ b/unittest/mysys/CMakeLists.txt
@@ -0,0 +1,36 @@
+# Copyright (C) 2007 MySQL AB, 2009 Sun Microsystems,Inc
+#
+# 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_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
+ ${CMAKE_SOURCE_DIR}/sql
+ ${CMAKE_SOURCE_DIR}/regex
+ ${CMAKE_SOURCE_DIR}/extra/yassl/include
+ ${CMAKE_SOURCE_DIR}/unittest/mytap)
+
+
+MACRO (MY_ADD_TEST name)
+ ADD_EXECUTABLE(${name}-t ${name}-t.c)
+ TARGET_LINK_LIBRARIES(${name}-t mytap mysys)
+ ADD_TEST(${name} ${name}-t)
+ENDMACRO()
+
+
+FOREACH(testname bitmap base64 my_vsnprintf)
+ MY_ADD_TEST(${testname})
+ENDFOREACH()
+IF(NOT WIN32)
+ # does not work on Windows in 5.x codebase
+ MY_ADD_TEST(my_atomic)
+ENDIF()
diff --git a/unittest/mysys/Makefile.am b/unittest/mysys/Makefile.am
index 56c65d71396..2dfa6d7698a 100644
--- a/unittest/mysys/Makefile.am
+++ b/unittest/mysys/Makefile.am
@@ -22,6 +22,8 @@ LDADD = $(top_builddir)/unittest/mytap/libmytap.a \
$(top_builddir)/strings/libmystrings.a
noinst_PROGRAMS = bitmap-t base64-t my_vsnprintf-t
+EXTRA_DIST = CMakeLists.txt
+
if NEED_THREAD
# my_atomic-t is used to check thread functions, so it is safe to
diff --git a/unittest/mytap/CMakeLists.txt b/unittest/mytap/CMakeLists.txt
new file mode 100644
index 00000000000..8a2f6c9639a
--- /dev/null
+++ b/unittest/mytap/CMakeLists.txt
@@ -0,0 +1,18 @@
+# Copyright (C) 2007 MySQL AB, 2009 Sun Microsystems, Inc
+#
+# 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_DIRECTORIES(${CMAKE_SOURCE_DIR}/include)
+ADD_LIBRARY(mytap tap.c)
diff --git a/unittest/mytap/Makefile.am b/unittest/mytap/Makefile.am
index c02bcd3b49d..8feefb134bb 100644
--- a/unittest/mytap/Makefile.am
+++ b/unittest/mytap/Makefile.am
@@ -20,6 +20,8 @@ noinst_HEADERS = tap.h
libmytap_a_SOURCES = tap.c
+EXTRA_DIST = CMakeLists.txt
+
SUBDIRS = . t
# Don't update the files from bitkeeper
diff --git a/unittest/mytap/tap.c b/unittest/mytap/tap.c
index 4e053e3e745..34a3b933eba 100644
--- a/unittest/mytap/tap.c
+++ b/unittest/mytap/tap.c
@@ -151,7 +151,9 @@ static signal_entry install_signal[]= {
{ SIGABRT, handle_core_signal },
{ SIGFPE, handle_core_signal },
{ SIGSEGV, handle_core_signal },
+#ifdef SIGBUS
{ SIGBUS, handle_core_signal }
+#endif
#ifdef SIGXCPU
, { SIGXCPU, handle_core_signal }
#endif
@@ -167,7 +169,7 @@ static signal_entry install_signal[]= {
};
void
-plan(int const count)
+plan(int count)
{
/*
Install signal handler
@@ -201,7 +203,7 @@ skip_all(char const *reason, ...)
}
void
-ok(int const pass, char const *fmt, ...)
+ok(int pass, char const *fmt, ...)
{
va_list ap;
va_start(ap, fmt);
@@ -218,7 +220,7 @@ ok(int const pass, char const *fmt, ...)
void
-skip(int how_many, char const *const fmt, ...)
+skip(int how_many, char const *fmt, ...)
{
char reason[80];
if (fmt && *fmt)
diff --git a/vio/CMakeLists.txt b/vio/CMakeLists.txt
index e1bd57d150f..6f44ecadb21 100755
--- a/vio/CMakeLists.txt
+++ b/vio/CMakeLists.txt
@@ -14,13 +14,12 @@
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-ADD_DEFINITIONS(-DUSE_SYMDIR)
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/extra/yassl/include)
+INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/include
+${SSL_INCLUDE_DIRS})
+ADD_DEFINITIONS(${SSL_DEFINES})
SET(VIO_SOURCES vio.c viosocket.c viossl.c viosslfactories.c)
-
-IF(NOT SOURCE_SUBLIBS)
- ADD_LIBRARY(vio ${VIO_SOURCES})
- ADD_DEPENDENCIES(vio GenError)
-ENDIF(NOT SOURCE_SUBLIBS)
+USE_ABSOLUTE_FILENAMES(VIO_SOURCES)
+ADD_LIBRARY(vio ${VIO_SOURCES})
+ADD_DEPENDENCIES(vio GenError)
diff --git a/win/create_def_file.js b/win/create_def_file.js
index aaaf4659736..21f884417e3 100644
--- a/win/create_def_file.js
+++ b/win/create_def_file.js
@@ -173,6 +173,7 @@ function IsCompilerDefinedSymbol(symbol)
(symbol.indexOf("??_R") != -1) ||
(symbol.indexOf("??_7") != -1) ||
(symbol.indexOf("?_G") != -1) || // scalar deleting destructor
+ (symbol.indexOf("_VInfreq_?") != -1) || // special label (exception handler?) for Intel compiler
(symbol.indexOf("?_E") != -1)); // vector deleting destructor
}
diff --git a/zlib/CMakeLists.txt b/zlib/CMakeLists.txt
index 43235b631f6..2d0706d024e 100755
--- a/zlib/CMakeLists.txt
+++ b/zlib/CMakeLists.txt
@@ -13,18 +13,15 @@
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
-# Note that this library is not using any "Thread Local Storage" (TLS),
-# i.e. no data declared "__declspec(thread)" or allocated with TlsAlloc().
-# Not directly and indirectly using any of the macros for creating and
-# using the storage, pthread_key*(), {,my_}{set,get}_specific*() ....
-INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/zlib)
-
-SET(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_DEBUG")
+INCLUDE_DIRECTORIES(
+${CMAKE_SOURCE_DIR}/include
+${CMAKE_SOURCE_DIR}/zlib
+)
SET(ZLIB_SOURCES adler32.c compress.c crc32.c crc32.h deflate.c deflate.h gzio.c infback.c inffast.c inffast.h
inffixed.h inflate.c inflate.h inftrees.c inftrees.h trees.c trees.h uncompr.c zconf.h zlib.h
zutil.c zutil.h)
-IF(NOT SOURCE_SUBLIBS)
- ADD_LIBRARY(zlib ${ZLIB_SOURCES})
-ENDIF(NOT SOURCE_SUBLIBS)
+USE_ABSOLUTE_FILENAMES(ZLIB_SOURCES)
+ADD_LIBRARY(zlib ${ZLIB_SOURCES})
+