diff options
author | Vladislav Vaintroub <vvaintroub@mysql.com> | 2009-11-09 12:32:48 +0100 |
---|---|---|
committer | Vladislav Vaintroub <vvaintroub@mysql.com> | 2009-11-09 12:32:48 +0100 |
commit | bc76ad8f6be7e75c7f1dccc322638566ee0fc0e7 (patch) | |
tree | ef650a7fd633d354f237aa267a871fce11fe48d3 /CMakeLists.txt | |
parent | d476bbb0becb27d7d3cb1fc5cc0ac4d401622893 (diff) | |
download | mariadb-git-bc76ad8f6be7e75c7f1dccc322638566ee0fc0e7.tar.gz |
WL#5161 : Cross-platform build with CMake
BUILD-CMAKE:
WL#5161 : Documentation on how to build with CMake on Unix/Windows
BUILD/Makefile.am:
Add new file
BUILD/autorun.sh:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
BUILD/choose_configure.sh:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
CMakeLists.txt:
WL#5161 : Rewrite top-level CMakeLists.txt.
Remove Windows specifics
- compiler flags handling moved to configure.cmake
- storage engine/plugin stuff moved into cmake/plugin.cmake
- copy docs
Makefile.am:
Added new files
client/CMakeLists.txt:
WL#5161 : Rewrite CMakeLists.txt to be platform-independent
Handle packagng (add INSTALL commands)
cmake/Makefile.am:
WL#5161 : use choose_configure instead of autotools configure script
(choose configure will call cmake if cmake is available)
cmake/abi_check.cmake:
Custom targets for abi_check (for cmake)
cmake/bison.cmake:
- Check bison availability
- Add RUN_BISON macro (used to create sql_yacc.cc and sql_yacc.h)
cmake/cat.cmake:
Add helper script to concatenate files.
cmake/character_sets.cmake:
Handle configuration parameters WITH_EXTRA_CHARSETS
cmake/check_minimal_version.cmake:
Helper script to check the minimum required version of cmake
cmake/configure.pl:
Add perl script to convert ./configure parameters for cmake
cmake/create_initial_db.cmake.in:
Add script helper to create initial database.
(on Windows, we pack initial db with the redistribution
package)
cmake/do_abi_check.cmake:
Perform abi check
cmake/dtrace.cmake:
Handle dtrace in CMake Build.
Check for dtrace availablility,
run dtrace -G on solaris in prelink step
cmake/dtrace_prelink.cmake:
Run dtrace -G on Solaris in pre-link step,
link the object it creates together with library or
executable
cmake/install_macros.cmake:
Helper macros for packaging
(install pdb on Windows, install symlinks on Unix)
cmake/make_dist.cmake.in:
"make dist" -
- pack autotools ./configure script with the source
(renamed to configure.am)
- pack bison output
cmake/merge_archives_unix.cmake.in:
script to merge static libraries on Unix
cmake/misc.cmake:
Build helper macros
- MERGE_STATIC_LIBS
We use it when building client library and embedded
(avoid recompilation)
- Convert source file paths to absolute names.
We use it in to locate files of a different project,
when the files need to be recompiled (e.g in embedded
several storage engines are recompiled with
-DEMBEDDED_LIBRARY)
cmake/mysql_version.cmake:
Extract version info from configure.in
Handle package names.
cmake/plugin.cmake:
Rewrote storage/mysql_storage_engine.cmake to handle
other types of plugins and do it in OS-independent manner.
cmake/readline.cmake:
Macros to handle WITH_READLINE/WITH_LIBEDIT parameters
cmake/ssl.cmake:
Add macros to handle WITH_SSL parameter.
cmake/stack_direction.c:
Helper to check stack direction.
cmake/zlib.cmake:
Add macros to handle WITH_ZLIB parameter
cmd-line-utils/libedit/CMakeLists.txt:
Build libedit with cmake.
cmd-line-utils/libedit/Makefile.am:
Add new file
cmd-line-utils/readline/CMakeLists.txt:
Build readline with CMake.
cmd-line-utils/readline/Makefile.am:
Add new file
config.h.cmake:
WL#5161 : Add config.h template for cmake
configure.cmake:
WL#5161 : Add platform tests ( for cmake)
configure.in:
Added new subdirectories
dbug/CMakeLists.txt:
WL#5161
extra/CMakeLists.txt:
WL#5161
extra/yassl/CMakeLists.txt:
WL#5161
extra/yassl/taocrypt/CMakeLists.txt:
WL#5161
include/Makefile.am:
Add new file
include/keycache.h:
remove configure-win.h and remove HUGE_PTR defined there.
include/my_global.h:
use my_config.h for Windows, not config-win.h anymore
include/my_pthread.h:
- Move thread_safe_increment from config-win.h to other headers
(config-win.h is not used anymore)
- Declare pthread_cancel on Windows (it is used in daemon_example)
include/my_sys.h:
Add malloc.h on Windows (we use -D_WIN32_LEAN_AND_MEAN now, and
with this define malloc.h is not included automatically via windows.h)
include/mysql/plugin.h:
Handle pure-C plugins with Microsoft compiler.
include/thr_alarm.h:
remove rf_SetTimer that used to be defined in config-win.h
Replace with UINT_PTR (we do not use config-win.h anymore
and typedef was needed in this single place only)
libmysql/CMakeLists.txt:
Avoid pointless recompilation of source files
in client library if possible. Merge static
libs (dbug, mysys) to create static client
library.
libmysqld/CMakeLists.txt:
Avoid pointless recompilation of source files
when building embedded. Instead, merge dbug and
mysys (and some other static libs) into embedded.
libmysqld/examples/CMakeLists.txt:
Embedded compilation on Unix
libmysqld/lib_sql.cc:
Do not define THD::clear_error() in lib_sql.cc
for embedded. Instead, use the same inline
definition from sql_class.h as in none-embedded
case (fixes duplicate symbol errors on Windows
and removes pointless #ifdef EMBEDDED)
man/CMakeLists.txt:
Install man files.
man/Makefile.am:
Add new file.
mysql-test/CMakeLists.txt:
Install mysql-test files
mysql-test/Makefile.am:
Add new files
mysql-test/lib/My/ConfigFactory.pm:
Allow testing with mtr in out-of-source builds.
mysql-test/lib/My/Find.pm:
the build configurations are now also available on Unix
Xcode on Mac uses the Release, RelwithDebinfo and Debug
subdirectories for executables. Earlier, build configurations
were available only on Windows.
mysql-test/lib/My/SafeProcess.pm:
Allow testing with mtr in out-of-source builds.
mysql-test/lib/My/SafeProcess/CMakeLists.txt:
Port CMakeLists.txt to Unix
mysql-test/lib/My/SafeProcess/safe_kill_win.cc:
add stdlib.h (to be able to compile with -DWIN32_LEAN_AND_MEAN)
mysql-test/lib/My/SafeProcess/safe_process_win.cc:
Add stdlib.h (to be able to compile with -DWIN32_LEAN_AND_MEAN)
define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE if not defined
(can happen using MinGW compiler that comes with old SDK)
mysql-test/mtr.out-of-source:
Allow testing with mtr in out-of-source builds.
mysql-test/mysql-test-run.pl:
Allow testing with mtr in out-of-source builds.
Use common find_plugin macro for Windows and unix.
mysql-test/t/fulltext_plugin.test:
This test can now run on Windows as well.
mysys/CMakeLists.txt:
Port CMakeLists.txt to Unix
mysys/my_create.c:
config-win.h is dead => NO_OPEN_3 is never defined.
mysys/my_getsystime.c:
config-win.h is dead => define OFFSET_TO_EPOCH where it is used.
mysys/my_winthread.c:
Add win32 pthread_cancel - used by daemon_example
mysys/mysys_priv.h:
config-win.h is dead => include <sys/stat.h> where it is used
fix prototype of my_win_(f)stat
plugin/daemon_example/CMakeLists.txt:
Compile daemon_example with CMake
plugin/daemon_example/Makefile.am:
Add new file
plugin/fulltext/CMakeLists.txt:
Compile full-text example with CMake
plugin/fulltext/Makefile.am:
Add new file.
plugin/semisync/CMakeLists.txt:
Fix semisync to use common macro for plugins.
regex/CMakeLists.txt:
Use absolute filenames, when adding regex library
(we recompile files in embedded, and want to locate
sources via GET_TARGET_PROPERTY( ... SOURCES ..))
regex/regex2.h:
Remove pointless typedef (produces error with MinGW compiler)
scripts/CMakeLists.txt:
Add configure/install for scripts
sql-bench/CMakeLists.txt:
install sql-bench files
sql-bench/Makefile.am:
Add new file
sql/CMakeLists.txt:
Port CmakeLists.txt to Unix
sql/nt_servc.cc:
compile server with -DWIN32_LEAN_AND_MEAN
sql/share/CMakeLists.txt:
Install charsets
sql/share/Makefile.am:
Add new file
sql/sql_builtin.cc.in:
Handle pure-C plugins on Windows.
sql/sql_class.h:
Use the same clear_error macro in embedded and not embedded.
Fixes pointless #ifdef and avoids duplicate symbols when linking
on Windows.
storage/Makefile.am:
storage/mysql_storage_engine.cmake => cmake/plugin.cmake
storage/archive/CMakeLists.txt:
Add names for static and dynamic plugin libraries.
Link archive with zlib
storage/blackhole/CMakeLists.txt:
Add names for static and dynamic storage
engine libraries
storage/csv/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/example/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/federated/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/heap/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/ibmdb2i/CMakeLists.txt:
Better port for ibmdb2i plugin
storage/innobase/CMakeLists.txt:
Run system checks.
Add names for static and dynamic storage engine
libraries.
storage/innobase/include/page0page.ic:
Fix compile error on OpenSolaris.
storage/myisam/CMakeLists.txt:
Port CmakeLists.txt to Unix
storage/myisammrg/CMakeLists.txt:
Add names for static and dynamic storage engine
libraries
storage/mysql_storage_engine.cmake:
storage/mysql_storage_engine.cmake => cmake/plugin.cmake
support-files/CMakeLists.txt:
Configure and install some files from support-files.
support-files/Makefile.am:
Add new file
tests/CMakeLists.txt:
In general case, mysqlclient library can be dependent
on C++ runtime(if it includes yassl and is not compiled
with gcc or MSVC)
unittest/mysys/CMakeLists.txt:
Add unit tests
unittest/mysys/Makefile.am:
Add new file
unittest/mytap/CMakeLists.txt:
Add library for unit tests
unittest/mytap/Makefile.am:
Add new file
unittest/mytap/tap.c:
fix function definitions to match declarations
win/create_def_file.js:
Fix link error with intel compiler (icl
defines of special label for exception handler)
Diffstat (limited to 'CMakeLists.txt')
-rwxr-xr-x | CMakeLists.txt | 499 |
1 files changed, 204 insertions, 295 deletions
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() |